@@ -123,12 +123,62 @@ class PatientSummaryUpdate(
123
123
return when {
124
124
isLabBasedStatinNudgeEnabled -> labBasedStatinNudge(event, model)
125
125
isNonLabBasedStatinNudgeEnabled -> nonLabBasedStatinNudge(event, model)
126
+ isPatientStatinNudgeV1Enabled -> staticStatinNudge(event, model)
126
127
else -> {
127
128
throw IllegalArgumentException (" Unknown case, statin prescription check info is unhandled" )
128
129
}
129
130
}
130
131
}
131
132
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
+
132
182
private fun labBasedStatinNudge (
133
183
event : StatinPrescriptionCheckInfoLoaded ,
134
184
model : PatientSummaryModel
0 commit comments