Skip to content

Commit 75bfb3a

Browse files
siddh1004Siddharth Agarwal
and
Siddharth Agarwal
authored
Fix the static statin nudge visibility (#5429)
https://app.shortcut.com/simpledotorg/story/15553/fix-the-static-statin-nudge-visibility --------- Co-authored-by: Siddharth Agarwal <[email protected]>
1 parent 2609636 commit 75bfb3a

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
### Fixes
4040

4141
- Fix crash when displaying large statin risk percentage text
42+
- Fix visibility for static statin nudge
4243

4344
## 2025.04.07
4445

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,62 @@ class PatientSummaryUpdate(
123123
return when {
124124
isLabBasedStatinNudgeEnabled -> labBasedStatinNudge(event, model)
125125
isNonLabBasedStatinNudgeEnabled -> nonLabBasedStatinNudge(event, model)
126+
isPatientStatinNudgeV1Enabled -> staticStatinNudge(event, model)
126127
else -> {
127128
throw IllegalArgumentException("Unknown case, statin prescription check info is unhandled")
128129
}
129130
}
130131
}
131132

133+
private fun staticStatinNudge(
134+
event: StatinPrescriptionCheckInfoLoaded,
135+
model: PatientSummaryModel
136+
): Next<PatientSummaryModel, PatientSummaryEffect> {
137+
val hasHadStroke = event.medicalHistory.hasHadStroke == Yes
138+
val hasHadHeartAttack = event.medicalHistory.hasHadHeartAttack == Yes
139+
val hasDiabetes = event.medicalHistory.diagnosedWithDiabetes == Yes
140+
141+
val hasCVD = hasHadStroke || hasHadHeartAttack
142+
val areStatinsPrescribedAlready = event.prescriptions.any { it.name.contains("statin", ignoreCase = true) }
143+
val canPrescribeStatin = event.isPatientDead.not() &&
144+
event.wasBPMeasuredWithin90Days &&
145+
areStatinsPrescribedAlready.not()
146+
147+
return when {
148+
hasCVD -> {
149+
val updatedModel = model.updateStatinInfo(
150+
StatinInfo(
151+
canShowStatinNudge = canPrescribeStatin,
152+
hasCVD = true
153+
)
154+
)
155+
156+
next(updatedModel)
157+
}
158+
159+
hasDiabetes && event.age >= minAgeForStatin -> {
160+
val updatedModel = model.updateStatinInfo(
161+
StatinInfo(
162+
canShowStatinNudge = canPrescribeStatin,
163+
hasDiabetes = true
164+
)
165+
)
166+
167+
next(updatedModel)
168+
}
169+
170+
else -> {
171+
val updatedModel = model.updateStatinInfo(
172+
StatinInfo(
173+
canShowStatinNudge = false,
174+
hasCVD = false
175+
)
176+
)
177+
next(updatedModel)
178+
}
179+
}
180+
}
181+
132182
private fun labBasedStatinNudge(
133183
event: StatinPrescriptionCheckInfoLoaded,
134184
model: PatientSummaryModel

0 commit comments

Comments
 (0)