Skip to content

Commit

Permalink
Merge pull request #1350 from TIP-Global-Health/issue-1327
Browse files Browse the repository at this point in the history
ANC - Immunization History pane for Progress Report
  • Loading branch information
anvmn authored Oct 1, 2024
2 parents 1684d52 + ff91a47 commit eeccbc8
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 16 deletions.
10 changes: 9 additions & 1 deletion client/src/assets/scss/_new.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3084,6 +3084,13 @@ div.page-report.clinical .ui.unstackable.items {
}
}

.vaccination-history {

.pane-content {
padding-left: 0;
}
}

.chw-activities {

.heading,
Expand Down Expand Up @@ -4054,7 +4061,8 @@ div.page-activity.well-child,
div.page-report.acute-illness,
div.page-report.well-child,
div.page-report.child-scoreboard,
div.page-activity.patient-record {
div.page-activity.patient-record,
div.page-report.clinical {

.heading {
border-bottom: 1px solid $color-text;
Expand Down
2 changes: 1 addition & 1 deletion client/src/elm/Backend/Measurement/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ type PrenatalHIVSign
| PartnerSurpressedViralLoad
-- This option is an indicator.
-- When Lab tech fills the result, they do not
-- answer follow up quesrtion. We use this optin to indicate
-- answer follow up question. We use this optin to indicate
-- that nurse will have to complete the results follow up.
| PrenatalHIVSignPendingInput
| NoPrenatalHIVSign
Expand Down
1 change: 1 addition & 0 deletions client/src/elm/Components/ReportToWhatsAppDialog/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type ReportComponentAntenatal
= ComponentAntenatalObstetricHistory
| ComponentAntenatalMedicalDiagnosis
| ComponentAntenatalObstetricalDiagnosis
| ComponentAntenatalImmunizationHistory
| ComponentAntenatalCHWActivity
| ComponentAntenatalPatientProgress
| ComponentAntenatalLabsResults
Expand Down
1 change: 1 addition & 0 deletions client/src/elm/Components/ReportToWhatsAppDialog/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy
[ ComponentAntenatalObstetricHistory
, ComponentAntenatalMedicalDiagnosis
, ComponentAntenatalObstetricalDiagnosis
, ComponentAntenatalImmunizationHistory
, ComponentAntenatalCHWActivity
, ComponentAntenatalPatientProgress
, ComponentAntenatalLabsResults
Expand Down
6 changes: 6 additions & 0 deletions client/src/elm/Measurement/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,12 @@ type alias VaccinationProgressDict =
Dict WellChildVaccineType (Dict VaccineDose NominalDate)


type VaccinationStatus
= StatusBehind
| StatusCompleted
| StatusUpToDate


type ImmunisationTask
= TaskBCG
| TaskDTP
Expand Down
24 changes: 19 additions & 5 deletions client/src/elm/Pages/Prenatal/Activity/Utils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5123,7 +5123,7 @@ expectImmunisationTask : NominalDate -> AssembledData -> ImmunisationTask -> Boo
expectImmunisationTask currentDate assembled task =
let
futureVaccinations =
generateFutureVaccinationsData currentDate assembled
generateFutureVaccinationsDataByHistory currentDate assembled
|> Dict.fromList

isTaskExpected vaccineType =
Expand All @@ -5139,11 +5139,25 @@ expectImmunisationTask currentDate assembled task =
|> isTaskExpected


generateFutureVaccinationsDataByHistory : NominalDate -> AssembledData -> List ( PrenatalVaccineType, Maybe ( VaccineDose, NominalDate ) )
generateFutureVaccinationsDataByHistory currentDate assembled =
generateFutureVaccinationsData currentDate assembled.globalLmpDate assembled.vaccinationHistory


generateFutureVaccinationsDataByProgress : NominalDate -> AssembledData -> List ( PrenatalVaccineType, Maybe ( VaccineDose, NominalDate ) )
generateFutureVaccinationsDataByProgress currentDate assembled =
generateFutureVaccinationsData currentDate assembled.globalLmpDate assembled.vaccinationProgress


{-| For each type of vaccine, we generate next dose and administration date.
If there's no need for future vaccination, Nothing is returned.
-}
generateFutureVaccinationsData : NominalDate -> AssembledData -> List ( PrenatalVaccineType, Maybe ( VaccineDose, NominalDate ) )
generateFutureVaccinationsData currentDate assembled =
generateFutureVaccinationsData :
NominalDate
-> Maybe NominalDate
-> VaccinationProgressDict
-> List ( PrenatalVaccineType, Maybe ( VaccineDose, NominalDate ) )
generateFutureVaccinationsData currentDate globalLmpDate vaccinationDict =
Maybe.map
(\lmpDate ->
let
Expand All @@ -5154,7 +5168,7 @@ generateFutureVaccinationsData currentDate assembled =
(\vaccineType ->
let
nextVaccinationData =
case latestVaccinationDataForVaccine assembled.vaccinationHistory vaccineType of
case latestVaccinationDataForVaccine vaccinationDict vaccineType of
Just ( lastDoseAdministered, lastDoseDate ) ->
nextVaccinationDataForVaccine currentDate egaInWeeks vaccineType lastDoseDate lastDoseAdministered

Expand All @@ -5169,7 +5183,7 @@ generateFutureVaccinationsData currentDate assembled =
)
allVaccineTypes
)
assembled.globalLmpDate
globalLmpDate
|> Maybe.withDefault []


Expand Down
77 changes: 75 additions & 2 deletions client/src/elm/Pages/Prenatal/ProgressReport/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import Html.Attributes exposing (..)
import Html.Events exposing (..)
import List.Extra exposing (greedyGroupsOf)
import Maybe.Extra exposing (isJust, isNothing, unwrap)
import Measurement.Model exposing (VaccinationStatus(..))
import Measurement.Utils
exposing
( outsideCareMedicationOptionsAnemia
Expand All @@ -64,10 +65,10 @@ import Measurement.Utils
, outsideCareMedicationOptionsSyphilis
)
import Pages.Page exposing (Page(..), UserPage(..))
import Pages.Prenatal.Activity.Utils exposing (respiratoryRateElevated)
import Pages.Prenatal.Activity.Utils exposing (generateFutureVaccinationsDataByProgress, respiratoryRateElevated)
import Pages.Prenatal.Encounter.Utils exposing (..)
import Pages.Prenatal.Encounter.View exposing (viewActionButton)
import Pages.Prenatal.Model exposing (AssembledData)
import Pages.Prenatal.Model exposing (AssembledData, VaccinationProgressDict)
import Pages.Prenatal.ProgressReport.Model exposing (..)
import Pages.Prenatal.ProgressReport.Svg exposing (viewBMIForEGA, viewFundalHeightForEGA, viewMarkers)
import Pages.Prenatal.ProgressReport.Utils exposing (..)
Expand Down Expand Up @@ -516,6 +517,8 @@ viewContent language currentDate site features isChw isLabTech isResultsReviewer
|> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentAntenatalMedicalDiagnosis)
, viewObstetricalDiagnosisPane language currentDate isChw firstNurseEncounterMeasurements assembled
|> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentAntenatalObstetricalDiagnosis)
, viewVaccinationHistoryPane language currentDate assembled
|> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentAntenatalImmunizationHistory)
, viewChwActivityPane language currentDate isChw assembled
|> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentAntenatalCHWActivity)
, viewPatientProgressPane language currentDate isChw assembled
Expand Down Expand Up @@ -989,6 +992,76 @@ viewObstetricalDiagnosisPane language currentDate isChw firstNurseEncounterMeasu
]


