Skip to content

Commit 403693b

Browse files
siddh1004sagarwal
andauthored
Update tobacco use dialog to single option select in Ethiopia (#5538)
https://app.shortcut.com/simpledotorg/story/16485/update-tobacco-use-dialog-to-single-option-select-in-ethiopia --------- Co-authored-by: sagarwal <[email protected]>
1 parent 5499774 commit 403693b

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
- Update min sdk version to 26 (Android 8.0)
2525
- Update statin translations for `om-ET` and `sid-ET`
26+
- Update tobacco use dialog to single option select in Ethiopia
2627

2728
## 2025.08.13
2829

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

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -692,18 +692,19 @@ class PatientSummaryScreen :
692692
}
693693

694694
override fun showTobaccoStatusDialog() {
695-
val options = if (country.isoCountryCode == Country.ETHIOPIA) {
696-
arrayOf(
697-
getString(R.string.tobacco_status_dialog_option_smokes),
698-
getString(R.string.tobacco_status_dialog_option_no)
699-
)
695+
if (country.isoCountryCode == Country.ETHIOPIA) {
696+
showTobaccoUseDialogWithoutSmokelessTobacco()
700697
} else {
701-
arrayOf(
702-
getString(R.string.tobacco_status_dialog_option_smokes),
703-
getString(R.string.tobacco_status_dialog_option_smokeless),
704-
getString(R.string.tobacco_status_dialog_option_no)
705-
)
698+
showTobaccoUseDialogWithSmokelessTobacco()
706699
}
700+
}
701+
702+
fun showTobaccoUseDialogWithSmokelessTobacco() {
703+
val options = arrayOf(
704+
getString(R.string.tobacco_status_dialog_option_smokes),
705+
getString(R.string.tobacco_status_dialog_option_smokeless),
706+
getString(R.string.tobacco_status_dialog_option_no)
707+
)
707708

708709
val checkedItems = BooleanArray(options.size)
709710

@@ -723,6 +724,29 @@ class PatientSummaryScreen :
723724
.show()
724725
}
725726

727+
fun showTobaccoUseDialogWithoutSmokelessTobacco() {
728+
val options = arrayOf(
729+
getString(R.string.tobacco_status_dialog_option_smokes),
730+
getString(R.string.tobacco_status_dialog_option_no))
731+
732+
var selectedOption = 1
733+
734+
MaterialAlertDialogBuilder(requireContext(), R.style.ThemeOverlay_Simple_MaterialAlertDialog_CheckedItem)
735+
.setTitle(R.string.tobacco_status_dialog_title)
736+
.setSingleChoiceItems(options, selectedOption) { _, indexSelected ->
737+
selectedOption = indexSelected
738+
}
739+
.setPositiveButton(R.string.tobacco_status_dialog_title_positive_button) { _, _ ->
740+
when (selectedOption) {
741+
0 -> hotEvents.onNext(SmokingStatusAnswered(Answer.Yes))
742+
1 -> hotEvents.onNext(SmokingStatusAnswered(Answer.No))
743+
else -> {}
744+
}
745+
}
746+
.setNegativeButton(R.string.tobacco_status_dialog_title_negative_button, null)
747+
.show()
748+
}
749+
726750
override fun openCholesterolEntrySheet(patientUuid: UUID) {
727751
router.pushExpectingResult(ScreenRequest.CholesterolEntrySheet, CholesterolEntrySheet.Key(patientUuid))
728752
}

0 commit comments

Comments
 (0)