Skip to content

Commit

Permalink
Merge pull request #1028 from TIP-Global-Health/develop
Browse files Browse the repository at this point in the history
Developments starting February 18, 2024
  • Loading branch information
anvmn authored Feb 25, 2024
2 parents 9231976 + e635385 commit d29093d
Show file tree
Hide file tree
Showing 97 changed files with 11,879 additions and 5,346 deletions.
3 changes: 2 additions & 1 deletion client/src/assets/scss/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ h3.ui.header {
background-size: 78px 78px;
}

.icon-task-laboratory {
.icon-task-laboratory,
.icon-task-laboratory-follow-ups {
background-image: url(#{$img-path}icon-laboratory-white.svg);
background-size: 78px 78px;
}
Expand Down
5 changes: 4 additions & 1 deletion client/src/assets/scss/_new.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2636,12 +2636,15 @@ div.page-report {
div.page-report.clinical,
div.page-report.demographics,
div.page-report.ncd {
padding: 0 20px 35px 20px;
height: 100%;
display: flex;
flex-direction: column;
overflow-x: hidden;
padding: 0 20px 35px 20px;


.ui.unstackable.items {
overflow-x: hidden;
overflow-y: auto;

.pane-heading {
Expand Down
26 changes: 17 additions & 9 deletions client/src/elm/App/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AssocList as Dict
import Backend.Endpoints exposing (nurseEndpoint)
import Backend.Model
import Backend.Nurse.Model
import Backend.Nurse.Utils exposing (isCommunityHealthWorker)
import Backend.Nurse.Utils exposing (isCommunityHealthWorker, isLabTechnician)
import Backend.NutritionActivity.Model exposing (NutritionActivity(..))
import Backend.Person.Model exposing (Initiator(..))
import Backend.PrenatalActivity.Model exposing (PrenatalActivity(..))
Expand Down Expand Up @@ -228,10 +228,17 @@ update msg model =
loggedInData =
getLoggedInData model

isChw =
loggedInData
|> Maybe.map (Tuple.second >> .nurse >> Tuple.second >> isCommunityHealthWorker)
|> Maybe.withDefault False
( isChw, isLabTech ) =
Maybe.map
(Tuple.second
>> .nurse
>> Tuple.second
>> (\nurse ->
( isCommunityHealthWorker nurse, isLabTechnician nurse )
)
)
loggedInData
|> Maybe.withDefault ( False, False )

site =
model.syncManager.syncInfoGeneral.site
Expand All @@ -246,8 +253,7 @@ update msg model =
MsgIndexedDb subMsg ->
let
nurseId =
loggedInData
|> Maybe.map (Tuple.second >> .nurse >> Tuple.first)
Maybe.map (Tuple.second >> .nurse >> Tuple.first) loggedInData

( subModel, subCmd, extraMsgs ) =
Backend.Update.updateIndexedDb model.language
Expand All @@ -260,6 +266,7 @@ update msg model =
model.healthCenterId
model.villageId
isChw
isLabTech
model.activePage
model.syncManager
subMsg
Expand Down Expand Up @@ -557,7 +564,7 @@ update msg model =
data.prenatalActivityPages
|> Dict.get ( id, activity )
|> Maybe.withDefault Pages.Prenatal.Activity.Model.emptyModel
|> Pages.Prenatal.Activity.Update.update model.language currentDate id model.indexedDb subMsg
|> Pages.Prenatal.Activity.Update.update model.language currentDate id isLabTech model.indexedDb subMsg
in
( { data | prenatalActivityPages = Dict.insert ( id, activity ) subModel data.prenatalActivityPages }
, Cmd.map (MsgLoggedIn << MsgPagePrenatalActivity id activity) subCmd
Expand All @@ -570,7 +577,7 @@ update msg model =
data.prenatalRecurrentActivityPages
|> Dict.get ( id, activity )
|> Maybe.withDefault Pages.Prenatal.RecurrentActivity.Model.emptyModel
|> Pages.Prenatal.RecurrentActivity.Update.update model.language currentDate id model.indexedDb subMsg
|> Pages.Prenatal.RecurrentActivity.Update.update model.language currentDate id isLabTech model.indexedDb subMsg
in
( { data | prenatalRecurrentActivityPages = Dict.insert ( id, activity ) subModel data.prenatalRecurrentActivityPages }
, Cmd.map (MsgLoggedIn << MsgPagePrenatalRecurrentActivity id activity) subCmd
Expand All @@ -587,6 +594,7 @@ update msg model =
currentDate
originEncounterId
labEncounterId
isLabTech
model.indexedDb
subMsg
in
Expand Down
20 changes: 15 additions & 5 deletions client/src/elm/App/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import App.Model exposing (..)
import App.Utils exposing (getLoggedInData)
import AssocList as Dict
import Backend.NCDEncounter.Types exposing (NCDProgressReportInitiator(..))
import Backend.Nurse.Utils exposing (isCommunityHealthWorker)
import Backend.Nurse.Utils exposing (isCommunityHealthWorker, isLabTechnician)
import Backend.Person.Model exposing (Initiator(..), ParticipantDirectoryOperation(..))
import Browser
import Config.Model
Expand Down Expand Up @@ -346,9 +346,11 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
currentDate =
fromLocalDateTime model.currentTime

isChw =
( isChw, isLabTech ) =
Tuple.second loggedInModel.nurse
|> isCommunityHealthWorker
|> (\nurse ->
( isCommunityHealthWorker nurse, isLabTechnician nurse )
)
in
case page of
MyAccountPage ->
Expand Down Expand Up @@ -380,6 +382,7 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
currentDate
site
features
(Tuple.second loggedInModel.nurse)
prenatalEncounterId
isChw
initiator
Expand Down Expand Up @@ -421,6 +424,7 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
currentDate
healthCenterId
model.villageId
isLabTech
model.syncManager
model.indexedDb
loggedInModel.globalCaseManagementPage
Expand Down Expand Up @@ -599,7 +603,7 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
Dict.get id loggedInModel.prenatalRecurrentEncounterPages
|> Maybe.withDefault Pages.Prenatal.RecurrentEncounter.Model.emptyModel
in
Pages.Prenatal.RecurrentEncounter.View.view model.language currentDate id model.indexedDb page_
Pages.Prenatal.RecurrentEncounter.View.view model.language currentDate (Tuple.second loggedInModel.nurse) id model.indexedDb page_
|> Html.map (MsgLoggedIn << MsgPagePrenatalRecurrentEncounter id)
|> flexPageWrapper configured.config model

Expand All @@ -609,7 +613,13 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur
Dict.get ( id, activity ) loggedInModel.prenatalRecurrentActivityPages
|> Maybe.withDefault Pages.Prenatal.RecurrentActivity.Model.emptyModel
in
Pages.Prenatal.RecurrentActivity.View.view model.language currentDate id activity model.indexedDb page_
Pages.Prenatal.RecurrentActivity.View.view model.language
currentDate
(Tuple.second loggedInModel.nurse)
id
activity
model.indexedDb
page_
|> Html.map (MsgLoggedIn << MsgPagePrenatalRecurrentActivity id activity)
|> flexPageWrapper configured.config model

Expand Down
4 changes: 2 additions & 2 deletions client/src/elm/Backend/AcuteIllnessEncounter/Encoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Gizra.NominalDate exposing (encodeYYYYMMDD)
import Json.Encode exposing (..)
import Json.Encode.Extra exposing (maybe)
import Restful.Endpoint exposing (encodeEntityUuid)
import Utils.Json exposing (encodeIfExists)
import Utils.Json exposing (encodeIfSet)


{-| Encodes a `AcuteIllnessEncounter`.
Expand All @@ -26,7 +26,7 @@ encodeAcuteIllnessEncounter session =
, ( "deleted", bool False )
, ( "type", string "acute_illness_encounter" )
]
++ encodeIfExists "shard" session.shard encodeEntityUuid
++ encodeIfSet "shard" session.shard encodeEntityUuid


encodeAcuteIllnessEncounterType : AcuteIllnessEncounterType -> Value
Expand Down
4 changes: 2 additions & 2 deletions client/src/elm/Backend/ChildScoreboardEncounter/Encoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Gizra.NominalDate exposing (encodeYYYYMMDD)
import Json.Encode exposing (..)
import Json.Encode.Extra exposing (maybe)
import Restful.Endpoint exposing (encodeEntityUuid)
import Utils.Json exposing (encodeIfExists)
import Utils.Json exposing (encodeIfSet)


{-| Encodes a `ChildScoreboardEncounter`.
Expand All @@ -22,4 +22,4 @@ encodeChildScoreboardEncounter session =
, ( "deleted", bool False )
, ( "type", string "child_scoreboard_encounter" )
]
++ encodeIfExists "shard" session.shard encodeEntityUuid
++ encodeIfSet "shard" session.shard encodeEntityUuid
4 changes: 2 additions & 2 deletions client/src/elm/Backend/HomeVisitEncounter/Encoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Gizra.NominalDate exposing (encodeYYYYMMDD)
import Json.Encode exposing (..)
import Json.Encode.Extra exposing (maybe)
import Restful.Endpoint exposing (encodeEntityUuid)
import Utils.Json exposing (encodeIfExists)
import Utils.Json exposing (encodeIfSet)


{-| Encodes a `HomeVisitEncounter`.
Expand All @@ -22,4 +22,4 @@ encodeHomeVisitEncounter session =
, ( "deleted", bool False )
, ( "type", string "home_visit_encounter" )
]
++ encodeIfExists "shard" session.shard encodeEntityUuid
++ encodeIfSet "shard" session.shard encodeEntityUuid
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Gizra.NominalDate exposing (encodeYYYYMMDD)
import Json.Encode exposing (..)
import Json.Encode.Extra exposing (maybe)
import Restful.Endpoint exposing (encodeEntityUuid)
import Utils.Json exposing (encodeIfExists)
import Utils.Json exposing (encodeIfSet)


encodeIndividualEncounterParticipant : IndividualEncounterParticipant -> List ( String, Value )
Expand All @@ -27,7 +27,7 @@ encodeIndividualEncounterParticipant data =
, ( "deleted", bool data.deleted )
, ( "type", string "individual_participant" )
]
++ encodeIfExists "shard" data.shard encodeEntityUuid
++ encodeIfSet "shard" data.shard encodeEntityUuid


encodeIndividualEncounterType : IndividualEncounterType -> Value
Expand Down
71 changes: 71 additions & 0 deletions client/src/elm/Backend/Measurement/Decoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ decodeBloodGpRsTestValue =
succeed BloodGpRsTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultNonRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultNonRDT)
|> optional "blood_group" (nullable decodeBloodGroup) Nothing
|> optional "rhesus" (nullable decodeRhesus) Nothing
|> optional "originating_encounter" (nullable decodeEntityUuid) Nothing
Expand Down Expand Up @@ -517,6 +522,11 @@ decodeHemoglobinTestValue =
succeed HemoglobinTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultNonRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultNonRDT)
|> optional "hemoglobin_count" (nullable decodeFloat) Nothing


Expand All @@ -530,6 +540,11 @@ decodeHepatitisBTestValue =
succeed HepatitisBTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultNonRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultNonRDT)
|> optional "test_result" (nullable decodeTestResult) Nothing
|> optional "originating_encounter" (nullable decodeEntityUuid) Nothing

Expand All @@ -544,6 +559,11 @@ decodeHIVTestValue =
succeed HIVTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultRDT)
|> optional "test_result" (nullable decodeTestResult) Nothing
|> optional "hiv_signs" (nullable (decodeEverySet decodePrenatalHIVSign)) Nothing

Expand All @@ -558,6 +578,11 @@ decodeHIVPCRTestValue =
succeed HIVPCRTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultNonRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultNonRDT)
|> optional "hiv_viral_load_status" (nullable decodeViralLoadStatus) Nothing
|> optional "hiv_viral_load" (nullable decodeFloat) Nothing

Expand All @@ -572,6 +597,11 @@ decodePartnerHIVTestValue =
succeed PartnerHIVTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultRDT)
|> optional "test_result" (nullable decodeTestResult) Nothing


Expand Down Expand Up @@ -615,6 +645,11 @@ decodeMalariaTestValue =
succeed MalariaTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultRDT)
|> optional "test_result" (nullable decodeTestResult) Nothing
|> optional "blood_smear_result" decodeBloodSmearResult BloodSmearNotTaken

