From a489e261bfee571d08548e60a180a6044fba0fb3 Mon Sep 17 00:00:00 2001 From: Alfred Mutai <124869802+Alfred-Mutai@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:17:04 +0300 Subject: [PATCH] =?UTF-8?q?POC-155:=20Family=20testing=20module=20does=20n?= =?UTF-8?q?ot=20display=20elicited=20contacts=20on=20=E2=80=A6=20(#1741)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * POC-155: Family testing module does not display elicited contacts on the form * POC-155: Family testing module does not display elicited contacts on the form --------- Co-authored-by: Faith Kamau <121166087+hiqedme@users.noreply.github.com> --- .../family-testing-resource.service.ts | 10 ++++-- .../patient-banner.component.ts | 36 +++++++++++++++---- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/app/etl-api/family-testing-resource.service.ts b/src/app/etl-api/family-testing-resource.service.ts index 923e0b159..612a80462 100644 --- a/src/app/etl-api/family-testing-resource.service.ts +++ b/src/app/etl-api/family-testing-resource.service.ts @@ -130,9 +130,13 @@ export class FamilyTestingService { ); } - public getPatientEncounters(patientUuid: string) { - const familyTestingEncounterTypeUuid = - '975ae894-7660-4224-b777-468c2e710a2a'; + public getPatientEncounters( + patientUuid: string, + isFamilyTestingEncounter: boolean + ) { + const familyTestingEncounterTypeUuid = isFamilyTestingEncounter + ? '3fbc8512-b37b-4bc2-a0f4-8d0ac7955127' + : '5a58f6f5-f5a6-47eb-a644-626abd83f83b'; return this.http.get( `${this.amrsUrl()}encounter?patient=${patientUuid}&encounterType=${familyTestingEncounterTypeUuid}` ); diff --git a/src/app/patient-dashboard/common/patient-banner/patient-banner.component.ts b/src/app/patient-dashboard/common/patient-banner/patient-banner.component.ts index 6b90d1e65..81349130a 100644 --- a/src/app/patient-dashboard/common/patient-banner/patient-banner.component.ts +++ b/src/app/patient-dashboard/common/patient-banner/patient-banner.component.ts @@ -52,6 +52,7 @@ export class PatientBannerComponent implements OnInit, OnDestroy, OnChanges { public isPatientEligibleForOtz = false; public isPatientVerified = false; public verificationStatus = false; + private isFamilyTestingEncounter = false; modalRef: BsModalRef; modalConfig = { backdrop: true, @@ -121,11 +122,32 @@ export class PatientBannerComponent implements OnInit, OnDestroy, OnChanges { ); this.getHIVPatient(_.filter(patient.enrolledPrograms, 'isEnrolled')); this.familyTestingService - .getPatientEncounters(this.patient.uuid) + .getPatientEncounters(this.patient.uuid, true) .subscribe((response: any) => { - this.familyTestingEncounterUuid = _.first(response.results); + if (response.results && response.results.length > 0) { + this.isFamilyTestingEncounter = true; + this.familyTestingEncounterUuid = _.first( + response.results + ); + } else { + this.isFamilyTestingEncounter = false; + } }); - this.getPatientEncounters(); + + setTimeout(async () => { + if (!this.isFamilyTestingEncounter) { + this.familyTestingService + .getPatientEncounters(this.patient.uuid, false) + .subscribe((response: any) => { + if (response.results && response.results.length > 0) { + this.familyTestingEncounterUuid = _.first( + response.results + ); + } + }); + } + this.getPatientEncounters(this.isFamilyTestingEncounter); + }, 4000); } else { this.searchIdentifiers = undefined; this.birthdate = undefined; @@ -347,7 +369,6 @@ export class PatientBannerComponent implements OnInit, OnDestroy, OnChanges { this.displayContacts = false; } public updateContacts() { - console.log('this.patient.uuid ', this.patient.uuid); const encounterUuid = _.first(this.patientEncounters).uuid; const familyPartnerHistoryForm = `3fbc8512-b37b-4bc2-a0f4-8d0ac7955127`; const url = `/patient-dashboard/patient/${this.patient.uuid}/general/general/formentry/${familyPartnerHistoryForm}`; @@ -361,9 +382,10 @@ export class PatientBannerComponent implements OnInit, OnDestroy, OnChanges { this.displayContacts = false; } - public getPatientEncounters() { - const familyAndPartnerTestingFormUuid = - '3fbc8512-b37b-4bc2-a0f4-8d0ac7955127'; + public getPatientEncounters(isFamilyTestingEncounter: boolean) { + const familyAndPartnerTestingFormUuid = isFamilyTestingEncounter + ? '3fbc8512-b37b-4bc2-a0f4-8d0ac7955127' + : '8b196bad-6ee5-4290-b1be-101539e04290'; this.encounterResourceService .getEncountersByPatientUuid(this.patient.uuid, false, null) .pipe(take(1))