@@ -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