Expand Down Expand Up @@ -675,6 +710,11 @@ decodeSyphilisTestValue =
succeed SyphilisTestValue
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultNonRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultNonRDT)
|> optional "test_result" (nullable decodeTestResult) Nothing
|> optional "illness_symptoms" (nullable (decodeEverySet decodeIllnessSymptom)) Nothing
|> optional "originating_encounter" (nullable decodeEntityUuid) Nothing
Expand Down Expand Up @@ -702,6 +742,11 @@ decodeUrineDipstickTestValue =
|> optional "test_variant" (nullable decodeTestVariant) Nothing
|> required "test_execution_note" decodeTestExecutionNote
|> optional "execution_date" (nullable Gizra.NominalDate.decodeYYYYMMDD) Nothing
|> optional "test_prerequisites"
(nullable
(decodeWithFallback prerequisitesDefaultNonRDT (decodeEverySet decodeTestPrerequisite))
)
(Just prerequisitesDefaultNonRDT)
|> optional "protein" (nullable decodeProteinValue) Nothing
|> optional "ph" (nullable decodePHValue) Nothing
|> optional "glucose" (nullable decodeGlucoseValue) Nothing
Expand Down Expand Up @@ -864,6 +909,9 @@ decodeTestExecutionNote =
"to-be-done-at-hospital" ->
succeed TestNoteToBeDoneAtHospital

