From 801fd5bd3ce1ed72225e3e896dc88d8fb4ad45f7 Mon Sep 17 00:00:00 2001 From: Sasikanth Date: Fri, 13 Sep 2024 14:05:08 +0530 Subject: [PATCH] Fix statin nudge not getting dismissed when a statin is added (#5082) --- CHANGELOG.md | 1 + .../simple/clinic/summary/PatientSummaryEffectHandler.kt | 9 +++++++-- .../clinic/summary/PatientSummaryEffectHandlerTest.kt | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3da1c34877..32a6cf78434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Bump AndroidX Lifecycle to v2.8.5 - Check statin nudge status in patient summary screen - Add feature flag for statin nudge +- Fix statin nudge not getting dismissed when a statin is added ### Features diff --git a/app/src/main/java/org/simple/clinic/summary/PatientSummaryEffectHandler.kt b/app/src/main/java/org/simple/clinic/summary/PatientSummaryEffectHandler.kt index 004fe9b8615..9b40111a2cd 100644 --- a/app/src/main/java/org/simple/clinic/summary/PatientSummaryEffectHandler.kt +++ b/app/src/main/java/org/simple/clinic/summary/PatientSummaryEffectHandler.kt @@ -115,13 +115,18 @@ class PatientSummaryEffectHandler @AssistedInject constructor( Pair(patient, it) } } - .map { (patient, hasBPRecordedToday) -> + .flatMap { (patient, hasBPRecordedToday) -> + val prescriptionsObservable = prescriptionRepository.newestPrescriptionsForPatient(patient.uuid) + prescriptionsObservable.map { prescriptions -> + Triple(patient, prescriptions, hasBPRecordedToday) + } + } + .map { (patient, prescriptions, hasBPRecordedToday) -> val assignedFacility = getAssignedFacility(patient.assignedFacilityId).toNullable() val medicalHistory = medicalHistoryRepository.historyForPatientOrDefaultImmediate( defaultHistoryUuid = uuidGenerator.v4(), patientUuid = patient.uuid ) - val prescriptions = prescriptionRepository.newestPrescriptionsForPatientImmediate(patient.uuid) StatinPrescriptionCheckInfoLoaded( age = patient.ageDetails.estimateAge(userClock = userClock), diff --git a/app/src/test/java/org/simple/clinic/summary/PatientSummaryEffectHandlerTest.kt b/app/src/test/java/org/simple/clinic/summary/PatientSummaryEffectHandlerTest.kt index 52097cd8824..2cca2563793 100644 --- a/app/src/test/java/org/simple/clinic/summary/PatientSummaryEffectHandlerTest.kt +++ b/app/src/test/java/org/simple/clinic/summary/PatientSummaryEffectHandlerTest.kt @@ -842,7 +842,7 @@ class PatientSummaryEffectHandlerTest { patientUuid = patientUuid, defaultHistoryUuid = uuidGenerator.v4() )) doReturn medicalHistory - whenever(prescriptionRepository.newestPrescriptionsForPatientImmediate(patientUuid)) doReturn emptyList() + whenever(prescriptionRepository.newestPrescriptionsForPatient(patientUuid)) doReturn Observable.just(emptyList()) // when testCase.dispatch(LoadStatinPrescriptionCheckInfo(patient))