Skip to content

Commit e6d1270

Browse files
Merge pull request #5818 from simpledotorg/master
2 parents 4b2d708 + 16543fb commit e6d1270

7 files changed

Lines changed: 89 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- Bump Coroutines to v1.11.0
88
- Bump Gradle to v9.5.1
99

10+
### Changes
11+
12+
- Update Titration nudge threshold for diabetic patients in SriLanka from `140/90` to `130/80`
13+
1014
## 2026.05.11
1115

1216
### Internal

app/src/androidTest/java/org/simple/clinic/bp/BloodPressureRepositoryAndroidTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ class BloodPressureRepositoryAndroidTest {
453453
val newestBpForPatient3 = TestData.bloodPressureMeasurement(
454454
uuid = UUID.fromString("3d948d3b-6d8f-4608-bde0-d8750fef75d4"),
455455
patientUuid = patient3Uuid,
456-
systolic = 150,
457-
diastolic = 90,
456+
systolic = 135,
457+
diastolic = 85,
458458
createdAt = Instant.parse("2000-01-01T00:03:00Z"),
459459
recordedAt = Instant.parse("2000-01-01T00:03:00Z"),
460460
updatedAt = Instant.parse("2000-01-01T00:03:00Z"),
@@ -475,9 +475,9 @@ class BloodPressureRepositoryAndroidTest {
475475
))
476476

477477
// when
478-
val isNewestBpEntryHighForPatient1 = repository.isNewestBpEntryHigh(patient1Uuid).blockingFirst()
479-
val isNewestBpEntryHighForPatient2 = repository.isNewestBpEntryHigh(patient2Uuid).blockingFirst()
480-
val isNewestBpEntryHighForPatient3 = repository.isNewestBpEntryHigh(patient3Uuid).blockingFirst()
478+
val isNewestBpEntryHighForPatient1 = repository.isNewestBpEntryHigh(patient1Uuid, isDiabeticPatient = false, isSriLankaEnabled = false).blockingFirst()
479+
val isNewestBpEntryHighForPatient2 = repository.isNewestBpEntryHigh(patient2Uuid, isDiabeticPatient = true, isSriLankaEnabled = false).blockingFirst()
480+
val isNewestBpEntryHighForPatient3 = repository.isNewestBpEntryHigh(patient3Uuid, isDiabeticPatient = true, isSriLankaEnabled = true).blockingFirst()
481481

482482
// then
483483
assertThat(isNewestBpEntryHighForPatient1).isTrue()

app/src/main/java/org/simple/clinic/bp/BloodPressureMeasurement.kt

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,25 @@ data class BloodPressureMeasurement(
252252
fun purgeBloodPressureMeasurementWhenPatientIsNull(): Int
253253

254254
@Query("""
255-
SELECT
256-
CASE
257-
WHEN (COUNT(BP.uuid) >= 1) THEN 1
258-
ELSE 0
259-
END
260-
FROM BloodPressureMeasurement BP
261-
WHERE
262-
BP.patientUuid = :patientUuid AND
263-
date(BP.recordedAt) == :currentDate AND
264-
(BP.systolic >= 140 OR BP.diastolic >= 90) AND
265-
BP.deletedAt IS NULL
266-
ORDER BY BP.recordedAt DESC
267-
LIMIT 1
268-
""")
269-
fun isNewestBpEntryHigh(patientUuid: UUID, currentDate: LocalDate): Observable<Boolean>
255+
SELECT
256+
CASE
257+
WHEN (COUNT(BP.uuid) >= 1) THEN 1
258+
ELSE 0
259+
END
260+
FROM BloodPressureMeasurement BP
261+
WHERE
262+
BP.patientUuid = :patientUuid AND
263+
date(BP.recordedAt) == :currentDate AND
264+
(BP.systolic >= :systolicThreshold OR BP.diastolic >= :diastolicThreshold) AND
265+
BP.deletedAt IS NULL
266+
ORDER BY BP.recordedAt DESC
267+
LIMIT 1
268+
""")
269+
fun isNewestBpEntryHigh(
270+
patientUuid: UUID,
271+
currentDate: LocalDate,
272+
systolicThreshold: Int,
273+
diastolicThreshold: Int
274+
): Observable<Boolean>
270275
}
271276
}

app/src/main/java/org/simple/clinic/bp/BloodPressureRepository.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,25 @@ class BloodPressureRepository @Inject constructor(
166166
)
167167
}
168168

169-
fun isNewestBpEntryHigh(patientUuid: UUID): Observable<Boolean> {
169+
fun isNewestBpEntryHigh(
170+
patientUuid: UUID,
171+
isDiabeticPatient: Boolean,
172+
isSriLankaEnabled: Boolean
173+
): Observable<Boolean> {
174+
170175
val currentDate = LocalDate.now(utcClock)
171176

172-
return dao.isNewestBpEntryHigh(patientUuid = patientUuid, currentDate = currentDate)
177+
val systolicThreshold =
178+
if (isSriLankaEnabled && isDiabeticPatient) 130 else 140
179+
180+
val diastolicThreshold =
181+
if (isSriLankaEnabled && isDiabeticPatient) 80 else 90
182+
183+
return dao.isNewestBpEntryHigh(
184+
patientUuid = patientUuid,
185+
currentDate = currentDate,
186+
systolicThreshold = systolicThreshold,
187+
diastolicThreshold = diastolicThreshold
188+
)
173189
}
174190
}

app/src/main/java/org/simple/clinic/summary/PatientSummaryEffectHandler.kt

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,38 @@ class PatientSummaryEffectHandler @AssistedInject constructor(
401401
effects
402402
.observeOn(schedulersProvider.io())
403403
.switchMap {
404+
404405
val patientUuid = it.patientUuid
405-
bloodPressureRepository.isNewestBpEntryHigh(patientUuid).map { Pair(patientUuid, it) }
406+
407+
val hasDiabetes =
408+
medicalHistoryRepository.historyForPatientOrDefaultImmediate(
409+
defaultHistoryUuid = uuidGenerator.v4(),
410+
patientUuid = patientUuid
411+
).diagnosedWithDiabetes == MedicalHistoryAnswer.Yes
412+
413+
val isSriLanka =
414+
country.isoCountryCode == Country.SRI_LANKA
415+
416+
bloodPressureRepository.isNewestBpEntryHigh(
417+
patientUuid = patientUuid,
418+
isDiabeticPatient = hasDiabetes,
419+
isSriLankaEnabled = isSriLanka
420+
).map { isNewestBpEntryHigh ->
421+
Pair(patientUuid, isNewestBpEntryHigh)
422+
}
406423
}
407424
.switchMap { (patientUuid, isNewestBpEntryHigh) ->
408-
prescriptionRepository.hasPrescriptionForPatientChangedToday(patientUuid).map { Pair(isNewestBpEntryHigh, it) }
425+
prescriptionRepository
426+
.hasPrescriptionForPatientChangedToday(patientUuid)
427+
.map { hasPrescriptionsChangedToday ->
428+
Pair(isNewestBpEntryHigh, hasPrescriptionsChangedToday)
429+
}
409430
}
410431
.map { (isNewestBpEntryHigh, hasPrescriptionsChangedToday) ->
411-
ClinicalDecisionSupportInfoLoaded(isNewestBpEntryHigh, hasPrescriptionsChangedToday)
432+
ClinicalDecisionSupportInfoLoaded(
433+
isNewestBpEntryHigh,
434+
hasPrescriptionsChangedToday
435+
)
412436
}
413437
}
414438
}

app/src/test/java/org/simple/clinic/summary/PatientSummaryEffectHandlerTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,14 @@ class PatientSummaryEffectHandlerTest {
652652
// given
653653
val patientUuid = UUID.fromString("44daeb85-de4c-4807-8b31-6a88bf597cc7")
654654

655-
whenever(bloodPressureRepository.isNewestBpEntryHigh(patientUuid)).doReturn(Observable.just(true))
655+
val medicalHistory = TestData.medicalHistory()
656+
657+
whenever(medicalHistoryRepository.historyForPatientOrDefaultImmediate(
658+
defaultHistoryUuid = uuidGenerator.v4(),
659+
patientUuid = patientUuid
660+
)) doReturn medicalHistory
661+
662+
whenever(bloodPressureRepository.isNewestBpEntryHigh(patientUuid, medicalHistory.diagnosedWithDiabetes == Yes, false)).doReturn(Observable.just(true))
656663
whenever(prescriptionRepository.hasPrescriptionForPatientChangedToday(patientUuid)).doReturn(Observable.just(true))
657664

658665
// when

app/src/test/java/org/simple/clinic/summary/PatientSummaryScreenLogicTest.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import org.simple.clinic.cvdrisk.calculator.NonLabBasedCVDRiskCalculator
2424
import org.simple.clinic.drugs.DiagnosisWarningPrescriptions
2525
import org.simple.clinic.drugs.PrescriptionRepository
2626
import org.simple.clinic.facility.FacilityRepository
27-
import org.simple.clinic.feature.Feature
28-
import org.simple.clinic.feature.Features
27+
import org.simple.clinic.medicalhistory.Answer
2928
import org.simple.clinic.medicalhistory.MedicalHistoryRepository
3029
import org.simple.clinic.overdue.Appointment.Status.Cancelled
3130
import org.simple.clinic.overdue.AppointmentCancelReason
@@ -35,11 +34,9 @@ import org.simple.clinic.patient.PatientRepository
3534
import org.simple.clinic.patient.businessid.Identifier
3635
import org.simple.clinic.patient.businessid.Identifier.IdentifierType.BpPassport
3736
import org.simple.clinic.patientattribute.PatientAttributeRepository
38-
import org.simple.clinic.remoteconfig.DefaultValueConfigReader
3937
import org.simple.clinic.summary.OpenIntention.LinkIdWithPatient
4038
import org.simple.clinic.summary.OpenIntention.ViewExistingPatient
4139
import org.simple.clinic.summary.OpenIntention.ViewNewPatient
42-
import org.simple.clinic.util.NoOpRemoteConfigService
4340
import org.simple.clinic.util.RxErrorsRule
4441
import org.simple.clinic.util.TestUserClock
4542
import org.simple.clinic.util.TestUtcClock
@@ -104,16 +101,17 @@ class PatientSummaryScreenLogicTest {
104101
.atZone(userClock.zone)
105102
.toInstant()
106103

107-
whenever(bpRepository.isNewestBpEntryHigh(patientUuid)) doReturn Observable.just(true)
104+
val medicalHistory = TestData.medicalHistory(uuid = medicalHistoryUuid)
105+
whenever(medicalHistoryRepository.historyForPatientOrDefaultImmediate(
106+
defaultHistoryUuid = uuidGenerator.v4(),
107+
patientUuid = patientUuid
108+
)) doReturn medicalHistory
109+
whenever(bpRepository.isNewestBpEntryHigh(patientUuid, isDiabeticPatient = medicalHistory.diagnosedWithDiabetes == Answer.Yes, isSriLankaEnabled = false)) doReturn Observable.just(true)
108110
whenever(patientRepository.patientProfile(patientUuid)) doReturn Observable.just(Optional.of(patientProfile))
109111
whenever(patientRepository.latestPhoneNumberForPatient(patientUuid)) doReturn Optional.empty()
110112
whenever(appointmentRepository.lastCreatedAppointmentForPatient(patientUuid)) doReturn Optional.empty()
111113
whenever(bpRepository.hasBPRecordedToday(patientUuid, today)) doReturn Observable.just(true)
112114
whenever(facilityRepository.facility(assignedFacilityUuid)) doReturn Optional.of(TestData.facility())
113-
whenever(medicalHistoryRepository.historyForPatientOrDefaultImmediate(
114-
defaultHistoryUuid = uuidGenerator.v4(),
115-
patientUuid = patientUuid
116-
)) doReturn TestData.medicalHistory(uuid = medicalHistoryUuid)
117115
whenever(prescriptionRepository.newestPrescriptionsForPatientImmediate(patientUuid)) doReturn emptyList()
118116
}
119117

0 commit comments

Comments
 (0)