viewVaccinationHistoryPane : Language -> NominalDate -> AssembledData -> Html any
viewVaccinationHistoryPane language currentDate assembled =
div [ class "vaccination-history" ] <|
[ viewItemHeading language Translate.ImmunizationHistory "blue"
, div [ class "pane-content" ] <|
viewVaccinationOverview language currentDate assembled
]


viewVaccinationOverview :
Language
-> NominalDate
-> AssembledData
-> List (Html any)
viewVaccinationOverview language currentDate assembled =
let
entriesHeading =
div [ class "heading vaccination" ]
[ div [ class "name" ] [ text <| translate language Translate.Immunisation ]
, div [ class "date" ] [ text <| translate language Translate.DateReceived ]
, div [ class "next-due" ] [ text <| translate language Translate.NextDue ]
, div [ class "status" ] [ text <| translate language Translate.StatusLabel ]
]

futureVaccinationsData =
generateFutureVaccinationsDataByProgress currentDate assembled
|> Dict.fromList

entries =
Dict.toList assembled.vaccinationProgress
|> List.map viewVaccinationEntry

viewVaccinationEntry ( vaccineType, doses ) =
let
nextDue =
Dict.get vaccineType futureVaccinationsData
|> Maybe.Extra.join
|> Maybe.map Tuple.second

