Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANC - consolidate questions in obstetric history #1347

Merged
merged 16 commits into from
Oct 1, 2024
Merged
14 changes: 14 additions & 0 deletions client/src/elm/Backend/Measurement/Decoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,17 @@ decodeObstetricHistorySign =
)


decodeObstetricHistoryStep2Sign : Decoder ObstetricHistoryStep2Sign
decodeObstetricHistoryStep2Sign =
string
|> andThen
(\sign ->
obstetricHistoryStep2SignFromString sign
|> Maybe.map succeed
|> Maybe.withDefault (sign ++ " is not a recognized ObstetricHistoryStep2Sign" |> fail)
)


decodeObstetricHistoryStep2 : Decoder ObstetricHistoryStep2
decodeObstetricHistoryStep2 =
succeed ObstetricHistoryStep2Value
Expand All @@ -2397,6 +2408,9 @@ decodeObstetricHistoryStep2 =
|> required "previous_delivery" (decodeEverySet decodePreviousDeliverySign)
|> required "previous_delivery_period" (decodeEverySet decodePreviousDeliveryPeriod)
|> required "obstetric_history" (decodeEverySet decodeObstetricHistorySign)
|> optional "obstetric_history_step2"
(decodeEverySet decodeObstetricHistoryStep2Sign)
(EverySet.singleton MigrateObstetricHistoryStep2Sign)
|> decodePrenatalMeasurement


Expand Down
6 changes: 6 additions & 0 deletions client/src/elm/Backend/Measurement/Encoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,11 @@ encodeObstetricHistorySign sign =
"none"


encodeObstetricHistoryStep2Sign : ObstetricHistoryStep2Sign -> Value
encodeObstetricHistoryStep2Sign =
obstetricHistoryStep2SignToString >> string


