Skip to content

Commit

Permalink
Merge pull request #951 from TIP-Global-Health/develop
Browse files Browse the repository at this point in the history
WIP: Developments starting November 19, 2023
  • Loading branch information
anvmn authored Dec 20, 2023
2 parents c4d3ae7 + 217e40c commit c8fc0a4
Show file tree
Hide file tree
Showing 54 changed files with 818 additions and 406 deletions.
6 changes: 3 additions & 3 deletions client/src/elm/App/Fetch.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Pages.AcuteIllness.ProgressReport.Fetch
import Pages.ChildScoreboard.Activity.Fetch
import Pages.ChildScoreboard.Encounter.Fetch
import Pages.ChildScoreboard.Participant.Fetch
import Pages.ChildScoreboard.Report.Fetch
import Pages.ChildScoreboard.ProgressReport.Fetch
import Pages.Clinical.Fetch
import Pages.Clinics.Fetch
import Pages.Dashboard.Fetch
Expand Down Expand Up @@ -363,8 +363,8 @@ fetch model =
Pages.NCD.ProgressReport.Fetch.fetch encounterId model.indexedDb
|> List.map MsgIndexedDb

UserPage (ChildScoreboardReportPage id) ->
Pages.ChildScoreboard.Report.Fetch.fetch id model.indexedDb
UserPage (ChildScoreboardProgressReportPage id) ->
Pages.ChildScoreboard.ProgressReport.Fetch.fetch id model.indexedDb
|> List.map MsgIndexedDb

