From 5ec9bad0d0213cf95878b889dea37a25a48d6088 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 3 Mar 2024 13:58:27 +0200 Subject: [PATCH 1/5] Fix calculations fir first of the month + consider creation date of patient for dashboard counters --- client/src/elm/Gizra/NominalDate.elm | 17 +- client/src/elm/Pages/Dashboard/Utils.elm | 9 +- client/src/elm/Pages/Dashboard/View.elm | 5 +- client/src/elm/Pages/Utils.elm | 9 +- server/elm/src/Backend/Scoreboard/Decoder.elm | 3 + server/elm/src/Backend/Scoreboard/Model.elm | 4 +- server/elm/src/Gizra/NominalDate.elm | 16 +- server/elm/src/Pages/Scoreboard/View.elm | 503 +++++++---- .../custom/hedley_ncda/hedley_ncda.module | 6 +- .../modules/custom/hedley_ncda/js/elm-main.js | 804 ++++++++++-------- 10 files changed, 822 insertions(+), 554 deletions(-) diff --git a/client/src/elm/Gizra/NominalDate.elm b/client/src/elm/Gizra/NominalDate.elm index 4d5771fcad..f901363b17 100644 --- a/client/src/elm/Gizra/NominalDate.elm +++ b/client/src/elm/Gizra/NominalDate.elm @@ -5,7 +5,7 @@ module Gizra.NominalDate exposing , fromLocalDateTime , diffDays, diffCalendarMonthsAndDays , NominalDateRange, decodeDrupalRange, encodeDrupalRange - , allMonths, daysInMonth, diffCalendarMonths, diffCalendarYearsAndMonths, diffMonths, diffWeeks, diffYears, formatDDMMYY, formatDDMMYYYY, isDiffTruthy, isLeapYear, monthMM, yearYY, yearYYNumber + , allMonths, daysInMonth, diffCalendarMonths, diffCalendarYearsAndMonths, diffMonths, diffWeeks, diffYears, formatDDMMYY, formatDDMMYYYY, isDiffTruthy, isLeapYear, monthMM, toLastDayOfMonth, yearYY, yearYYNumber ) {-| Some utilities for dealing with "pure" dates that have no time or @@ -24,7 +24,7 @@ time zone information. -} -import Date +import Date exposing (..) import Gizra.String exposing (addLeadingZero) import Json.Decode exposing (Decoder, andThen, field, map2, string) import Json.Decode.Extra exposing (fromResult) @@ -93,6 +93,19 @@ fromLocalDateTime = Date.fromPosix Time.utc +{-| Given a date, return date representing it's last month day. + + toLastDayOfMonth 2019-08-01" --> 2019-08-31" + toLastDayOfMonth 2017-02-20" --> 2017-02-28" + +-} +toLastDayOfMonth : NominalDate -> NominalDate +toLastDayOfMonth = + Date.floor Month + >> Date.add Months 1 + >> Date.add Days -1 + + {-| Decodes nominal date from string of the form "2017-02-20". import Json.Decode exposing (..) diff --git a/client/src/elm/Pages/Dashboard/Utils.elm b/client/src/elm/Pages/Dashboard/Utils.elm index 15d1d7e13d..9b3b8fd462 100644 --- a/client/src/elm/Pages/Dashboard/Utils.elm +++ b/client/src/elm/Pages/Dashboard/Utils.elm @@ -58,7 +58,7 @@ import Backend.PrenatalEncounter.Types exposing (PrenatalDiagnosis(..)) import Backend.Village.Model exposing (Village) import Date exposing (Unit(..), isBetween) import EverySet -import Gizra.NominalDate exposing (NominalDate) +import Gizra.NominalDate exposing (NominalDate, toLastDayOfMonth) import List.Extra import Maybe.Extra exposing (isJust) import Measurement.Model exposing (VaccinationProgressDict) @@ -79,7 +79,6 @@ import Pages.GlobalCaseManagement.View , generateNutritionFollowUpEntries , generatePrenatalFollowUpEntries ) -import Pages.Utils exposing (getLastDayOfMonth) import SyncManager.Model exposing (Site) import Translate exposing (Language) import Utils.NominalDate exposing (sortByDate, sortByDateDesc) @@ -1236,7 +1235,7 @@ generateTotalBeneficiariesMonthlyDuringPastYear currentDate stats = let maxJoinDate = Date.add Months (-1 * index) currentDate - |> getLastDayOfMonth + |> toLastDayOfMonth minGraduationDate = Date.add Months (-1 * index) currentDate @@ -1462,7 +1461,7 @@ filterStatsByPeriod fiterFunc currentDate period stats = ( Date.add Months -1 currentDate |> Date.floor Date.Month , Date.add Months -1 currentDate - |> getLastDayOfMonth + |> toLastDayOfMonth ) ThreeMonthsAgo -> @@ -1470,7 +1469,7 @@ filterStatsByPeriod fiterFunc currentDate period stats = ( Date.add Months -2 currentDate |> Date.floor Date.Month , Date.add Months -2 currentDate - |> getLastDayOfMonth + |> toLastDayOfMonth ) filterPartial = diff --git a/client/src/elm/Pages/Dashboard/View.elm b/client/src/elm/Pages/Dashboard/View.elm index 9d6137fdfd..f005be6043 100644 --- a/client/src/elm/Pages/Dashboard/View.elm +++ b/client/src/elm/Pages/Dashboard/View.elm @@ -39,7 +39,7 @@ import Date exposing (Month, Unit(..), numberToMonth) import Debug exposing (toString) import EverySet import Gizra.Html exposing (emptyNode, showMaybe) -import Gizra.NominalDate exposing (NominalDate, isDiffTruthy) +import Gizra.NominalDate exposing (NominalDate, isDiffTruthy, toLastDayOfMonth) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (onClick, onInput) @@ -1664,8 +1664,7 @@ viewBeneficiariesTable language currentDate stats currentPeriodStats malnourishe let maxJoinDate = Date.add Months -1 currentDate - |> Date.ceiling Date.Month - |> Date.add Days -1 + |> toLastDayOfMonth minGraduationDate = Date.add Months -1 currentDate diff --git a/client/src/elm/Pages/Utils.elm b/client/src/elm/Pages/Utils.elm index 8900867815..28dff7a16d 100644 --- a/client/src/elm/Pages/Utils.elm +++ b/client/src/elm/Pages/Utils.elm @@ -18,7 +18,7 @@ import Backend.Utils exposing (reportToWhatsAppEnabled) import Date import EverySet exposing (EverySet) import Gizra.Html exposing (emptyNode, showIf) -import Gizra.NominalDate exposing (NominalDate, formatDDMMYYYY) +import Gizra.NominalDate exposing (NominalDate, formatDDMMYYYY, toLastDayOfMonth) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) @@ -433,12 +433,7 @@ resolveSelectedDateForMonthSelector currentDate monthGap = else Date.add Date.Months (-1 * monthGap) currentDate - |> getLastDayOfMonth - - -getLastDayOfMonth : NominalDate -> NominalDate -getLastDayOfMonth = - Date.ceiling Date.Month >> Date.add Date.Days -1 + |> toLastDayOfMonth diff --git a/server/elm/src/Backend/Scoreboard/Decoder.elm b/server/elm/src/Backend/Scoreboard/Decoder.elm index 8dc17069dd..cb8cac87d0 100644 --- a/server/elm/src/Backend/Scoreboard/Decoder.elm +++ b/server/elm/src/Backend/Scoreboard/Decoder.elm @@ -6,6 +6,7 @@ import Backend.Scoreboard.Model exposing (..) import Backend.Scoreboard.Utils exposing (..) import Date import EverySet exposing (EverySet) +import Gizra.Json exposing (decodeInt) import Gizra.NominalDate exposing (NominalDate, decodeYYYYMMDD, diffMonths) import Json.Decode exposing (Decoder, andThen, bool, fail, list, map, maybe, string, succeed) import Json.Decode.Pipeline exposing (optional, required) @@ -47,6 +48,8 @@ decodeSelectedEntity = decodePatientData : NominalDate -> Decoder PatientData decodePatientData currentDate = succeed PatientData + |> required "id" decodeInt + |> required "created" decodeYYYYMMDD |> required "birth_date" decodeYYYYMMDD |> required "edd_date" decodeYYYYMMDD |> optional "low_birth_weight" (maybe bool) Nothing diff --git a/server/elm/src/Backend/Scoreboard/Model.elm b/server/elm/src/Backend/Scoreboard/Model.elm index 206b33b19e..39931f012f 100644 --- a/server/elm/src/Backend/Scoreboard/Model.elm +++ b/server/elm/src/Backend/Scoreboard/Model.elm @@ -23,7 +23,9 @@ type SelectedEntity type alias PatientData = - { birthDate : NominalDate + { id : Int + , created : NominalDate + , birthDate : NominalDate , eddDate : NominalDate , lowBirthWeight : Maybe Bool , nutrition : NutritionCriterionsData diff --git a/server/elm/src/Gizra/NominalDate.elm b/server/elm/src/Gizra/NominalDate.elm index 91ec7695b6..631b86fc69 100644 --- a/server/elm/src/Gizra/NominalDate.elm +++ b/server/elm/src/Gizra/NominalDate.elm @@ -5,7 +5,7 @@ module Gizra.NominalDate exposing , fromLocalDateTime , diffDays, diffCalendarMonthsAndDays , NominalDateRange, decodeDrupalRange, encodeDrupalRange - , allMonths, daysInMonth, diffCalendarMonths, diffCalendarYearsAndMonths, diffMonths, diffWeeks, diffYears, formatDDMMYY, formatDDMMYYYY, isDiffTruthy, isLeapYear, yearYYNumber + , allMonths, daysInMonth, diffCalendarMonths, diffCalendarYearsAndMonths, diffMonths, diffWeeks, diffYears, formatDDMMYY, formatDDMMYYYY, isDiffTruthy, isLeapYear, toLastDayOfMonth, yearYYNumber ) {-| Some utilities for dealing with "pure" dates that have no time or @@ -24,7 +24,7 @@ time zone information. -} -import Date +import Date exposing (..) import Json.Decode exposing (Decoder, andThen, field, map2, string) import Json.Decode.Extra exposing (fromResult) import Json.Encode exposing (Value, object) @@ -91,6 +91,18 @@ fromLocalDateTime : Time.Posix -> NominalDate fromLocalDateTime = Date.fromPosix Time.utc +{-| Given a date, return date representing it's last month day. + + toLastDayOfMonth 2019-08-01" --> 2019-08-31" + toLastDayOfMonth 2017-02-20" --> 2017-02-28" + +-} +toLastDayOfMonth : NominalDate -> NominalDate +toLastDayOfMonth = + Date.floor Month + >> Date.add Months 1 + >> Date.add Days -1 + {-| Decodes nominal date from string of the form "2017-02-20". diff --git a/server/elm/src/Pages/Scoreboard/View.elm b/server/elm/src/Pages/Scoreboard/View.elm index eca683a6b4..71f01d3a5b 100644 --- a/server/elm/src/Pages/Scoreboard/View.elm +++ b/server/elm/src/Pages/Scoreboard/View.elm @@ -4,9 +4,9 @@ import App.Types exposing (Language, Site) import AssocList as Dict exposing (Dict) import Backend.Model exposing (ModelBackend) import Backend.Scoreboard.Model exposing (ScoreboardData) -import Date +import Date exposing (Interval(..), Unit(..)) import Gizra.Html exposing (emptyNode) -import Gizra.NominalDate exposing (NominalDate, diffMonths) +import Gizra.NominalDate exposing (NominalDate, diffMonths, formatDDMMYYYY, toLastDayOfMonth) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (onClick) @@ -68,20 +68,30 @@ viewScoreboardData language currentDate data model = childrenUnder2 = List.foldl (\record accum -> - let - ageInMonths = - diffMonths record.birthDate currentDate - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + ageInMonths = + diffMonths record.birthDate targetDateForMonth + gap = ageInMonths - gapInMonths + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT in - if gap >= 0 && gap < 24 then + if + existedDuringExaminationMonth + && (gap >= 0) + && (gap < 24) + then accumValue + 1 else @@ -108,6 +118,20 @@ viewScoreboardData language currentDate data model = ] +{-| Resolves date for last day of examined month. +For, current month, it's current date. For past month, +it's last day of that month. +-} +resolveTargetDateForMonth : Int -> NominalDate -> NominalDate +resolveTargetDateForMonth gapInMonths currentDate = + if gapInMonths == 0 then + currentDate + + else + Date.add Months (-1 * gapInMonths) currentDate + |> toLastDayOfMonth + + viewAggregatedChildScoreboardPane : Language -> ScoreboardData -> Html any viewAggregatedChildScoreboardPane language data = div [ class "pane" ] @@ -135,28 +159,38 @@ viewDemographicsPane language currentDate yearSelectorGap monthsGap childrenUnde valuesByRow = List.foldl (\record accum -> - let - ageInMonths = - diffMonths record.birthDate currentDate - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + ageInMonths = + diffMonths record.birthDate targetDateForMonth + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + gap = ageInMonths - gapInMonths row2 = - if gap == 0 then + if existedDuringExaminationMonth && gap == 0 then accumValue.row2 + 1 else accumValue.row2 row3 = - if gap == 0 && record.lowBirthWeight == Just True then + if + existedDuringExaminationMonth + && (gap == 0) + && (record.lowBirthWeight == Just True) + then accumValue.row3 + 1 else @@ -221,71 +255,83 @@ viewAcuteMalnutritionPane language currentDate yearSelectorGap monthsGap childre valuesByRow = List.foldl (\record accum -> - let - stuntingSevereAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.stunting.severe + List.indexedMap + (\index accumValue -> + Dict.get index monthsGap + |> Maybe.map + (\gapInMonths -> + let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate - stuntingModerateAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.stunting.moderate + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT - stuntingNormalAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.stunting.normal + stuntingSevereAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.severe - underweightSevereAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.underweight.severe + stuntingModerateAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.moderate - underweightModerateAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.underweight.moderate + stuntingNormalAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.normal - underweightNormalAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.underweight.normal + underweightSevereAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.underweight.severe - wastingSevereAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.wasting.severe + underweightModerateAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.underweight.moderate - wastingModerateAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.wasting.moderate + underweightNormalAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.underweight.normal - wastingNormalAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.wasting.normal + wastingSevereAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.wasting.severe - muacSevereAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.muac.severe + wastingModerateAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.wasting.moderate - muacModerateAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.muac.moderate + wastingNormalAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.wasting.normal + + muacSevereAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.muac.severe + + muacModerateAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.muac.moderate + + muacNormalAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.muac.normal - muacNormalAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.muac.normal - in - List.indexedMap - (\index accumValue -> - Dict.get index monthsGap - |> Maybe.map - (\gapInMonths -> - let ( row1, row2, row3 ) = if - List.member gapInMonths stuntingSevereAsAgeInMonths - || List.member gapInMonths underweightSevereAsAgeInMonths - || List.member gapInMonths wastingSevereAsAgeInMonths - || List.member gapInMonths muacSevereAsAgeInMonths + existedDuringExaminationMonth + && (List.member gapInMonths stuntingSevereAsAgeInMonths + || List.member gapInMonths underweightSevereAsAgeInMonths + || List.member gapInMonths wastingSevereAsAgeInMonths + || List.member gapInMonths muacSevereAsAgeInMonths + ) then ( accumValue.row1 + 1, accumValue.row2, accumValue.row3 ) else if - List.member gapInMonths stuntingModerateAsAgeInMonths - || List.member gapInMonths underweightModerateAsAgeInMonths - || List.member gapInMonths wastingModerateAsAgeInMonths - || List.member gapInMonths muacModerateAsAgeInMonths + existedDuringExaminationMonth + && (List.member gapInMonths stuntingModerateAsAgeInMonths + || List.member gapInMonths underweightModerateAsAgeInMonths + || List.member gapInMonths wastingModerateAsAgeInMonths + || List.member gapInMonths muacModerateAsAgeInMonths + ) then ( accumValue.row1, accumValue.row2 + 1, accumValue.row3 ) else if - List.member gapInMonths stuntingNormalAsAgeInMonths - || List.member gapInMonths underweightNormalAsAgeInMonths - || List.member gapInMonths wastingNormalAsAgeInMonths - || List.member gapInMonths muacNormalAsAgeInMonths + existedDuringExaminationMonth + && (List.member gapInMonths stuntingNormalAsAgeInMonths + || List.member gapInMonths underweightNormalAsAgeInMonths + || List.member gapInMonths wastingNormalAsAgeInMonths + || List.member gapInMonths muacNormalAsAgeInMonths + ) then ( accumValue.row1, accumValue.row2, accumValue.row3 + 1 ) @@ -336,38 +382,53 @@ viewStuntingPane language currentDate yearSelectorGap monthsGap childrenUnder2 v valuesByRow = List.foldl (\record accum -> - let - severeAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.stunting.severe - - moderateAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.stunting.moderate - - normalAsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.nutrition.stunting.normal - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + + severeAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.severe + + moderateAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.moderate + + normalAsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.normal + row1 = - if List.member gapInMonths severeAsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths severeAsAgeInMonths + then accumValue.row1 + 1 else accumValue.row1 row2 = - if List.member gapInMonths moderateAsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths moderateAsAgeInMonths + then accumValue.row2 + 1 else accumValue.row2 row3 = - if List.member gapInMonths normalAsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths normalAsAgeInMonths + then accumValue.row3 + 1 else @@ -417,33 +478,46 @@ viewANCNewbornPane language currentDate yearSelectorGap monthsGap childrenUnder2 valuesByRow = List.foldl (\record accum -> - let - ageInMonths = - -- Using EDD date to properly resolve the month of - -- prgnancy (as child may have been borm premature). - diffMonths record.eddDate currentDate - - row1AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.ancNewborn.row1 - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + + ageInMonths = + -- Using EDD date to properly resolve the month of + -- prgnancy (as child may have been borm premature). + diffMonths record.eddDate targetDateForMonth + + row1AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.ancNewborn.row1 + gap = gapInMonths - ageInMonths row1 = - if List.member gapInMonths row1AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row1AsAgeInMonths + then accumValue.row1 + 1 else accumValue.row1 row2 = - if record.ncda.ancNewborn.row2 && gap > 0 && gap < 10 then + if + existedDuringExaminationMonth + && (record.ncda.ancNewborn.row2 && gap > 0) + && (gap < 10) + then accumValue.row2 + 1 else @@ -491,33 +565,43 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa valuesByRow = List.foldl (\record accum -> - let - ageInMonths = - diffMonths record.birthDate currentDate - - row2AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.universalIntervention.row2 - - row3AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.universalIntervention.row3 - - row4AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.universalIntervention.row4 - - row5AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.universalIntervention.row5 - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + + ageInMonths = + diffMonths record.birthDate targetDateForMonth + ageInMonthsForIndexCell = ageInMonths - gapInMonths + row2AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row2 + + row3AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row3 + + row4AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row4 + + row5AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row5 + row1 = - if (ageInMonthsForIndexCell < 0) || (ageInMonthsForIndexCell >= 24) then + if + not existedDuringExaminationMonth + || (ageInMonthsForIndexCell < 0) + || (ageInMonthsForIndexCell >= 24) + then accumValue.row1 else @@ -570,7 +654,10 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row2AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row2AsAgeInMonths + then accumValue.row2 + 1 else @@ -581,7 +668,10 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row3AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row3AsAgeInMonths + then accumValue.row3 + 1 else @@ -592,7 +682,10 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row4AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row4AsAgeInMonths + then accumValue.row4 + 1 else @@ -603,7 +696,10 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row5AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row5AsAgeInMonths + then accumValue.row5 + 1 else @@ -668,51 +764,71 @@ viewNutritionBehaviorPane language currentDate yearSelectorGap monthsGap childre valuesByRow = List.foldl (\record accum -> - let - ageInMonths = - diffMonths record.birthDate currentDate - - row2AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.nutritionBehavior.row2 - - row3AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.nutritionBehavior.row3 - - row4AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.nutritionBehavior.row4 - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + + ageInMonths = + diffMonths record.birthDate targetDateForMonth + + row2AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.nutritionBehavior.row2 + + row3AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.nutritionBehavior.row3 + + row4AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.nutritionBehavior.row4 + gap = ageInMonths - gapInMonths row1 = - if gap >= 0 && gap < 6 && record.ncda.nutritionBehavior.row1 then + if + existedDuringExaminationMonth + && (gap >= 0) + && (gap < 6) + && record.ncda.nutritionBehavior.row1 + then accumValue.row1 + 1 else accumValue.row1 row2 = - if List.member gapInMonths row2AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row2AsAgeInMonths + then accumValue.row2 + 1 else accumValue.row2 row3 = - if List.member gapInMonths row3AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row3AsAgeInMonths + then accumValue.row3 + 1 else accumValue.row3 row4 = - if List.member gapInMonths row4AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row4AsAgeInMonths + then accumValue.row4 + 1 else @@ -770,34 +886,40 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi valuesByRow = List.foldl (\record accum -> - let - ageInMonths = - diffMonths record.birthDate currentDate - - row1AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.targetedInterventions.row1 - - row2AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.targetedInterventions.row2 - - row3AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.targetedInterventions.row3 - - row4AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.targetedInterventions.row4 - - row5AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.targetedInterventions.row5 - - row6AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.targetedInterventions.row6 - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + + ageInMonths = + diffMonths record.birthDate targetDateForMonth + + row1AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row1 + + row2AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row2 + + row3AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row3 + + row4AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row4 + + row5AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row5 + + row6AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row6 + gap = ageInMonths - gapInMonths @@ -806,7 +928,10 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi -- children age is up until 2 years old. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row1AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row1AsAgeInMonths + then accumValue.row1 + 1 else @@ -815,7 +940,12 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi row2 = -- Manutrition treatment can be given to children older that 2 years, therefore, -- we must verify that at given month, child age is between 0 and 24 months. - if List.member gapInMonths row2AsAgeInMonths && gap >= 0 && gap < 24 then + if + existedDuringExaminationMonth + && List.member gapInMonths row2AsAgeInMonths + && (gap >= 0) + && (gap < 24) + then accumValue.row2 + 1 else @@ -824,7 +954,12 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi row3 = -- Diarrhea treatment can be given to children older that 2 years, therefore, -- we must verify that at given month, child age is between 0 and 24 months. - if List.member gapInMonths row3AsAgeInMonths && gap >= 0 && gap < 24 then + if + existedDuringExaminationMonth + && List.member gapInMonths row3AsAgeInMonths + && (gap >= 0) + && (gap < 24) + then accumValue.row3 + 1 else @@ -835,7 +970,10 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row4AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row4AsAgeInMonths + then accumValue.row4 + 1 else @@ -846,7 +984,10 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row5AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row5AsAgeInMonths + then accumValue.row5 + 1 else @@ -857,7 +998,10 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi -- reaches age of 2 years. -- NCDA data is also for childern that up until 2 years old, so -- no need to check child age for given month. - if List.member gapInMonths row6AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row6AsAgeInMonths + then accumValue.row6 + 1 else @@ -913,44 +1057,59 @@ viewInfrastructureEnvironmentWashPane language currentDate yearSelectorGap month valuesByRow = List.foldl (\record accum -> - let - ageInMonths = - diffMonths record.birthDate currentDate - - row1AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.infrastructureEnvironmentWash.row1 - - row2AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.infrastructureEnvironmentWash.row2 - - row3AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.infrastructureEnvironmentWash.row3 - - row5AsAgeInMonths = - List.map (\date -> diffMonths date currentDate) record.ncda.infrastructureEnvironmentWash.row5 - in List.indexedMap (\index accumValue -> Dict.get index monthsGap |> Maybe.map (\gapInMonths -> let + targetDateForMonth = + resolveTargetDateForMonth gapInMonths currentDate + + existedDuringExaminationMonth = + -- Making sure patient was already created during examination month. + Date.compare record.created targetDateForMonth == LT + + ageInMonths = + diffMonths record.birthDate targetDateForMonth + + row1AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row1 + + row2AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row2 + + row3AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row3 + + row5AsAgeInMonths = + List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row5 + row1 = - if List.member gapInMonths row1AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row1AsAgeInMonths + then accumValue.row1 + 1 else accumValue.row1 row2 = - if List.member gapInMonths row2AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row2AsAgeInMonths + then accumValue.row2 + 1 else accumValue.row2 row3 = - if List.member gapInMonths row3AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row3AsAgeInMonths + then accumValue.row3 + 1 else @@ -961,14 +1120,22 @@ viewInfrastructureEnvironmentWashPane language currentDate yearSelectorGap month gap = ageInMonths - gapInMonths in - if record.ncda.infrastructureEnvironmentWash.row4 && gap >= 0 && gap < 24 then + if + existedDuringExaminationMonth + && record.ncda.infrastructureEnvironmentWash.row4 + && (gap >= 0) + && (gap < 24) + then accumValue.row4 + 1 else accumValue.row4 row5 = - if List.member gapInMonths row5AsAgeInMonths then + if + existedDuringExaminationMonth + && List.member gapInMonths row5AsAgeInMonths + then accumValue.row5 + 1 else diff --git a/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module b/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module index 755b96c35b..801b8f663b 100644 --- a/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module +++ b/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module @@ -398,7 +398,11 @@ function hedley_ncda_generate_results_data($province, $district, $sector, $cell, continue; } - $data[] = json_decode($json_data); + $decoded = json_decode($json_data); + $decoded->id = $node->nid; + $decoded->created = date("Y-m-d", $node->created); + + $data[] = $decoded; } $nid = end($ids); diff --git a/server/hedley/modules/custom/hedley_ncda/js/elm-main.js b/server/hedley/modules/custom/hedley_ncda/js/elm-main.js index 323a973cb4..1763694ef9 100644 --- a/server/hedley/modules/custom/hedley_ncda/js/elm-main.js +++ b/server/hedley/modules/custom/hedley_ncda/js/elm-main.js @@ -5825,11 +5825,31 @@ var $author$project$Backend$Scoreboard$Model$ScoreboardData = F4( function (site, entityName, entityType, records) { return {entityName: entityName, entityType: entityType, records: records, site: site}; }); -var $author$project$Backend$Scoreboard$Model$PatientData = F5( - function (birthDate, eddDate, lowBirthWeight, nutrition, ncda) { - return {birthDate: birthDate, eddDate: eddDate, lowBirthWeight: lowBirthWeight, ncda: ncda, nutrition: nutrition}; +var $author$project$Backend$Scoreboard$Model$PatientData = F7( + function (id, created, birthDate, eddDate, lowBirthWeight, nutrition, ncda) { + return {birthDate: birthDate, created: created, eddDate: eddDate, id: id, lowBirthWeight: lowBirthWeight, ncda: ncda, nutrition: nutrition}; }); var $elm$json$Json$Decode$bool = _Json_decodeBool; +var $elm$json$Json$Decode$fail = _Json_fail; +var $elm$json$Json$Decode$int = _Json_decodeInt; +var $elm$json$Json$Decode$oneOf = _Json_oneOf; +var $author$project$Gizra$Json$decodeInt = $elm$json$Json$Decode$oneOf( + _List_fromArray( + [ + $elm$json$Json$Decode$int, + A2( + $elm$json$Json$Decode$andThen, + function (s) { + var _v0 = $elm$core$String$toInt(s); + if (_v0.$ === 'Just') { + var value = _v0.a; + return $elm$json$Json$Decode$succeed(value); + } else { + return $elm$json$Json$Decode$fail('Not an integer'); + } + }, + $elm$json$Json$Decode$string) + ])); var $author$project$Backend$Scoreboard$Model$NCDAData = F5( function (ancNewborn, universalIntervention, nutritionBehavior, targetedInterventions, infrastructureEnvironmentWash) { return {ancNewborn: ancNewborn, infrastructureEnvironmentWash: infrastructureEnvironmentWash, nutritionBehavior: nutritionBehavior, targetedInterventions: targetedInterventions, universalIntervention: universalIntervention}; @@ -6651,7 +6671,6 @@ var $justinmimbs$date$Date$fromIsoString = A2( $elm$core$Basics$composeR, $elm$core$Maybe$map($justinmimbs$date$Date$deadEndToString), $elm$core$Maybe$withDefault(''))))); -var $elm$json$Json$Decode$fail = _Json_fail; var $elm_community$json_extra$Json$Decode$Extra$fromResult = function (result) { if (result.$ === 'Ok') { var successValue = result.a; @@ -6854,7 +6873,6 @@ var $author$project$Backend$Scoreboard$Decoder$decodeMonthlyValues = function (c $elm$json$Json$Decode$list($author$project$Gizra$NominalDate$decodeYYYYMMDD)); }; var $elm$json$Json$Decode$null = _Json_decodeNull; -var $elm$json$Json$Decode$oneOf = _Json_oneOf; var $elm$json$Json$Decode$value = _Json_decodeValue; var $NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$optionalDecoder = F3( function (pathDecoder, valDecoder, fallback) { @@ -7427,7 +7445,15 @@ var $author$project$Backend$Scoreboard$Decoder$decodePatientData = function (cur $NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$required, 'birth_date', $author$project$Gizra$NominalDate$decodeYYYYMMDD, - $elm$json$Json$Decode$succeed($author$project$Backend$Scoreboard$Model$PatientData)))))); + A3( + $NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$required, + 'created', + $author$project$Gizra$NominalDate$decodeYYYYMMDD, + A3( + $NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$required, + 'id', + $author$project$Gizra$Json$decodeInt, + $elm$json$Json$Decode$succeed($author$project$Backend$Scoreboard$Model$PatientData)))))))); }; var $author$project$Backend$Scoreboard$Model$EntityCell = {$: 'EntityCell'}; var $author$project$Backend$Scoreboard$Model$EntityDistrict = {$: 'EntityDistrict'}; @@ -28110,6 +28136,142 @@ var $elm$core$List$repeat = F2( function (n, value) { return A3($elm$core$List$repeatHelp, _List_Nil, n, value); }); +var $elm$core$Basics$min = F2( + function (x, y) { + return (_Utils_cmp(x, y) < 0) ? x : y; + }); +var $justinmimbs$date$Date$add = F3( + function (unit, n, _v0) { + var rd = _v0.a; + switch (unit.$) { + case 'Years': + return A3( + $justinmimbs$date$Date$add, + $justinmimbs$date$Date$Months, + 12 * n, + $justinmimbs$date$Date$RD(rd)); + case 'Months': + var date = $justinmimbs$date$Date$toCalendarDate( + $justinmimbs$date$Date$RD(rd)); + var wholeMonths = ((12 * (date.year - 1)) + ($justinmimbs$date$Date$monthToNumber(date.month) - 1)) + n; + var m = $justinmimbs$date$Date$numberToMonth( + A2($elm$core$Basics$modBy, 12, wholeMonths) + 1); + var y = A2($justinmimbs$date$Date$floorDiv, wholeMonths, 12) + 1; + return $justinmimbs$date$Date$RD( + ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + A2( + $elm$core$Basics$min, + date.day, + A2($justinmimbs$date$Date$daysInMonth, y, m))); + case 'Weeks': + return $justinmimbs$date$Date$RD(rd + (7 * n)); + default: + return $justinmimbs$date$Date$RD(rd + n); + } + }); +var $justinmimbs$date$Date$Days = {$: 'Days'}; +var $justinmimbs$date$Date$Month = {$: 'Month'}; +var $elm$time$Time$Fri = {$: 'Fri'}; +var $elm$time$Time$Mon = {$: 'Mon'}; +var $elm$time$Time$Sat = {$: 'Sat'}; +var $elm$time$Time$Sun = {$: 'Sun'}; +var $elm$time$Time$Thu = {$: 'Thu'}; +var $elm$time$Time$Tue = {$: 'Tue'}; +var $elm$time$Time$Wed = {$: 'Wed'}; +var $justinmimbs$date$Date$weekdayToNumber = function (wd) { + switch (wd.$) { + case 'Mon': + return 1; + case 'Tue': + return 2; + case 'Wed': + return 3; + case 'Thu': + return 4; + case 'Fri': + return 5; + case 'Sat': + return 6; + default: + return 7; + } +}; +var $justinmimbs$date$Date$daysSincePreviousWeekday = F2( + function (wd, date) { + return A2( + $elm$core$Basics$modBy, + 7, + ($justinmimbs$date$Date$weekdayNumber(date) + 7) - $justinmimbs$date$Date$weekdayToNumber(wd)); + }); +var $justinmimbs$date$Date$firstOfMonth = F2( + function (y, m) { + return $justinmimbs$date$Date$RD( + ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + 1); + }); +var $justinmimbs$date$Date$monthToQuarter = function (m) { + return (($justinmimbs$date$Date$monthToNumber(m) + 2) / 3) | 0; +}; +var $justinmimbs$date$Date$quarter = A2($elm$core$Basics$composeR, $justinmimbs$date$Date$month, $justinmimbs$date$Date$monthToQuarter); +var $justinmimbs$date$Date$quarterToMonth = function (q) { + return $justinmimbs$date$Date$numberToMonth((q * 3) - 2); +}; +var $justinmimbs$date$Date$floor = F2( + function (interval, date) { + var rd = date.a; + switch (interval.$) { + case 'Year': + return $justinmimbs$date$Date$firstOfYear( + $justinmimbs$date$Date$year(date)); + case 'Quarter': + return A2( + $justinmimbs$date$Date$firstOfMonth, + $justinmimbs$date$Date$year(date), + $justinmimbs$date$Date$quarterToMonth( + $justinmimbs$date$Date$quarter(date))); + case 'Month': + return A2( + $justinmimbs$date$Date$firstOfMonth, + $justinmimbs$date$Date$year(date), + $justinmimbs$date$Date$month(date)); + case 'Week': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Mon, date)); + case 'Monday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Mon, date)); + case 'Tuesday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Tue, date)); + case 'Wednesday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Wed, date)); + case 'Thursday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Thu, date)); + case 'Friday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Fri, date)); + case 'Saturday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Sat, date)); + case 'Sunday': + return $justinmimbs$date$Date$RD( + rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Sun, date)); + default: + return date; + } + }); +var $author$project$Gizra$NominalDate$toLastDayOfMonth = A2( + $elm$core$Basics$composeR, + $justinmimbs$date$Date$floor($justinmimbs$date$Date$Month), + A2( + $elm$core$Basics$composeR, + A2($justinmimbs$date$Date$add, $justinmimbs$date$Date$Months, 1), + A2($justinmimbs$date$Date$add, $justinmimbs$date$Date$Days, -1))); +var $author$project$Pages$Scoreboard$View$resolveTargetDateForMonth = F2( + function (gapInMonths, currentDate) { + return (!gapInMonths) ? currentDate : $author$project$Gizra$NominalDate$toLastDayOfMonth( + A3($justinmimbs$date$Date$add, $justinmimbs$date$Date$Months, (-1) * gapInMonths, currentDate)); + }); var $author$project$Translate$ANCNewborn = {$: 'ANCNewborn'}; var $author$project$Pages$Scoreboard$Model$IronDuringPregnancy = {$: 'IronDuringPregnancy'}; var $author$project$Translate$NCDAANCNewbornItemLabel = function (a) { @@ -28512,13 +28674,6 @@ var $author$project$Pages$Scoreboard$View$viewANCNewbornPane = F7( $elm$core$List$foldl, F2( function (record, accum) { - var row1AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.ancNewborn.row1); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.eddDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -28529,9 +28684,20 @@ var $author$project$Pages$Scoreboard$View$viewANCNewbornPane = F7( A2( $elm$core$Maybe$map, function (gapInMonths) { - var row1 = A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths) ? (accumValue.row1 + 1) : accumValue.row1; + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var row1AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.ancNewborn.row1); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var row1 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths)) ? (accumValue.row1 + 1) : accumValue.row1; + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.eddDate, targetDateForMonth); var gap = gapInMonths - ageInMonths; - var row2 = (record.ncda.ancNewborn.row2 && ((gap > 0) && (gap < 10))) ? (accumValue.row2 + 1) : accumValue.row2; + var row2 = (existedDuringExaminationMonth && ((record.ncda.ancNewborn.row2 && (gap > 0)) && (gap < 10))) ? (accumValue.row2 + 1) : accumValue.row2; return {row1: row1, row2: row2}; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); @@ -28608,78 +28774,6 @@ var $author$project$Pages$Scoreboard$View$viewAcuteMalnutritionPane = F7( $elm$core$List$foldl, F2( function (record, accum) { - var wastingSevereAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.wasting.severe); - var wastingNormalAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.wasting.normal); - var wastingModerateAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.wasting.moderate); - var underweightSevereAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.underweight.severe); - var underweightNormalAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.underweight.normal); - var underweightModerateAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.underweight.moderate); - var stuntingSevereAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.stunting.severe); - var stuntingNormalAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.stunting.normal); - var stuntingModerateAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.stunting.moderate); - var muacSevereAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.muac.severe); - var muacNormalAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.muac.normal); - var muacModerateAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.muac.moderate); return A2( $elm$core$List$indexedMap, F2( @@ -28690,7 +28784,83 @@ var $author$project$Pages$Scoreboard$View$viewAcuteMalnutritionPane = F7( A2( $elm$core$Maybe$map, function (gapInMonths) { - var _v0 = (A2($elm$core$List$member, gapInMonths, stuntingSevereAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, underweightSevereAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, wastingSevereAsAgeInMonths) || A2($elm$core$List$member, gapInMonths, muacSevereAsAgeInMonths)))) ? _Utils_Tuple3(accumValue.row1 + 1, accumValue.row2, accumValue.row3) : ((A2($elm$core$List$member, gapInMonths, stuntingModerateAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, underweightModerateAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, wastingModerateAsAgeInMonths) || A2($elm$core$List$member, gapInMonths, muacModerateAsAgeInMonths)))) ? _Utils_Tuple3(accumValue.row1, accumValue.row2 + 1, accumValue.row3) : ((A2($elm$core$List$member, gapInMonths, stuntingNormalAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, underweightNormalAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, wastingNormalAsAgeInMonths) || A2($elm$core$List$member, gapInMonths, muacNormalAsAgeInMonths)))) ? _Utils_Tuple3(accumValue.row1, accumValue.row2, accumValue.row3 + 1) : _Utils_Tuple3(accumValue.row1, accumValue.row2, accumValue.row3))); + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var underweightModerateAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.underweight.moderate); + var underweightNormalAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.underweight.normal); + var underweightSevereAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.underweight.severe); + var wastingModerateAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.wasting.moderate); + var wastingNormalAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.wasting.normal); + var wastingSevereAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.wasting.severe); + var stuntingSevereAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.stunting.severe); + var stuntingNormalAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.stunting.normal); + var stuntingModerateAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.stunting.moderate); + var muacSevereAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.muac.severe); + var muacNormalAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.muac.normal); + var muacModerateAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.muac.moderate); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var _v0 = (existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, stuntingSevereAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, underweightSevereAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, wastingSevereAsAgeInMonths) || A2($elm$core$List$member, gapInMonths, muacSevereAsAgeInMonths))))) ? _Utils_Tuple3(accumValue.row1 + 1, accumValue.row2, accumValue.row3) : ((existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, stuntingModerateAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, underweightModerateAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, wastingModerateAsAgeInMonths) || A2($elm$core$List$member, gapInMonths, muacModerateAsAgeInMonths))))) ? _Utils_Tuple3(accumValue.row1, accumValue.row2 + 1, accumValue.row3) : ((existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, stuntingNormalAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, underweightNormalAsAgeInMonths) || (A2($elm$core$List$member, gapInMonths, wastingNormalAsAgeInMonths) || A2($elm$core$List$member, gapInMonths, muacNormalAsAgeInMonths))))) ? _Utils_Tuple3(accumValue.row1, accumValue.row2, accumValue.row3 + 1) : _Utils_Tuple3(accumValue.row1, accumValue.row2, accumValue.row3))); var row1 = _v0.a; var row2 = _v0.b; var row3 = _v0.c; @@ -28830,7 +29000,6 @@ var $author$project$Pages$Scoreboard$View$viewDemographicsPane = F7( $elm$core$List$foldl, F2( function (record, accum) { - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -28841,11 +29010,16 @@ var $author$project$Pages$Scoreboard$View$viewDemographicsPane = F7( A2( $elm$core$Maybe$map, function (gapInMonths) { + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); var gap = ageInMonths - gapInMonths; - var row2 = (!gap) ? (accumValue.row2 + 1) : accumValue.row2; - var row3 = ((!gap) && _Utils_eq( + var row2 = (existedDuringExaminationMonth && (!gap)) ? (accumValue.row2 + 1) : accumValue.row2; + var row3 = (existedDuringExaminationMonth && ((!gap) && _Utils_eq( record.lowBirthWeight, - $elm$core$Maybe$Just(true))) ? (accumValue.row3 + 1) : accumValue.row3; + $elm$core$Maybe$Just(true)))) ? (accumValue.row3 + 1) : accumValue.row3; return {row2: row2, row3: row3}; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); @@ -28940,31 +29114,6 @@ var $author$project$Pages$Scoreboard$View$viewInfrastructureEnvironmentWashPane $elm$core$List$foldl, F2( function (record, accum) { - var row5AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.infrastructureEnvironmentWash.row5); - var row3AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.infrastructureEnvironmentWash.row3); - var row2AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.infrastructureEnvironmentWash.row2); - var row1AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.infrastructureEnvironmentWash.row1); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -28975,14 +29124,43 @@ var $author$project$Pages$Scoreboard$View$viewInfrastructureEnvironmentWashPane A2( $elm$core$Maybe$map, function (gapInMonths) { - var row5 = A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths) ? (accumValue.row5 + 1) : accumValue.row5; + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var row5AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.infrastructureEnvironmentWash.row5); + var row3AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.infrastructureEnvironmentWash.row3); + var row2AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.infrastructureEnvironmentWash.row2); + var row1AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.infrastructureEnvironmentWash.row1); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var row1 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths)) ? (accumValue.row1 + 1) : accumValue.row1; + var row2 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths)) ? (accumValue.row2 + 1) : accumValue.row2; + var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; + var row5 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths)) ? (accumValue.row5 + 1) : accumValue.row5; + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); var row4 = function () { var gap = ageInMonths - gapInMonths; - return (record.ncda.infrastructureEnvironmentWash.row4 && ((gap >= 0) && (gap < 24))) ? (accumValue.row4 + 1) : accumValue.row4; + return (existedDuringExaminationMonth && (record.ncda.infrastructureEnvironmentWash.row4 && ((gap >= 0) && (gap < 24)))) ? (accumValue.row4 + 1) : accumValue.row4; }(); - var row3 = A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths) ? (accumValue.row3 + 1) : accumValue.row3; - var row2 = A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths) ? (accumValue.row2 + 1) : accumValue.row2; - var row1 = A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths) ? (accumValue.row1 + 1) : accumValue.row1; return {row1: row1, row2: row2, row3: row3, row4: row4, row5: row5}; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); @@ -29078,25 +29256,6 @@ var $author$project$Pages$Scoreboard$View$viewNutritionBehaviorPane = F7( $elm$core$List$foldl, F2( function (record, accum) { - var row4AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.nutritionBehavior.row4); - var row3AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.nutritionBehavior.row3); - var row2AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.nutritionBehavior.row2); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -29107,11 +29266,34 @@ var $author$project$Pages$Scoreboard$View$viewNutritionBehaviorPane = F7( A2( $elm$core$Maybe$map, function (gapInMonths) { - var row4 = A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths) ? (accumValue.row4 + 1) : accumValue.row4; - var row3 = A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths) ? (accumValue.row3 + 1) : accumValue.row3; - var row2 = A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths) ? (accumValue.row2 + 1) : accumValue.row2; + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var row4AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.nutritionBehavior.row4); + var row3AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.nutritionBehavior.row3); + var row2AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.nutritionBehavior.row2); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var row2 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths)) ? (accumValue.row2 + 1) : accumValue.row2; + var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; + var row4 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths)) ? (accumValue.row4 + 1) : accumValue.row4; + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); var gap = ageInMonths - gapInMonths; - var row1 = ((gap >= 0) && ((gap < 6) && record.ncda.nutritionBehavior.row1)) ? (accumValue.row1 + 1) : accumValue.row1; + var row1 = (existedDuringExaminationMonth && ((gap >= 0) && ((gap < 6) && record.ncda.nutritionBehavior.row1))) ? (accumValue.row1 + 1) : accumValue.row1; return {row1: row1, row2: row2, row3: row3, row4: row4}; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); @@ -29200,24 +29382,6 @@ var $author$project$Pages$Scoreboard$View$viewStuntingPane = F7( $elm$core$List$foldl, F2( function (record, accum) { - var severeAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.stunting.severe); - var normalAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.stunting.normal); - var moderateAsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.nutrition.stunting.moderate); return A2( $elm$core$List$indexedMap, F2( @@ -29228,9 +29392,31 @@ var $author$project$Pages$Scoreboard$View$viewStuntingPane = F7( A2( $elm$core$Maybe$map, function (gapInMonths) { - var row3 = A2($elm$core$List$member, gapInMonths, normalAsAgeInMonths) ? (accumValue.row3 + 1) : accumValue.row3; - var row2 = A2($elm$core$List$member, gapInMonths, moderateAsAgeInMonths) ? (accumValue.row2 + 1) : accumValue.row2; - var row1 = A2($elm$core$List$member, gapInMonths, severeAsAgeInMonths) ? (accumValue.row1 + 1) : accumValue.row1; + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var severeAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.stunting.severe); + var normalAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.stunting.normal); + var moderateAsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.nutrition.stunting.moderate); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var row1 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, severeAsAgeInMonths)) ? (accumValue.row1 + 1) : accumValue.row1; + var row2 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, moderateAsAgeInMonths)) ? (accumValue.row2 + 1) : accumValue.row2; + var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, normalAsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; return {row1: row1, row2: row2, row3: row3}; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); @@ -29316,43 +29502,6 @@ var $author$project$Pages$Scoreboard$View$viewTargetedInterventionsPane = F7( $elm$core$List$foldl, F2( function (record, accum) { - var row6AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.targetedInterventions.row6); - var row5AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.targetedInterventions.row5); - var row4AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.targetedInterventions.row4); - var row3AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.targetedInterventions.row3); - var row2AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.targetedInterventions.row2); - var row1AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.targetedInterventions.row1); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -29363,13 +29512,54 @@ var $author$project$Pages$Scoreboard$View$viewTargetedInterventionsPane = F7( A2( $elm$core$Maybe$map, function (gapInMonths) { - var row6 = A2($elm$core$List$member, gapInMonths, row6AsAgeInMonths) ? (accumValue.row6 + 1) : accumValue.row6; - var row5 = A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths) ? (accumValue.row5 + 1) : accumValue.row5; - var row4 = A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths) ? (accumValue.row4 + 1) : accumValue.row4; - var row1 = A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths) ? (accumValue.row1 + 1) : accumValue.row1; + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var row6AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.targetedInterventions.row6); + var row5AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.targetedInterventions.row5); + var row4AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.targetedInterventions.row4); + var row3AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.targetedInterventions.row3); + var row2AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.targetedInterventions.row2); + var row1AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.targetedInterventions.row1); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var row1 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths)) ? (accumValue.row1 + 1) : accumValue.row1; + var row4 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths)) ? (accumValue.row4 + 1) : accumValue.row4; + var row5 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths)) ? (accumValue.row5 + 1) : accumValue.row5; + var row6 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row6AsAgeInMonths)) ? (accumValue.row6 + 1) : accumValue.row6; + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); var gap = ageInMonths - gapInMonths; - var row2 = (A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths) && ((gap >= 0) && (gap < 24))) ? (accumValue.row2 + 1) : accumValue.row2; - var row3 = (A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths) && ((gap >= 0) && (gap < 24))) ? (accumValue.row3 + 1) : accumValue.row3; + var row2 = (existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths) && ((gap >= 0) && (gap < 24)))) ? (accumValue.row2 + 1) : accumValue.row2; + var row3 = (existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths) && ((gap >= 0) && (gap < 24)))) ? (accumValue.row3 + 1) : accumValue.row3; return {row1: row1, row2: row2, row3: row3, row4: row4, row5: row5, row6: row6}; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); @@ -29453,139 +29643,15 @@ var $author$project$Pages$Scoreboard$View$viewTargetedInterventionsPane = F7( rows)) ])); }); -var $justinmimbs$date$Date$Days = {$: 'Days'}; var $author$project$Pages$Scoreboard$Model$Deworming = {$: 'Deworming'}; var $author$project$Pages$Scoreboard$Model$ECDServices = {$: 'ECDServices'}; var $author$project$Pages$Scoreboard$Model$Immunization = {$: 'Immunization'}; -var $justinmimbs$date$Date$Month = {$: 'Month'}; var $author$project$Translate$NCDAUniversalInterventionItemLabel = function (a) { return {$: 'NCDAUniversalInterventionItemLabel', a: a}; }; var $author$project$Pages$Scoreboard$Model$OngeraMNP = {$: 'OngeraMNP'}; var $author$project$Translate$UniversalIntervention = {$: 'UniversalIntervention'}; var $author$project$Pages$Scoreboard$Model$VitaminA = {$: 'VitaminA'}; -var $elm$core$Basics$min = F2( - function (x, y) { - return (_Utils_cmp(x, y) < 0) ? x : y; - }); -var $justinmimbs$date$Date$add = F3( - function (unit, n, _v0) { - var rd = _v0.a; - switch (unit.$) { - case 'Years': - return A3( - $justinmimbs$date$Date$add, - $justinmimbs$date$Date$Months, - 12 * n, - $justinmimbs$date$Date$RD(rd)); - case 'Months': - var date = $justinmimbs$date$Date$toCalendarDate( - $justinmimbs$date$Date$RD(rd)); - var wholeMonths = ((12 * (date.year - 1)) + ($justinmimbs$date$Date$monthToNumber(date.month) - 1)) + n; - var m = $justinmimbs$date$Date$numberToMonth( - A2($elm$core$Basics$modBy, 12, wholeMonths) + 1); - var y = A2($justinmimbs$date$Date$floorDiv, wholeMonths, 12) + 1; - return $justinmimbs$date$Date$RD( - ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + A2( - $elm$core$Basics$min, - date.day, - A2($justinmimbs$date$Date$daysInMonth, y, m))); - case 'Weeks': - return $justinmimbs$date$Date$RD(rd + (7 * n)); - default: - return $justinmimbs$date$Date$RD(rd + n); - } - }); -var $elm$time$Time$Fri = {$: 'Fri'}; -var $elm$time$Time$Mon = {$: 'Mon'}; -var $elm$time$Time$Sat = {$: 'Sat'}; -var $elm$time$Time$Sun = {$: 'Sun'}; -var $elm$time$Time$Thu = {$: 'Thu'}; -var $elm$time$Time$Tue = {$: 'Tue'}; -var $elm$time$Time$Wed = {$: 'Wed'}; -var $justinmimbs$date$Date$weekdayToNumber = function (wd) { - switch (wd.$) { - case 'Mon': - return 1; - case 'Tue': - return 2; - case 'Wed': - return 3; - case 'Thu': - return 4; - case 'Fri': - return 5; - case 'Sat': - return 6; - default: - return 7; - } -}; -var $justinmimbs$date$Date$daysSincePreviousWeekday = F2( - function (wd, date) { - return A2( - $elm$core$Basics$modBy, - 7, - ($justinmimbs$date$Date$weekdayNumber(date) + 7) - $justinmimbs$date$Date$weekdayToNumber(wd)); - }); -var $justinmimbs$date$Date$firstOfMonth = F2( - function (y, m) { - return $justinmimbs$date$Date$RD( - ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + 1); - }); -var $justinmimbs$date$Date$monthToQuarter = function (m) { - return (($justinmimbs$date$Date$monthToNumber(m) + 2) / 3) | 0; -}; -var $justinmimbs$date$Date$quarter = A2($elm$core$Basics$composeR, $justinmimbs$date$Date$month, $justinmimbs$date$Date$monthToQuarter); -var $justinmimbs$date$Date$quarterToMonth = function (q) { - return $justinmimbs$date$Date$numberToMonth((q * 3) - 2); -}; -var $justinmimbs$date$Date$floor = F2( - function (interval, date) { - var rd = date.a; - switch (interval.$) { - case 'Year': - return $justinmimbs$date$Date$firstOfYear( - $justinmimbs$date$Date$year(date)); - case 'Quarter': - return A2( - $justinmimbs$date$Date$firstOfMonth, - $justinmimbs$date$Date$year(date), - $justinmimbs$date$Date$quarterToMonth( - $justinmimbs$date$Date$quarter(date))); - case 'Month': - return A2( - $justinmimbs$date$Date$firstOfMonth, - $justinmimbs$date$Date$year(date), - $justinmimbs$date$Date$month(date)); - case 'Week': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Mon, date)); - case 'Monday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Mon, date)); - case 'Tuesday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Tue, date)); - case 'Wednesday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Wed, date)); - case 'Thursday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Thu, date)); - case 'Friday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Fri, date)); - case 'Saturday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Sat, date)); - case 'Sunday': - return $justinmimbs$date$Date$RD( - rd - A2($justinmimbs$date$Date$daysSincePreviousWeekday, $elm$time$Time$Sun, date)); - default: - return date; - } - }); var $author$project$Pages$Scoreboard$Utils$allVaccineTypes = _List_fromArray( [$author$project$Backend$Scoreboard$Model$VaccineBCG, $author$project$Backend$Scoreboard$Model$VaccineOPV, $author$project$Backend$Scoreboard$Model$VaccineDTP, $author$project$Backend$Scoreboard$Model$VaccineDTPStandalone, $author$project$Backend$Scoreboard$Model$VaccinePCV13, $author$project$Backend$Scoreboard$Model$VaccineRotarix, $author$project$Backend$Scoreboard$Model$VaccineIPV, $author$project$Backend$Scoreboard$Model$VaccineMR]); var $justinmimbs$date$Date$Weeks = {$: 'Weeks'}; @@ -29849,31 +29915,6 @@ var $author$project$Pages$Scoreboard$View$viewUniversalInterventionPane = F8( $elm$core$List$foldl, F2( function (record, accum) { - var row5AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.universalIntervention.row5); - var row4AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.universalIntervention.row4); - var row3AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.universalIntervention.row3); - var row2AsAgeInMonths = A2( - $elm$core$List$map, - function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, currentDate); - }, - record.ncda.universalIntervention.row2); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -29884,13 +29925,42 @@ var $author$project$Pages$Scoreboard$View$viewUniversalInterventionPane = F8( A2( $elm$core$Maybe$map, function (gapInMonths) { - var row5 = A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths) ? (accumValue.row5 + 1) : accumValue.row5; - var row4 = A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths) ? (accumValue.row4 + 1) : accumValue.row4; - var row3 = A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths) ? (accumValue.row3 + 1) : accumValue.row3; - var row2 = A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths) ? (accumValue.row2 + 1) : accumValue.row2; + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var row5AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.universalIntervention.row5); + var row4AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.universalIntervention.row4); + var row3AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.universalIntervention.row3); + var row2AsAgeInMonths = A2( + $elm$core$List$map, + function (date) { + return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + }, + record.ncda.universalIntervention.row2); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var row2 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths)) ? (accumValue.row2 + 1) : accumValue.row2; + var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; + var row4 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths)) ? (accumValue.row4 + 1) : accumValue.row4; + var row5 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths)) ? (accumValue.row5 + 1) : accumValue.row5; + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); var ageInMonthsForIndexCell = ageInMonths - gapInMonths; var row1 = function () { - if ((ageInMonthsForIndexCell < 0) || (ageInMonthsForIndexCell >= 24)) { + if ((!existedDuringExaminationMonth) || ((ageInMonthsForIndexCell < 0) || (ageInMonthsForIndexCell >= 24))) { return accumValue.row1; } else { var referenceDate = A2(resolveLastDayForMonthX, ageInMonthsForIndexCell, record.birthDate); @@ -30232,7 +30302,6 @@ var $author$project$Pages$Scoreboard$View$viewScoreboardData = F4( $elm$core$List$foldl, F2( function (record, accum) { - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, currentDate); return A2( $elm$core$List$indexedMap, F2( @@ -30243,8 +30312,13 @@ var $author$project$Pages$Scoreboard$View$viewScoreboardData = F4( A2( $elm$core$Maybe$map, function (gapInMonths) { + var targetDateForMonth = A2($author$project$Pages$Scoreboard$View$resolveTargetDateForMonth, gapInMonths, currentDate); + var existedDuringExaminationMonth = _Utils_eq( + A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), + $elm$core$Basics$LT); + var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); var gap = ageInMonths - gapInMonths; - return ((gap >= 0) && (gap < 24)) ? (accumValue + 1) : accumValue; + return (existedDuringExaminationMonth && ((gap >= 0) && (gap < 24))) ? (accumValue + 1) : accumValue; }, A2($pzp1997$assoc_list$AssocList$get, index, monthsGap))); }), From 092406b322a28465937ba2c30274cf5e8ad11a69 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 3 Mar 2024 15:55:43 +0200 Subject: [PATCH 2/5] Fix logic for calculation of most recent month --- server/elm/src/Pages/Scoreboard/View.elm | 198 +++++++++++++++--- .../modules/custom/hedley_ncda/js/elm-main.js | 165 ++++++++++++--- 2 files changed, 297 insertions(+), 66 deletions(-) diff --git a/server/elm/src/Pages/Scoreboard/View.elm b/server/elm/src/Pages/Scoreboard/View.elm index 71f01d3a5b..40f73debfe 100644 --- a/server/elm/src/Pages/Scoreboard/View.elm +++ b/server/elm/src/Pages/Scoreboard/View.elm @@ -269,40 +269,88 @@ viewAcuteMalnutritionPane language currentDate yearSelectorGap monthsGap childre Date.compare record.created targetDateForMonth == LT stuntingSevereAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.severe + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.stunting.severe stuntingModerateAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.moderate + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.stunting.moderate stuntingNormalAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.normal + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.stunting.normal underweightSevereAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.underweight.severe + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.underweight.severe underweightModerateAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.underweight.moderate + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.underweight.moderate underweightNormalAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.underweight.normal + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.underweight.normal wastingSevereAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.wasting.severe + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.wasting.severe wastingModerateAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.wasting.moderate + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.wasting.moderate wastingNormalAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.wasting.normal + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.wasting.normal muacSevereAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.muac.severe + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.muac.severe muacModerateAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.muac.moderate + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.muac.moderate muacNormalAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.muac.normal + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.muac.normal ( row1, row2, row3 ) = if @@ -396,13 +444,25 @@ viewStuntingPane language currentDate yearSelectorGap monthsGap childrenUnder2 v Date.compare record.created targetDateForMonth == LT severeAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.severe + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.stunting.severe moderateAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.moderate + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.stunting.moderate normalAsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.nutrition.stunting.normal + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.nutrition.stunting.normal row1 = if @@ -497,7 +557,11 @@ viewANCNewbornPane language currentDate yearSelectorGap monthsGap childrenUnder2 diffMonths record.eddDate targetDateForMonth row1AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.ancNewborn.row1 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.ancNewborn.row1 gap = gapInMonths - ageInMonths @@ -585,16 +649,32 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa ageInMonths - gapInMonths row2AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row2 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.universalIntervention.row2 row3AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row3 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.universalIntervention.row3 row4AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row4 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.universalIntervention.row4 row5AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.universalIntervention.row5 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.universalIntervention.row5 row1 = if @@ -781,13 +861,25 @@ viewNutritionBehaviorPane language currentDate yearSelectorGap monthsGap childre diffMonths record.birthDate targetDateForMonth row2AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.nutritionBehavior.row2 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.nutritionBehavior.row2 row3AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.nutritionBehavior.row3 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.nutritionBehavior.row3 row4AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.nutritionBehavior.row4 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.nutritionBehavior.row4 gap = ageInMonths - gapInMonths @@ -903,22 +995,46 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi diffMonths record.birthDate targetDateForMonth row1AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row1 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.targetedInterventions.row1 row2AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row2 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.targetedInterventions.row2 row3AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row3 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.targetedInterventions.row3 row4AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row4 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.targetedInterventions.row4 row5AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row5 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.targetedInterventions.row5 row6AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.targetedInterventions.row6 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.targetedInterventions.row6 gap = ageInMonths - gapInMonths @@ -1074,16 +1190,32 @@ viewInfrastructureEnvironmentWashPane language currentDate yearSelectorGap month diffMonths record.birthDate targetDateForMonth row1AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row1 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.infrastructureEnvironmentWash.row1 row2AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row2 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.infrastructureEnvironmentWash.row2 row3AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row3 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.infrastructureEnvironmentWash.row3 row5AsAgeInMonths = - List.map (\date -> diffMonths date targetDateForMonth) record.ncda.infrastructureEnvironmentWash.row5 + List.map + (\date -> + diffMonths (Date.floor Month date) targetDateForMonth + ) + record.ncda.infrastructureEnvironmentWash.row5 row1 = if diff --git a/server/hedley/modules/custom/hedley_ncda/js/elm-main.js b/server/hedley/modules/custom/hedley_ncda/js/elm-main.js index 1763694ef9..9b87b52a2f 100644 --- a/server/hedley/modules/custom/hedley_ncda/js/elm-main.js +++ b/server/hedley/modules/custom/hedley_ncda/js/elm-main.js @@ -28688,7 +28688,10 @@ var $author$project$Pages$Scoreboard$View$viewANCNewbornPane = F7( var row1AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.ancNewborn.row1); var existedDuringExaminationMonth = _Utils_eq( @@ -28788,73 +28791,109 @@ var $author$project$Pages$Scoreboard$View$viewAcuteMalnutritionPane = F7( var underweightModerateAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.underweight.moderate); var underweightNormalAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.underweight.normal); var underweightSevereAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.underweight.severe); var wastingModerateAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.wasting.moderate); var wastingNormalAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.wasting.normal); var wastingSevereAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.wasting.severe); var stuntingSevereAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.stunting.severe); var stuntingNormalAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.stunting.normal); var stuntingModerateAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.stunting.moderate); var muacSevereAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.muac.severe); var muacNormalAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.muac.normal); var muacModerateAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.muac.moderate); var existedDuringExaminationMonth = _Utils_eq( @@ -29128,25 +29167,37 @@ var $author$project$Pages$Scoreboard$View$viewInfrastructureEnvironmentWashPane var row5AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.infrastructureEnvironmentWash.row5); var row3AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.infrastructureEnvironmentWash.row3); var row2AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.infrastructureEnvironmentWash.row2); var row1AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.infrastructureEnvironmentWash.row1); var existedDuringExaminationMonth = _Utils_eq( @@ -29270,19 +29321,28 @@ var $author$project$Pages$Scoreboard$View$viewNutritionBehaviorPane = F7( var row4AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.nutritionBehavior.row4); var row3AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.nutritionBehavior.row3); var row2AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.nutritionBehavior.row2); var existedDuringExaminationMonth = _Utils_eq( @@ -29396,19 +29456,28 @@ var $author$project$Pages$Scoreboard$View$viewStuntingPane = F7( var severeAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.stunting.severe); var normalAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.stunting.normal); var moderateAsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.nutrition.stunting.moderate); var existedDuringExaminationMonth = _Utils_eq( @@ -29516,37 +29585,55 @@ var $author$project$Pages$Scoreboard$View$viewTargetedInterventionsPane = F7( var row6AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.targetedInterventions.row6); var row5AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.targetedInterventions.row5); var row4AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.targetedInterventions.row4); var row3AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.targetedInterventions.row3); var row2AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.targetedInterventions.row2); var row1AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.targetedInterventions.row1); var existedDuringExaminationMonth = _Utils_eq( @@ -29929,25 +30016,37 @@ var $author$project$Pages$Scoreboard$View$viewUniversalInterventionPane = F8( var row5AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.universalIntervention.row5); var row4AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.universalIntervention.row4); var row3AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.universalIntervention.row3); var row2AsAgeInMonths = A2( $elm$core$List$map, function (date) { - return A2($author$project$Gizra$NominalDate$diffMonths, date, targetDateForMonth); + return A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, date), + targetDateForMonth); }, record.ncda.universalIntervention.row2); var existedDuringExaminationMonth = _Utils_eq( From 5a55493e2fa92638073642afe169f03b2ee81918 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 3 Mar 2024 16:05:10 +0200 Subject: [PATCH 3/5] Update elm-format version --- ci-scripts/install_elm_format.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-scripts/install_elm_format.sh b/ci-scripts/install_elm_format.sh index 1ba143299f..27d9edc1e5 100755 --- a/ci-scripts/install_elm_format.sh +++ b/ci-scripts/install_elm_format.sh @@ -7,6 +7,6 @@ set -e # # ---------------------------------------------------------------------------- # -wget https://github.com/avh4/elm-format/releases/download/0.8.5/elm-format-0.8.5-linux-x64.tgz -tar xfz elm-format-0.8.5-linux-x64.tgz +wget https://github.com/avh4/elm-format/releases/download/0.8.7/elm-format-0.8.7-linux-x64.tgz +tar xfz elm-format-0.8.7-linux-x64.tgz sudo mv elm-format /usr/bin/ From d4151acabfa1df18823f2838fc19e75d9db97d1c Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 3 Mar 2024 17:05:35 +0200 Subject: [PATCH 4/5] More fixes --- server/elm/src/Pages/Scoreboard/View.elm | 14 +- .../modules/custom/hedley_ncda/js/elm-main.js | 187 ++++++++++-------- 2 files changed, 111 insertions(+), 90 deletions(-) diff --git a/server/elm/src/Pages/Scoreboard/View.elm b/server/elm/src/Pages/Scoreboard/View.elm index 40f73debfe..9742360822 100644 --- a/server/elm/src/Pages/Scoreboard/View.elm +++ b/server/elm/src/Pages/Scoreboard/View.elm @@ -78,7 +78,7 @@ viewScoreboardData language currentDate data model = resolveTargetDateForMonth gapInMonths currentDate ageInMonths = - diffMonths record.birthDate targetDateForMonth + diffMonths (Date.floor Month record.birthDate) targetDateForMonth gap = ageInMonths - gapInMonths @@ -169,7 +169,7 @@ viewDemographicsPane language currentDate yearSelectorGap monthsGap childrenUnde resolveTargetDateForMonth gapInMonths currentDate ageInMonths = - diffMonths record.birthDate targetDateForMonth + diffMonths (Date.floor Month record.birthDate) targetDateForMonth existedDuringExaminationMonth = -- Making sure patient was already created during examination month. @@ -554,7 +554,7 @@ viewANCNewbornPane language currentDate yearSelectorGap monthsGap childrenUnder2 ageInMonths = -- Using EDD date to properly resolve the month of -- prgnancy (as child may have been borm premature). - diffMonths record.eddDate targetDateForMonth + diffMonths (Date.floor Month record.eddDate) targetDateForMonth row1AsAgeInMonths = List.map @@ -643,7 +643,7 @@ viewUniversalInterventionPane language currentDate site yearSelectorGap monthsGa Date.compare record.created targetDateForMonth == LT ageInMonths = - diffMonths record.birthDate targetDateForMonth + diffMonths (Date.floor Month record.birthDate) targetDateForMonth ageInMonthsForIndexCell = ageInMonths - gapInMonths @@ -858,7 +858,7 @@ viewNutritionBehaviorPane language currentDate yearSelectorGap monthsGap childre Date.compare record.created targetDateForMonth == LT ageInMonths = - diffMonths record.birthDate targetDateForMonth + diffMonths (Date.floor Month record.birthDate) targetDateForMonth row2AsAgeInMonths = List.map @@ -992,7 +992,7 @@ viewTargetedInterventionsPane language currentDate yearSelectorGap monthsGap chi Date.compare record.created targetDateForMonth == LT ageInMonths = - diffMonths record.birthDate targetDateForMonth + diffMonths (Date.floor Month record.birthDate) targetDateForMonth row1AsAgeInMonths = List.map @@ -1187,7 +1187,7 @@ viewInfrastructureEnvironmentWashPane language currentDate yearSelectorGap month Date.compare record.created targetDateForMonth == LT ageInMonths = - diffMonths record.birthDate targetDateForMonth + diffMonths (Date.floor Month record.birthDate) targetDateForMonth row1AsAgeInMonths = List.map diff --git a/server/hedley/modules/custom/hedley_ncda/js/elm-main.js b/server/hedley/modules/custom/hedley_ncda/js/elm-main.js index 9b87b52a2f..08480cc3d4 100644 --- a/server/hedley/modules/custom/hedley_ncda/js/elm-main.js +++ b/server/hedley/modules/custom/hedley_ncda/js/elm-main.js @@ -28090,86 +28090,11 @@ var $author$project$Pages$Scoreboard$Model$ChaneYearGap = function (a) { return {$: 'ChaneYearGap', a: a}; }; var $author$project$Pages$Scoreboard$Model$ModePercentages = {$: 'ModePercentages'}; +var $justinmimbs$date$Date$Month = {$: 'Month'}; var $author$project$Translate$NewSelection = {$: 'NewSelection'}; var $author$project$Pages$Scoreboard$Model$SetViewMode = function (a) { return {$: 'SetViewMode', a: a}; }; -var $justinmimbs$date$Date$month = A2( - $elm$core$Basics$composeR, - $justinmimbs$date$Date$toCalendarDate, - function ($) { - return $.month; - }); -var $justinmimbs$date$Date$monthNumber = A2($elm$core$Basics$composeR, $justinmimbs$date$Date$month, $justinmimbs$date$Date$monthToNumber); -var $author$project$Pages$Scoreboard$View$generateMonthsGap = F2( - function (currentDate, yearSelectorGap) { - var currentMonthNumber = $justinmimbs$date$Date$monthNumber(currentDate); - return $pzp1997$assoc_list$AssocList$fromList( - A2( - $elm$core$List$indexedMap, - $elm$core$Tuple$pair, - A2( - $elm$core$List$map, - function (monthNumber) { - return (((-1) * 12) * yearSelectorGap) + ((-1) * (monthNumber - currentMonthNumber)); - }, - A2($elm$core$List$range, 1, 12)))); - }); -var $elm$core$List$repeatHelp = F3( - function (result, n, value) { - repeatHelp: - while (true) { - if (n <= 0) { - return result; - } else { - var $temp$result = A2($elm$core$List$cons, value, result), - $temp$n = n - 1, - $temp$value = value; - result = $temp$result; - n = $temp$n; - value = $temp$value; - continue repeatHelp; - } - } - }); -var $elm$core$List$repeat = F2( - function (n, value) { - return A3($elm$core$List$repeatHelp, _List_Nil, n, value); - }); -var $elm$core$Basics$min = F2( - function (x, y) { - return (_Utils_cmp(x, y) < 0) ? x : y; - }); -var $justinmimbs$date$Date$add = F3( - function (unit, n, _v0) { - var rd = _v0.a; - switch (unit.$) { - case 'Years': - return A3( - $justinmimbs$date$Date$add, - $justinmimbs$date$Date$Months, - 12 * n, - $justinmimbs$date$Date$RD(rd)); - case 'Months': - var date = $justinmimbs$date$Date$toCalendarDate( - $justinmimbs$date$Date$RD(rd)); - var wholeMonths = ((12 * (date.year - 1)) + ($justinmimbs$date$Date$monthToNumber(date.month) - 1)) + n; - var m = $justinmimbs$date$Date$numberToMonth( - A2($elm$core$Basics$modBy, 12, wholeMonths) + 1); - var y = A2($justinmimbs$date$Date$floorDiv, wholeMonths, 12) + 1; - return $justinmimbs$date$Date$RD( - ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + A2( - $elm$core$Basics$min, - date.day, - A2($justinmimbs$date$Date$daysInMonth, y, m))); - case 'Weeks': - return $justinmimbs$date$Date$RD(rd + (7 * n)); - default: - return $justinmimbs$date$Date$RD(rd + n); - } - }); -var $justinmimbs$date$Date$Days = {$: 'Days'}; -var $justinmimbs$date$Date$Month = {$: 'Month'}; var $elm$time$Time$Fri = {$: 'Fri'}; var $elm$time$Time$Mon = {$: 'Mon'}; var $elm$time$Time$Sat = {$: 'Sat'}; @@ -28207,6 +28132,12 @@ var $justinmimbs$date$Date$firstOfMonth = F2( return $justinmimbs$date$Date$RD( ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + 1); }); +var $justinmimbs$date$Date$month = A2( + $elm$core$Basics$composeR, + $justinmimbs$date$Date$toCalendarDate, + function ($) { + return $.month; + }); var $justinmimbs$date$Date$monthToQuarter = function (m) { return (($justinmimbs$date$Date$monthToNumber(m) + 2) / 3) | 0; }; @@ -28260,6 +28191,75 @@ var $justinmimbs$date$Date$floor = F2( return date; } }); +var $justinmimbs$date$Date$monthNumber = A2($elm$core$Basics$composeR, $justinmimbs$date$Date$month, $justinmimbs$date$Date$monthToNumber); +var $author$project$Pages$Scoreboard$View$generateMonthsGap = F2( + function (currentDate, yearSelectorGap) { + var currentMonthNumber = $justinmimbs$date$Date$monthNumber(currentDate); + return $pzp1997$assoc_list$AssocList$fromList( + A2( + $elm$core$List$indexedMap, + $elm$core$Tuple$pair, + A2( + $elm$core$List$map, + function (monthNumber) { + return (((-1) * 12) * yearSelectorGap) + ((-1) * (monthNumber - currentMonthNumber)); + }, + A2($elm$core$List$range, 1, 12)))); + }); +var $elm$core$List$repeatHelp = F3( + function (result, n, value) { + repeatHelp: + while (true) { + if (n <= 0) { + return result; + } else { + var $temp$result = A2($elm$core$List$cons, value, result), + $temp$n = n - 1, + $temp$value = value; + result = $temp$result; + n = $temp$n; + value = $temp$value; + continue repeatHelp; + } + } + }); +var $elm$core$List$repeat = F2( + function (n, value) { + return A3($elm$core$List$repeatHelp, _List_Nil, n, value); + }); +var $elm$core$Basics$min = F2( + function (x, y) { + return (_Utils_cmp(x, y) < 0) ? x : y; + }); +var $justinmimbs$date$Date$add = F3( + function (unit, n, _v0) { + var rd = _v0.a; + switch (unit.$) { + case 'Years': + return A3( + $justinmimbs$date$Date$add, + $justinmimbs$date$Date$Months, + 12 * n, + $justinmimbs$date$Date$RD(rd)); + case 'Months': + var date = $justinmimbs$date$Date$toCalendarDate( + $justinmimbs$date$Date$RD(rd)); + var wholeMonths = ((12 * (date.year - 1)) + ($justinmimbs$date$Date$monthToNumber(date.month) - 1)) + n; + var m = $justinmimbs$date$Date$numberToMonth( + A2($elm$core$Basics$modBy, 12, wholeMonths) + 1); + var y = A2($justinmimbs$date$Date$floorDiv, wholeMonths, 12) + 1; + return $justinmimbs$date$Date$RD( + ($justinmimbs$date$Date$daysBeforeYear(y) + A2($justinmimbs$date$Date$daysBeforeMonth, y, m)) + A2( + $elm$core$Basics$min, + date.day, + A2($justinmimbs$date$Date$daysInMonth, y, m))); + case 'Weeks': + return $justinmimbs$date$Date$RD(rd + (7 * n)); + default: + return $justinmimbs$date$Date$RD(rd + n); + } + }); +var $justinmimbs$date$Date$Days = {$: 'Days'}; var $author$project$Gizra$NominalDate$toLastDayOfMonth = A2( $elm$core$Basics$composeR, $justinmimbs$date$Date$floor($justinmimbs$date$Date$Month), @@ -28698,7 +28698,10 @@ var $author$project$Pages$Scoreboard$View$viewANCNewbornPane = F7( A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), $elm$core$Basics$LT); var row1 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row1AsAgeInMonths)) ? (accumValue.row1 + 1) : accumValue.row1; - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.eddDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.eddDate), + targetDateForMonth); var gap = gapInMonths - ageInMonths; var row2 = (existedDuringExaminationMonth && ((record.ncda.ancNewborn.row2 && (gap > 0)) && (gap < 10))) ? (accumValue.row2 + 1) : accumValue.row2; return {row1: row1, row2: row2}; @@ -29053,7 +29056,10 @@ var $author$project$Pages$Scoreboard$View$viewDemographicsPane = F7( var existedDuringExaminationMonth = _Utils_eq( A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), $elm$core$Basics$LT); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.birthDate), + targetDateForMonth); var gap = ageInMonths - gapInMonths; var row2 = (existedDuringExaminationMonth && (!gap)) ? (accumValue.row2 + 1) : accumValue.row2; var row3 = (existedDuringExaminationMonth && ((!gap) && _Utils_eq( @@ -29207,7 +29213,10 @@ var $author$project$Pages$Scoreboard$View$viewInfrastructureEnvironmentWashPane var row2 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths)) ? (accumValue.row2 + 1) : accumValue.row2; var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; var row5 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths)) ? (accumValue.row5 + 1) : accumValue.row5; - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.birthDate), + targetDateForMonth); var row4 = function () { var gap = ageInMonths - gapInMonths; return (existedDuringExaminationMonth && (record.ncda.infrastructureEnvironmentWash.row4 && ((gap >= 0) && (gap < 24)))) ? (accumValue.row4 + 1) : accumValue.row4; @@ -29351,7 +29360,10 @@ var $author$project$Pages$Scoreboard$View$viewNutritionBehaviorPane = F7( var row2 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths)) ? (accumValue.row2 + 1) : accumValue.row2; var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; var row4 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths)) ? (accumValue.row4 + 1) : accumValue.row4; - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.birthDate), + targetDateForMonth); var gap = ageInMonths - gapInMonths; var row1 = (existedDuringExaminationMonth && ((gap >= 0) && ((gap < 6) && record.ncda.nutritionBehavior.row1))) ? (accumValue.row1 + 1) : accumValue.row1; return {row1: row1, row2: row2, row3: row3, row4: row4}; @@ -29643,7 +29655,10 @@ var $author$project$Pages$Scoreboard$View$viewTargetedInterventionsPane = F7( var row4 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths)) ? (accumValue.row4 + 1) : accumValue.row4; var row5 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths)) ? (accumValue.row5 + 1) : accumValue.row5; var row6 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row6AsAgeInMonths)) ? (accumValue.row6 + 1) : accumValue.row6; - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.birthDate), + targetDateForMonth); var gap = ageInMonths - gapInMonths; var row2 = (existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, row2AsAgeInMonths) && ((gap >= 0) && (gap < 24)))) ? (accumValue.row2 + 1) : accumValue.row2; var row3 = (existedDuringExaminationMonth && (A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths) && ((gap >= 0) && (gap < 24)))) ? (accumValue.row3 + 1) : accumValue.row3; @@ -30056,7 +30071,10 @@ var $author$project$Pages$Scoreboard$View$viewUniversalInterventionPane = F8( var row3 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row3AsAgeInMonths)) ? (accumValue.row3 + 1) : accumValue.row3; var row4 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row4AsAgeInMonths)) ? (accumValue.row4 + 1) : accumValue.row4; var row5 = (existedDuringExaminationMonth && A2($elm$core$List$member, gapInMonths, row5AsAgeInMonths)) ? (accumValue.row5 + 1) : accumValue.row5; - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.birthDate), + targetDateForMonth); var ageInMonthsForIndexCell = ageInMonths - gapInMonths; var row1 = function () { if ((!existedDuringExaminationMonth) || ((ageInMonthsForIndexCell < 0) || (ageInMonthsForIndexCell >= 24))) { @@ -30415,7 +30433,10 @@ var $author$project$Pages$Scoreboard$View$viewScoreboardData = F4( var existedDuringExaminationMonth = _Utils_eq( A2($justinmimbs$date$Date$compare, record.created, targetDateForMonth), $elm$core$Basics$LT); - var ageInMonths = A2($author$project$Gizra$NominalDate$diffMonths, record.birthDate, targetDateForMonth); + var ageInMonths = A2( + $author$project$Gizra$NominalDate$diffMonths, + A2($justinmimbs$date$Date$floor, $justinmimbs$date$Date$Month, record.birthDate), + targetDateForMonth); var gap = ageInMonths - gapInMonths; return (existedDuringExaminationMonth && ((gap >= 0) && (gap < 24))) ? (accumValue + 1) : accumValue; }, From f41cf6aae4904ea1cac556feecd5c7242f222b60 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 3 Mar 2024 17:16:53 +0200 Subject: [PATCH 5/5] Decrease batch size pt avoid out of memory exceptions --- server/hedley/modules/custom/hedley_ncda/hedley_ncda.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module b/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module index 801b8f663b..fc560688be 100644 --- a/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module +++ b/server/hedley/modules/custom/hedley_ncda/hedley_ncda.module @@ -371,7 +371,7 @@ function hedley_ncda_generate_results_data($province, $district, $sector, $cell, $data = []; $nid = 0; - $batch = 500; + $batch = 400; while (TRUE) { // Free up memory. drupal_static_reset();