Skip to content

Commit fe41a32

Browse files
siddh1004Siddharth Agarwal
andauthored
Update lab-based statin nudge threshold to 20% (#5435)
https://app.shortcut.com/simpledotorg/story/15529/fix-the-lab-based-statin-nudge --------- Co-authored-by: Siddharth Agarwal <[email protected]>
1 parent 4a19081 commit fe41a32

File tree

7 files changed

+61
-81
lines changed

7 files changed

+61
-81
lines changed

app/src/main/java/org/simple/clinic/cvdrisk/CVDRiskRange.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ data class CVDRiskRange(
1515
val level: CVDRiskLevel
1616
get() = CVDRiskLevel.compute(this)
1717

18-
val canPrescribeStatin: Boolean
18+
val canPrescribeNonLabBasedStatin: Boolean
1919
get() = max >= 10
2020

21+
val canPrescribeLabBasedStatin: Boolean
22+
get() = max >= 20
23+
2124
class RoomTypeConverter {
2225

2326
@TypeConverter

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PatientSummaryUpdate(
3535
private val isLabBasedStatinNudgeEnabled: Boolean,
3636
private val minAgeForStatin: Int = 40,
3737
private val maxAgeForCVDRisk: Int = 74,
38-
private val minReqMaxRiskRangeForLabBasedNudge: Int = 10,
38+
private val minReqMaxRiskRangeForLabBasedNudge: Int = 20,
3939
) : Update<PatientSummaryModel, PatientSummaryEvent, PatientSummaryEffect> {
4040

4141
override fun update(
@@ -319,9 +319,9 @@ class PatientSummaryUpdate(
319319
val bmiReading = event.bmiReading
320320
val calculatedRiskRange = event.riskRange
321321
val canPrescribeStatin = if (isLabBasedStatinNudgeEnabled) {
322-
checkIfLabBasedNudgeCanBeShown(event.medicalHistory, event.riskRange)
322+
calculatedRiskRange?.canPrescribeLabBasedStatin ?: false
323323
} else {
324-
calculatedRiskRange?.canPrescribeStatin ?: false
324+
calculatedRiskRange?.canPrescribeNonLabBasedStatin ?: false
325325
}
326326

327327
val canShowSmokingStatusDialog = canPrescribeStatin &&
@@ -353,14 +353,6 @@ class PatientSummaryUpdate(
353353
}
354354
}
355355

356-
private fun checkIfLabBasedNudgeCanBeShown(
357-
medicalHistory: MedicalHistory,
358-
riskRange: CVDRiskRange?
359-
): Boolean {
360-
val maxRiskRange = riskRange?.max ?: 0
361-
return !(medicalHistory.diagnosedWithDiabetes != Yes && maxRiskRange < minReqMaxRiskRangeForLabBasedNudge)
362-
}
363-
364356
private fun labBasedRiskRange(calculatedRiskRange: CVDRiskRange?): CVDRiskRange? {
365357
if (calculatedRiskRange == null) return null
366358

app/src/main/java/org/simple/clinic/summary/compose/StatinNudgeView.kt

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ fun StatinNudge(
9696
Spacer(modifier = Modifier.height(16.dp))
9797
DescriptionText(
9898
isLabBasedStatinNudgeEnabled = isLabBasedStatinNudgeEnabled,
99+
isNonLabBasedStatinNudgeEnabled = isNonLabBasedStatinNudgeEnabled,
99100
statinInfo = statinInfo
100101
)
101102

@@ -262,17 +263,22 @@ fun RiskProgressBar(
262263
fun DescriptionText(
263264
statinInfo: StatinInfo,
264265
isLabBasedStatinNudgeEnabled: Boolean,
266+
isNonLabBasedStatinNudgeEnabled: Boolean,
265267
) {
266268
val text = descriptionText(
267269
isLabBasedStatinNudgeEnabled = isLabBasedStatinNudgeEnabled,
270+
isNonLabBasedStatinNudgeEnabled = isNonLabBasedStatinNudgeEnabled,
268271
statinInfo = statinInfo,
269272
)
270273

271274
val textColor = when {
272-
statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel.HIGH || statinInfo.hasDiabetes
273-
-> SimpleTheme.colors.material.error
275+
statinInfo.hasDiabetes || statinInfo.hasCVD -> SimpleTheme.colors.material.error
276+
isLabBasedStatinNudgeEnabled && (statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel.VERY_HIGH) -> SimpleTheme.colors.material.error
277+
isNonLabBasedStatinNudgeEnabled && (statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel.HIGH) -> SimpleTheme.colors.material.error
278+
isLabBasedStatinNudgeEnabled && (statinInfo.isSmoker == Answer.Unanswered || statinInfo.cholesterol == null) ->
279+
SimpleTheme.colors.onSurface67
274280

275-
statinInfo.isSmoker == Answer.Unanswered || statinInfo.bmiReading == null || statinInfo.cholesterol == null ->
281+
isNonLabBasedStatinNudgeEnabled && (statinInfo.isSmoker == Answer.Unanswered || statinInfo.bmiReading == null) ->
276282
SimpleTheme.colors.onSurface67
277283

278284
else -> SimpleTheme.colors.material.error
@@ -294,46 +300,67 @@ fun DescriptionText(
294300
@Composable
295301
@ReadOnlyComposable
296302
private fun descriptionText(
303+
isNonLabBasedStatinNudgeEnabled: Boolean,
297304
isLabBasedStatinNudgeEnabled: Boolean,
298305
statinInfo: StatinInfo
299306
): AnnotatedString {
300-
val maxCvdRiskRange = statinInfo.cvdRisk?.max ?: 0
301-
302307
return when {
303308
statinInfo.hasCVD -> stringResource(R.string.statin_alert_refer_to_doctor)
304309

305-
statinInfo.hasDiabetes && statinInfo.age >= MIN_AGE_FOR_STATIN && isLabBasedStatinNudgeEnabled.not() ->
310+
statinInfo.hasDiabetes && statinInfo.age >= MIN_AGE_FOR_STATIN ->
306311
stringResource(R.string.statin_alert_refer_to_doctor_diabetic_40)
307312

308-
statinInfo.hasDiabetes && statinInfo.age >= MIN_AGE_FOR_STATIN && isLabBasedStatinNudgeEnabled && maxCvdRiskRange < LAB_BASED_MIN_REQ_MAX_RISK_RANGE ->
309-
stringResource(R.string.statin_alert_refer_to_doctor_diabetic_40)
313+
isLabBasedStatinNudgeEnabled -> labBasedDescriptionText(statinInfo)
314+
isNonLabBasedStatinNudgeEnabled -> nonLabBasedDescriptionText(statinInfo)
310315

311-
statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel.HIGH ->
312-
stringResource(R.string.statin_alert_refer_to_doctor)
316+
else -> stringResource(R.string.statin_alert_refer_to_doctor)
317+
}.toAnnotatedString()
318+
}
313319

314-
statinInfo.hasDiabetes && isLabBasedStatinNudgeEnabled ->
315-
stringResource(R.string.statin_alert_refer_to_doctor_diabetic)
320+
@Composable
321+
@ReadOnlyComposable
322+
private fun labBasedDescriptionText(
323+
statinInfo: StatinInfo
324+
): String {
325+
return when {
316326

317-
statinInfo.isSmoker == Answer.Unanswered && statinInfo.bmiReading == null && isLabBasedStatinNudgeEnabled.not() ->
318-
stringResource(R.string.statin_alert_add_smoking_and_bmi_info)
327+
statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel.VERY_HIGH ->
328+
stringResource(R.string.statin_alert_refer_to_doctor)
329+
330+
statinInfo.isSmoker == Answer.Unanswered && statinInfo.cholesterol == null ->
331+
stringResource(R.string.statin_alert_add_smoking_and_cholesterol_info)
319332

320-
statinInfo.isSmoker == Answer.Unanswered && statinInfo.bmiReading != null && isLabBasedStatinNudgeEnabled.not() ->
333+
statinInfo.isSmoker == Answer.Unanswered && statinInfo.cholesterol != null ->
321334
stringResource(R.string.statin_alert_add_smoking_info)
322335

323-
statinInfo.isSmoker != Answer.Unanswered && statinInfo.bmiReading == null && isLabBasedStatinNudgeEnabled.not() ->
324-
stringResource(R.string.statin_alert_add_bmi_info)
336+
statinInfo.isSmoker != Answer.Unanswered && statinInfo.cholesterol == null ->
337+
stringResource(R.string.statin_alert_add_cholesterol_info)
325338

326-
statinInfo.isSmoker == Answer.Unanswered && statinInfo.cholesterol == null && isLabBasedStatinNudgeEnabled ->
327-
stringResource(R.string.statin_alert_add_smoking_and_cholesterol_info)
339+
else -> stringResource(R.string.statin_alert_refer_to_doctor)
340+
}
341+
}
342+
343+
@Composable
344+
@ReadOnlyComposable
345+
private fun nonLabBasedDescriptionText(
346+
statinInfo: StatinInfo
347+
): String {
348+
return when {
328349

329-
statinInfo.isSmoker == Answer.Unanswered && statinInfo.cholesterol != null && isLabBasedStatinNudgeEnabled ->
350+
statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel.HIGH ->
351+
stringResource(R.string.statin_alert_refer_to_doctor)
352+
353+
statinInfo.isSmoker == Answer.Unanswered && statinInfo.bmiReading == null ->
354+
stringResource(R.string.statin_alert_add_smoking_and_bmi_info)
355+
356+
statinInfo.isSmoker == Answer.Unanswered && statinInfo.bmiReading != null ->
330357
stringResource(R.string.statin_alert_add_smoking_info)
331358

332-
statinInfo.isSmoker != Answer.Unanswered && statinInfo.cholesterol == null && isLabBasedStatinNudgeEnabled ->
333-
stringResource(R.string.statin_alert_add_cholesterol_info)
359+
statinInfo.isSmoker != Answer.Unanswered && statinInfo.bmiReading == null ->
360+
stringResource(R.string.statin_alert_add_bmi_info)
334361

335362
else -> stringResource(R.string.statin_alert_refer_to_doctor)
336-
}.toAnnotatedString()
363+
}
337364
}
338365

339366
@Composable

app/src/main/res/values-si-rLK/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,6 @@
926926
<string name="statin_alert_at_risk_patient">අවදානමක් සහිත රෝගීන්</string>
927927
<string name="statin_alert_refer_to_doctor">&lt;b&gt;ස්ටැටින් ප්‍රතිකාර&lt;/b&gt; සදහා වෛද්‍යවරයා වෙත යොමු කරන්න</string>
928928
<string name="statin_alert_refer_to_doctor_diabetic_40"> වයස අවුරුදු 40 ට වැඩි, දියවැඩියා රෝගියෙකු නම් ස්ටැටින් ඖෂධ සඳහා වෛද්‍යවරයා වෙත යොමු කරන්න</string>
929-
<string name="statin_alert_refer_to_doctor_diabetic"> දියවැඩියා රෝගියෙකු නම් ස්ටැටින් ඖෂධ සඳහා වෛද්‍යවරයා වෙත යොමු කරන්න</string>
930929
<string name="statin_alert_add_smoking">දුම් පානය</string>
931930
<string name="statin_alert_add_bmi">BMI අගය</string>
932931
<string name="statin_alert_add_cholesterol">කොලෙස්ටරෝල් අගය එකතු කරන්න</string>

app/src/main/res/values-ta-rLK/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@
925925
<string name="statin_alert_at_risk_patient">ஆபத்தில் உள்ள நோயாளி</string>
926926
<string name="statin_alert_refer_to_doctor">&lt;b&gt;ஸ்டேடின் மருந்துக்காக&lt;/b&gt; மருத்துவரை அணுகவும்</string>
927927
<string name="statin_alert_refer_to_doctor_diabetic_40">நீரிழிவு நோயாளி, 40 வயதுக்கு மேற்பட்டவர் எனின் ஸ்டேடின்(statin) மருந்துக்கு மருத்துவரை நாடவும்</string>
928-
<string name="statin_alert_refer_to_doctor_diabetic"> நீரிழிவு நோயாளி எனின் ஸ்டேடின் மருந்துக்கு மருத்துவரைப் நாடவும்</string>
929928
<string name="statin_alert_add_smoking">புகைத்தலைச் சேர்க்க</string>
930929
<string name="statin_alert_add_bmi">உடற் திணிவுச் சுட்டியினை சேர்க்க</string>
931930
<string name="statin_alert_add_cholesterol">கொலஸ்ட்ரோலின் அளவைக் கூட்டுக</string>

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,6 @@ The Simple app contains private health information of patients (“Data”).\n\n
10931093
<string name="statin_alert_at_risk_patient">AT RISK PATIENT</string>
10941094
<string name="statin_alert_refer_to_doctor">Refer to doctor for &lt;b&gt;statin medicine&lt;/b&gt;</string>
10951095
<string name="statin_alert_refer_to_doctor_diabetic_40">Diabetic patient, age above 40. Refer to doctor for &lt;b&gt;statin medicine&lt;/b&gt;</string>
1096-
<string name="statin_alert_refer_to_doctor_diabetic">Diabetic patient. Refer to doctor for &lt;b&gt;statin medicine&lt;/b&gt;</string>
10971096
<string name="statin_alert_add_smoking">Add smoking</string>
10981097
<string name="statin_alert_add_bmi">Add BMI</string>
10991098
<string name="statin_alert_add_cholesterol">Add cholesterol</string>

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

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ class PatientSummaryUpdateTest {
23772377
fun `when statin info is loaded, then update the state`() {
23782378
val statinInfo = StatinInfo(
23792379
canShowStatinNudge = true,
2380-
cvdRisk = CVDRiskRange(11, 11),
2380+
cvdRisk = CVDRiskRange(11, 27),
23812381
isSmoker = Yes,
23822382
bmiReading = BMIReading(165f, 60f),
23832383
hasCVD = true,
@@ -2397,7 +2397,7 @@ class PatientSummaryUpdateTest {
23972397
isSmoking = Yes,
23982398
cholesterol = null,
23992399
),
2400-
riskRange = CVDRiskRange(11, 11),
2400+
riskRange = CVDRiskRange(11, 27),
24012401
bmiReading = BMIReading(165f, 60f),
24022402
))
24032403
.then(assertThatNext(
@@ -2445,45 +2445,6 @@ class PatientSummaryUpdateTest {
24452445
))
24462446
}
24472447

2448-
@Test
2449-
fun `when statin info is loaded and lab-based statin is enabled and has diabetes, then statin can be prescribed`() {
2450-
val statinInfo = StatinInfo(
2451-
canShowStatinNudge = true,
2452-
cvdRisk = null,
2453-
isSmoker = Yes,
2454-
bmiReading = BMIReading(165f, 60f),
2455-
hasCVD = true,
2456-
hasDiabetes = true,
2457-
age = 55,
2458-
cholesterol = null,
2459-
)
2460-
val updateSpec = UpdateSpec(PatientSummaryUpdate(
2461-
isPatientReassignmentFeatureEnabled = true,
2462-
isPatientStatinNudgeV1Enabled = true,
2463-
isNonLabBasedStatinNudgeEnabled = true,
2464-
isLabBasedStatinNudgeEnabled = true,
2465-
))
2466-
2467-
updateSpec
2468-
.given(defaultModel)
2469-
.whenEvent(StatinInfoLoaded(
2470-
age = 55,
2471-
medicalHistory = TestData.medicalHistory(
2472-
hasHadStroke = Yes,
2473-
hasHadHeartAttack = Yes,
2474-
hasDiabetes = Yes,
2475-
isSmoking = Yes,
2476-
cholesterol = null,
2477-
),
2478-
riskRange = CVDRiskRange(9, 9),
2479-
bmiReading = BMIReading(165f, 60f),
2480-
))
2481-
.then(assertThatNext(
2482-
hasModel(defaultModel.updateStatinInfo(statinInfo)),
2483-
hasNoEffects()
2484-
))
2485-
}
2486-
24872448
@Test
24882449
fun `when statin info is loaded and lab-based statin is enabled and has diabetes and max risk is less than 10, then statin cannot be prescribed`() {
24892450
val statinInfo = StatinInfo(
@@ -2527,7 +2488,7 @@ class PatientSummaryUpdateTest {
25272488
fun `when statin info is loaded and risk is low-high, then update the state and show smoking status dialog`() {
25282489
val statinInfo = StatinInfo(
25292490
canShowStatinNudge = true,
2530-
cvdRisk = CVDRiskRange(4, 11),
2491+
cvdRisk = CVDRiskRange(4, 27),
25312492
isSmoker = Unanswered,
25322493
bmiReading = BMIReading(165f, 60f),
25332494
hasCVD = true,
@@ -2546,7 +2507,7 @@ class PatientSummaryUpdateTest {
25462507
isSmoking = Unanswered,
25472508
cholesterol = null,
25482509
),
2549-
riskRange = CVDRiskRange(4, 11),
2510+
riskRange = CVDRiskRange(4, 27),
25502511
bmiReading = BMIReading(165f, 60f),
25512512
))
25522513
.then(assertThatNext(

0 commit comments

Comments
 (0)