UserPage (AcuteIllnessOutcomePage id) ->
Expand Down
6 changes: 3 additions & 3 deletions client/src/elm/App/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Pages.AcuteIllness.Participant.Model
import Pages.AcuteIllness.ProgressReport.Model
import Pages.ChildScoreboard.Activity.Model
import Pages.ChildScoreboard.Encounter.Model
import Pages.ChildScoreboard.Report.Model
import Pages.ChildScoreboard.ProgressReport.Model
import Pages.Clinics.Model
import Pages.Dashboard.Model
import Pages.Device.Model
Expand Down Expand Up @@ -301,7 +301,7 @@ type alias LoggedInModel =
, ncdProgressReportPages : Dict NCDEncounterId Pages.NCD.ProgressReport.Model.Model
, childScoreboardEncounterPages : Dict ChildScoreboardEncounterId Pages.ChildScoreboard.Encounter.Model.Model
, childScoreboardActivityPages : Dict ( ChildScoreboardEncounterId, ChildScoreboardActivity ) Pages.ChildScoreboard.Activity.Model.Model
, childScoreboardReportPages : Dict ChildScoreboardEncounterId Pages.ChildScoreboard.Report.Model.Model
, childScoreboardReportPages : Dict ChildScoreboardEncounterId Pages.ChildScoreboard.ProgressReport.Model.Model
, traceContactPages : Dict AcuteIllnessTraceContactId Pages.TraceContact.Model.Model
, clinicalProgressReportPages : Dict PrenatalEncounterId Pages.Prenatal.ProgressReport.Model.Model
, patientRecordPages : Dict PersonId Pages.PatientRecord.Model.Model
Expand Down Expand Up @@ -428,7 +428,7 @@ type MsgLoggedIn
| MsgPageNutritionProgressReport NutritionEncounterId Pages.Nutrition.ProgressReport.Model.Msg
| MsgPageWellChildProgressReport WellChildEncounterId Pages.WellChild.ProgressReport.Model.Msg
| MsgPageNCDProgressReport NCDEncounterId Pages.NCD.ProgressReport.Model.Msg
| MsgPageChildScoreboardReport ChildScoreboardEncounterId Pages.ChildScoreboard.Report.Model.Msg
| MsgPageChildScoreboardReport ChildScoreboardEncounterId Pages.ChildScoreboard.ProgressReport.Model.Msg
| MsgPageAcuteIllnessOutcome IndividualEncounterParticipantId Pages.AcuteIllness.Outcome.Model.Msg
| MsgPageTraceContact AcuteIllnessTraceContactId Pages.TraceContact.Model.Msg
| MsgPageClinicalProgressReport PrenatalEncounterId Pages.Prenatal.ProgressReport.Model.Msg
Expand Down
8 changes: 4 additions & 4 deletions client/src/elm/App/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import Pages.ChildScoreboard.Activity.Model
import Pages.ChildScoreboard.Activity.Update
import Pages.ChildScoreboard.Encounter.Model
import Pages.ChildScoreboard.Encounter.Update
import Pages.ChildScoreboard.Report.Model
import Pages.ChildScoreboard.Report.Update
import Pages.ChildScoreboard.ProgressReport.Model
import Pages.ChildScoreboard.ProgressReport.Update
import Pages.Clinics.Update
import Pages.Dashboard.Model
import Pages.Dashboard.Update
Expand Down Expand Up @@ -760,8 +760,8 @@ update msg model =
let
( subModel, subCmd, extraMsgs ) =
Dict.get id data.childScoreboardReportPages
|> Maybe.withDefault Pages.ChildScoreboard.Report.Model.emptyModel
|> Pages.ChildScoreboard.Report.Update.update subMsg
|> Maybe.withDefault Pages.ChildScoreboard.ProgressReport.Model.emptyModel
|> Pages.ChildScoreboard.ProgressReport.Update.update subMsg
in
( { data | childScoreboardReportPages = Dict.insert id subModel data.childScoreboardReportPages }
, Cmd.map (MsgLoggedIn << MsgPageChildScoreboardReport id) subCmd
Expand Down
11 changes: 6 additions & 5 deletions client/src/elm/App/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import Pages.ChildScoreboard.Activity.View
import Pages.ChildScoreboard.Encounter.Model
import Pages.ChildScoreboard.Encounter.View
import Pages.ChildScoreboard.Participant.View
import Pages.ChildScoreboard.Report.Model
import Pages.ChildScoreboard.Report.View
import Pages.ChildScoreboard.ProgressReport.Model
import Pages.ChildScoreboard.ProgressReport.View
import Pages.Clinical.View
import Pages.Clinics.View
import Pages.Dashboard.View
Expand Down Expand Up @@ -931,16 +931,17 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
|> Html.map (MsgLoggedIn << MsgPageChildScoreboardActivity id activity)
|> flexPageWrapper configured.config model

ChildScoreboardReportPage encounterId ->
ChildScoreboardProgressReportPage encounterId ->
let
page_ =
Dict.get encounterId loggedInModel.childScoreboardReportPages
|> Maybe.withDefault Pages.ChildScoreboard.Report.Model.emptyModel
|> Maybe.withDefault Pages.ChildScoreboard.ProgressReport.Model.emptyModel
in
Pages.ChildScoreboard.Report.View.view model.language
Pages.ChildScoreboard.ProgressReport.View.view model.language
currentDate
model.zscores
site
features
encounterId
model.indexedDb
page_
Expand Down
1 change: 1 addition & 0 deletions client/src/elm/Backend/AcuteIllnessEncounter/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ type AcuteIllnessProgressReportInitiator
| InitiatorGroupNutritionProgressReport SessionId PersonId
| InitiatorPatientRecord PatientRecordInitiator PersonId
| InitiatorNCDProgressReport NCDProgressReportInitiator
| InitiatorChildScoreboardProgressReport ChildScoreboardEncounterId


type Msg
Expand Down
9 changes: 9 additions & 0 deletions client/src/elm/Backend/AcuteIllnessEncounter/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ progressReportInitiatorToUrlFragment initiator =
InitiatorNCDProgressReport ncdProgressReportInitiator ->
"ncd-progress-report-" ++ Backend.NCDEncounter.Utils.progressReportInitiatorToUrlFragment ncdProgressReportInitiator

InitiatorChildScoreboardProgressReport encounterId ->
"child-scoreboard-progress-report-" ++ fromEntityUuid encounterId


progressReportInitiatorFromUrlFragment : String -> Maybe AcuteIllnessProgressReportInitiator
progressReportInitiatorFromUrlFragment s =
Expand All @@ -149,6 +152,12 @@ progressReportInitiatorFromUrlFragment s =
|> InitiatorIndividualNutritionProgressReport
|> Just

else if String.startsWith "child-scoreboard-progress-report-" s then
String.dropLeft 33 s
|> toEntityUuid
|> InitiatorChildScoreboardProgressReport
|> Just

else if String.startsWith "progress-report-" s then
let
ids =
Expand Down
4 changes: 2 additions & 2 deletions client/src/elm/Backend/HomeVisitActivity/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ getActivityIcon activity =
"food-security"


getAllActivities : List HomeVisitActivity
getAllActivities =
allActivities : List HomeVisitActivity
allActivities =
[ Feeding, Caring, Hygiene, FoodSecurity ]
4 changes: 2 additions & 2 deletions client/src/elm/Backend/NCDActivity/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ getRecurrentActivityIcon activity =
recurrentActivityToString activity


getAllActivities : List NCDActivity
getAllActivities =
allActivities : List NCDActivity
allActivities =
[ DangerSigns
, SymptomReview
, MedicalHistory
Expand Down
4 changes: 2 additions & 2 deletions client/src/elm/Backend/NutritionActivity/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ getActivityIcon activity =
"next-steps"


getAllActivities : List NutritionActivity
getAllActivities =
allActivities : List NutritionActivity
allActivities =
[ Height, Muac, Nutrition, Weight, Photo, NCDA, NextSteps ]
1 change: 1 addition & 0 deletions client/src/elm/Backend/NutritionEncounter/Fetch.elm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fetch id db =

-- Fetch Group measuments that belong to child.
, Backend.Model.FetchChildMeasurements id
, Backend.Model.FetchExpectedSessions id
]
++ fetchForNutrition id db
++ fetchForWellChild id db
Expand Down
18 changes: 16 additions & 2 deletions client/src/elm/Backend/NutritionEncounter/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import List.Extra
import Maybe.Extra
import Pages.Utils exposing (ifEverySetEmpty)
import RemoteData exposing (RemoteData(..), WebData)
import SyncManager.Model exposing (Site(..))
import Utils.NominalDate exposing (sortTuplesByDateDesc)
import ZScore.Model exposing (Kilograms(..))
import ZScore.Utils exposing (diffDays, zScoreWeightForAge)
Expand Down Expand Up @@ -499,10 +500,11 @@ resolveNCDAValuesForChild childId db =

resolvePreviousValuesSetForChild :
NominalDate
-> Site
-> PersonId
-> ModelIndexedDb
-> PreviousValuesSet
resolvePreviousValuesSetForChild currentDate childId db =
resolvePreviousValuesSetForChild currentDate site childId db =
let
previousMeasurementsSet =
resolvePreviousMeasurementsSetForChild childId db
Expand All @@ -514,10 +516,22 @@ resolvePreviousValuesSetForChild currentDate childId db =
)
>> List.head
>> Maybe.map Tuple.second

