Skip to content

Commit

Permalink
Merge pull request #1348 from TIP-Global-Health/issues-1338/39/40/41
Browse files Browse the repository at this point in the history
ANC - consolidate questions in medical history
  • Loading branch information
anvmn authored Oct 1, 2024
2 parents ca27f87 + bf7cf54 commit 1684d52
Show file tree
Hide file tree
Showing 21 changed files with 943 additions and 376 deletions.
7 changes: 7 additions & 0 deletions client/src/assets/scss/_new.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,13 @@ div.page-activity.stock-management {
margin-top: -10px;
}
}

&.medical {

.checkbox-select-input {
margin-bottom: 50px;
}
}
}

.form.examination {
Expand Down
89 changes: 50 additions & 39 deletions client/src/elm/Backend/Measurement/Decoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1928,57 +1928,68 @@ decodeLmpDateNotConfidentReason =
)


decodeMedicalHistory : Decoder MedicalHistory
decodeMedicalHistory =
decodePrenatalMeasurement decodeMedicalHistoryValue


decodeMedicalHistoryValue : Decoder MedicalHistoryValue
decodeMedicalHistoryValue =
succeed MedicalHistoryValue
|> required "medical_history" (decodeEverySet decodeMedicalHistorySign)
|> optional "physical_condition_history"
(decodeEverySet decodeMedicalHistoryPhysicalCondition)
(EverySet.singleton MigrateMedicalHistoryPhysicalCondition)
|> optional "infectious_disease_history"
(decodeEverySet decodeMedicalHistoryInfectiousDisease)
(EverySet.singleton NoMedicalHistoryInfectiousDisease)
|> optional "mental_health_issues"
(decodeEverySet decodeMedicalHistoryMentalHealthIssue)
(EverySet.singleton NoMedicalHistoryMentalHealthIssue)


decodeMedicalHistorySign : Decoder MedicalHistorySign
decodeMedicalHistorySign =
string
|> andThen
(\s ->
case s of
"uterine-myonma" ->
succeed UterineMyoma

"diabetes" ->
succeed Diabetes

"cardiac-disease" ->
succeed CardiacDisease

"renal-disease" ->
succeed RenalDisease

"hypertension-before-pregnancy" ->
succeed HypertensionBeforePregnancy

"tuberculosis-past" ->
succeed TuberculosisPast

"tuberculosis-present" ->
succeed TuberculosisPresent

"asthma" ->
succeed Asthma

"bowed-legs" ->
succeed BowedLegs
medicalHistorySignFromString s
|> Maybe.map succeed
|> Maybe.withDefault (s ++ " is not a recognized MedicalHistorySign" |> fail)
)

"hiv" ->
succeed HIV

"mental-health-history" ->
succeed MentalHealthHistory
decodeMedicalHistoryPhysicalCondition : Decoder MedicalHistoryPhysicalCondition
decodeMedicalHistoryPhysicalCondition =
string
|> andThen
(\s ->
medicalHistoryPhysicalConditionFromString s
|> Maybe.map succeed
|> Maybe.withDefault (s ++ " is not a recognized MedicalHistoryPhysicalCondition" |> fail)
)

"none" ->
succeed NoMedicalHistorySigns

_ ->
fail <| s ++ " is not a recognized MedicalHistorySign"
decodeMedicalHistoryInfectiousDisease : Decoder MedicalHistoryInfectiousDisease
decodeMedicalHistoryInfectiousDisease =
string
|> andThen
(\s ->
medicalHistoryInfectiousDiseaseFromString s
|> Maybe.map succeed
|> Maybe.withDefault (s ++ " is not a recognized MedicalHistoryInfectiousDisease" |> fail)
)


decodeMedicalHistory : Decoder MedicalHistory
decodeMedicalHistory =
field "medical_history" (decodeEverySet decodeMedicalHistorySign)
|> decodePrenatalMeasurement
decodeMedicalHistoryMentalHealthIssue : Decoder MedicalHistoryMentalHealthIssue
decodeMedicalHistoryMentalHealthIssue =
string
|> andThen
(\s ->
medicalHistoryMentalHealthIssueFromString s
|> Maybe.map succeed
|> Maybe.withDefault (s ++ " is not a recognized MedicalHistoryMentalHealthIssue" |> fail)
)


decodeMedicationSign : Decoder MedicationSign
Expand Down
66 changes: 24 additions & 42 deletions client/src/elm/Backend/Measurement/Encoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1322,58 +1322,40 @@ encodeLmpDateNotConfidentReason =
lmpDateNotConfidentReasonToString >> string


encodeMedicalHistorySign : MedicalHistorySign -> Value
encodeMedicalHistorySign sign =
string <|
case sign of
UterineMyoma ->
"uterine-myonma"

