Skip to content

Commit

Permalink
Call LoadStatinInfo when risk is loaded or calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Dec 20, 2024
1 parent fddbe25 commit 9f41b95
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PatientSummaryUpdate(
is HypertensionNotNowClicked -> hypertensionNotNowClicked(event.continueToDiabetesDiagnosisWarning)
is StatinPrescriptionCheckInfoLoaded -> statinPrescriptionCheckInfoLoaded(event, model)
is CVDRiskLoaded -> cvdRiskLoaded(event, model)
is CVDRiskCalculated -> cvdRiskCalculated(event, model)
is CVDRiskCalculated -> dispatch(LoadStatinInfo(model.patientUuid))
is StatinInfoLoaded -> statinInfoLoaded(event, model)
}
}
Expand Down Expand Up @@ -129,30 +129,18 @@ class PatientSummaryUpdate(
): Next<PatientSummaryModel, PatientSummaryEffect> {
val cvdRisk = event.risk
return if (cvdRisk != null) {
//load statin
noChange()

dispatch(LoadStatinInfo(model.patientUuid))
} else {
noChange()
//calculate cvd risk
dispatch(CalculateCVDRisk(model.patientSummaryProfile!!.patient))
}
}

private fun cvdRiskCalculated(
event: CVDRiskCalculated,
model: PatientSummaryModel
): Next<PatientSummaryModel, PatientSummaryEffect> {
val cvdRisk = event.risk
//load statin nudge info
return noChange()
}

private fun statinInfoLoaded(
event: StatinInfoLoaded,
model: PatientSummaryModel
): Next<PatientSummaryModel, PatientSummaryEffect> {
val statinInfo = event.statinInfo
//load statin nudge info
//update model with statin info
return noChange()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,44 @@ class PatientSummaryUpdateTest {
))
}

@Test
fun `when cvd risk is loaded and risk score is not null, then load statin info`() {
updateSpec
.given(defaultModel)
.whenEvent(CVDRiskLoaded(
risk = "27"
))
.then(assertThatNext(
hasEffects(LoadStatinInfo(patientUuid))
))
}

@Test
fun `when cvd risk is loaded and risk score is null, then calculate cvd risk`() {
val model = defaultModel
.patientSummaryProfileLoaded(patientSummaryProfile)
updateSpec
.given(model)
.whenEvent(CVDRiskLoaded(
risk = null
))
.then(assertThatNext(
hasEffects(CalculateCVDRisk(model.patientSummaryProfile!!.patient))
))
}

@Test
fun `when cvd risk is calculated, then load statin info`() {
updateSpec
.given(defaultModel)
.whenEvent(CVDRiskCalculated(
risk = null
))
.then(assertThatNext(
hasEffects(LoadStatinInfo(patientUuid))
))
}

private fun PatientSummaryModel.forExistingPatient(): PatientSummaryModel {
return copy(openIntention = ViewExistingPatient)
}
Expand Down

0 comments on commit 9f41b95

Please sign in to comment.