Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poc 155 #1394

Merged
merged 3 commits into from
Jul 19, 2024
Merged

Poc 155 #1394

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions service/patient-reminder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ function newViralLoadPresent(data) {
}

function pendingViralLoadLabResult(eidResults) {
// console.log('EID Results', eidResults);
let incompleteResult = eidResults.find((result) => {
if (result) {
if (result.sample_status) {
Expand Down Expand Up @@ -1100,12 +1099,45 @@ function transformZeroVl(vl) {
}

function getEncountersByEncounterType(patient_uuid) {
const family_testing_encounter = '975ae894-7660-4224-b777-468c2e710a2a';
return new Promise(function (resolve, reject) {
const primaryFamilyTestingEncounter = '975ae894-7660-4224-b777-468c2e710a2a';
const secondaryFamilyTestingEncounter =
'5a58f6f5-f5a6-47eb-a644-626abd83f83b';
const specificConceptUuid = '0df3af2d-4eeb-4552-8395-51ef32270842';

function findSpecificObservation(encounters) {
for (const encounter of encounters) {
if (Array.isArray(encounter.obs)) {
for (const observation of encounter.obs) {
if (observation.concept.uuid === specificConceptUuid) {
return true;
}
}
}
}
return false;
}

return new Promise((resolve, reject) => {
encounter_service
.getEncountersByEncounterType(patient_uuid, family_testing_encounter)
.getEncountersByEncounterType(patient_uuid, primaryFamilyTestingEncounter)
.then((encounters) => {
resolve(encounters);
if (encounters == null || encounters.results.length === 0) {
return encounter_service.getEncountersByEncounterType(
patient_uuid,
secondaryFamilyTestingEncounter
);
}
return encounters;
})
.then((encounters) => {
if (encounters == null || encounters.results.length === 0) {
resolve(null);
} else {
if (findSpecificObservation(encounters.results)) {
console.log('Encounters from Family testing: ', encounters);
}
resolve(encounters);
}
})
.catch((err) => {
reject(err);
Expand Down
Loading