muacValueFunc =
case site of
SiteBurundi ->
-- MUAC value is stored in cm, but at Burundi, we
-- need to show it as mm.
(*) 10

_ ->
identity
in
PreviousValuesSet
(getLatestValue previousMeasurementsSet.heights)
(getLatestValue previousMeasurementsSet.muacs)
(getLatestValue previousMeasurementsSet.muacs
|> Maybe.map muacValueFunc
)
(getLatestValue previousMeasurementsSet.weights)
(getLatestValue previousMeasurementsSet.headCircumferences)

Expand Down
13 changes: 9 additions & 4 deletions client/src/elm/Backend/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1827,8 +1827,9 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h

setPopUpStateMsg popupType =
Pages.WellChild.Encounter.Model.PopupECD popupType
|> Pages.WellChild.Encounter.Model.DialogWarning
|> Just
|> Pages.WellChild.Encounter.Model.SetWarningPopupState
|> Pages.WellChild.Encounter.Model.SetDialogState
|> App.Model.MsgPageWellChildEncounter id
|> App.Model.MsgLoggedIn

Expand Down Expand Up @@ -6406,7 +6407,9 @@ generateNutritionAssessmentGroupMsgs currentDate zscores features isChw childId
case activePage of
UserPage (SessionPage _ (ChildPage _)) ->
updateAssesmentMsgs
++ [ Pages.Participant.Model.SetWarningPopupState assessmentAfter
++ [ Pages.Participant.Model.DialogWarning assessmentAfter
|> Just
|> Pages.Participant.Model.SetDialogState
|> Pages.Session.Model.MsgChild childId
|> App.Model.MsgPageSession sessionId
|> App.Model.MsgLoggedIn
Expand Down Expand Up @@ -6723,7 +6726,9 @@ generateWellChildDangerSignsAlertMsgs currentDate maybeId =
App.Model.SetActivePage (UserPage (WellChildEncounterPage id))

-- Show danger signs alert popup.
, Pages.WellChild.Encounter.Model.SetWarningPopupState (Just Pages.WellChild.Encounter.Model.PopupDangerSigns)
, Pages.WellChild.Encounter.Model.DialogWarning Pages.WellChild.Encounter.Model.PopupDangerSigns
|> Just
|> Pages.WellChild.Encounter.Model.SetDialogState
|> App.Model.MsgPageWellChildEncounter id
|> App.Model.MsgLoggedIn
]
Expand All @@ -6742,7 +6747,7 @@ generateChildScoreboardAssesmentCompletedMsgs currentDate site after id =
List.all (Pages.ChildScoreboard.Activity.Utils.activityCompleted currentDate site assembled after)
Backend.ChildScoreboardActivity.Utils.allActivities
then
[ App.Model.SetActivePage (UserPage (ChildScoreboardReportPage id)) ]
[ App.Model.SetActivePage (UserPage (ChildScoreboardProgressReportPage id)) ]

else
[]
Expand Down
26 changes: 18 additions & 8 deletions client/src/elm/Pages/Activities/Model.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Pages.Activities.Model exposing (Model, Msg(..), Tab(..), emptyModel)
module Pages.Activities.Model exposing (DialogType(..), Model, Msg(..), Tab(..), emptyModel)

import Activity.Model exposing (Activity)
import EverySet exposing (EverySet)
import Pages.Page exposing (Page)


Expand All @@ -22,15 +24,25 @@ desired activity. So, we're not drawing a wrapper around the `Page.Activity`
-}
type alias Model =
{ selectedTab : Tab
, showEndSessionDialog : Bool
, skippedActivities : EverySet Activity
, dialogState : Maybe DialogType
}


