Skip to content

Commit 803fa35

Browse files
Merge pull request #5472 from simpledotorg/master
2 parents 2349cbc + a4707c7 commit 803fa35

File tree

29 files changed

+84
-145
lines changed

29 files changed

+84
-145
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- Replace `android-database-sqlcipher` library with `sqlcipher-android`
2323
- Replace Flipper with Chucker for network inspection
2424
- Update statin risk threshold to 20% for sri Lanka
25+
- Update smoking dialog to a multi-choice tobacco dialog
2526

2627
## 2025.05.20
2728

app/src/androidTest/java/org/simple/clinic/summary/statin/StatinNudgeTest.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class StatinNudgeTest {
3535
isNonLabBasedStatinNudgeEnabled = true,
3636
isLabBasedStatinNudgeEnabled = false,
3737
useVeryHighRiskAsThreshold = true,
38-
addSmokingClick = { },
38+
addTobaccoUseClicked = { },
3939
addBMIClick = { },
4040
addCholesterol = { }
4141
)
@@ -71,7 +71,7 @@ class StatinNudgeTest {
7171
isNonLabBasedStatinNudgeEnabled = true,
7272
isLabBasedStatinNudgeEnabled = false,
7373
useVeryHighRiskAsThreshold = true,
74-
addSmokingClick = { },
74+
addTobaccoUseClicked = { },
7575
addBMIClick = { },
7676
addCholesterol = { }
7777
)
@@ -108,7 +108,7 @@ class StatinNudgeTest {
108108
isNonLabBasedStatinNudgeEnabled = true,
109109
isLabBasedStatinNudgeEnabled = false,
110110
useVeryHighRiskAsThreshold = false,
111-
addSmokingClick = { },
111+
addTobaccoUseClicked = { },
112112
addBMIClick = { },
113113
addCholesterol = { }
114114
)
@@ -145,7 +145,7 @@ class StatinNudgeTest {
145145
isNonLabBasedStatinNudgeEnabled = true,
146146
isLabBasedStatinNudgeEnabled = false,
147147
useVeryHighRiskAsThreshold = false,
148-
addSmokingClick = { },
148+
addTobaccoUseClicked = { },
149149
addBMIClick = { },
150150
addCholesterol = { }
151151
)
@@ -182,7 +182,7 @@ class StatinNudgeTest {
182182
isNonLabBasedStatinNudgeEnabled = true,
183183
isLabBasedStatinNudgeEnabled = false,
184184
useVeryHighRiskAsThreshold = false,
185-
addSmokingClick = { },
185+
addTobaccoUseClicked = { },
186186
addBMIClick = { },
187187
addCholesterol = { }
188188
)
@@ -223,7 +223,7 @@ class StatinNudgeTest {
223223
isNonLabBasedStatinNudgeEnabled = true,
224224
isLabBasedStatinNudgeEnabled = false,
225225
useVeryHighRiskAsThreshold = true,
226-
addSmokingClick = { },
226+
addTobaccoUseClicked = { },
227227
addBMIClick = { },
228228
addCholesterol = { }
229229
)
@@ -260,7 +260,7 @@ class StatinNudgeTest {
260260
isNonLabBasedStatinNudgeEnabled = true,
261261
isLabBasedStatinNudgeEnabled = false,
262262
useVeryHighRiskAsThreshold = false,
263-
addSmokingClick = { },
263+
addTobaccoUseClicked = { },
264264
addBMIClick = { },
265265
addCholesterol = { }
266266
)
@@ -301,7 +301,7 @@ class StatinNudgeTest {
301301
isNonLabBasedStatinNudgeEnabled = false,
302302
isLabBasedStatinNudgeEnabled = true,
303303
useVeryHighRiskAsThreshold = false,
304-
addSmokingClick = { },
304+
addTobaccoUseClicked = { },
305305
addBMIClick = { },
306306
addCholesterol = { }
307307
)
@@ -339,7 +339,7 @@ class StatinNudgeTest {
339339
isNonLabBasedStatinNudgeEnabled = false,
340340
isLabBasedStatinNudgeEnabled = true,
341341
useVeryHighRiskAsThreshold = false,
342-
addSmokingClick = { },
342+
addTobaccoUseClicked = { },
343343
addBMIClick = { },
344344
addCholesterol = { }
345345
)
@@ -377,7 +377,7 @@ class StatinNudgeTest {
377377
isNonLabBasedStatinNudgeEnabled = false,
378378
isLabBasedStatinNudgeEnabled = true,
379379
useVeryHighRiskAsThreshold = false,
380-
addSmokingClick = { },
380+
addTobaccoUseClicked = { },
381381
addBMIClick = { },
382382
addCholesterol = { }
383383
)
@@ -420,7 +420,7 @@ class StatinNudgeTest {
420420
isNonLabBasedStatinNudgeEnabled = false,
421421
isLabBasedStatinNudgeEnabled = true,
422422
useVeryHighRiskAsThreshold = false,
423-
addSmokingClick = { },
423+
addTobaccoUseClicked = { },
424424
addBMIClick = { },
425425
addCholesterol = { }
426426
)
@@ -463,7 +463,7 @@ class StatinNudgeTest {
463463
isNonLabBasedStatinNudgeEnabled = false,
464464
isLabBasedStatinNudgeEnabled = true,
465465
useVeryHighRiskAsThreshold = false,
466-
addSmokingClick = { },
466+
addTobaccoUseClicked = { },
467467
addBMIClick = { },
468468
addCholesterol = { }
469469
)
@@ -506,7 +506,7 @@ class StatinNudgeTest {
506506
isNonLabBasedStatinNudgeEnabled = false,
507507
isLabBasedStatinNudgeEnabled = true,
508508
useVeryHighRiskAsThreshold = false,
509-
addSmokingClick = { },
509+
addTobaccoUseClicked = { },
510510
addBMIClick = { },
511511
addCholesterol = { }
512512
)
@@ -548,7 +548,7 @@ class StatinNudgeTest {
548548
isNonLabBasedStatinNudgeEnabled = false,
549549
isLabBasedStatinNudgeEnabled = true,
550550
useVeryHighRiskAsThreshold = false,
551-
addSmokingClick = { },
551+
addTobaccoUseClicked = { },
552552
addBMIClick = { },
553553
addCholesterol = { }
554554
)
@@ -585,7 +585,7 @@ class StatinNudgeTest {
585585
isNonLabBasedStatinNudgeEnabled = false,
586586
isLabBasedStatinNudgeEnabled = true,
587587
useVeryHighRiskAsThreshold = false,
588-
addSmokingClick = { },
588+
addTobaccoUseClicked = { },
589589
addBMIClick = { },
590590
addCholesterol = { }
591591
)
@@ -622,7 +622,7 @@ class StatinNudgeTest {
622622
isNonLabBasedStatinNudgeEnabled = false,
623623
isLabBasedStatinNudgeEnabled = true,
624624
useVeryHighRiskAsThreshold = false,
625-
addSmokingClick = { },
625+
addTobaccoUseClicked = { },
626626
addBMIClick = { },
627627
addCholesterol = { }
628628
)
@@ -663,7 +663,7 @@ class StatinNudgeTest {
663663
isNonLabBasedStatinNudgeEnabled = false,
664664
isLabBasedStatinNudgeEnabled = true,
665665
useVeryHighRiskAsThreshold = true,
666-
addSmokingClick = { },
666+
addTobaccoUseClicked = { },
667667
addBMIClick = { },
668668
addCholesterol = { }
669669
)
@@ -700,7 +700,7 @@ class StatinNudgeTest {
700700
isNonLabBasedStatinNudgeEnabled = false,
701701
isLabBasedStatinNudgeEnabled = true,
702702
useVeryHighRiskAsThreshold = false,
703-
addSmokingClick = { },
703+
addTobaccoUseClicked = { },
704704
addBMIClick = { },
705705
addCholesterol = { }
706706
)
@@ -726,7 +726,7 @@ class StatinNudgeTest {
726726
}
727727

