Skip to content

Commit 7fa5fec

Browse files
siddh1004sagarwal
andauthored
Update Refer to diagnosis option visibility based on feature flag Screening (#5659)
https://app.shortcut.com/simpledotorg/story/17239/add-a-flipper-flag-to-handle-suspected-feature --------- Co-authored-by: sagarwal <[email protected]>
1 parent d6e0b70 commit 7fa5fec

File tree

12 files changed

+49
-13
lines changed

12 files changed

+49
-13
lines changed

CHANGELOG.md

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

3636
- Hide next button when registration is going
3737
- Add Suspected option to hypertension and diabetes questions
38+
- Handle Screening feature visibility based on feature flag `Screening`
3839

3940
## 2025.09.09
4041

app/src/main/java/org/simple/clinic/feature/Feature.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ enum class Feature(
2525
PatientReassignment(false, "patient_reassignment_v0"),
2626
PatientStatinNudge(false, "patient_statin_nudge_v0"),
2727
NonLabBasedStatinNudge(false, "non_lab_based_statin_nudge"),
28-
LabBasedStatinNudge(false, "lab_based_statin_nudge")
28+
LabBasedStatinNudge(false, "lab_based_statin_nudge"),
29+
Screening(false, "screening_feature_v0")
2930
}

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/DiagnosisContainer.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fun DiagnosisContainer(
2121
hypertensionAnswer: Answer?,
2222
diabetesAnswer: Answer?,
2323
showDiabetesDiagnosisView: Boolean,
24+
isScreeningFeatureEnabled: Boolean,
2425
modifier: Modifier = Modifier,
2526
onAnswerChange: (MedicalHistoryQuestion, Answer) -> Unit,
2627
) {
@@ -30,10 +31,16 @@ fun DiagnosisContainer(
3031
.padding(dimensionResource(R.dimen.spacing_16))
3132
) {
3233

34+
val options = if (isScreeningFeatureEnabled) {
35+
listOf(Answer.Yes, Answer.No, Answer.Suspected)
36+
} else {
37+
listOf(Answer.Yes, Answer.No)
38+
}
39+
3340
MedicalHistoryDiagnosisQuestionItem(
3441
header = stringResource(R.string.medicalhistorysummaryview_hypertension_diagnosis),
3542
question = MedicalHistoryQuestion.DiagnosedWithHypertension,
36-
options = listOf(Answer.Yes, Answer.No, Answer.Suspected),
43+
options = options,
3744
selectedAnswer = hypertensionAnswer,
3845
onAnswerChange = onAnswerChange
3946
)
@@ -49,7 +56,7 @@ fun DiagnosisContainer(
4956
MedicalHistoryDiagnosisQuestionItem(
5057
header = stringResource(R.string.medicalhistorysummaryview_diabetes_diagnosis),
5158
question = MedicalHistoryQuestion.DiagnosedWithDiabetes,
52-
options = listOf(Answer.Yes, Answer.No, Answer.Suspected),
59+
options = options,
5360
selectedAnswer = diabetesAnswer,
5461
onAnswerChange = onAnswerChange
5562
)
@@ -66,6 +73,7 @@ fun DiagnosisContainerPreview(modifier: Modifier = Modifier) {
6673
hypertensionAnswer = Answer.Yes,
6774
diabetesAnswer = Answer.No,
6875
showDiabetesDiagnosisView = true,
76+
isScreeningFeatureEnabled = true,
6977
modifier = modifier,
7078
onAnswerChange = { _, _ -> }
7179
)

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/main/java/org/simple/clinic/summary/medicalhistory/MedicalHistorySummaryView.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ class MedicalHistorySummaryView(
122122
isUsingSmokelessTobaccoAnswer = medicalHistory?.isUsingSmokelessTobacco,
123123
diabetesManagementEnabled = diabetesManagementEnabled,
124124
showSmokerQuestion = showSmokerQuestion,
125-
showSmokelessTobaccoQuestion = showSmokelessTobaccoQuestion
125+
showSmokelessTobaccoQuestion = showSmokelessTobaccoQuestion,
126+
isScreeningFeatureEnabled = features.isEnabled(Feature.Screening)
126127
) { question, answer ->
127128
answerToggled(question, answer)
128129
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fun MedicalHistorySummary(
2828
diabetesManagementEnabled: Boolean,
2929
showSmokerQuestion: Boolean,
3030
showSmokelessTobaccoQuestion: Boolean,
31+
isScreeningFeatureEnabled: Boolean,
3132
modifier: Modifier = Modifier,
3233
onAnswerChange: (MedicalHistoryQuestion, Answer) -> Unit,
3334
) {
@@ -42,6 +43,7 @@ fun MedicalHistorySummary(
4243
hypertensionAnswer = hypertensionAnswer,
4344
diabetesAnswer = diabetesAnswer,
4445
showDiabetesDiagnosisView = diabetesManagementEnabled,
46+
isScreeningFeatureEnabled = isScreeningFeatureEnabled,
4547
onAnswerChange = onAnswerChange,
4648
)
4749

@@ -80,6 +82,7 @@ private fun MedicalHistorySummaryPreview() {
8082
diabetesManagementEnabled = true,
8183
showSmokerQuestion = false,
8284
showSmokelessTobaccoQuestion = false,
85+
isScreeningFeatureEnabled = true,
8386
onAnswerChange = { _, _ ->
8487
// no-op
8588
}
@@ -102,6 +105,7 @@ private fun MedicalHistorySummaryNoDiabetesManagementPreview() {
102105
diabetesManagementEnabled = false,
103106
showSmokerQuestion = false,
104107
showSmokelessTobaccoQuestion = false,
108+
isScreeningFeatureEnabled = true,
105109
onAnswerChange = { _, _ ->
106110
// no-op
107111
}
@@ -124,6 +128,7 @@ private fun MedicalHistorySummarySmokerPreview() {
124128
diabetesManagementEnabled = true,
125129
showSmokerQuestion = true,
126130
showSmokelessTobaccoQuestion = false,
131+
isScreeningFeatureEnabled = true,
127132
onAnswerChange = { _, _ ->
128133
// no-op
129134
}
@@ -146,6 +151,7 @@ private fun MedicalHistorySummaryTobaccoUsePreview() {
146151
diabetesManagementEnabled = true,
147152
showSmokerQuestion = true,
148153
showSmokelessTobaccoQuestion = true,
154+
isScreeningFeatureEnabled = true,
149155
onAnswerChange = { _, _ ->
150156
// no-op
151157
}

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())

0 commit comments

Comments
 (0)