Skip to content

Commit

Permalink
Add support accommodate lab observation codes
Browse files Browse the repository at this point in the history
  • Loading branch information
josephatJ committed Dec 19, 2024
1 parent 6e152fa commit 1e9377a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/create-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ async function processMappings(datastoreKeyData) {
return mappingItem.code;
});
}

query += ` FROM encounter_flat en \n`;

// Be careful when choosing right vs left join
Expand All @@ -160,6 +159,13 @@ async function processMappings(datastoreKeyData) {
query += `AND drep.code IN ('${loincOrderCodes.join("','")}') \n`;
}

if (loincObsCodes.length > 0) {
query += ` RIGHT JOIN observation_flat obs ON obs.encounter_id = en.encounter_id \n`;
query += `AND obs.val_concept_code IN ('${loincObsCodes.join(
"','"
)}') \n`;
}

query += `LEFT JOIN patient_flat pt ON pt.id = en.patient_id \n `;

query +=
Expand Down

0 comments on commit 1e9377a

Please sign in to comment.