nextDueText =
Maybe.map formatDDMMYYYY nextDue
|> Maybe.withDefault ""

( status, statusClass ) =
Maybe.map
(\dueDate ->
if Date.compare dueDate currentDate == LT then
( StatusBehind, "behind" )

else
( StatusUpToDate, "up-to-date" )
)
nextDue
|> Maybe.withDefault ( StatusCompleted, "completed" )
in
div [ class "entry vaccination" ]
[ div [ class "cell name" ] [ text <| translate language <| Translate.PrenatalVaccineLabel vaccineType ]
, Dict.values doses
|> List.sortWith Date.compare
|> List.map (formatDDMMYYYY >> text >> List.singleton >> p [])
|> div [ class "cell date" ]
, div [ classList [ ( "cell next-due ", True ), ( "red", status == StatusBehind ) ] ]
[ text nextDueText ]
, div [ class <| "cell status " ++ statusClass ]
[ text <| translate language <| Translate.VaccinationStatus status ]
]
in
entriesHeading :: entries


viewChwActivityPane : Language -> NominalDate -> Bool -> AssembledData -> Html Msg
viewChwActivityPane language currentDate isChw assembled =
let
Expand Down
6 changes: 0 additions & 6 deletions client/src/elm/Pages/WellChild/Activity/Types.elm
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
module Pages.WellChild.Activity.Types exposing (..)


type VaccinationStatus
= StatusBehind
| StatusCompleted
| StatusUpToDate


type DangerSignsTask
= TaskSymptomsReview
| TaskVitals
Expand Down
1 change: 1 addition & 0 deletions client/src/elm/Pages/WellChild/Activity/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Measurement.Model
, PhotoForm
, VaccinationFormViewMode(..)
, VaccinationProgressDict
, VaccinationStatus(..)
, VitalsForm
, VitalsFormMode(..)
)
Expand Down
5 changes: 4 additions & 1 deletion client/src/elm/Translate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import Measurement.Model
, LaboratoryTask(..)
, NCDAStep(..)
, NextStepsTask(..)
, VaccinationStatus(..)
)
import Pages.AcuteIllness.Activity.Types
exposing
Expand Down Expand Up @@ -144,7 +145,6 @@ import Pages.WellChild.Activity.Types
( HomeVisitTask(..)
, NextStepsTask(..)
, NutritionAssessmentTask(..)
, VaccinationStatus(..)
)
import Pages.WellChild.Encounter.Model exposing (ECDPopupType(..), WarningPopupType(..))
import Pages.WellChild.ProgressReport.Model
Expand Down Expand Up @@ -18524,6 +18524,9 @@ translationSet trans =
, kirundi = Just "Isuzuma ry'ivyara"
}

ComponentAntenatalImmunizationHistory ->
translationSet ImmunizationHistory

ComponentAntenatalCHWActivity ->
{ english = "CHW Activity"
, kinyarwanda = Nothing
Expand Down

0 comments on commit eeccbc8

Please sign in to comment.