Skip to content

Commit

Permalink
Merge pull request #1331 from TIP-Global-Health/issue-1325
Browse files Browse the repository at this point in the history
ANC - skip Obstetric History step 2 on first pregnancy
  • Loading branch information
anvmn authored Sep 23, 2024
2 parents 30414f0 + c7bd192 commit aa387af
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ci-scripts/circleci_wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

CMD="$*"

TIMEOUT=3700
TIMEOUT=4300
INTERVAL=240
$CMD &
CMD_PID=$!
Expand Down
2 changes: 1 addition & 1 deletion client/src/elm/Pages/Prenatal/Activity/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Msg
-- HistoryMsgs, OB, Step 1
| SetCurrentlyPregnant Bool
| SetOBIntInput (Maybe Int -> ObstetricFormFirstStep -> ObstetricFormFirstStep) String
| SaveOBHistoryStep1 PersonId (Maybe ( ObstetricHistoryId, ObstetricHistory ))
| SaveOBHistoryStep1 Bool PersonId (Maybe ( ObstetricHistoryId, ObstetricHistory )) (Maybe HistoryTask)
-- HistoryMsgs, OB, Step 2
| SetCSectionReason CSectionReason
| SetNumberOfCSections String
Expand Down
22 changes: 16 additions & 6 deletions client/src/elm/Pages/Prenatal/Activity/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,28 @@ update language currentDate id isLabTech db msg model =
, []
)

SaveOBHistoryStep1 personId saved ->
SaveOBHistoryStep1 skipSecondStep personId saved nextTask ->
let
measurementId =
Maybe.map Tuple.first saved

measurement =
getMeasurementValueFunc saved

( appMsgs, updatedData ) =
( model.historyData.obstetricFormFirstStep
( extraMsgs, updatedData ) =
if skipSecondStep then
( generateHistoryMsgs nextTask
, model.historyData
)

else
( []
, model.historyData
|> (\data -> { data | obstetricHistoryStep = ObstetricHistorySecondStep })
)

appMsgs =
model.historyData.obstetricFormFirstStep
|> toObstetricHistoryValueWithDefault measurement
|> Maybe.map
(Backend.PrenatalEncounter.Model.SaveObstetricHistory personId measurementId
Expand All @@ -374,14 +386,12 @@ update language currentDate id isLabTech db msg model =
>> List.singleton
)
|> Maybe.withDefault []
, model.historyData
|> (\data -> { data | obstetricHistoryStep = ObstetricHistorySecondStep })
)
in
( { model | historyData = updatedData }
, Cmd.none
, appMsgs
)
|> sequenceExtra (update language currentDate id isLabTech db) extraMsgs

SetCSectionReason reason ->
let
Expand Down
28 changes: 25 additions & 3 deletions client/src/elm/Pages/Prenatal/Activity/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import Measurement.Utils
import Measurement.View exposing (viewActionTakenLabel)
import Pages.Prenatal.Activity.Model exposing (..)
import Pages.Prenatal.Activity.Types exposing (..)
import Pages.Prenatal.Encounter.Utils exposing (emergencyReferalRequired, getAllActivities)
import Pages.Prenatal.Encounter.Utils exposing (emergencyReferalRequired, generateGravida, generatePara, getAllActivities)
import Pages.Prenatal.Model exposing (AssembledData, HealthEducationForm, PrenatalEncounterPhase(..), ReferralForm, VaccinationProgressDict)
import Pages.Prenatal.Utils exposing (..)
import Pages.Utils
Expand Down Expand Up @@ -788,8 +788,16 @@ historyTaskCompleted : AssembledData -> HistoryTask -> Bool
historyTaskCompleted assembled task =
case task of
Obstetric ->
isJust assembled.measurements.obstetricHistory
&& isJust assembled.measurements.obstetricHistoryStep2
let
obstetricHistoryValue =
getMeasurementValueFunc assembled.measurements.obstetricHistory
in
if skipObstetricHistorySecondStep obstetricHistoryValue then
isJust assembled.measurements.obstetricHistory

else
isJust assembled.measurements.obstetricHistory
&& isJust assembled.measurements.obstetricHistoryStep2

Medical ->
isJust assembled.measurements.medicalHistory
Expand All @@ -801,6 +809,20 @@ historyTaskCompleted assembled task =
isJust assembled.measurements.outsideCare


skipObstetricHistorySecondStep : Maybe ObstetricHistoryValue -> Bool
skipObstetricHistorySecondStep obstetricHistoryValue =
let
gravida =
Maybe.map generateGravida obstetricHistoryValue
|> Maybe.withDefault ""

para =
Maybe.map generatePara obstetricHistoryValue
|> Maybe.withDefault ""
in
gravida == "01" && para == "0000"


resolveExaminationTasks : AssembledData -> List ExaminationTask
resolveExaminationTasks assembled =
let
Expand Down
22 changes: 19 additions & 3 deletions client/src/elm/Pages/Prenatal/Activity/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,12 @@ viewHistoryContent language currentDate assembled data =
Maybe.andThen (\task -> Dict.get task tasksCompletedFromTotalDict) activeTask
|> Maybe.withDefault ( 0, 0 )

( obstetricFormFirstStepInputs, obstetricFormFirstStepTasks ) =
obstetricFormFirstStep =
getMeasurementValueFunc assembled.measurements.obstetricHistory
|> obstetricHistoryFormWithDefault data.obstetricFormFirstStep
|> obstetricFormFirstStepInputsAndTasks language currentDate assembled

( obstetricFormFirstStepInputs, obstetricFormFirstStepTasks ) =
obstetricFormFirstStepInputsAndTasks language currentDate assembled obstetricFormFirstStep

( obstetricFormSecondStepInputs, obstetricFormSecondStepTasks ) =
getMeasurementValueFunc assembled.measurements.obstetricHistoryStep2
Expand Down Expand Up @@ -750,13 +752,27 @@ viewHistoryContent language currentDate assembled data =
Obstetric ->
case data.obstetricHistoryStep of
ObstetricHistoryFirstStep ->
let
skipSecondStep =
toObstetricHistoryValue obstetricFormFirstStep
|> skipObstetricHistorySecondStep

label =
if skipSecondStep then
Translate.Save

else
Translate.SaveAndNext
in
[ customSaveButton language
saveButtonActive
(SaveOBHistoryStep1
skipSecondStep
assembled.participant.person
assembled.measurements.obstetricHistory
nextTask
)
Translate.SaveAndNext
label
]

ObstetricHistorySecondStep ->
Expand Down

0 comments on commit aa387af

Please sign in to comment.