728728
private fun hideButtons() {
729-
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_SMOKING")
729+
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_TOBACCO_USE")
730730
.assertDoesNotExist()
731731

732732
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_BMI")
@@ -737,8 +737,8 @@ class StatinNudgeTest {
737737
}
738738

739739
private fun showSmokingAndBmiButtons() {
740-
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_SMOKING")
741-
.assertTextEquals(context.getString(R.string.statin_alert_add_smoking))
740+
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_TOBACCO_USE")
741+
.assertTextEquals(context.getString(R.string.statin_alert_add_tobacco_use))
742742
.assertIsDisplayed()
743743

744744
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_BMI")
@@ -750,8 +750,8 @@ class StatinNudgeTest {
750750
}
751751

752752
private fun showSmokingAndCholesterolButtons() {
753-
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_SMOKING")
754-
.assertTextEquals(context.getString(R.string.statin_alert_add_smoking))
753+
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_TOBACCO_USE")
754+
.assertTextEquals(context.getString(R.string.statin_alert_add_tobacco_use))
755755
.assertIsDisplayed()
756756

757757
composeTestRule.onNodeWithTag("STATIN_NUDGE_ADD_CHOLESTEROL")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ data object ShowDiabetesDiagnosisWarning : PatientSummaryViewEffect()
138138

139139
data class ShowHypertensionDiagnosisWarning(val continueToDiabetesDiagnosisWarning: Boolean) : PatientSummaryViewEffect()
140140

141-
data object ShowSmokingStatusDialog : PatientSummaryViewEffect()
141+
data object ShowTobaccoStatusDialog : PatientSummaryViewEffect()
142142

143143
data class OpenBMIEntrySheet(val patientUuid: UUID) : PatientSummaryViewEffect()
144144

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ data class StatinInfoLoaded(
170170
val bmiReading: BMIReading?,
171171
) : PatientSummaryEvent()
172172

173-
data object AddSmokingClicked : PatientSummaryEvent()
173+
data object AddTobaccoUseClicked : PatientSummaryEvent()
174174

175175
data class SmokingStatusAnswered(
176176
val isSmoker: Answer

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data class PatientSummaryModel(
2929
val scheduledAppointment: ParcelableOptional<Appointment>?,
3030
val hasShownDiagnosisWarningDialog: Boolean,
3131
val statinInfo: StatinInfo?,
32-
val hasShownSmokingStatusDialog: Boolean,
32+
val hasShownTobaccoUseDialog: Boolean,
3333
) : Parcelable, PatientSummaryChildModel {
3434

3535
companion object {
@@ -49,7 +49,7 @@ data class PatientSummaryModel(
4949
scheduledAppointment = null,
5050
hasShownDiagnosisWarningDialog = false,
5151
statinInfo = null,
52-
hasShownSmokingStatusDialog = false,
52+
hasShownTobaccoUseDialog = false,
5353
)
5454
}
5555
}
@@ -135,7 +135,7 @@ data class PatientSummaryModel(
135135
return copy(statinInfo = statinInfo)
136136
}
137137

138-
fun showSmokingStatusDialog(): PatientSummaryModel {
139-
return copy(hasShownSmokingStatusDialog = true)
138+
fun showTobaccoUseDialog(): PatientSummaryModel {
139+
return copy(hasShownTobaccoUseDialog = true)
140140
}
141141
}

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class PatientSummaryScreen :
317317
modifier = Modifier.padding(start = 8.dp, end = 8.dp, top = 8.dp),
318318
isNonLabBasedStatinNudgeEnabled = features.isEnabled(Feature.NonLabBasedStatinNudge),
319319
isLabBasedStatinNudgeEnabled = features.isEnabled(Feature.LabBasedStatinNudge),
320-
addSmokingClick = { additionalEvents.notify(AddSmokingClicked) },
320+
addTobaccoUseClicked = { additionalEvents.notify(AddTobaccoUseClicked) },
321321
addBMIClick = { additionalEvents.notify(AddBMIClicked) },
322322
addCholesterol = { additionalEvents.notify(AddCholesterolClicked) },
323323
useVeryHighRiskAsThreshold = country.isoCountryCode == Country.SRI_LANKA
@@ -695,25 +695,35 @@ class PatientSummaryScreen :
695695
.show()
696696
}
697697

698-
override fun showSmokingStatusDialog() {
699-
val options = arrayOf(
700-
getString(R.string.smoking_status_dialog_option_yes),
701-
getString(R.string.smoking_status_dialog_option_no))
702-
var selectedOption = 1
698+
override fun showTobaccoStatusDialog() {
699+
val options = if (country.isoCountryCode == Country.ETHIOPIA) {
700+
arrayOf(
701+
getString(R.string.tobacco_status_dialog_option_smoker),
702+
getString(R.string.tobacco_status_dialog_option_no)
703+
)
704+
} else {
705+
arrayOf(
706+
getString(R.string.tobacco_status_dialog_option_smoker),
707+
getString(R.string.tobacco_status_dialog_option_smokeless),
708+
getString(R.string.tobacco_status_dialog_option_no)
709+
)
710+
}
711+
712+
val checkedItems = BooleanArray(options.size)
703713

704714
MaterialAlertDialogBuilder(requireContext(), R.style.ThemeOverlay_Simple_MaterialAlertDialog_CheckedItem)
705-
.setTitle(R.string.smoking_status_dialog_title)
706-
.setSingleChoiceItems(options, selectedOption) { _, indexSelected ->
707-
selectedOption = indexSelected
715+
.setTitle(R.string.tobacco_status_dialog_title)
716+
.setMultiChoiceItems(options, checkedItems) { _, index, isChecked ->
717+
checkedItems[index] = isChecked
708718
}
709-
.setPositiveButton(R.string.smoking_status_dialog_title_positive_button) { _, _ ->
710-
when (selectedOption) {
711-
0 -> hotEvents.onNext(SmokingStatusAnswered(Answer.Yes))
712-
1 -> hotEvents.onNext(SmokingStatusAnswered(Answer.No))
713-
else -> {}
719+
.setPositiveButton(R.string.tobacco_status_dialog_title_positive_button) { _, _ ->
720+
if (checkedItems[0]) {
721+
hotEvents.onNext(SmokingStatusAnswered(Answer.Yes))
722+
} else {
723+
hotEvents.onNext(SmokingStatusAnswered(Answer.No))
714724
}
715725
}
716-
.setNegativeButton(R.string.smoking_status_dialog_title_negative_button, null)
726+
.setNegativeButton(R.string.tobacco_status_dialog_title_negative_button, null)
717727
.show()
718728
}
719729

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface PatientSummaryUiActions {
4040

4141
fun showDiabetesDiagnosisWarning()
4242
fun showHypertensionDiagnosisWarning(continueToDiabetesDiagnosisWarning: Boolean)
43-
fun showSmokingStatusDialog()
43+
fun showTobaccoStatusDialog()
4444
fun openBMIEntrySheet(patientUuid: UUID)
4545
fun openCholesterolEntrySheet(patientUuid: UUID)
4646
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class PatientSummaryUpdate(
105105
is CVDRiskCalculated -> saveOrUpdateCVDRisk(event, model)
106106
is CVDRiskUpdated -> dispatch(LoadStatinInfo(model.patientUuid))
107107
is StatinInfoLoaded -> statinInfoLoaded(event, model)
108-
is AddSmokingClicked -> dispatch(ShowSmokingStatusDialog)
108+
is AddTobaccoUseClicked -> dispatch(ShowTobaccoStatusDialog)
109109
is SmokingStatusAnswered -> dispatch(UpdateSmokingStatus(model.patientUuid, event.isSmoker))
110110
is BMIReadingAdded -> dispatch(CalculateNonLabBasedCVDRisk(model.patientSummaryProfile!!.patient))
111111
is AddBMIClicked -> dispatch(OpenBMIEntrySheet(model.patientUuid))
@@ -319,11 +319,11 @@ class PatientSummaryUpdate(
319319
val bmiReading = event.bmiReading
320320
val calculatedRiskRange = event.riskRange
321321

322-
val canShowSmokingStatusDialog = event.canPrescribeStatin &&
322+
val canShowTobaccoUseDialog = event.canPrescribeStatin &&
323323
(calculatedRiskRange?.level == CVDRiskLevel.LOW_HIGH ||
324324
calculatedRiskRange?.level == CVDRiskLevel.MEDIUM_HIGH) &&
325325
medicalHistory.isSmoking == MedicalHistoryAnswer.Unanswered &&
326-
!model.hasShownSmokingStatusDialog
326+
!model.hasShownTobaccoUseDialog
327327

328328
val statinInfo = StatinInfo(
329329
canShowStatinNudge = event.canPrescribeStatin,
@@ -336,8 +336,8 @@ class PatientSummaryUpdate(
336336
cholesterol = cholesterol,
337337
)
338338

339-
return if (canShowSmokingStatusDialog) {
340-
next(model.updateStatinInfo(statinInfo).showSmokingStatusDialog(), ShowSmokingStatusDialog)
339+
return if (canShowTobaccoUseDialog) {
340+
next(model.updateStatinInfo(statinInfo).showTobaccoUseDialog(), ShowTobaccoStatusDialog)
341341
} else {
342342
next(model.updateStatinInfo(statinInfo))
343343
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PatientSummaryViewEffectHandler(
3838
)
3939
ShowDiabetesDiagnosisWarning -> uiActions.showDiabetesDiagnosisWarning()
4040
is ShowHypertensionDiagnosisWarning -> uiActions.showHypertensionDiagnosisWarning(viewEffect.continueToDiabetesDiagnosisWarning)
41-
is ShowSmokingStatusDialog -> uiActions.showSmokingStatusDialog()
41+
is ShowTobaccoStatusDialog -> uiActions.showTobaccoStatusDialog()
4242
is OpenBMIEntrySheet -> uiActions.openBMIEntrySheet(viewEffect.patientUuid)
4343
is OpenCholesterolEntrySheet -> uiActions.openCholesterolEntrySheet(viewEffect.patientUuid)
4444
}.exhaustive()

0 commit comments

Comments
 (0)