encodeObstetricHistoryStep2 : ObstetricHistoryStep2 -> List ( String, Value )
encodeObstetricHistoryStep2 =
encodePrenatalMeasurement encodeObstetricHistoryStep2Value
Expand All @@ -1701,6 +1706,7 @@ encodeObstetricHistoryStep2Value : ObstetricHistoryStep2Value -> List ( String,
encodeObstetricHistoryStep2Value value =
[ ( "c_sections", int value.cSections )
, ( "obstetric_history", encodeEverySet encodeObstetricHistorySign value.obstetricHistory )
, ( "obstetric_history_step2", encodeEverySet encodeObstetricHistoryStep2Sign value.signs )
, ( "previous_delivery", encodeEverySet encodePreviousDeliverySign value.previousDelivery )
, ( "previous_delivery_period", encodeEverySet encodePreviousDeliveryPeriod value.previousDeliveryPeriod )
, ( "deleted", bool False )
Expand Down
22 changes: 21 additions & 1 deletion client/src/elm/Backend/Measurement/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,11 @@ type alias ObstetricHistoryStep2Value =
, cSectionReason : Maybe (EverySet CSectionReason)
, previousDelivery : EverySet PreviousDeliverySign
, previousDeliveryPeriod : EverySet PreviousDeliveryPeriod

-- @todo: obstetricHistory is depricated, and can be removed
-- around January 2025.
, obstetricHistory : EverySet ObstetricHistorySign
, signs : EverySet ObstetricHistoryStep2Sign
}


Expand All @@ -806,15 +810,18 @@ type PreviousDeliveryPeriod
type PreviousDeliverySign
= CSectionInPast
| CSectionInPreviousDelivery
| NoPreviousDeliverySign
-- @todo: Bellow signs are deprecated. Can be removed around January 2025.
anvmn marked this conversation as resolved.
Show resolved Hide resolved
| StillbornPreviousDelivery
| BabyDiedOnDayOfBirthPreviousDelivery
| PartialPlacentaPreviousDelivery
| SevereHemorrhagingPreviousDelivery
| ConvulsionsPreviousDelivery
| ConvulsionsAndUnconsciousPreviousDelivery
| NoPreviousDeliverySign


{-| @todo: ObstetricHistorySign is deprecated. Can be removed around January 2025.
-}
type ObstetricHistorySign
= SuccessiveAbortions
| SuccessivePrematureDeliveries
Expand All @@ -825,6 +832,19 @@ type ObstetricHistorySign
| NoObstetricHistorySign


type ObstetricHistoryStep2Sign
= ObstetricHistoryPreeclampsiaPreviousPregnancy
| ObstetricHistoryGestationalDiabetesPreviousPregnancy
| ObstetricHistoryIncompleteCervixPreviousPregnancy
| ObstetricHistoryBabyDiedOnDayOfBirthPreviousDelivery
| ObstetricHistoryPartialPlacentaPreviousDelivery
| ObstetricHistorySevereHemorrhagingPreviousDelivery
| ObstetricHistoryConvulsionsPreviousDelivery
| ObstetricHistoryConvulsionsAndUnconsciousPreviousDelivery
| NoObstetricHistoryStep2Sign
| MigrateObstetricHistoryStep2Sign


type alias ObstetricHistoryStep2 =
PrenatalMeasurement ObstetricHistoryStep2Value

Expand Down
71 changes: 71 additions & 0 deletions client/src/elm/Backend/Measurement/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4475,3 +4475,74 @@ hivHealthEducationSignFromString diagnosis =

_ ->
Nothing


obstetricHistoryStep2SignToString : ObstetricHistoryStep2Sign -> String
obstetricHistoryStep2SignToString sign =
case sign of
ObstetricHistoryPreeclampsiaPreviousPregnancy ->
"preeclampsia-previous-pregnancy"

ObstetricHistoryGestationalDiabetesPreviousPregnancy ->
"gestational-diabetes-previous-pregnancy"

ObstetricHistoryIncompleteCervixPreviousPregnancy ->
"incomplete-cervix-previous-pregnancy"

ObstetricHistoryBabyDiedOnDayOfBirthPreviousDelivery ->
"baby-died-on-day-of-birth-previous-delivery"

ObstetricHistoryPartialPlacentaPreviousDelivery ->
"partial-placenta-previous-delivery"

ObstetricHistorySevereHemorrhagingPreviousDelivery ->
"severe-hemorrhaging-previous-delivery"

ObstetricHistoryConvulsionsPreviousDelivery ->
"convulsions-previous-delivery"

ObstetricHistoryConvulsionsAndUnconsciousPreviousDelivery ->
"convulsions-and-unconscious-previous-delivery"

NoObstetricHistoryStep2Sign ->
"none"

MigrateObstetricHistoryStep2Sign ->
"migrate"


obstetricHistoryStep2SignFromString : String -> Maybe ObstetricHistoryStep2Sign
obstetricHistoryStep2SignFromString sign =
case sign of
"preeclampsia-previous-pregnancy" ->
Just ObstetricHistoryPreeclampsiaPreviousPregnancy

"gestational-diabetes-previous-pregnancy" ->
Just ObstetricHistoryGestationalDiabetesPreviousPregnancy

"incomplete-cervix-previous-pregnancy" ->
Just ObstetricHistoryIncompleteCervixPreviousPregnancy

"baby-died-on-day-of-birth-previous-delivery" ->
Just ObstetricHistoryBabyDiedOnDayOfBirthPreviousDelivery

"partial-placenta-previous-delivery" ->
Just ObstetricHistoryPartialPlacentaPreviousDelivery

"severe-hemorrhaging-previous-delivery" ->
Just ObstetricHistorySevereHemorrhagingPreviousDelivery

"convulsions-previous-delivery" ->
Just ObstetricHistoryConvulsionsPreviousDelivery

"convulsions-and-unconscious-previous-delivery" ->
Just ObstetricHistoryConvulsionsAndUnconsciousPreviousDelivery

"none" ->
Just NoObstetricHistoryStep2Sign

"migrate" ->
Just MigrateObstetricHistoryStep2Sign

_ ->
Nothing
40 changes: 0 additions & 40 deletions client/src/elm/Backend/PrenatalActivity/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@ type PrenatalRecurrentActivity
| LabsResultsFollowUps


type RiskFactor
= FactorNumberOfCSections
| FactorCSectionInPreviousDelivery
| FactorCSectionReason
| FactorPreviousDeliveryPeriod
| FactorSuccessiveAbortions
| FactorSuccessivePrematureDeliveries
| FactorStillbornPreviousDelivery
| FactorBabyDiedOnDayOfBirthPreviousDelivery
| FactorPartialPlacentaPreviousDelivery
| FactorSevereHemorrhagingPreviousDelivery
| FactorPreeclampsiaPreviousPregnancy
| FactorConvulsionsPreviousDelivery
| FactorConvulsionsAndUnconsciousPreviousDelivery
| FactorIncompleteCervixPreviousPregnancy
| FactorVerticalCSectionScar
| FactorGestationalDiabetesPreviousPregnancy


type HighRiskFactor
= HighRiskConvulsionsAndUnconsciousPreviousDelivery
| HighRiskConvulsionsPreviousDelivery
Expand Down Expand Up @@ -122,27 +103,6 @@ allRecurringHighSeverityAlerts =
[ BloodPressure ]


allRiskFactors : List RiskFactor
allRiskFactors =
[ FactorNumberOfCSections
, FactorCSectionInPreviousDelivery
, FactorCSectionReason
, FactorPreviousDeliveryPeriod
, FactorSuccessiveAbortions
, FactorSuccessivePrematureDeliveries
, FactorStillbornPreviousDelivery
, FactorBabyDiedOnDayOfBirthPreviousDelivery
, FactorPartialPlacentaPreviousDelivery
, FactorSevereHemorrhagingPreviousDelivery
, FactorPreeclampsiaPreviousPregnancy
, FactorConvulsionsPreviousDelivery
, FactorConvulsionsAndUnconsciousPreviousDelivery
, FactorIncompleteCervixPreviousPregnancy
, FactorVerticalCSectionScar
, FactorGestationalDiabetesPreviousPregnancy
]


allObstetricalDiagnoses : List ObstetricalDiagnosis
allObstetricalDiagnoses =
[ DiagnosisModerateUnderweight
Expand Down
Loading