emptyModel : Model
emptyModel =
{ selectedTab = Pending
, skippedActivities = EverySet.empty
, dialogState = Nothing
}


type Msg
= CloseSession
| SetRedirectPage Page
| SetSelectedTab Tab
| ShowEndSessionDialog Bool
| SkipActivity Activity
| SetDialogState (Maybe DialogType)


{-| This is related to the `Tab` type in `Pages.Activity.Model`, except that here
Expand All @@ -43,8 +55,6 @@ type Tab
| Pending


emptyModel : Model
emptyModel =
{ selectedTab = Pending
, showEndSessionDialog = False
}
type DialogType
= DialogEndSession
| DialogSkipNCDA
18 changes: 14 additions & 4 deletions client/src/elm/Pages/Activities/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Pages.Activities.Update exposing (update)
import Activity.Model exposing (Activity(..), ChildActivity(..))
import App.Ports exposing (bindDropZone)
import Backend.Session.Model exposing (EditableSession)
import EverySet exposing (EverySet)
import Pages.Activities.Model exposing (Model, Msg(..))
import Pages.Page exposing (Page(..), UserPage(..))
import Pages.Session.Model
Expand All @@ -14,7 +15,7 @@ update : EditableSession -> Msg -> Model -> ( Model, Cmd Msg, List Pages.Session
update session msg model =
case msg of
CloseSession ->
( { model | showEndSessionDialog = False }
( { model | dialogState = Nothing }
, Cmd.none
, [ Pages.Session.Model.MsgSession <| Backend.Session.Model.CloseSession
, Pages.Session.Model.SetActivePage <| UserPage ClinicalPage
Expand All @@ -33,13 +34,22 @@ update session msg model =
_ ->
Cmd.none
in
( model
( { model | dialogState = Nothing }
, cmd
, [ Pages.Session.Model.SetActivePage page ]
)

SetSelectedTab tab ->
( { model | selectedTab = tab }, Cmd.none, [] )

ShowEndSessionDialog show ->
( { model | showEndSessionDialog = show }, Cmd.none, [] )
SkipActivity activity ->
( { model
| skippedActivities = EverySet.insert activity model.skippedActivities
, dialogState = Nothing
}
, Cmd.none
, []
)

SetDialogState state ->
( { model | dialogState = state }, Cmd.none, [] )
Loading

0 comments on commit c8fc0a4

Please sign in to comment.