"run-confirmed-by-lab-tech" ->
succeed TestNoteRunConfirmedByLabTech

_ ->
fail <|
note
Expand All @@ -882,6 +930,16 @@ decodeTestResult =
)


prerequisitesDefaultRDT : EverySet TestPrerequisite
prerequisitesDefaultRDT =
EverySet.singleton PrerequisiteImmediateResult


prerequisitesDefaultNonRDT : EverySet TestPrerequisite
prerequisitesDefaultNonRDT =
EverySet.singleton NoTestPrerequisites


decodePrenatalLabsResults : Decoder PrenatalLabsResults
decodePrenatalLabsResults =
decodePrenatalMeasurement decodeLabsResultsValue
Expand All @@ -894,6 +952,8 @@ decodeLabsResultsValue =
|> required "completed_tests" (decodeEverySet decodeLaboratoryTest)
|> required "date_concluded" Gizra.NominalDate.decodeYYYYMMDD
|> optional "patient_notified" bool False
|> optional "review_state" (nullable decodeLabsResultsReviewState) Nothing
|> optional "tests_with_follow_up" (nullable (decodeEverySet decodeLaboratoryTest)) Nothing


decodeLaboratoryTest : Decoder LaboratoryTest
Expand All @@ -907,6 +967,17 @@ decodeLaboratoryTest =
)


decodeLabsResultsReviewState : Decoder LabsResultsReviewState
decodeLabsResultsReviewState =
string
|> andThen
(\s ->
reviewStateFromString s
|> Maybe.map succeed
|> Maybe.withDefault (fail <| s ++ " is not a recognized LaboratoryTest")
)


decodePrenatalMedicationDistribution : Decoder PrenatalMedicationDistribution
decodePrenatalMedicationDistribution =
decodePrenatalMeasurement decodePrenatalMedicationDistributionValue
Expand Down
Loading

0 comments on commit d29093d

Please sign in to comment.