Skip to content

Commit 2e39093

Browse files
author
sagarwal
committed
Update new medical history screen diagnosis question options based on feature flag
1 parent 9968ea1 commit 2e39093

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

app/src/main/java/org/simple/clinic/medicalhistory/newentry/NewMedicalHistoryModel.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ data class NewMedicalHistoryModel(
2222
val hasShownChangeDiagnosisError: Boolean,
2323
val showIsSmokingQuestion: Boolean,
2424
val showSmokelessTobaccoQuestion: Boolean,
25+
val isScreeningFeatureEnabled: Boolean,
2526
) : Parcelable {
2627

2728
val hasLoadedPatientEntry: Boolean
@@ -76,7 +77,8 @@ data class NewMedicalHistoryModel(
7677
fun default(
7778
country: Country,
7879
showIsSmokingQuestion: Boolean,
79-
showSmokelessTobaccoQuestion: Boolean
80+
showSmokelessTobaccoQuestion: Boolean,
81+
isScreeningFeatureEnabled: Boolean,
8082
): NewMedicalHistoryModel = NewMedicalHistoryModel(
8183
country = country,
8284
ongoingPatientEntry = null,
@@ -85,7 +87,8 @@ data class NewMedicalHistoryModel(
8587
nextButtonState = null,
8688
hasShownChangeDiagnosisError = false,
8789
showIsSmokingQuestion = showIsSmokingQuestion,
88-
showSmokelessTobaccoQuestion = showSmokelessTobaccoQuestion
90+
showSmokelessTobaccoQuestion = showSmokelessTobaccoQuestion,
91+
isScreeningFeatureEnabled = isScreeningFeatureEnabled,
8992
)
9093
}
9194

app/src/main/java/org/simple/clinic/medicalhistory/newentry/NewMedicalHistoryViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class NewMedicalHistoryViewModel(
2222
country = country,
2323
showIsSmokingQuestion = features.isEnabled(Feature.NonLabBasedStatinNudge) ||
2424
features.isEnabled(Feature.LabBasedStatinNudge),
25-
showSmokelessTobaccoQuestion = country.isoCountryCode != Country.ETHIOPIA
25+
showSmokelessTobaccoQuestion = country.isoCountryCode != Country.ETHIOPIA,
26+
isScreeningFeatureEnabled = features.isEnabled(Feature.Screening),
2627
),
2728
init = NewMedicalHistoryInit(),
2829
loopFactoryProvider = { viewEffectsConsumer ->

app/src/main/java/org/simple/clinic/medicalhistory/ui/MedicalHistoryDiagnosisWithTreatment.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fun MedicalHistoryDiagnosisWithTreatment(
2929
treatmentQuestion: MedicalHistoryQuestion,
3030
treatmentAnswer: Answer?,
3131
showTreatmentQuestion: Boolean,
32+
isScreeningFeatureEnabled: Boolean,
3233
modifier: Modifier = Modifier,
3334
onSelectionChange: (MedicalHistoryQuestion, Answer) -> Unit,
3435
) {
@@ -43,10 +44,16 @@ fun MedicalHistoryDiagnosisWithTreatment(
4344
modifier = Modifier.padding(dimensionResource(R.dimen.spacing_16))
4445
) {
4546

47+
val options = if (isScreeningFeatureEnabled) {
48+
listOf(Answer.Yes, Answer.No, Answer.Suspected)
49+
} else {
50+
listOf(Answer.Yes, Answer.No)
51+
}
52+
4653
MedicalHistoryDiagnosisQuestionItem(
4754
header = diagnosisLabel,
4855
question = diagnosisQuestion,
49-
options = listOf(Answer.Yes, Answer.No, Answer.Suspected),
56+
options = options,
5057
selectedAnswer = diagnosisAnswer,
5158
onAnswerChange = onSelectionChange
5259
)
@@ -85,6 +92,7 @@ private fun MedicalHistoryDiagnosisWithTreatmentPreview() {
8592
treatmentQuestion = IsOnHypertensionTreatment(Country.INDIA),
8693
treatmentAnswer = Answer.Unanswered,
8794
showTreatmentQuestion = true,
95+
isScreeningFeatureEnabled = true,
8896
onSelectionChange = { _, _ -> }
8997
)
9098
}

app/src/main/java/org/simple/clinic/medicalhistory/ui/NewMedicalHistoryUi.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ fun NewMedicalHistoryUi(
9494
treatmentQuestion = IsOnHypertensionTreatment(model.country.isoCountryCode),
9595
treatmentAnswer = model.ongoingMedicalHistoryEntry.isOnHypertensionTreatment,
9696
showTreatmentQuestion = model.showOngoingHypertensionTreatment,
97+
isScreeningFeatureEnabled = model.isScreeningFeatureEnabled,
9798
onSelectionChange = onSelectionChange
9899
)
99100
if (showDiabetesDiagnosis) {
@@ -104,6 +105,7 @@ fun NewMedicalHistoryUi(
104105
treatmentQuestion = IsOnDiabetesTreatment,
105106
treatmentAnswer = model.ongoingMedicalHistoryEntry.isOnDiabetesTreatment,
106107
showTreatmentQuestion = model.showOngoingDiabetesTreatment,
108+
isScreeningFeatureEnabled = model.isScreeningFeatureEnabled,
107109
onSelectionChange = onSelectionChange
108110
)
109111
}
@@ -141,7 +143,8 @@ private val previewMedicalHistoryModel = NewMedicalHistoryModel(
141143
nextButtonState = null,
142144
hasShownChangeDiagnosisError = true,
143145
showIsSmokingQuestion = true,
144-
showSmokelessTobaccoQuestion = true
146+
showSmokelessTobaccoQuestion = true,
147+
isScreeningFeatureEnabled = true
145148
)
146149

147150
@Preview

app/src/test/java/org/simple/clinic/medicalhistory/newentry/NewMedicalHistoryInitTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class NewMedicalHistoryInitTest {
1414
private val defaultModel = NewMedicalHistoryModel.default(
1515
country = country,
1616
showIsSmokingQuestion = false,
17-
showSmokelessTobaccoQuestion = false
17+
showSmokelessTobaccoQuestion = false,
18+
isScreeningFeatureEnabled = true,
1819
)
1920

2021
private val initSpec = InitSpec(NewMedicalHistoryInit())

app/src/test/java/org/simple/clinic/medicalhistory/newentry/NewMedicalHistoryScreenLogicTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ class NewMedicalHistoryScreenLogicTest {
306306
defaultModel = NewMedicalHistoryModel.default(
307307
country = country,
308308
showIsSmokingQuestion = true,
309-
showSmokelessTobaccoQuestion = true
309+
showSmokelessTobaccoQuestion = true,
310+
isScreeningFeatureEnabled = true,
310311
),
311312
init = NewMedicalHistoryInit(),
312313
update = NewMedicalHistoryUpdate(),

0 commit comments

Comments
 (0)