-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1092 from TIP-Global-Health/develop
Developments starting March 24, 2024
- Loading branch information
Showing
67 changed files
with
2,427 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ()) |
Oops, something went wrong.