Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pig job to create the DocGraph structure
filteredNPIData = FOREACH npiData GENERATE
REPLACE(NPI, '\\"','') as npiRX,
REPLACE(Provider_Business_Mailing_Address_State_Name, '\\"','') as NPIState,
REPLACE(Healthcare_Provider_Taxonomy_Code_1, '\\"','') as NPITaxonomy,
REPLACE(Provider_Organization_Name_Legal_Business_Name, '\\"','') as NPIOrgName,
CONCAT(CONCAT(REPLACE(Provider_First_Name,'\\"',''),' '), REPLACE(Provider_Last_Name_Legal_Name,'\\"','')) as docName;
--join the filtered set to the NPI data to get the NPI information
joinReferred = JOIN docGraphRXData BY referringDoc, filteredNPIData by npiRX;
joinReferredTo = JOIN joinReferred BY referredDoc, filteredNPIData by npiRX;
-- join the set to the NUCC codes
joinReferredNUCC = JOIN joinReferredTo BY joinReferred::filteredNPIData::NPITaxonomy, nucc_codes by nuccCode;
joinReferredToNUCC = JOIN joinReferredNUCC BY joinReferredTo::filteredNPIData::NPITaxonomy, nucc_codes by nuccCode;
prunedDocGraphRXData = FOREACH joinReferredToNUCC GENERATE
joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::referringDoc as referringDoc,
joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::referredDoc as referredToDoc,
joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::sharedTransactionCount as sharedTransactionCount,
joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::patientTotal as patientTotal,
joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::sameDayTotal as sameDayTotal,
(float)(joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::sameDayTotal / joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::sharedTransactionCount) as pctSameDayTotal,
(float)(joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::patientTotal / joinReferredNUCC::joinReferredTo::joinReferred::docGraphRXData::sharedTransactionCount) as pctTransactions,
joinReferredNUCC::joinReferredTo::joinReferred::filteredNPIData::npiRX as referringDocNPI,
joinReferredNUCC::joinReferredTo::joinReferred::filteredNPIData::NPIState as referringDocState,
joinReferredNUCC::joinReferredTo::joinReferred::filteredNPIData::NPITaxonomy as referringDocTaxonomy,
joinReferredNUCC::joinReferredTo::joinReferred::filteredNPIData::NPIOrgName as referringDocOrgName,
joinReferredNUCC::joinReferredTo::joinReferred::filteredNPIData::docName as referringDocName,
joinReferredNUCC::joinReferredTo::filteredNPIData::npiRX as referredToDocNPI,
joinReferredNUCC::joinReferredTo::filteredNPIData::NPIState as referredToDocState,
joinReferredNUCC::joinReferredTo::filteredNPIData::NPITaxonomy as referredToDocTaxonomy,
joinReferredNUCC::joinReferredTo::filteredNPIData::NPIOrgName as referredToDocOrgName,
joinReferredNUCC::joinReferredTo::filteredNPIData::docName as referredToDocName,
joinReferredNUCC::nucc_codes::nuccCode as referringDocNUCCCode,
joinReferredNUCC::nucc_codes::nuccType as referringDocNUCCType,
nucc_codes::nuccCode as referredToDocNUCCCode,
nucc_codes::nuccType as referredToDocNUCCType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment