Skip to content

Commit

Permalink
Merge pull request #1092 from TIP-Global-Health/develop
Browse files Browse the repository at this point in the history
Developments starting March 24, 2024
  • Loading branch information
anvmn authored Mar 31, 2024
2 parents 5d10321 + d316853 commit 6d7f06a
Show file tree
Hide file tree
Showing 67 changed files with 2,427 additions and 365 deletions.
1 change: 1 addition & 0 deletions .ddev/config.local.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ hooks:
- exec: drush vset hedley_admin_feature_ncda_enabled 1
- exec: drush vset hedley_admin_feature_stock_management_enabled 1
- exec: drush vset hedley_admin_feature_tuberculosis_management_enabled 1
- exec: drush vset hedley_admin_feature_group_education_enabled 1
- exec: drush vset hedley_admin_report_to_whatsapp_management_enabled 1
- exec: drush uli
56 changes: 56 additions & 0 deletions client/src/assets/scss/_new.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,62 @@ div.page-activity.tuberculosis {

}

div.page-activity.education-session {

.ui.full.segment {

.full.content {

.ui.checkbox.activity {
margin-bottom: 15px;
}
}

.registration-page.search {
min-height: 780px;

.search-top {
margin-bottom: 40px;

.toggle-initial-display {
cursor: pointer;
line-height: 50px;
margin-bottom: 10px;
padding-left: 1rem;

.toggle-text {
color: $color-primary;
font-weight: bold;
margin-left: 10px;
}
}
}

.items.participants-list {
max-height: 400px;
overflow: auto;

.item {
margin-bottom: 30px;
max-height: 400px;
overflow: auto;
padding: 0 30px;

.content {
margin-top: 15px;
}

.button-check-in,
.button-checked-in {
margin-top: 30px;
}
}
}
}
}
}


div.page-outcome {

.tasks-count {
Expand Down
21 changes: 21 additions & 0 deletions client/src/elm/App/Fetch.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import Pages.Clinical.Fetch
import Pages.Clinics.Fetch
import Pages.Dashboard.Fetch
import Pages.Device.Fetch
import Pages.EducationSession.Fetch
import Pages.EducationSession.Model
import Pages.GlobalCaseManagement.Fetch
import Pages.GroupEncounterTypes.Fetch
import Pages.HomeVisit.Activity.Fetch
import Pages.HomeVisit.Encounter.Fetch
import Pages.IndividualEncounterParticipants.Fetch
Expand Down Expand Up @@ -280,6 +283,10 @@ fetch model =
Pages.IndividualEncounterTypes.Fetch.fetch
|> List.map MsgIndexedDb

UserPage GroupEncounterTypesPage ->
Pages.GroupEncounterTypes.Fetch.fetch
|> List.map MsgIndexedDb

UserPage (PregnancyOutcomePage _ id) ->
Pages.Prenatal.Outcome.Fetch.fetch id model.indexedDb
|> List.map MsgIndexedDb
Expand Down Expand Up @@ -358,6 +365,20 @@ fetch model =
Pages.Tuberculosis.Activity.Fetch.fetch id model.indexedDb
|> List.map MsgIndexedDb

UserPage (EducationSessionPage id) ->
getLoggedInData model
|> Maybe.map
(\( _, loggedIn ) ->
let
page_ =
Dict.get id loggedIn.educationSessionPages
|> Maybe.withDefault Pages.EducationSession.Model.emptyModel
in
Pages.EducationSession.Fetch.fetch id model.villageId model.indexedDb page_
|> List.map MsgIndexedDb
)
|> Maybe.withDefault []

UserPage (NutritionProgressReportPage id) ->
Pages.Nutrition.ProgressReport.Fetch.fetch id model.indexedDb
|> List.map MsgIndexedDb
Expand Down
9 changes: 7 additions & 2 deletions client/src/elm/App/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Pages.ChildScoreboard.ProgressReport.Model
import Pages.Clinics.Model
import Pages.Dashboard.Model
import Pages.Device.Model
import Pages.EducationSession.Model
import Pages.GlobalCaseManagement.Model
import Pages.HomeVisit.Activity.Model
import Pages.HomeVisit.Encounter.Model
Expand Down Expand Up @@ -307,6 +308,7 @@ type alias LoggedInModel =
, childScoreboardReportPages : Dict ChildScoreboardEncounterId Pages.ChildScoreboard.ProgressReport.Model.Model
, tuberculosisEncounterPages : Dict TuberculosisEncounterId Pages.Tuberculosis.Encounter.Model.Model
, tuberculosisActivityPages : Dict ( TuberculosisEncounterId, TuberculosisActivity ) Pages.Tuberculosis.Activity.Model.Model
, educationSessionPages : Dict EducationSessionId Pages.EducationSession.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 @@ -357,6 +359,7 @@ emptyLoggedInModel site villageId nurse =
, childScoreboardReportPages = Dict.empty
, tuberculosisEncounterPages = Dict.empty
, tuberculosisActivityPages = Dict.empty
, educationSessionPages = Dict.empty
, traceContactPages = Dict.empty
, clinicalProgressReportPages = Dict.empty
, patientRecordPages = Dict.empty
Expand All @@ -365,9 +368,10 @@ emptyLoggedInModel site villageId nurse =


type Msg
= -- Manage data we get from IndexedDb, and communication with the service
= NoOp
-- Manage data we get from IndexedDb, and communication with the service
-- worker
MsgIndexedDb Backend.Model.MsgIndexedDb
| MsgIndexedDb Backend.Model.MsgIndexedDb
| MsgServiceWorker ServiceWorker.Model.Msg
| MsgSyncManager SyncManager.Model.Msg
-- Messages that require login, or manage the login process
Expand Down Expand Up @@ -421,6 +425,7 @@ type MsgLoggedIn
| MsgPageNCDRecurrentEncounter NCDEncounterId Pages.NCD.RecurrentEncounter.Model.Msg
| MsgPageChildScoreboardEncounter ChildScoreboardEncounterId Pages.ChildScoreboard.Encounter.Model.Msg
| MsgPageTuberculosisEncounter TuberculosisEncounterId Pages.Tuberculosis.Encounter.Model.Msg
| MsgPageEducationSession EducationSessionId Pages.EducationSession.Model.Msg
| MsgPagePrenatalActivity PrenatalEncounterId PrenatalActivity Pages.Prenatal.Activity.Model.Msg
| MsgPagePrenatalRecurrentActivity PrenatalEncounterId PrenatalRecurrentActivity Pages.Prenatal.RecurrentActivity.Model.Msg
| MsgPagePrenatalLabsHistory PrenatalEncounterId PrenatalEncounterId LaboratoryTest Pages.Prenatal.RecurrentActivity.Model.Msg
Expand Down
18 changes: 18 additions & 0 deletions client/src/elm/App/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import Pages.Dashboard.Model
import Pages.Dashboard.Update
import Pages.Device.Model
import Pages.Device.Update
import Pages.EducationSession.Model
import Pages.EducationSession.Update
import Pages.GlobalCaseManagement.Update
import Pages.HomeVisit.Activity.Model
import Pages.HomeVisit.Activity.Update
Expand Down Expand Up @@ -254,6 +256,9 @@ update msg model =
model.syncManager.reverseGeoInfo
in
case msg of
NoOp ->
( model, Cmd.none )

MsgIndexedDb subMsg ->
let
nurseId =
Expand Down Expand Up @@ -575,6 +580,19 @@ update msg model =
, extraMsgs
)

MsgPageEducationSession id subMsg ->
let
( subModel, subCmd, extraMsgs ) =
data.educationSessionPages
|> Dict.get id
|> Maybe.withDefault Pages.EducationSession.Model.emptyModel
|> Pages.EducationSession.Update.update currentDate id subMsg
in
( { data | educationSessionPages = Dict.insert id subModel data.educationSessionPages }
, Cmd.map (MsgLoggedIn << MsgPageEducationSession id) subCmd
, extraMsgs
)

MsgPagePrenatalActivity id activity subMsg ->
let
( subModel, subCmd, extraMsgs ) =
Expand Down
24 changes: 23 additions & 1 deletion client/src/elm/App/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import Pages.Clinical.View
import Pages.Clinics.View
import Pages.Dashboard.View
import Pages.Device.View
import Pages.EducationSession.Model
import Pages.EducationSession.View
import Pages.GlobalCaseManagement.View
import Pages.GroupEncounterTypes.View
import Pages.HomeVisit.Activity.Model
import Pages.HomeVisit.Activity.View
import Pages.HomeVisit.Encounter.Model
Expand Down Expand Up @@ -363,7 +366,7 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
|> oldPageWrapper configured.config model

ClinicalPage ->
Pages.Clinical.View.view model.language currentDate ( healthCenterId, model.villageId ) isChw model
Pages.Clinical.View.view model.language currentDate healthCenterId isChw model
|> flexPageWrapper configured.config model

ClinicsPage ->
Expand Down Expand Up @@ -647,6 +650,15 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
Pages.IndividualEncounterTypes.View.view model.language currentDate features healthCenterId isChw model
|> flexPageWrapper configured.config model

GroupEncounterTypesPage ->
Pages.GroupEncounterTypes.View.view model.language
currentDate
features
healthCenterId
(Tuple.first loggedInModel.nurse)
model
|> flexPageWrapper configured.config model

PregnancyOutcomePage initiator id ->
let
page_ =
Expand Down Expand Up @@ -964,6 +976,16 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
|> Html.map (MsgLoggedIn << MsgPageTuberculosisActivity id activity)
|> flexPageWrapper configured.config model

EducationSessionPage id ->
let
page_ =
Dict.get id loggedInModel.educationSessionPages
|> Maybe.withDefault Pages.EducationSession.Model.emptyModel
in
Pages.EducationSession.View.view model.language currentDate model.villageId id model.indexedDb page_
|> Html.map (MsgLoggedIn << MsgPageEducationSession id)
|> flexPageWrapper configured.config model

TraceContactPage traceContactId ->
let
page_ =
Expand Down
4 changes: 4 additions & 0 deletions client/src/elm/Backend/Decoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Backend.ChildScoreboardEncounter.Decoder exposing (decodeChildScoreboardE
import Backend.Clinic.Decoder exposing (decodeClinic)
import Backend.Counseling.Decoder exposing (decodeCounselingSchedule, decodeCounselingTopic)
import Backend.Dashboard.Decoder exposing (decodeDashboardStatsRaw)
import Backend.EducationSession.Decoder exposing (decodeEducationSession)
import Backend.HealthCenter.Decoder exposing (decodeCatchmentArea, decodeHealthCenter)
import Backend.HomeVisitEncounter.Decoder exposing (decodeHomeVisitEncounter)
import Backend.IndividualEncounterParticipant.Decoder exposing (decodeIndividualEncounterParticipant)
Expand Down Expand Up @@ -142,6 +143,9 @@ decodeRevision =
"danger_signs" ->
decodeWithUuid DangerSignsRevision decodeDangerSigns

"education_session" ->
decodeWithUuid EducationSessionRevision decodeEducationSession

"exposure" ->
decodeWithUuid ExposureRevision decodeExposure

Expand Down
33 changes: 33 additions & 0 deletions client/src/elm/Backend/EducationSession/Decoder.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Backend.EducationSession.Decoder exposing (decodeEducationSession)

import Backend.EducationSession.Model exposing (..)
import Backend.EducationSession.Utils exposing (..)
import EverySet exposing (EverySet)
import Gizra.NominalDate exposing (decodeYYYYMMDD)
import Json.Decode exposing (Decoder, andThen, fail, nullable, string, succeed)
import Json.Decode.Pipeline exposing (optional, optionalAt, required, requiredAt)
import Restful.Endpoint exposing (decodeEntityUuid)
import Utils.Json exposing (decodeEverySet)


decodeEducationSession : Decoder EducationSession
decodeEducationSession =
succeed EducationSession
|> requiredAt [ "scheduled_date", "value" ] decodeYYYYMMDD
|> required "nurse" decodeEntityUuid
|> required "village_ref" decodeEntityUuid
|> optional "education_topics" (decodeEverySet decodeEducationTopic) EverySet.empty
|> optional "participating_patients" (decodeEverySet decodeEntityUuid) EverySet.empty
|> optionalAt [ "scheduled_date", "value2" ] (nullable decodeYYYYMMDD) Nothing
|> optional "shard" (nullable decodeEntityUuid) Nothing


decodeEducationTopic : Decoder EducationTopic
decodeEducationTopic =
string
|> andThen
(\sign ->
educationTopicFromString sign
|> Maybe.map succeed
|> Maybe.withDefault (fail <| sign ++ " is not a recognized EducationTopic")
)
34 changes: 34 additions & 0 deletions client/src/elm/Backend/EducationSession/Encoder.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Backend.EducationSession.Encoder exposing (encodeEducationSession)

import Backend.EducationSession.Model exposing (..)
import Backend.EducationSession.Utils exposing (..)
import Gizra.NominalDate exposing (encodeYYYYMMDD)
import Json.Encode exposing (..)
import Json.Encode.Extra exposing (maybe)
import Restful.Endpoint exposing (encodeEntityUuid)
import Utils.Json exposing (encodeEverySet, encodeIfSet)


{-| Encodes a `EducationSession`.
-}
encodeEducationSession : EducationSession -> List ( String, Value )
encodeEducationSession session =
[ ( "scheduled_date"
, object
[ ( "value", encodeYYYYMMDD session.startDate )
, ( "value2", maybe encodeYYYYMMDD session.endDate )
]
)
, ( "nurse", encodeEntityUuid session.nurse )
, ( "village_ref", encodeEntityUuid session.village )
, ( "education_topics", encodeEverySet encodeEducationTopic session.topics )
, ( "participating_patients", encodeEverySet encodeEntityUuid session.participants )
, ( "deleted", bool False )
, ( "type", string "education_session" )
]
++ encodeIfSet "shard" session.shard encodeEntityUuid


encodeEducationTopic : EducationTopic -> Value
encodeEducationTopic =
educationTopicToString >> string
62 changes: 62 additions & 0 deletions client/src/elm/Backend/EducationSession/Model.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module Backend.EducationSession.Model exposing (..)

import Backend.Entities exposing (..)
import Backend.Measurement.Model exposing (..)
import EverySet exposing (EverySet)
import Gizra.NominalDate exposing (NominalDate)
import RemoteData exposing (RemoteData(..), WebData)


type alias EducationSession =
{ startDate : NominalDate
, nurse : NurseId
, village : VillageId
, topics : EverySet EducationTopic
, participants : EverySet PersonId
, endDate : Maybe NominalDate
, shard : Maybe HealthCenterId
}


emptyEducationSession : NominalDate -> NurseId -> VillageId -> Maybe HealthCenterId -> EducationSession
emptyEducationSession startDate nurse village shard =
{ startDate = startDate
, nurse = nurse
, village = village
, topics = EverySet.empty
, participants = EverySet.empty
, endDate = Nothing
, shard = shard
}


type EducationTopic
= TopicTuberculosis
| TopicSTD
| TopicMentalHealth
| TopicMalaria
| TopicChildhoodIllnesses
| TopicMalnutrition
| TopicANCPostpartum
| TopicFamilyPlanning
| TopicGender
| TopicNCD


{-| This is a subdivision of ModelIndexedDb that tracks requests in-progress
to peform the updates indicated by the `Msg` type below.
-}
type alias Model =
{ updateEducationSession : WebData ()
}


emptyModel : Model
emptyModel =
{ updateEducationSession = NotAsked
}


type Msg
= Update (EducationSession -> EducationSession)
| HandleUpdated (WebData ())
Loading

0 comments on commit 6d7f06a

Please sign in to comment.