Diabetes ->
"diabetes"

CardiacDisease ->
"cardiac-disease"

RenalDisease ->
"renal-disease"

HypertensionBeforePregnancy ->
"hypertension-before-pregnancy"

TuberculosisPast ->
"tuberculosis-past"
encodeMedicalHistory : MedicalHistory -> List ( String, Value )
encodeMedicalHistory =
encodePrenatalMeasurement encodeMedicalHistoryValue

TuberculosisPresent ->
"tuberculosis-present"

Asthma ->
"asthma"
encodeMedicalHistoryValue : MedicalHistoryValue -> List ( String, Value )
encodeMedicalHistoryValue value =
[ ( "medical_history", encodeEverySet encodeMedicalHistorySign value.signs )
, ( "physical_condition_history", encodeEverySet encodeMedicalHistoryPhysicalCondition value.physicalConditions )
, ( "infectious_disease_history", encodeEverySet encodeMedicalHistoryInfectiousDisease value.infectiousDiseases )
, ( "mental_health_issues", encodeEverySet encodeMedicalHistoryMentalHealthIssue value.mentalHealthIssues )
, ( "deleted", bool False )
, ( "type", string "medical_history" )
]

BowedLegs ->
"bowed-legs"

HIV ->
"hiv"
encodeMedicalHistorySign : MedicalHistorySign -> Value
encodeMedicalHistorySign =
medicalHistorySignToString >> string

MentalHealthHistory ->
"mental-health-history"

NoMedicalHistorySigns ->
"none"
encodeMedicalHistoryPhysicalCondition : MedicalHistoryPhysicalCondition -> Value
encodeMedicalHistoryPhysicalCondition =
medicalHistoryPhysicalConditionToString >> string


encodeMedicalHistory : MedicalHistory -> List ( String, Value )
encodeMedicalHistory =
encodePrenatalMeasurement encodeMedicalHistoryValue
encodeMedicalHistoryInfectiousDisease : MedicalHistoryInfectiousDisease -> Value
encodeMedicalHistoryInfectiousDisease =
medicalHistoryInfectiousDiseaseToString >> string


encodeMedicalHistoryValue : EverySet MedicalHistorySign -> List ( String, Value )
encodeMedicalHistoryValue value =
[ ( "medical_history", encodeEverySet encodeMedicalHistorySign value )
, ( "deleted", bool False )
, ( "type", string "medical_history" )
]
encodeMedicalHistoryMentalHealthIssue : MedicalHistoryMentalHealthIssue -> Value
encodeMedicalHistoryMentalHealthIssue =
medicalHistoryMentalHealthIssueToString >> string


encodeMedicationSign : MedicationSign -> Value
Expand Down
48 changes: 40 additions & 8 deletions client/src/elm/Backend/Measurement/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -670,22 +670,54 @@ type alias LastMenstrualPeriod =


type MedicalHistorySign
= UterineMyoma
| Diabetes
= Asthma
| CardiacDisease
| RenalDisease
| Diabetes
| HypertensionBeforePregnancy
| TuberculosisPast
| TuberculosisPresent
| Asthma
| RenalDisease
| NoMedicalHistorySigns
-- @todo: Below signs are deprecated. Can be removed around January 2025.
| BowedLegs
| UterineMyoma
| HIV
| TuberculosisPast
| TuberculosisPresent
| MentalHealthHistory
| NoMedicalHistorySigns


type MedicalHistoryPhysicalCondition
= PhysicalConditionUterineMyomaCurrent
| PhysicalConditionUterineMyomaSurgicalResection
| PhysicalConditionBowedLegs
| NoMedicalHistoryPhysicalCondition
| MigrateMedicalHistoryPhysicalCondition


type MedicalHistoryInfectiousDisease
= InfectiousDiseasesHIV
| InfectiousDiseasesTuberculosisPast
| InfectiousDiseasesTuberculosisPresent
| NoMedicalHistoryInfectiousDisease


type MedicalHistoryMentalHealthIssue
= MentalHealthIssueGeneralDepression
| MentalHealthIssuePerinatalDepression
| MentalHealthIssueSchizophrenia
| MentalHealthIssueTrauma
| NoMedicalHistoryMentalHealthIssue


type alias MedicalHistory =
PrenatalMeasurement (EverySet MedicalHistorySign)
PrenatalMeasurement MedicalHistoryValue


type alias MedicalHistoryValue =
{ signs : EverySet MedicalHistorySign
, physicalConditions : EverySet MedicalHistoryPhysicalCondition
, infectiousDiseases : EverySet MedicalHistoryInfectiousDisease
, mentalHealthIssues : EverySet MedicalHistoryMentalHealthIssue
}


type MedicationSign
Expand Down
Loading

0 comments on commit 1684d52

Please sign in to comment.