@@ -40,6 +40,7 @@ import org.simple.clinic.R
4040import org.simple.clinic.common.ui.components.FilledButton
4141import org.simple.clinic.common.ui.theme.SimpleInverseTheme
4242import org.simple.clinic.common.ui.theme.SimpleTheme
43+ import org.simple.clinic.cvdrisk.CVDRiskLevel
4344import org.simple.clinic.cvdrisk.CVDRiskRange
4445import org.simple.clinic.cvdrisk.StatinInfo
4546import org.simple.clinic.medicalhistory.Answer
@@ -119,15 +120,10 @@ fun RiskText(
119120 val riskText = when {
120121 hasCVD -> stringResource(R .string.statin_alert_very_high_risk_patient)
121122 cvdRiskRange == null -> stringResource(R .string.statin_alert_at_risk_patient)
122- cvdRiskRange.min > 10 -> stringResource(R .string.statin_alert_high_risk_patient_x, riskPercentage)
123- cvdRiskRange.min < 5 -> stringResource(R .string.statin_alert_low_high_risk_patient_x, riskPercentage)
124- else -> stringResource(R .string.statin_alert_medium_high_risk_patient_x, riskPercentage)
123+ else -> stringResource(cvdRiskRange.level.displayStringResId, riskPercentage)
125124 }
126125
127- val riskColor = when {
128- cvdRiskRange == null || cvdRiskRange.min > 10 -> SimpleTheme .colors.material.error
129- else -> Color (0xFFFF7A00 )
130- }
126+ val riskColor = cvdRiskRange?.level?.color ? : SimpleTheme .colors.material.error
131127
132128 val textMeasurer = rememberTextMeasurer()
133129 val textWidth = textMeasurer.measure(
@@ -164,11 +160,11 @@ fun RiskProgressBar(
164160 endOffset : Float
165161) {
166162 val riskColors = listOf (
167- Color (0xFF00B849 ), // Very Low
168- Color (0xFFFFC800 ), // Low
169- SimpleTheme .colors.material.error, // Medium
170- Color (0xFFB81631 ), // High
171- Color (0xFF731814 ) // Very High
163+ Color (0xFF00B849 ), // Low
164+ Color (0xFFFFC800 ), // MEDIUM
165+ SimpleTheme .colors.material.error, // HIGH
166+ Color (0xFFB81631 ), // VERY HIGH
167+ Color (0xFF731814 ) // CRITICAL
172168 )
173169
174170 val indicatorColor = Color (0xFF2F363D )
@@ -240,26 +236,28 @@ fun DescriptionText(
240236 statinInfo : StatinInfo
241237) {
242238 val text = when {
243- statinInfo.cvdRisk == null ||
244- statinInfo.cvdRisk.min >= 10 -> stringResource(R .string.statin_alert_refer_to_doctor)
239+ statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel . HIGH ->
240+ stringResource(R .string.statin_alert_refer_to_doctor)
245241
246- statinInfo.isSmoker == Answer .Unanswered &&
247- statinInfo.bmiReading == null -> stringResource(R .string.statin_alert_add_smoking_and_bmi_info)
242+ statinInfo.isSmoker == Answer .Unanswered && statinInfo.bmiReading == null ->
243+ stringResource(R .string.statin_alert_add_smoking_and_bmi_info)
248244
249- statinInfo.isSmoker == Answer .Unanswered &&
250- statinInfo.bmiReading != null -> stringResource(R .string.statin_alert_add_smoking_info)
245+ statinInfo.isSmoker == Answer .Unanswered && statinInfo.bmiReading != null ->
246+ stringResource(R .string.statin_alert_add_smoking_info)
251247
252- statinInfo.isSmoker != Answer .Unanswered &&
253- statinInfo.bmiReading == null -> stringResource(R .string.statin_alert_add_bmi_info)
248+ statinInfo.isSmoker != Answer .Unanswered && statinInfo.bmiReading == null ->
249+ stringResource(R .string.statin_alert_add_bmi_info)
254250
255251 else -> stringResource(R .string.statin_alert_refer_to_doctor)
256252 }.toAnnotatedString()
257253
258254 val textColor = when {
259- statinInfo.cvdRisk == null ||
260- statinInfo.cvdRisk.min >= 10 -> SimpleTheme .colors.material.error
255+ statinInfo.cvdRisk == null || statinInfo.cvdRisk.level == CVDRiskLevel .HIGH
256+ -> SimpleTheme .colors.material.error
257+
258+ statinInfo.isSmoker == Answer .Unanswered || statinInfo.bmiReading == null ->
259+ SimpleTheme .colors.onSurface67
261260
262- statinInfo.isSmoker == Answer .Unanswered || statinInfo.bmiReading == null -> SimpleTheme .colors.onSurface67
263261 else -> SimpleTheme .colors.material.error
264262 }
265263
@@ -324,11 +322,11 @@ fun StainNudgeAddButtons(
324322
325323fun getOffsets (cvdRiskRange : CVDRiskRange ? , size : Size ): Pair <Float , Float > {
326324 val riskRanges = listOf (
327- 0 .. 4 , // Very Low
328- 5 .. 9 , // Low
329- 10 .. 19 , // Medium
330- 20 .. 29 , // High
331- 30 .. 33 // Very High
325+ 0 .. 4 , // LOW
326+ 5 .. 9 , // MEDIUM
327+ 10 .. 19 , // HIGH
328+ 20 .. 29 , // VERY HIGH
329+ 30 .. 33 // CRITICAL
332330 )
333331
334332 val startRatio: Float
0 commit comments