From 0e415632b5036f228064474c69e84fca5764f171 Mon Sep 17 00:00:00 2001 From: Alfred-Mutai Date: Mon, 20 May 2024 14:54:15 +0300 Subject: [PATCH] POC-155: Family testing module does not display elicited contacts on the form --- .../family-testing-resource.service.ts | 10 ++++-- .../patient-banner.component.ts | 34 +++++++++++++++---- 2 files changed, 35 insertions(+), 9 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..dbc9b6eb6 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 + ? '975ae894-7660-4224-b777-468c2e710a2a' + : '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..5d46fff4c 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,31 @@ 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(); + + 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); } else { this.searchIdentifiers = undefined; this.birthdate = undefined; @@ -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))