Skip to content

Commit b23bc27

Browse files
siddh1004sagarwal
andauthored
1 parent a65d71e commit b23bc27

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Next Release
44

55
### Internal
6+
67
- Bump Sentry to v8.22.0
78
- Bump AndroidX Lifecycle to v2.9.4
89
- Bump AndroidX Test Runner to v1.7.0
@@ -37,10 +38,12 @@
3738
- Add Suspected option to hypertension and diabetes questions
3839
- Handle Screening feature visibility based on feature flag `Screening`
3940
- Add `hypertensionDiagnosedAt` and `diabetesDiagnosedAt` in `MedicalHistory` table
41+
- Hide schedule appointment sheet for suspected patients
4042

4143
## 2025.09.09
4244

4345
### Internal
46+
4447
- Bump AGP to v8.13.0
4548
- Bump Lint to v31.13.0
4649
- Bump dagger to v2.57.1

app/src/main/java/org/simple/clinic/medicalhistory/MedicalHistory.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.room.RawQuery
1313
import androidx.sqlite.db.SimpleSQLiteQuery
1414
import io.reactivex.Flowable
1515
import kotlinx.parcelize.Parcelize
16+
import org.simple.clinic.medicalhistory.Answer.Suspected
1617
import org.simple.clinic.medicalhistory.Answer.Unanswered
1718
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion.DiagnosedWithDiabetes
1819
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion.DiagnosedWithHypertension
@@ -92,6 +93,9 @@ data class MedicalHistory(
9293
val diagnosisRecorded: Boolean
9394
get() = hypertensionRecorded && diabetesRecorded
9495

96+
val suspected: Boolean
97+
get() = diagnosedWithHypertension == Suspected && diagnosedWithDiabetes == Suspected
98+
9599
fun answered(question: MedicalHistoryQuestion, answer: Answer): MedicalHistory {
96100
return when (question) {
97101
DiagnosedWithHypertension -> copy(diagnosedWithHypertension = answer)

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,10 @@ class PatientSummaryUpdate(
575575
prescribedDrugs: List<PrescribedDrug>,
576576
diagnosisWarningPrescriptions: DiagnosisWarningPrescriptions,
577577
): Next<PatientSummaryModel, PatientSummaryEffect> {
578-
val canShowAppointmentSheet = hasPatientMeasurementDataChangedSinceScreenCreated && !hasAppointmentChangedSinceScreenCreated
578+
val canShowAppointmentSheet = hasPatientMeasurementDataChangedSinceScreenCreated &&
579+
!hasAppointmentChangedSinceScreenCreated &&
580+
medicalHistory.suspected.not()
581+
579582
val hasAtLeastOneMeasurementRecorded = countOfRecordedBloodPressures + countOfRecordedBloodSugars > 0
580583
val shouldShowDiagnosisError = hasAtLeastOneMeasurementRecorded && when {
581584
model.isDiabetesManagementEnabled -> medicalHistory.diagnosisRecorded.not()
@@ -589,8 +592,10 @@ class PatientSummaryUpdate(
589592
medicalHistory = medicalHistory,
590593
hasShownMeasurementsWarningDialog = model.hasShownMeasurementsWarningDialog
591594
)
595+
592596
val canShowHTNDiagnosisWarning = medicalHistory.diagnosedWithHypertension != Yes &&
593597
prescribedDrugs.any { prescription -> diagnosisWarningPrescriptions.htnPrescriptions.contains(prescription.name.lowercase()) }
598+
594599
val canShowDiabetesDiagnosisWarning = medicalHistory.diagnosedWithDiabetes != Yes &&
595600
prescribedDrugs.any { prescription -> diagnosisWarningPrescriptions.diabetesPrescriptions.contains(prescription.name.lowercase()) }
596601

@@ -616,21 +621,29 @@ class PatientSummaryUpdate(
616621
prescribedDrugs: List<PrescribedDrug>,
617622
diagnosisWarningPrescriptions: DiagnosisWarningPrescriptions,
618623
): Next<PatientSummaryModel, PatientSummaryEffect> {
619-
val openIntention = model.openIntention
620-
val canShowAppointmentSheet = hasPatientMeasurementDataChangedSinceScreenCreated && !hasAppointmentChangedSinceScreenCreated
624+
val canShowAppointmentSheet = hasPatientMeasurementDataChangedSinceScreenCreated
625+
&& !hasAppointmentChangedSinceScreenCreated
626+
&& medicalHistory.suspected.not()
627+
621628
val hasAtLeastOneMeasurementRecorded = countOfRecordedBloodPressures + countOfRecordedBloodSugars > 0
622629
val shouldShowDiagnosisError = hasAtLeastOneMeasurementRecorded && when {
623630
model.isDiabetesManagementEnabled -> medicalHistory.diagnosisRecorded.not()
624631
else -> medicalHistory.hypertensionRecorded.not()
625632
}
633+
634+
val openIntention = model.openIntention
626635
val shouldGoToPreviousScreen = openIntention is ViewExistingPatient
627-
val shouldGoToHomeScreen = openIntention is LinkIdWithPatient || openIntention is ViewNewPatient || openIntention is ViewExistingPatientWithTeleconsultLog
636+
val shouldGoToHomeScreen = openIntention is LinkIdWithPatient ||
637+
openIntention is ViewNewPatient ||
638+
openIntention is ViewExistingPatientWithTeleconsultLog
639+
628640
val measurementWarningEffect = validateMeasurements(
629641
isDiabetesManagementEnabled = model.isDiabetesManagementEnabled,
630642
countOfRecordedBloodSugars = countOfRecordedBloodSugars,
631643
countOfRecordedBloodPressures = countOfRecordedBloodPressures,
632644
medicalHistory = medicalHistory,
633645
hasShownMeasurementsWarningDialog = model.hasShownMeasurementsWarningDialog)
646+
634647
val canShowHTNDiagnosisWarning = medicalHistory.diagnosedWithHypertension != Yes &&
635648
prescribedDrugs.any { prescription -> diagnosisWarningPrescriptions.htnPrescriptions.contains(prescription.name.lowercase()) }
636649
val canShowDiabetesDiagnosisWarning = medicalHistory.diagnosedWithDiabetes != Yes &&

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.simple.clinic.cvdrisk.StatinInfo
1313
import org.simple.clinic.drugs.DiagnosisWarningPrescriptions
1414
import org.simple.clinic.facility.FacilityConfig
1515
import org.simple.clinic.medicalhistory.Answer.No
16+
import org.simple.clinic.medicalhistory.Answer.Suspected
1617
import org.simple.clinic.medicalhistory.Answer.Unanswered
1718
import org.simple.clinic.medicalhistory.Answer.Yes
1819
import org.simple.clinic.patient.Answer
@@ -2820,6 +2821,60 @@ class PatientSummaryUpdateTest {
28202821
))
28212822
}
28222823

2824+
@Test
2825+
fun `when there are patient is suspected, clicking on back should not show the schedule appointment sheet`() {
2826+
val model = defaultModel.currentFacilityLoaded(facilityWithDiabetesManagementEnabled)
2827+
2828+
updateSpec
2829+
.given(model)
2830+
.whenEvent(DataForBackClickLoaded(
2831+
hasPatientMeasurementDataChangedSinceScreenCreated = true,
2832+
hasAppointmentChangeSinceScreenCreated = false,
2833+
countOfRecordedBloodPressures = 1,
2834+
countOfRecordedBloodSugars = 1,
2835+
medicalHistory = TestData.medicalHistory(
2836+
uuid = UUID.fromString("94056dc9-85e9-472e-8674-1657bbab56bb"),
2837+
patientUuid = patientUuid,
2838+
diagnosedWithHypertension = Suspected,
2839+
hasDiabetes = Suspected
2840+
),
2841+
canShowPatientReassignmentWarning = false,
2842+
prescribedDrugs = emptyList(),
2843+
diagnosisWarningPrescriptions = DiagnosisWarningPrescriptions.empty()
2844+
))
2845+
.then(assertThatNext(
2846+
hasNoModel(),
2847+
hasEffects(GoBackToPreviousScreen)
2848+
))
2849+
}
2850+
2851+
@Test
2852+
fun `when there are patient is suspected, clicking on done should not show the schedule appointment sheet`() {
2853+
val model = defaultModel.currentFacilityLoaded(facilityWithDiabetesManagementEnabled)
2854+
2855+
updateSpec
2856+
.given(model)
2857+
.whenEvent(DataForDoneClickLoaded(
2858+
hasPatientMeasurementDataChangedSinceScreenCreated = true,
2859+
hasAppointmentChangeSinceScreenCreated = false,
2860+
countOfRecordedBloodPressures = 1,
2861+
countOfRecordedBloodSugars = 0,
2862+
medicalHistory = TestData.medicalHistory(
2863+
uuid = UUID.fromString("7aeb58c1-19f8-43f8-952c-8fb069b9268b"),
2864+
patientUuid = patientUuid,
2865+
diagnosedWithHypertension = Suspected,
2866+
hasDiabetes = Suspected
2867+
),
2868+
canShowPatientReassignmentWarning = false,
2869+
prescribedDrugs = emptyList(),
2870+
diagnosisWarningPrescriptions = DiagnosisWarningPrescriptions.empty()
2871+
))
2872+
.then(assertThatNext(
2873+
hasNoModel(),
2874+
hasEffects(GoToHomeScreen)
2875+
))
2876+
}
2877+
28232878
private fun PatientSummaryModel.forExistingPatient(): PatientSummaryModel {
28242879
return copy(openIntention = ViewExistingPatient)
28252880
}

0 commit comments

Comments
 (0)