From 6f499460a9b9e965a107478578e8522377bf865f Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 9 May 2024 16:13:11 +0300 Subject: [PATCH 01/63] Field on Nurse CT, to store messages data [ci skip] --- .../hedley_user.features.field_base.inc | 20 ++++++++++ .../hedley_user.features.field_instance.inc | 40 +++++++++++++++++++ .../custom/hedley_user/hedley_user.info | 2 + 3 files changed, 62 insertions(+) diff --git a/server/hedley/modules/custom/hedley_user/hedley_user.features.field_base.inc b/server/hedley/modules/custom/hedley_user/hedley_user.features.field_base.inc index c319386045..48e7a74873 100644 --- a/server/hedley/modules/custom/hedley_user/hedley_user.features.field_base.inc +++ b/server/hedley/modules/custom/hedley_user/hedley_user.features.field_base.inc @@ -200,6 +200,26 @@ function hedley_user_field_default_field_bases() { 'type' => 'text', ); + // Exported field_base: 'field_resilience_messages'. + $field_bases['field_resilience_messages'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_id_type' => NULL, + 'entity_types' => array(), + 'field_name' => 'field_resilience_messages', + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + // Exported field_base: 'field_resilience_program'. $field_bases['field_resilience_program'] = array( 'active' => 1, diff --git a/server/hedley/modules/custom/hedley_user/hedley_user.features.field_instance.inc b/server/hedley/modules/custom/hedley_user/hedley_user.features.field_instance.inc index f9edfa3f5b..2a3be446c6 100644 --- a/server/hedley/modules/custom/hedley_user/hedley_user.features.field_instance.inc +++ b/server/hedley/modules/custom/hedley_user/hedley_user.features.field_instance.inc @@ -235,6 +235,45 @@ function hedley_user_field_default_field_instances() { ), ); + // Exported field_instance: 'node-nurse-field_resilience_messages'. + $field_instances['node-nurse-field_resilience_messages'] = array( + 'bundle' => 'nurse', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 16, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_resilience_messages', + 'label' => 'Resilience Messages', + 'required' => FALSE, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 16, + ), + ); + // Exported field_instance: 'node-nurse-field_resilience_program'. $field_instances['node-nurse-field_resilience_program'] = array( 'bundle' => 'nurse', @@ -724,6 +763,7 @@ function hedley_user_field_default_field_instances() { t('PIN code'); t('Phone'); t('Profile photo'); + t('Resilience Messages'); t('Resilience Next Reminder'); t('Resilience Program'); t('Role'); diff --git a/server/hedley/modules/custom/hedley_user/hedley_user.info b/server/hedley/modules/custom/hedley_user/hedley_user.info index 6f282d5107..9440d347a6 100644 --- a/server/hedley/modules/custom/hedley_user/hedley_user.info +++ b/server/hedley/modules/custom/hedley_user/hedley_user.info @@ -24,6 +24,7 @@ features[field_base][] = field_health_centers features[field_base][] = field_next_reminder features[field_base][] = field_phone features[field_base][] = field_pin_code +features[field_base][] = field_resilience_messages features[field_base][] = field_resilience_program features[field_base][] = field_role features[field_base][] = field_sync_phase @@ -35,6 +36,7 @@ features[field_instance][] = node-nurse-field_email features[field_instance][] = node-nurse-field_health_centers features[field_instance][] = node-nurse-field_next_reminder features[field_instance][] = node-nurse-field_pin_code +features[field_instance][] = node-nurse-field_resilience_messages features[field_instance][] = node-nurse-field_resilience_program features[field_instance][] = node-nurse-field_role features[field_instance][] = node-nurse-field_uuid From 9939bfa03b7f70572a0e480e3023158d35617c9a Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 9 May 2024 16:13:33 +0300 Subject: [PATCH 02/63] Expose with Restful [ci skip] --- .../plugins/restful/node/HedleyRestfulNurses.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php index d81d553f1a..022c9c5d8d 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php @@ -26,6 +26,7 @@ public function publicFieldsInfo() { 'field_marital_status', 'field_ubudehe', 'field_next_reminder', + 'field_resilience_messages', ]; foreach ($standard_fields_names as $field_name) { From b1faa10476956d7fcb8c82ee6eff5bfcf87d6bb2 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 9 May 2024 16:14:02 +0300 Subject: [PATCH 03/63] Introduce to front-end, Encode + Deode [ci skip] --- client/src/elm/Backend/Nurse/Decoder.elm | 9 +++++++++ client/src/elm/Backend/Nurse/Encoder.elm | 16 +++++++++++++--- client/src/elm/Backend/Nurse/Model.elm | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/client/src/elm/Backend/Nurse/Decoder.elm b/client/src/elm/Backend/Nurse/Decoder.elm index 5d6ac01f0e..ac3ea6714f 100644 --- a/client/src/elm/Backend/Nurse/Decoder.elm +++ b/client/src/elm/Backend/Nurse/Decoder.elm @@ -9,6 +9,8 @@ import Backend.Person.Decoder , decodeMaritalStatus , decodeUbudehe ) +import Backend.ResilienceMessage.Decoder exposing (decodeResilienceMessage) +import Backend.ResilienceMessage.Model exposing (ResilienceMessage) import EverySet exposing (EverySet) import Gizra.NominalDate exposing (decodeYYYYMMDD) import Gizra.TimePosix exposing (decodeSecondsAsPosix) @@ -35,6 +37,7 @@ decodeNurse = |> optional "ubudehe" (nullable decodeUbudehe) Nothing |> optional "marital_status" (nullable decodeMaritalStatus) Nothing |> optional "next_reminder" (nullable decodeSecondsAsPosix) Nothing + |> optional "resilience_messages" (list decodeResilienceMessage) [] decodeRoles : Decoder (EverySet Role) @@ -83,3 +86,9 @@ decodeResilienceRole = ++ " is not a recognized ResilienceRole." ) ) + + +decodeResilienceMessages : Decoder (List ResilienceMessage) +decodeResilienceMessages = + string + |> andThen (\s -> succeed []) diff --git a/client/src/elm/Backend/Nurse/Encoder.elm b/client/src/elm/Backend/Nurse/Encoder.elm index 5022cc6dbe..c3b4be5427 100644 --- a/client/src/elm/Backend/Nurse/Encoder.elm +++ b/client/src/elm/Backend/Nurse/Encoder.elm @@ -3,17 +3,26 @@ module Backend.Nurse.Encoder exposing (encodeNurse) import Backend.Nurse.Model exposing (..) import Backend.Nurse.Utils exposing (resilienceRoleToString) import Backend.Person.Encoder exposing (encodeEducationLevel, encodeGender, encodeMaritalStatus, encodeUbudehe) +import Backend.ResilienceMessage.Encoder exposing (encodeResilienceMessage) import EverySet import Gizra.NominalDate exposing (encodeYYYYMMDD) import Gizra.TimePosix exposing (encodePosixAsSeconds) import Json.Encode exposing (..) import Json.Encode.Extra exposing (maybe) import Restful.Endpoint exposing (encodeEntityUuid) -import Utils.Json exposing (encodeNullable) +import Utils.Json exposing (encodeIfSet, encodeNullable) encodeNurse : Nurse -> List ( String, Value ) encodeNurse nurse = + let + resilienceMessages = + if List.isEmpty nurse.resilienceMessages then + [] + + else + [ ( "resilience_messages", list (encodeResilienceMessage >> Json.Encode.object) nurse.resilienceMessages ) ] + in [ ( "label", string nurse.name ) , ( "health_centers", list encodeEntityUuid (EverySet.toList nurse.healthCenters) ) , ( "villages", list encodeEntityUuid (EverySet.toList nurse.villages) ) @@ -30,8 +39,9 @@ encodeNurse nurse = , ( "deleted", bool False ) , ( "type", string "nurse" ) ] - ++ encodeNullable "email" nurse.email string - ++ encodeNullable "next_reminder" nurse.resilienceNextReminder encodePosixAsSeconds + ++ encodeIfSet "email" nurse.email string + ++ encodeIfSet "next_reminder" nurse.resilienceNextReminder encodePosixAsSeconds + ++ resilienceMessages encodeRole : Role -> Value diff --git a/client/src/elm/Backend/Nurse/Model.elm b/client/src/elm/Backend/Nurse/Model.elm index 7e1834c270..8141c58739 100644 --- a/client/src/elm/Backend/Nurse/Model.elm +++ b/client/src/elm/Backend/Nurse/Model.elm @@ -1,8 +1,10 @@ module Backend.Nurse.Model exposing (..) +import AssocList as Dict exposing (Dict) import Backend.Entities exposing (..) import Backend.Measurement.Model exposing (Gender) import Backend.Person.Model exposing (EducationLevel, MaritalStatus, Ubudehe) +import Backend.ResilienceMessage.Model exposing (ResilienceCategory, ResilienceMessage) import EverySet exposing (EverySet) import Gizra.NominalDate exposing (NominalDate) import RemoteData exposing (RemoteData(..), WebData) @@ -25,6 +27,7 @@ type alias Nurse = , resilienceUbudehe : Maybe Ubudehe , resilienceMaritalStatus : Maybe MaritalStatus , resilienceNextReminder : Maybe Time.Posix + , resilienceMessages : List ResilienceMessage } From daa11d160b193b2dc7a940a8ebf516cce48bdc84 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 9 May 2024 16:14:38 +0300 Subject: [PATCH 04/63] Adjustments on backend from proper saving and pulling [ci skip] --- .../plugins/restful/node/HedleyRestfulNurses.class.php | 1 + .../plugins/restful/node/HedleyRestfulSync.class.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php index 022c9c5d8d..e0f8e77aef 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php @@ -125,6 +125,7 @@ protected function postExecuteQueryForViewWithDbSelect(array $items = []) { $resilience_start_date = explode(' ', $item->resilience_start_date); $item->resilience_start_date = !empty($resilience_start_date[0]) ? $resilience_start_date[0] : NULL; + $item->resilience_messages = drupal_json_decode($item->resilience_messages); } return $items; diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php index 422d907711..7d16f79a59 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php @@ -486,6 +486,9 @@ public function handleChanges() { elseif ($key != 'uuid' && is_string($value) && Uuid::isValid($value)) { $data[$key] = hedley_restful_uuid_to_nid($value); } + elseif ($key == 'resilience_messages') { + $data[$key] = json_encode($value); + } else { $data[$key] = $value; } From fbefdfa422c9fdbda85034da9b67c8f58b446610 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 9 May 2024 16:32:31 +0300 Subject: [PATCH 05/63] A fix [ci skip] --- .../plugins/restful/node/HedleyRestfulNurses.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php index e0f8e77aef..074cff4a02 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulNurses.class.php @@ -81,6 +81,7 @@ protected function alterQueryForViewWithDbSelect(SelectQuery $query) { 'field_birth_date', 'field_resilience_start_date', 'field_next_reminder', + 'field_resilience_messages', ]; foreach ($field_names as $field_name) { From 5f91ae4648f439e81e3fe056267b935c6bb7af5d Mon Sep 17 00:00:00 2001 From: anvmn Date: Fri, 10 May 2024 10:21:10 +0300 Subject: [PATCH 06/63] Store messages as Dict [ci skip] --- client/src/elm/Backend/Nurse/Decoder.elm | 12 +++--------- client/src/elm/Backend/Nurse/Encoder.elm | 9 +++++++-- client/src/elm/Backend/Nurse/Model.elm | 2 +- .../src/elm/Backend/ResilienceMessage/Decoder.elm | 14 +++++++++++++- client/src/elm/Backend/ResilienceMessage/Utils.elm | 5 +++++ client/src/elm/Pages/PinCode/View.elm | 5 +++++ 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/client/src/elm/Backend/Nurse/Decoder.elm b/client/src/elm/Backend/Nurse/Decoder.elm index ac3ea6714f..d0790347ab 100644 --- a/client/src/elm/Backend/Nurse/Decoder.elm +++ b/client/src/elm/Backend/Nurse/Decoder.elm @@ -1,5 +1,6 @@ module Backend.Nurse.Decoder exposing (decodeNurse) +import AssocList as Dict exposing (Dict) import Backend.Nurse.Model exposing (..) import Backend.Nurse.Utils exposing (resilienceRoleFromString) import Backend.Person.Decoder @@ -9,8 +10,7 @@ import Backend.Person.Decoder , decodeMaritalStatus , decodeUbudehe ) -import Backend.ResilienceMessage.Decoder exposing (decodeResilienceMessage) -import Backend.ResilienceMessage.Model exposing (ResilienceMessage) +import Backend.ResilienceMessage.Decoder exposing (decodeResilienceMessages) import EverySet exposing (EverySet) import Gizra.NominalDate exposing (decodeYYYYMMDD) import Gizra.TimePosix exposing (decodeSecondsAsPosix) @@ -37,7 +37,7 @@ decodeNurse = |> optional "ubudehe" (nullable decodeUbudehe) Nothing |> optional "marital_status" (nullable decodeMaritalStatus) Nothing |> optional "next_reminder" (nullable decodeSecondsAsPosix) Nothing - |> optional "resilience_messages" (list decodeResilienceMessage) [] + |> optional "resilience_messages" decodeResilienceMessages Dict.empty decodeRoles : Decoder (EverySet Role) @@ -86,9 +86,3 @@ decodeResilienceRole = ++ " is not a recognized ResilienceRole." ) ) - - -decodeResilienceMessages : Decoder (List ResilienceMessage) -decodeResilienceMessages = - string - |> andThen (\s -> succeed []) diff --git a/client/src/elm/Backend/Nurse/Encoder.elm b/client/src/elm/Backend/Nurse/Encoder.elm index c3b4be5427..2b57c36809 100644 --- a/client/src/elm/Backend/Nurse/Encoder.elm +++ b/client/src/elm/Backend/Nurse/Encoder.elm @@ -1,5 +1,6 @@ module Backend.Nurse.Encoder exposing (encodeNurse) +import AssocList as Dict exposing (Dict) import Backend.Nurse.Model exposing (..) import Backend.Nurse.Utils exposing (resilienceRoleToString) import Backend.Person.Encoder exposing (encodeEducationLevel, encodeGender, encodeMaritalStatus, encodeUbudehe) @@ -17,11 +18,15 @@ encodeNurse : Nurse -> List ( String, Value ) encodeNurse nurse = let resilienceMessages = - if List.isEmpty nurse.resilienceMessages then + let + messages = + Dict.values nurse.resilienceMessages + in + if List.isEmpty messages then [] else - [ ( "resilience_messages", list (encodeResilienceMessage >> Json.Encode.object) nurse.resilienceMessages ) ] + [ ( "resilience_messages", list (encodeResilienceMessage >> Json.Encode.object) messages ) ] in [ ( "label", string nurse.name ) , ( "health_centers", list encodeEntityUuid (EverySet.toList nurse.healthCenters) ) diff --git a/client/src/elm/Backend/Nurse/Model.elm b/client/src/elm/Backend/Nurse/Model.elm index 8141c58739..ef541d7d60 100644 --- a/client/src/elm/Backend/Nurse/Model.elm +++ b/client/src/elm/Backend/Nurse/Model.elm @@ -27,7 +27,7 @@ type alias Nurse = , resilienceUbudehe : Maybe Ubudehe , resilienceMaritalStatus : Maybe MaritalStatus , resilienceNextReminder : Maybe Time.Posix - , resilienceMessages : List ResilienceMessage + , resilienceMessages : Dict String ResilienceMessage } diff --git a/client/src/elm/Backend/ResilienceMessage/Decoder.elm b/client/src/elm/Backend/ResilienceMessage/Decoder.elm index 658cc9e754..971bad839c 100644 --- a/client/src/elm/Backend/ResilienceMessage/Decoder.elm +++ b/client/src/elm/Backend/ResilienceMessage/Decoder.elm @@ -1,5 +1,6 @@ -module Backend.ResilienceMessage.Decoder exposing (decodeResilienceMessage) +module Backend.ResilienceMessage.Decoder exposing (decodeResilienceMessage, decodeResilienceMessages) +import AssocList as Dict exposing (Dict) import Backend.ResilienceMessage.Model exposing (..) import Backend.ResilienceMessage.Utils exposing (..) import Gizra.Json exposing (decodeInt) @@ -9,6 +10,17 @@ import Json.Decode.Pipeline exposing (..) import Restful.Endpoint exposing (decodeEntityUuid) +decodeResilienceMessages : Decoder (Dict String ResilienceMessage) +decodeResilienceMessages = + list decodeResilienceMessage + |> andThen + (\messages -> + List.map (\message -> ( resolveResilienceMessageId message, message )) messages + |> Dict.fromList + |> succeed + ) + + decodeResilienceMessage : Decoder ResilienceMessage decodeResilienceMessage = succeed ResilienceMessage diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index 6ccead4429..3c7d931800 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -113,3 +113,8 @@ resilienceMessageOrderFromString value = _ -> Nothing + + +resolveResilienceMessageId : ResilienceMessage -> String +resolveResilienceMessageId message = + resilienceCategoryToString message.category ++ "-" ++ resilienceMessageOrderToString message.order diff --git a/client/src/elm/Pages/PinCode/View.elm b/client/src/elm/Pages/PinCode/View.elm index c92e6a3817..65d619cf91 100644 --- a/client/src/elm/Pages/PinCode/View.elm +++ b/client/src/elm/Pages/PinCode/View.elm @@ -7,6 +7,7 @@ import Backend.Nurse.Model exposing (Nurse) import Backend.Nurse.Utils exposing (assignedToHealthCenter, assignedToVillage, isCommunityHealthWorker, isLabTechnician) import Backend.Person.Model exposing (Initiator(..)) import Backend.Person.Utils exposing (getHealthCenterName) +import Backend.ResilienceMessage.Model exposing (ResilienceCategory(..), ResilienceMessage, ResilienceMessageOrder(..)) import Backend.Utils exposing (stockManagementEnabled) import Date exposing (Unit(..)) import EverySet exposing (EverySet) @@ -346,6 +347,10 @@ viewLoggedInContent language currentTime features nurseId nurse ( healthCenterId resilienceReminderDialog : Language -> Time.Posix -> NominalDate -> NurseId -> Nurse -> Maybe (Html Msg) resilienceReminderDialog language currentTime currentDate nurseId nurse = + let + _ = + Debug.log "" nurse + in Maybe.andThen (\programStartDate -> resolveResilienceReminderType currentDate programStartDate From 522eee95686aea4fb8ab4ad4163f1872bd202fc2 Mon Sep 17 00:00:00 2001 From: anvmn Date: Fri, 10 May 2024 11:17:32 +0300 Subject: [PATCH 07/63] Utility functions [ci skip] --- .../elm/Backend/ResilienceMessage/Model.elm | 5 +- .../elm/Backend/ResilienceMessage/Utils.elm | 202 ++++++++++++++++++ 2 files changed, 206 insertions(+), 1 deletion(-) diff --git a/client/src/elm/Backend/ResilienceMessage/Model.elm b/client/src/elm/Backend/ResilienceMessage/Model.elm index c9fe9bfe9c..93f21e87fa 100644 --- a/client/src/elm/Backend/ResilienceMessage/Model.elm +++ b/client/src/elm/Backend/ResilienceMessage/Model.elm @@ -6,9 +6,12 @@ import Time type alias ResilienceMessage = - { nurse : NurseId + { -- @todo: Remove + nurse : NurseId , category : ResilienceCategory , order : ResilienceMessageOrder + + -- @todo: Remove , displayDay : Int , timeRead : Maybe Time.Posix , nextReminder : Maybe Time.Posix diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index 3c7d931800..3eb2911f08 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -1,6 +1,10 @@ module Backend.ResilienceMessage.Utils exposing (..) +import AssocList as Dict exposing (Dict) +import Backend.Entities exposing (NurseId) import Backend.ResilienceMessage.Model exposing (..) +import Date exposing (Unit(..)) +import Gizra.NominalDate exposing (NominalDate) resilienceCategoryToString : ResilienceCategory -> String @@ -118,3 +122,201 @@ resilienceMessageOrderFromString value = resolveResilienceMessageId : ResilienceMessage -> String resolveResilienceMessageId message = resilienceCategoryToString message.category ++ "-" ++ resilienceMessageOrderToString message.order + + +generateEmptyMessagesByProgramStartDate : NurseId -> NominalDate -> NominalDate -> Dict ResilienceCategory ResilienceMessage +generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = + Dict.toList numberOfMessagesByCategory + |> List.map + (\( category, numberOfMessages ) -> + List.range 1 numberOfMessages + |> List.filterMap + (String.fromInt + >> resilienceMessageOrderFromString + >> Maybe.andThen + (\order -> + resolveDisplayDay category order + |> Maybe.andThen + (\displayDay -> + let + shouldShow = + Date.compare currentDate (Date.add Days (displayDay - 1) programStartDate) == LT + in + if shouldShow then + Just + ( category + , { nurse = nurseId + , category = category + , order = order + , displayDay = displayDay + , timeRead = Nothing + , nextReminder = Nothing + , isFavorite = False + } + ) + + else + Nothing + ) + ) + ) + ) + |> List.concat + |> Dict.fromList + + +numberOfMessagesByCategory : Dict ResilienceCategory Int +numberOfMessagesByCategory = + Dict.fromList + [ ( ResilienceCategoryIntroduction, 8 ) + , ( ResilienceCategoryGrowth, 4 ) + , ( ResilienceCategoryStressManagement, 4 ) + , ( ResilienceCategoryMindfulness, 7 ) + , ( ResilienceCategoryConnecting, 6 ) + , ( ResilienceCategorySelfCare, 3 ) + , ( ResilienceCategoryEndOfPeriod, 2 ) + ] + + +resolveDisplayDay : ResilienceCategory -> ResilienceMessageOrder -> Maybe Int +resolveDisplayDay category order = + case category of + ResilienceCategoryIntroduction -> + case order of + ResilienceMessage1 -> + Just 0 + + ResilienceMessage2 -> + Just 0 + + ResilienceMessage3 -> + Just 0 + + ResilienceMessage4 -> + Just 0 + + ResilienceMessage5 -> + Just 2 + + ResilienceMessage6 -> + Just 2 + + ResilienceMessage7 -> + Just 2 + + ResilienceMessage8 -> + Just 2 + + ResilienceCategoryGrowth -> + case order of + ResilienceMessage1 -> + Just 2 + + ResilienceMessage2 -> + Just 28 + + ResilienceMessage3 -> + Just 49 + + ResilienceMessage4 -> + Just 61 + + _ -> + Nothing + + ResilienceCategoryStressManagement -> + case order of + ResilienceMessage1 -> + Just 7 + + ResilienceMessage2 -> + Just 9 + + ResilienceMessage3 -> + Just 33 + + ResilienceMessage4 -> + Just 44 + + ResilienceMessage5 -> + Just 54 + + ResilienceMessage6 -> + Just 63 + + ResilienceMessage7 -> + Just 65 + + _ -> + Nothing + + ResilienceCategoryMindfulness -> + case order of + ResilienceMessage1 -> + Just 12 + + ResilienceMessage2 -> + Just 14 + + ResilienceMessage3 -> + Just 19 + + ResilienceMessage4 -> + Just 35 + + ResilienceMessage5 -> + Just 37 + + ResilienceMessage6 -> + Just 47 + + _ -> + Nothing + + ResilienceCategoryConnecting -> + case order of + ResilienceMessage1 -> + Just 16 + + ResilienceMessage2 -> + Just 23 + + ResilienceMessage3 -> + Just 26 + + ResilienceMessage4 -> + Just 40 + + ResilienceMessage5 -> + Just 51 + + ResilienceMessage6 -> + Just 68 + + _ -> + Nothing + + ResilienceCategorySelfCare -> + case order of + ResilienceMessage1 -> + Just 21 + + ResilienceMessage2 -> + Just 42 + + ResilienceMessage3 -> + Just 58 + + _ -> + Nothing + + ResilienceCategoryEndOfPeriod -> + case order of + ResilienceMessage1 -> + Just 30 + + ResilienceMessage2 -> + Just 56 + + _ -> + Nothing From a1b3765557e63ad58a0b34b325b7c85db237aa06 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 12 May 2024 22:49:02 +0300 Subject: [PATCH 08/63] WIP [ci skip] --- .../elm/Backend/ResilienceMessage/Decoder.elm | 2 +- .../elm/Backend/ResilienceMessage/Utils.elm | 50 +++++++++---------- .../src/elm/Pages/MessagingCenter/Utils.elm | 40 +++++---------- client/src/elm/Pages/MessagingCenter/View.elm | 17 +++++-- 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/client/src/elm/Backend/ResilienceMessage/Decoder.elm b/client/src/elm/Backend/ResilienceMessage/Decoder.elm index 971bad839c..515ae8e198 100644 --- a/client/src/elm/Backend/ResilienceMessage/Decoder.elm +++ b/client/src/elm/Backend/ResilienceMessage/Decoder.elm @@ -15,7 +15,7 @@ decodeResilienceMessages = list decodeResilienceMessage |> andThen (\messages -> - List.map (\message -> ( resolveResilienceMessageId message, message )) messages + List.map (\message -> ( generateResilienceMessageId message.category message.order, message )) messages |> Dict.fromList |> succeed ) diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index 3eb2911f08..844c1e98e4 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -119,13 +119,17 @@ resilienceMessageOrderFromString value = Nothing -resolveResilienceMessageId : ResilienceMessage -> String -resolveResilienceMessageId message = - resilienceCategoryToString message.category ++ "-" ++ resilienceMessageOrderToString message.order +generateEmptyMessagesByProgramStartDate : NurseId -> NominalDate -> NominalDate -> Dict String ResilienceMessage +generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = + generateEmptyMessages nurseId + |> Dict.filter + (\_ message -> + Date.compare currentDate (Date.add Days (message.displayDay - 1) programStartDate) == LT + ) -generateEmptyMessagesByProgramStartDate : NurseId -> NominalDate -> NominalDate -> Dict ResilienceCategory ResilienceMessage -generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = +generateEmptyMessages : NurseId -> Dict String ResilienceMessage +generateEmptyMessages nurseId = Dict.toList numberOfMessagesByCategory |> List.map (\( category, numberOfMessages ) -> @@ -136,27 +140,18 @@ generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = >> Maybe.andThen (\order -> resolveDisplayDay category order - |> Maybe.andThen + |> Maybe.map (\displayDay -> - let - shouldShow = - Date.compare currentDate (Date.add Days (displayDay - 1) programStartDate) == LT - in - if shouldShow then - Just - ( category - , { nurse = nurseId - , category = category - , order = order - , displayDay = displayDay - , timeRead = Nothing - , nextReminder = Nothing - , isFavorite = False - } - ) - - else - Nothing + ( generateResilienceMessageId category order + , { nurse = nurseId + , category = category + , order = order + , displayDay = displayDay + , timeRead = Nothing + , nextReminder = Nothing + , isFavorite = False + } + ) ) ) ) @@ -165,6 +160,11 @@ generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = |> Dict.fromList +generateResilienceMessageId : ResilienceCategory -> ResilienceMessageOrder -> String +generateResilienceMessageId category order = + resilienceCategoryToString category ++ "-" ++ resilienceMessageOrderToString order + + numberOfMessagesByCategory : Dict ResilienceCategory Int numberOfMessagesByCategory = Dict.fromList diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index a3a78df14e..01e035f28d 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -5,6 +5,7 @@ import Backend.Entities exposing (..) import Backend.Model exposing (ModelIndexedDb) import Backend.Nurse.Model exposing (Nurse) import Backend.ResilienceMessage.Model exposing (ResilienceMessage) +import Backend.ResilienceMessage.Utils exposing (generateEmptyMessagesByProgramStartDate) import Backend.ResilienceSurvey.Model exposing (ResilienceSurveyQuestion(..)) import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) @@ -21,23 +22,6 @@ monthlySurveyQuestions = ] -resolveNumberOfUnreadMessages : Time.Posix -> NominalDate -> NurseId -> Nurse -> ModelIndexedDb -> Int -resolveNumberOfUnreadMessages currentTime currentDate nurseId nurse db = - resolveUnreadMessages currentTime currentDate nurseId nurse db - |> Dict.size - - -resolveUnreadMessages : Time.Posix -> NominalDate -> NurseId -> Nurse -> ModelIndexedDb -> Dict ResilienceMessageId ResilienceMessage -resolveUnreadMessages currentTime currentDate nurseId nurse db = - Maybe.map - (\programStartDate -> - resolveInboxMessages currentDate programStartDate nurseId db - |> Dict.filter (\_ message -> isMessageUnread currentTime message) - ) - nurse.resilienceProgramStartDate - |> Maybe.withDefault (resolveInboxMessagesProgramNotStarted currentDate nurseId db) - - isMessageUnread : Time.Posix -> ResilienceMessage -> Bool isMessageUnread currentTime message = case message.timeRead of @@ -64,17 +48,19 @@ isMessageUnread currentTime message = Maybe.withDefault False -resolveInboxMessages : NominalDate -> NominalDate -> NurseId -> ModelIndexedDb -> Dict ResilienceMessageId ResilienceMessage -resolveInboxMessages currentDate programStartDate nurseId db = - Dict.get nurseId db.resilienceMessagesByNurse - |> Maybe.andThen RemoteData.toMaybe - |> Maybe.map - (Dict.filter - (\_ message -> - Date.compare currentDate (Date.add Days (message.displayDay - 1) programStartDate) == GT - ) +generateInboxMessages : NurseId -> NominalDate -> NominalDate -> Dict String ResilienceMessage -> Dict String ResilienceMessage +generateInboxMessages nurseId currentDate programStartDate recordedMessage = + generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate + |> Dict.foldl + (\key value accum -> + Dict.get key recordedMessage + |> Maybe.map + (\recordedValue -> + Dict.insert key recordedValue accum + ) + |> Maybe.withDefault (Dict.insert key value accum) ) - |> Maybe.withDefault Dict.empty + Dict.empty resolveInboxMessagesProgramNotStarted : NominalDate -> NurseId -> ModelIndexedDb -> Dict ResilienceMessageId ResilienceMessage diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index f9e74c2b38..8d94ce96d6 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -9,6 +9,7 @@ import Backend.Nurse.Utils exposing (resilienceRoleToString) import Backend.Person.Model exposing (EducationLevel(..), MaritalStatus(..), allUbudehes) import Backend.Person.Utils exposing (educationLevelToInt, genderToString, maritalStatusToString, ubudeheToInt) import Backend.ResilienceMessage.Model exposing (ResilienceCategory(..), ResilienceMessage, ResilienceMessageOrder(..)) +import Backend.ResilienceMessage.Utils exposing (..) import Backend.ResilienceSurvey.Model exposing ( ResilienceSurveyQuestionOption(..) @@ -48,8 +49,18 @@ view language currentTime nurseId nurse db model = currentDate = fromLocalDateTime currentTime + emptyMessages = + generateEmptyMessages nurseId + numberOfUnreadMessages = - resolveNumberOfUnreadMessages currentTime currentDate nurseId nurse db + Maybe.map + (\programStartDate -> + generateInboxMessages nurseId currentDate programStartDate nurse.resilienceMessages + |> Dict.filter (\_ message -> isMessageUnread currentTime message) + ) + nurse.resilienceProgramStartDate + |> Maybe.withDefault (Dict.filter (\_ message -> message.displayDay == 0) emptyMessages) + |> Dict.size header = div [ class "ui basic head segment" ] @@ -314,7 +325,7 @@ viewMessagingCenter : Language -> Time.Posix -> NominalDate -> NominalDate -> Nu viewMessagingCenter language currentTime currentDate programStartDate nurseId nurse db model = let messages = - resolveInboxMessages currentDate programStartDate nurseId db + generateInboxMessages nurseId currentDate programStartDate nurse.resilienceMessages ( unread, read ) = Dict.toList messages @@ -442,7 +453,7 @@ viewTabs language model = ++ [ scrollRightButton ] -viewResilienceMessage : Language -> NurseId -> Nurse -> Model -> ( ResilienceMessageId, ResilienceMessage ) -> Html Msg +viewResilienceMessage : Language -> NurseId -> Nurse -> Model -> ( String, ResilienceMessage ) -> Html Msg viewResilienceMessage language nurseId nurse model ( messageId, message ) = let ( extraClass, ( head, body ) ) = From 99475e5dff23c0ff310f9904043213e978d6242e Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 12 May 2024 23:09:09 +0300 Subject: [PATCH 09/63] More WIP [ci skip] --- client/src/elm/Backend/Entities.elm | 4 ++ client/src/elm/Backend/Nurse/Model.elm | 2 +- .../elm/Backend/ResilienceMessage/Model.elm | 2 - .../elm/Backend/ResilienceMessage/Utils.elm | 8 +-- .../src/elm/Pages/MessagingCenter/Model.elm | 14 ++--- .../src/elm/Pages/MessagingCenter/Update.elm | 45 ++++++++------- .../src/elm/Pages/MessagingCenter/Utils.elm | 55 +++++++++++-------- client/src/elm/Pages/MessagingCenter/View.elm | 14 +---- client/src/elm/Pages/PinCode/View.elm | 4 +- client/src/elm/Pages/Wellbeing/View.elm | 2 +- 10 files changed, 78 insertions(+), 72 deletions(-) diff --git a/client/src/elm/Backend/Entities.elm b/client/src/elm/Backend/Entities.elm index 6ac53f3154..ee1227ec8d 100644 --- a/client/src/elm/Backend/Entities.elm +++ b/client/src/elm/Backend/Entities.elm @@ -1399,6 +1399,10 @@ type ResilienceSurveyUuidType = ResilienceSurveyUuidType +type alias ResilienceMessageNEWId = + String + + type alias ResilienceMessageId = EntityUuid ResilienceMessageUuidType diff --git a/client/src/elm/Backend/Nurse/Model.elm b/client/src/elm/Backend/Nurse/Model.elm index ef541d7d60..98c98ca411 100644 --- a/client/src/elm/Backend/Nurse/Model.elm +++ b/client/src/elm/Backend/Nurse/Model.elm @@ -27,7 +27,7 @@ type alias Nurse = , resilienceUbudehe : Maybe Ubudehe , resilienceMaritalStatus : Maybe MaritalStatus , resilienceNextReminder : Maybe Time.Posix - , resilienceMessages : Dict String ResilienceMessage + , resilienceMessages : Dict ResilienceMessageNEWId ResilienceMessage } diff --git a/client/src/elm/Backend/ResilienceMessage/Model.elm b/client/src/elm/Backend/ResilienceMessage/Model.elm index 93f21e87fa..18dd7921a1 100644 --- a/client/src/elm/Backend/ResilienceMessage/Model.elm +++ b/client/src/elm/Backend/ResilienceMessage/Model.elm @@ -10,8 +10,6 @@ type alias ResilienceMessage = nurse : NurseId , category : ResilienceCategory , order : ResilienceMessageOrder - - -- @todo: Remove , displayDay : Int , timeRead : Maybe Time.Posix , nextReminder : Maybe Time.Posix diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index 844c1e98e4..fcc65d2daf 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -1,7 +1,7 @@ module Backend.ResilienceMessage.Utils exposing (..) import AssocList as Dict exposing (Dict) -import Backend.Entities exposing (NurseId) +import Backend.Entities exposing (NurseId, ResilienceMessageNEWId) import Backend.ResilienceMessage.Model exposing (..) import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) @@ -119,7 +119,7 @@ resilienceMessageOrderFromString value = Nothing -generateEmptyMessagesByProgramStartDate : NurseId -> NominalDate -> NominalDate -> Dict String ResilienceMessage +generateEmptyMessagesByProgramStartDate : NurseId -> NominalDate -> NominalDate -> Dict ResilienceMessageNEWId ResilienceMessage generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = generateEmptyMessages nurseId |> Dict.filter @@ -128,7 +128,7 @@ generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = ) -generateEmptyMessages : NurseId -> Dict String ResilienceMessage +generateEmptyMessages : NurseId -> Dict ResilienceMessageNEWId ResilienceMessage generateEmptyMessages nurseId = Dict.toList numberOfMessagesByCategory |> List.map @@ -160,7 +160,7 @@ generateEmptyMessages nurseId = |> Dict.fromList -generateResilienceMessageId : ResilienceCategory -> ResilienceMessageOrder -> String +generateResilienceMessageId : ResilienceCategory -> ResilienceMessageOrder -> ResilienceMessageNEWId generateResilienceMessageId category order = resilienceCategoryToString category ++ "-" ++ resilienceMessageOrderToString order diff --git a/client/src/elm/Pages/MessagingCenter/Model.elm b/client/src/elm/Pages/MessagingCenter/Model.elm index 60f4d215d0..02276d5985 100644 --- a/client/src/elm/Pages/MessagingCenter/Model.elm +++ b/client/src/elm/Pages/MessagingCenter/Model.elm @@ -21,7 +21,7 @@ import Pages.Page exposing (Page) type alias Model = { activeTab : MessagingTab , tabScrollPosition : Int - , expandedMessages : EverySet ResilienceMessageId + , expandedMessages : EverySet ResilienceMessageNEWId , messageOptionsDialogState : Maybe MessageOptionsDialogState , kickOffForm : KickOffForm , monthlySurveyForm : MonthlySurveyForm @@ -52,8 +52,8 @@ type MessagingTab type MessageOptionsDialogState - = MessageOptionsStateMain ( ResilienceMessageId, ResilienceMessage ) - | MessageOptionsStateReminder ( ResilienceMessageId, ResilienceMessage ) + = MessageOptionsStateMain ( ResilienceMessageNEWId, ResilienceMessage ) + | MessageOptionsStateReminder ( ResilienceMessageNEWId, ResilienceMessage ) type alias KickOffForm = @@ -107,8 +107,8 @@ type Msg | SetSurveyScoreDialogState (Maybe SurveyScoreDialogState) | SetActiveTab MessagingTab | ScrollTab Int - | ResilienceMessageClicked NurseId ResilienceMessageId ResilienceMessage Bool + | ResilienceMessageClicked NurseId ResilienceMessageNEWId ResilienceMessage Bool | SetMessageOptionsDialogState (Maybe MessageOptionsDialogState) - | ToggleMessageRead NurseId ResilienceMessageId ResilienceMessage Bool - | ToggleMessageFavorite NurseId ResilienceMessageId ResilienceMessage - | ScheduleMessageReminder Int NurseId ResilienceMessageId ResilienceMessage + | ToggleMessageRead NurseId ResilienceMessageNEWId ResilienceMessage Bool + | ToggleMessageFavorite NurseId ResilienceMessageNEWId ResilienceMessage + | ScheduleMessageReminder Int NurseId ResilienceMessageNEWId ResilienceMessage diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index 17814c3ad8..ae088626bd 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -242,7 +242,9 @@ update currentTime currentDate msg model = if EverySet.member messageId model.expandedMessages then ( { model | expandedMessages = EverySet.remove messageId model.expandedMessages } , if updateTimeRead then - [ markMessageReadAction currentTime nurseId messageId message ] + [-- @todo: + -- markMessageReadAction currentTime nurseId messageId message + ] else [] @@ -271,17 +273,20 @@ update currentTime currentDate msg model = -- To mark message as unread, we set reminder to current time, -- and message read time to one second before current time. -- In essence, scheduling message reminder to right now. - [ Backend.ResilienceMessage.Model.UpdateMessage messageId - { message - | nextReminder = Just currentTime - , timeRead = Just <| Time.Extra.add Time.Extra.Second -1 Time.utc currentTime - } - |> Backend.Model.MsgResilienceMessage nurseId - |> App.Model.MsgIndexedDb + [-- @todo: + -- Backend.ResilienceMessage.Model.UpdateMessage messageId + -- { message + -- | nextReminder = Just currentTime + -- , timeRead = Just <| Time.Extra.add Time.Extra.Second -1 Time.utc currentTime + -- } + -- |> Backend.Model.MsgResilienceMessage nurseId + -- |> App.Model.MsgIndexedDb ] else - [ markMessageReadAction currentTime nurseId messageId message ] + [-- @todo: + -- markMessageReadAction currentTime nurseId messageId message + ] in ( { model | expandedMessages = EverySet.remove messageId model.expandedMessages @@ -297,9 +302,10 @@ update currentTime currentDate msg model = , messageOptionsDialogState = Nothing } , Cmd.none - , [ Backend.ResilienceMessage.Model.UpdateMessage messageId { message | isFavorite = not message.isFavorite } - |> Backend.Model.MsgResilienceMessage nurseId - |> App.Model.MsgIndexedDb + , [-- @todo: + -- Backend.ResilienceMessage.Model.UpdateMessage messageId { message | isFavorite = not message.isFavorite } + -- |> Backend.Model.MsgResilienceMessage nurseId + -- |> App.Model.MsgIndexedDb ] ) @@ -310,13 +316,14 @@ update currentTime currentDate msg model = } , Cmd.none , -- Marking message as read, and setting reminder time in X hours. - [ Backend.ResilienceMessage.Model.UpdateMessage messageId - { message - | nextReminder = Just <| Time.Extra.add Time.Extra.Hour hours Time.utc currentTime - , timeRead = Just currentTime - } - |> Backend.Model.MsgResilienceMessage nurseId - |> App.Model.MsgIndexedDb + [-- @todo: + -- Backend.ResilienceMessage.Model.UpdateMessage messageId + -- { message + -- | nextReminder = Just <| Time.Extra.add Time.Extra.Hour hours Time.utc currentTime + -- , timeRead = Just currentTime + -- } + -- |> Backend.Model.MsgResilienceMessage nurseId + -- |> App.Model.MsgIndexedDb ] ) diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 01e035f28d..8c07869139 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -5,7 +5,7 @@ import Backend.Entities exposing (..) import Backend.Model exposing (ModelIndexedDb) import Backend.Nurse.Model exposing (Nurse) import Backend.ResilienceMessage.Model exposing (ResilienceMessage) -import Backend.ResilienceMessage.Utils exposing (generateEmptyMessagesByProgramStartDate) +import Backend.ResilienceMessage.Utils exposing (generateEmptyMessages, generateEmptyMessagesByProgramStartDate) import Backend.ResilienceSurvey.Model exposing (ResilienceSurveyQuestion(..)) import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) @@ -22,6 +22,36 @@ monthlySurveyQuestions = ] +generateInboxMessages : NurseId -> NominalDate -> NominalDate -> Dict String ResilienceMessage -> Dict String ResilienceMessage +generateInboxMessages nurseId currentDate programStartDate recordedMessage = + generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate + |> Dict.foldl + (\key value accum -> + Dict.get key recordedMessage + |> Maybe.map + (\recordedValue -> + Dict.insert key recordedValue accum + ) + |> Maybe.withDefault (Dict.insert key value accum) + ) + Dict.empty + + +resolveNumberOfUnreadMessages : Time.Posix -> NurseId -> NominalDate -> Nurse -> Int +resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse = + Maybe.map + (\programStartDate -> + generateInboxMessages nurseId currentDate programStartDate nurse.resilienceMessages + |> Dict.filter (\_ message -> isMessageUnread currentTime message) + ) + nurse.resilienceProgramStartDate + |> Maybe.withDefault + (generateEmptyMessages nurseId + |> Dict.filter (\_ message -> message.displayDay == 0) + ) + |> Dict.size + + isMessageUnread : Time.Posix -> ResilienceMessage -> Bool isMessageUnread currentTime message = case message.timeRead of @@ -46,26 +76,3 @@ isMessageUnread currentTime message = |> -- No reminder set but read time was set => -- messages was read. Maybe.withDefault False - - -generateInboxMessages : NurseId -> NominalDate -> NominalDate -> Dict String ResilienceMessage -> Dict String ResilienceMessage -generateInboxMessages nurseId currentDate programStartDate recordedMessage = - generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate - |> Dict.foldl - (\key value accum -> - Dict.get key recordedMessage - |> Maybe.map - (\recordedValue -> - Dict.insert key recordedValue accum - ) - |> Maybe.withDefault (Dict.insert key value accum) - ) - Dict.empty - - -resolveInboxMessagesProgramNotStarted : NominalDate -> NurseId -> ModelIndexedDb -> Dict ResilienceMessageId ResilienceMessage -resolveInboxMessagesProgramNotStarted currentDate nurseId db = - Dict.get nurseId db.resilienceMessagesByNurse - |> Maybe.andThen RemoteData.toMaybe - |> Maybe.map (Dict.filter (\_ message -> message.displayDay == 0)) - |> Maybe.withDefault Dict.empty diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 8d94ce96d6..4fbbbd043d 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -49,18 +49,8 @@ view language currentTime nurseId nurse db model = currentDate = fromLocalDateTime currentTime - emptyMessages = - generateEmptyMessages nurseId - numberOfUnreadMessages = - Maybe.map - (\programStartDate -> - generateInboxMessages nurseId currentDate programStartDate nurse.resilienceMessages - |> Dict.filter (\_ message -> isMessageUnread currentTime message) - ) - nurse.resilienceProgramStartDate - |> Maybe.withDefault (Dict.filter (\_ message -> message.displayDay == 0) emptyMessages) - |> Dict.size + resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse header = div [ class "ui basic head segment" ] @@ -453,7 +443,7 @@ viewTabs language model = ++ [ scrollRightButton ] -viewResilienceMessage : Language -> NurseId -> Nurse -> Model -> ( String, ResilienceMessage ) -> Html Msg +viewResilienceMessage : Language -> NurseId -> Nurse -> Model -> ( ResilienceMessageNEWId, ResilienceMessage ) -> Html Msg viewResilienceMessage language nurseId nurse model ( messageId, message ) = let ( extraClass, ( head, body ) ) = diff --git a/client/src/elm/Pages/PinCode/View.elm b/client/src/elm/Pages/PinCode/View.elm index 65d619cf91..abd05c2eee 100644 --- a/client/src/elm/Pages/PinCode/View.elm +++ b/client/src/elm/Pages/PinCode/View.elm @@ -276,7 +276,7 @@ viewLoggedInContent language currentTime features nurseId nurse ( healthCenterId viewCardFunc = if activity == MenuWellbeing then - resolveNumberOfUnreadMessages currentTime currentDate nurseId nurse db + resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse |> activityCardWithCounter else @@ -451,7 +451,7 @@ resilienceNotificationDialog language currentTime currentDate nurseId nurse db m if notificationTimeReached && isJust nurse.resilienceProgramStartDate then let numberOfUnreadMessages = - resolveNumberOfUnreadMessages currentTime currentDate nurseId nurse db + resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse in if numberOfUnreadMessages > 0 then Just <| diff --git a/client/src/elm/Pages/Wellbeing/View.elm b/client/src/elm/Pages/Wellbeing/View.elm index 7c245c99cd..7a2ae545a5 100644 --- a/client/src/elm/Pages/Wellbeing/View.elm +++ b/client/src/elm/Pages/Wellbeing/View.elm @@ -21,7 +21,7 @@ view language currentTime nurseId nurse db model = fromLocalDateTime currentTime numberOfUnreadMessages = - resolveNumberOfUnreadMessages currentTime currentDate nurseId nurse db + resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse header = div [ class "ui basic head segment" ] From e1ea7a1952b9fb1afe20c4b4fde2d2b2afba45fa Mon Sep 17 00:00:00 2001 From: anvmn Date: Mon, 13 May 2024 11:14:11 +0300 Subject: [PATCH 10/63] Use messages on nurse for presentation and updates [ci skip] --- .../src/elm/Pages/MessagingCenter/Model.elm | 8 +- .../src/elm/Pages/MessagingCenter/Update.elm | 97 +++++++++++-------- client/src/elm/Pages/MessagingCenter/View.elm | 28 +++--- 3 files changed, 79 insertions(+), 54 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Model.elm b/client/src/elm/Pages/MessagingCenter/Model.elm index 02276d5985..85e6c03310 100644 --- a/client/src/elm/Pages/MessagingCenter/Model.elm +++ b/client/src/elm/Pages/MessagingCenter/Model.elm @@ -107,8 +107,8 @@ type Msg | SetSurveyScoreDialogState (Maybe SurveyScoreDialogState) | SetActiveTab MessagingTab | ScrollTab Int - | ResilienceMessageClicked NurseId ResilienceMessageNEWId ResilienceMessage Bool + | ResilienceMessageClicked ResilienceMessageNEWId NurseId Nurse Bool | SetMessageOptionsDialogState (Maybe MessageOptionsDialogState) - | ToggleMessageRead NurseId ResilienceMessageNEWId ResilienceMessage Bool - | ToggleMessageFavorite NurseId ResilienceMessageNEWId ResilienceMessage - | ScheduleMessageReminder Int NurseId ResilienceMessageNEWId ResilienceMessage + | ToggleMessageRead ResilienceMessageNEWId NurseId Nurse Bool + | ToggleMessageFavorite ResilienceMessageNEWId NurseId Nurse + | ScheduleMessageReminder Int ResilienceMessageNEWId NurseId Nurse diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index ae088626bd..78f2993a0a 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -4,7 +4,7 @@ import App.Model import AssocList as Dict import Backend.Entities exposing (..) import Backend.Model -import Backend.Nurse.Model +import Backend.Nurse.Model exposing (Nurse) import Backend.Nurse.Utils exposing (resilienceRoleFromString) import Backend.Person.Utils exposing @@ -236,15 +236,13 @@ update currentTime currentDate msg model = , [] ) - ResilienceMessageClicked nurseId messageId message updateTimeRead -> + ResilienceMessageClicked messageId nurseId nurse updateTimeRead -> let ( updatedModel, msgs ) = if EverySet.member messageId model.expandedMessages then ( { model | expandedMessages = EverySet.remove messageId model.expandedMessages } , if updateTimeRead then - [-- @todo: - -- markMessageReadAction currentTime nurseId messageId message - ] + markMessageReadAction currentTime messageId nurseId nurse else [] @@ -266,27 +264,25 @@ update currentTime currentDate msg model = , [] ) - ToggleMessageRead nurseId messageId message isRead -> + ToggleMessageRead messageId nurseId nurse isRead -> let action = if isRead then -- To mark message as unread, we set reminder to current time, -- and message read time to one second before current time. -- In essence, scheduling message reminder to right now. - [-- @todo: - -- Backend.ResilienceMessage.Model.UpdateMessage messageId - -- { message - -- | nextReminder = Just currentTime - -- , timeRead = Just <| Time.Extra.add Time.Extra.Second -1 Time.utc currentTime - -- } - -- |> Backend.Model.MsgResilienceMessage nurseId - -- |> App.Model.MsgIndexedDb - ] + updateMessageAction messageId + nurseId + nurse + (\message -> + { message + | nextReminder = Just currentTime + , timeRead = Just <| Time.Extra.add Time.Extra.Second -1 Time.utc currentTime + } + ) else - [-- @todo: - -- markMessageReadAction currentTime nurseId messageId message - ] + markMessageReadAction currentTime messageId nurseId nurse in ( { model | expandedMessages = EverySet.remove messageId model.expandedMessages @@ -296,40 +292,63 @@ update currentTime currentDate msg model = , action ) - ToggleMessageFavorite nurseId messageId message -> + ToggleMessageFavorite messageId nurseId nurse -> ( { model | expandedMessages = EverySet.remove messageId model.expandedMessages , messageOptionsDialogState = Nothing } , Cmd.none - , [-- @todo: - -- Backend.ResilienceMessage.Model.UpdateMessage messageId { message | isFavorite = not message.isFavorite } - -- |> Backend.Model.MsgResilienceMessage nurseId - -- |> App.Model.MsgIndexedDb - ] + , updateMessageAction messageId + nurseId + nurse + (\message -> { message | isFavorite = not message.isFavorite }) ) - ScheduleMessageReminder hours nurseId messageId message -> + ScheduleMessageReminder hours messageId nurseId nurse -> ( { model | expandedMessages = EverySet.remove messageId model.expandedMessages , messageOptionsDialogState = Nothing } , Cmd.none , -- Marking message as read, and setting reminder time in X hours. - [-- @todo: - -- Backend.ResilienceMessage.Model.UpdateMessage messageId - -- { message - -- | nextReminder = Just <| Time.Extra.add Time.Extra.Hour hours Time.utc currentTime - -- , timeRead = Just currentTime - -- } - -- |> Backend.Model.MsgResilienceMessage nurseId - -- |> App.Model.MsgIndexedDb - ] + updateMessageAction messageId + nurseId + nurse + (\message -> + { message + | nextReminder = Just <| Time.Extra.add Time.Extra.Hour hours Time.utc currentTime + , timeRead = Just currentTime + } + ) + ) + + +updateMessageAction : ResilienceMessageNEWId -> NurseId -> Nurse -> (ResilienceMessage -> ResilienceMessage) -> List App.Model.Msg +updateMessageAction messageId nurseId nurse updateFunc = + Dict.get messageId nurse.resilienceMessages + |> Maybe.map + (\message -> + let + updatedNurse = + { nurse + | resilienceMessages = + Dict.insert + messageId + (updateFunc message) + nurse.resilienceMessages + } + in + [ Backend.Nurse.Model.UpdateNurse nurseId updatedNurse + |> Backend.Model.MsgNurse nurseId + |> App.Model.MsgIndexedDb + ] ) + |> Maybe.withDefault [] -markMessageReadAction : Time.Posix -> NurseId -> ResilienceMessageId -> ResilienceMessage -> App.Model.Msg -markMessageReadAction currentTime nurseId messageId message = - Backend.ResilienceMessage.Model.UpdateMessage messageId { message | timeRead = Just currentTime } - |> Backend.Model.MsgResilienceMessage nurseId - |> App.Model.MsgIndexedDb +markMessageReadAction : Time.Posix -> ResilienceMessageNEWId -> NurseId -> Nurse -> List App.Model.Msg +markMessageReadAction currentTime messageId nurseId nurse = + updateMessageAction messageId + nurseId + nurse + (\message -> { message | timeRead = Just currentTime }) diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 4fbbbd043d..895512c693 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -312,13 +312,18 @@ surveyScoreDialog language = viewMessagingCenter : Language -> Time.Posix -> NominalDate -> NominalDate -> NurseId -> Nurse -> ModelIndexedDb -> Model -> Html Msg -viewMessagingCenter language currentTime currentDate programStartDate nurseId nurse db model = +viewMessagingCenter language currentTime currentDate programStartDate nurseId nurse_ db model = let - messages = - generateInboxMessages nurseId currentDate programStartDate nurse.resilienceMessages + nurse = + -- Genrate full list of messages that are supposed to + -- appear at inbox on current date. + { nurse_ + | resilienceMessages = + generateInboxMessages nurseId currentDate programStartDate nurse_.resilienceMessages + } ( unread, read ) = - Dict.toList messages + Dict.toList nurse.resilienceMessages |> List.partition (\( _, message ) -> case message.timeRead of @@ -356,7 +361,7 @@ viewMessagingCenter language currentTime currentDate programStartDate nurseId nu List.map viewMessage unread TabFavorites -> - Dict.toList messages + Dict.toList nurse.resilienceMessages |> List.filter (Tuple.second >> .isFavorite) |> List.map viewMessage @@ -380,7 +385,7 @@ viewMessagingCenter language currentTime currentDate programStartDate nurseId nu , div [ class "ui report unstackable items" ] content , viewModal <| - Maybe.map (messageOptionsDialog language currentTime currentDate nurseId model.activeTab) + Maybe.map (messageOptionsDialog language currentTime currentDate nurseId nurse model.activeTab) model.messageOptionsDialogState ] @@ -490,7 +495,7 @@ viewResilienceMessage language nurseId nurse model ( messageId, message ) = model.activeTab == TabUnread messageClickedAction = - ResilienceMessageClicked nurseId messageId message updateTimeRead + ResilienceMessageClicked messageId nurseId nurse updateTimeRead sentDate = Maybe.map (Date.add Days message.displayDay) nurse.resilienceProgramStartDate @@ -932,10 +937,11 @@ messageOptionsDialog : -> Time.Posix -> NominalDate -> NurseId + -> Nurse -> MessagingTab -> MessageOptionsDialogState -> Html Msg -messageOptionsDialog language currentTime currentDate nurseId tab state = +messageOptionsDialog language currentTime currentDate nurseId nurse tab state = case state of MessageOptionsStateMain ( messageId, message ) -> let @@ -953,7 +959,7 @@ messageOptionsDialog language currentTime currentDate nurseId tab state = in [ button [ class "ui fluid button cyan" - , onClick <| ToggleMessageRead nurseId messageId message isRead + , onClick <| ToggleMessageRead messageId nurseId nurse isRead ] [ img [ src "assets/images/envelope.svg" ] [] , text <| translate language <| Translate.ReadToggle isRead @@ -963,7 +969,7 @@ messageOptionsDialog language currentTime currentDate nurseId tab state = favoriteUnfavorite = [ button [ class "ui fluid button purple" - , onClick <| ToggleMessageFavorite nurseId messageId message + , onClick <| ToggleMessageFavorite messageId nurseId nurse ] [ img [ src "assets/images/star.svg" ] [] , text <| translate language <| Translate.FavoriteToggle message.isFavorite @@ -998,7 +1004,7 @@ messageOptionsDialog language currentTime currentDate nurseId tab state = buttonForView hours = button [ class "ui fluid button primary" - , onClick <| ScheduleMessageReminder hours nurseId messageId message + , onClick <| ScheduleMessageReminder hours messageId nurseId nurse ] [ text <| translate language <| Translate.HoursSinglePlural hours ] From 0be418a35ec58177a2f33a9cbe40837ed9dd111c Mon Sep 17 00:00:00 2001 From: anvmn Date: Mon, 13 May 2024 11:46:11 +0300 Subject: [PATCH 11/63] Drop Resilience Messages CT related code [ci skip] --- client/src/elm/Backend/Decoder.elm | 3 - client/src/elm/Backend/Endpoints.elm | 8 - client/src/elm/Backend/Fetch.elm | 8 - client/src/elm/Backend/Model.elm | 9 - .../elm/Backend/ResilienceMessage/Model.elm | 5 - .../elm/Backend/ResilienceMessage/Update.elm | 34 -- client/src/elm/Backend/Update.elm | 50 --- .../src/elm/Pages/MessagingCenter/Fetch.elm | 3 +- client/src/elm/Pages/PinCode/Fetch.elm | 5 - client/src/elm/SyncManager/Decoder.elm | 3 - client/src/elm/SyncManager/Model.elm | 1 - client/src/elm/SyncManager/Utils.elm | 9 - client/src/elm/SyncManager/View.elm | 3 - client/src/js/nodes.js | 4 +- client/src/js/sw.js | 1 - server/hedley/hedley.install | 7 + .../hedley_resilience.features.field_base.inc | 137 ------- ...ley_resilience.features.field_instance.inc | 366 ------------------ .../hedley_resilience.features.inc | 8 - ...ey_resilience.features.user_permission.inc | 48 --- .../hedley_resilience/hedley_resilience.info | 28 -- .../hedley_resilience.module | 188 --------- .../hedley_resilience.strongarm.inc | 78 ---- .../hedley_restful/hedley_restful.module | 1 - .../HedleyRestfulResilienceMessage.class.php | 103 ----- .../restful/node/resilience-message.inc | 17 - 26 files changed, 10 insertions(+), 1117 deletions(-) delete mode 100644 client/src/elm/Backend/ResilienceMessage/Update.elm delete mode 100644 server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulResilienceMessage.class.php delete mode 100644 server/hedley/modules/custom/hedley_restful/plugins/restful/node/resilience-message.inc diff --git a/client/src/elm/Backend/Decoder.elm b/client/src/elm/Backend/Decoder.elm index 5078c04d2f..e6595ab2df 100644 --- a/client/src/elm/Backend/Decoder.elm +++ b/client/src/elm/Backend/Decoder.elm @@ -462,9 +462,6 @@ decodeRevision = "relationship" -> decodeWithUuid RelationshipRevision decodeRelationship - "resilience_message" -> - decodeWithUuid ResilienceMessageRevision decodeResilienceMessage - "resilience_survey" -> decodeWithUuid ResilienceSurveyRevision decodeResilienceSurvey diff --git a/client/src/elm/Backend/Endpoints.elm b/client/src/elm/Backend/Endpoints.elm index c51191719b..0ad4f21375 100644 --- a/client/src/elm/Backend/Endpoints.elm +++ b/client/src/elm/Backend/Endpoints.elm @@ -57,7 +57,6 @@ import Backend.Relationship.Decoder exposing (decodeRelationship) import Backend.Relationship.Encoder exposing (encodeRelationship) import Backend.Relationship.Model exposing (Relationship) import Backend.ResilienceMessage.Decoder exposing (decodeResilienceMessage) -import Backend.ResilienceMessage.Encoder exposing (encodeResilienceMessage) import Backend.ResilienceMessage.Model exposing (ResilienceMessage) import Backend.ResilienceSurvey.Decoder exposing (decodeResilienceSurvey) import Backend.ResilienceSurvey.Encoder exposing (encodeResilienceSurvey) @@ -1254,13 +1253,6 @@ resilienceSurveyEndpoint = |> withParamsEncoder encodeByNurseParam -resilienceMessageEndpoint : ReadWriteEndPoint Error ResilienceMessageId ResilienceMessage ResilienceMessage (Maybe NurseId) -resilienceMessageEndpoint = - swEndpoint "nodes/resilience_message" decodeResilienceMessage - |> withValueEncoder (object << encodeResilienceMessage) - |> withParamsEncoder encodeByNurseParam - - encodeByNurseParam : Maybe NurseId -> List ( String, String ) encodeByNurseParam params = case params of diff --git a/client/src/elm/Backend/Fetch.elm b/client/src/elm/Backend/Fetch.elm index 8fbbf1ab26..bc2975ac7b 100644 --- a/client/src/elm/Backend/Fetch.elm +++ b/client/src/elm/Backend/Fetch.elm @@ -461,11 +461,6 @@ shouldFetch currentTime model msg = |> Maybe.withDefault NotAsked |> isNotAsked - FetchResilienceMessagesForNurse id -> - Dict.get id model.resilienceMessagesByNurse - |> Maybe.withDefault NotAsked - |> isNotAsked - -- For other messages, we answer false. _ -> False @@ -638,9 +633,6 @@ forget msg model = FetchResilienceSurveysForNurse id -> { model | resilienceSurveysByNurse = Dict.remove id model.resilienceSurveysByNurse } - FetchResilienceMessagesForNurse id -> - { model | resilienceMessagesByNurse = Dict.remove id model.resilienceMessagesByNurse } - -- For other messages, we do nothing. _ -> model diff --git a/client/src/elm/Backend/Model.elm b/client/src/elm/Backend/Model.elm index 73da00a1f5..bbc55dae62 100644 --- a/client/src/elm/Backend/Model.elm +++ b/client/src/elm/Backend/Model.elm @@ -44,7 +44,6 @@ import Backend.Person.Model exposing (Initiator, PatchPersonInitator, Person) import Backend.PmtctParticipant.Model exposing (PmtctParticipant) import Backend.PrenatalEncounter.Model exposing (PrenatalEncounter, PrenatalEncounterPostCreateDestination) import Backend.Relationship.Model exposing (MyRelationship, Relationship) -import Backend.ResilienceMessage.Model exposing (ResilienceMessage) import Backend.ResilienceSurvey.Model exposing (ResilienceSurvey) import Backend.Session.Model exposing (EditableSession, ExpectedParticipants, Session) import Backend.StockUpdate.Model exposing (StockManagementData) @@ -105,7 +104,6 @@ type alias ModelIndexedDb = , traceContactRequests : Dict AcuteIllnessTraceContactId Backend.TraceContact.Model.Model , nurseRequests : Dict NurseId Backend.Nurse.Model.Model , resilienceSurveyRequests : Dict NurseId Backend.ResilienceSurvey.Model.Model - , resilienceMessageRequests : Dict NurseId Backend.ResilienceMessage.Model.Model , stockUpdateRequests : Dict NurseId Backend.StockUpdate.Model.Model , educationSessionRequests : Dict EducationSessionId Backend.EducationSession.Model.Model @@ -177,7 +175,6 @@ type alias ModelIndexedDb = -- Resilience. , resilienceSurveysByNurse : Dict NurseId (WebData (Dict ResilienceSurveyId ResilienceSurvey)) - , resilienceMessagesByNurse : Dict NurseId (WebData (Dict ResilienceMessageId ResilienceMessage)) -- Stock Management. , stockUpdates : WebData (Dict StockUpdateId StockUpdate) @@ -266,7 +263,6 @@ emptyModelIndexedDb = , individualEncounterParticipantRequests = Dict.empty , nurseRequests = Dict.empty , resilienceSurveyRequests = Dict.empty - , resilienceMessageRequests = Dict.empty , stockUpdateRequests = Dict.empty , individualParticipants = Dict.empty , individualParticipantsByPerson = Dict.empty @@ -278,7 +274,6 @@ emptyModelIndexedDb = , computedDashboards = Dict.empty , computedDashboardLastFetched = Time.millisToPosix 0 , resilienceSurveysByNurse = Dict.empty - , resilienceMessagesByNurse = Dict.empty , stockUpdates = NotAsked , educationSessionsByPerson = Dict.empty , postPerson = NotAsked @@ -386,7 +381,6 @@ type MsgIndexedDb | FetchPrenatalEncountersForParticipants (List IndividualEncounterParticipantId) | FetchPrenatalMeasurements PrenatalEncounterId | FetchRelationshipsForPerson PersonId - | FetchResilienceMessagesForNurse NurseId | FetchResilienceSurveysForNurse NurseId | FetchSession SessionId | FetchSessionsByClinic ClinicId @@ -460,7 +454,6 @@ type MsgIndexedDb | HandleFetchedPrenatalEncountersForParticipants (WebData (Dict IndividualEncounterParticipantId (Dict PrenatalEncounterId PrenatalEncounter))) | HandleFetchedPrenatalMeasurements PrenatalEncounterId (WebData PrenatalMeasurements) | HandleFetchedRelationshipsForPerson PersonId (WebData (Dict RelationshipId MyRelationship)) - | HandleFetchedResilienceMessagesForNurse NurseId (WebData (Dict ResilienceMessageId ResilienceMessage)) | HandleFetchedResilienceSurveysForNurse NurseId (WebData (Dict ResilienceSurveyId ResilienceSurvey)) | HandleFetchedSession SessionId (WebData Session) | HandleFetchedSessionsByClinic ClinicId (WebData (Dict SessionId Session)) @@ -534,7 +527,6 @@ type MsgIndexedDb | MsgIndividualEncounterParticipant IndividualEncounterParticipantId Backend.IndividualEncounterParticipant.Model.Msg | MsgNurse NurseId Backend.Nurse.Model.Msg | MsgResilienceSurvey NurseId Backend.ResilienceSurvey.Model.Msg - | MsgResilienceMessage NurseId Backend.ResilienceMessage.Model.Msg | MsgStockUpdate NurseId Backend.StockUpdate.Model.Msg | ResetFailedToFetchAuthorities @@ -685,7 +677,6 @@ type Revision | PrenatalTetanusImmunisationRevision PrenatalTetanusImmunisationId PrenatalTetanusImmunisation | PrenatalUrineDipstickTestRevision PrenatalUrineDipstickTestId PrenatalUrineDipstickTest | RelationshipRevision RelationshipId Relationship - | ResilienceMessageRevision ResilienceMessageId ResilienceMessage | ResilienceSurveyRevision ResilienceSurveyId ResilienceSurvey | SendToHCRevision SendToHCId SendToHC | SessionRevision SessionId Session diff --git a/client/src/elm/Backend/ResilienceMessage/Model.elm b/client/src/elm/Backend/ResilienceMessage/Model.elm index 18dd7921a1..210edf25e3 100644 --- a/client/src/elm/Backend/ResilienceMessage/Model.elm +++ b/client/src/elm/Backend/ResilienceMessage/Model.elm @@ -45,8 +45,3 @@ type alias Model = emptyModel : Model emptyModel = { updateMessage = NotAsked } - - -type Msg - = UpdateMessage ResilienceMessageId ResilienceMessage - | HandleUpdatedMessage (WebData ()) diff --git a/client/src/elm/Backend/ResilienceMessage/Update.elm b/client/src/elm/Backend/ResilienceMessage/Update.elm deleted file mode 100644 index 35a0fb6b91..0000000000 --- a/client/src/elm/Backend/ResilienceMessage/Update.elm +++ /dev/null @@ -1,34 +0,0 @@ -module Backend.ResilienceMessage.Update exposing (update) - -import App.Model -import App.Utils exposing (triggerRollbarOnFailure) -import Backend.Endpoints exposing (..) -import Backend.Entities exposing (..) -import Backend.ResilienceMessage.Model exposing (..) -import Backend.Utils exposing (sw) -import Gizra.NominalDate exposing (NominalDate) -import RemoteData exposing (RemoteData(..)) -import Restful.Endpoint exposing (toCmd, withoutDecoder) - - -update : NominalDate -> Msg -> Model -> ( Model, Cmd Msg, List App.Model.Msg ) -update currentDate msg model = - case msg of - UpdateMessage messageId message -> - updateMessage currentDate messageId message model - - HandleUpdatedMessage data -> - ( { model | updateMessage = data } - , Cmd.none - , triggerRollbarOnFailure data - ) - - -updateMessage : NominalDate -> ResilienceMessageId -> ResilienceMessage -> Model -> ( Model, Cmd Msg, List App.Model.Msg ) -updateMessage currentDate messageId message model = - ( { model | updateMessage = Loading } - , sw.patchFull resilienceMessageEndpoint messageId message - |> withoutDecoder - |> toCmd (RemoteData.fromResult >> HandleUpdatedMessage) - , [] - ) diff --git a/client/src/elm/Backend/Update.elm b/client/src/elm/Backend/Update.elm index db20605f41..e29d7446e4 100644 --- a/client/src/elm/Backend/Update.elm +++ b/client/src/elm/Backend/Update.elm @@ -72,7 +72,6 @@ import Backend.Relationship.Encoder exposing (encodeRelationshipChanges) import Backend.Relationship.Model exposing (MyRelatedBy(..), MyRelationship, RelatedBy(..)) import Backend.Relationship.Utils exposing (toMyRelationship, toRelationship) import Backend.ResilienceMessage.Model -import Backend.ResilienceMessage.Update import Backend.ResilienceSurvey.Model import Backend.ResilienceSurvey.Update import Backend.Session.Model exposing (CheckedIn, EditableSession, OfflineSession) @@ -1802,19 +1801,6 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h , [] ) - FetchResilienceMessagesForNurse id -> - ( { model | resilienceMessagesByNurse = Dict.insert id Loading model.resilienceMessagesByNurse } - , sw.select resilienceMessageEndpoint (Just id) - |> toCmd (RemoteData.fromResult >> RemoteData.map (.items >> Dict.fromList) >> HandleFetchedResilienceMessagesForNurse id) - , [] - ) - - HandleFetchedResilienceMessagesForNurse id data -> - ( { model | resilienceMessagesByNurse = Dict.insert id data model.resilienceMessagesByNurse } - , Cmd.none - , [] - ) - FetchVillages -> ( { model | villages = Loading } , sw.select villageEndpoint () @@ -3884,20 +3870,6 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h , appMsgs ) - MsgResilienceMessage messageNurseId subMsg -> - let - requests = - Dict.get messageNurseId model.resilienceMessageRequests - |> Maybe.withDefault Backend.ResilienceMessage.Model.emptyModel - - ( subModel, subCmd, appMsgs ) = - Backend.ResilienceMessage.Update.update currentDate subMsg requests - in - ( { model | resilienceMessageRequests = Dict.insert messageNurseId subModel model.resilienceMessageRequests } - , Cmd.map (MsgResilienceMessage messageNurseId) subCmd - , appMsgs - ) - MsgStockUpdate updateNurseId subMsg -> let requests = @@ -6096,28 +6068,6 @@ handleRevision currentDate healthCenterId villageId revision (( model, recalc ) , True ) - ResilienceMessageRevision uuid data -> - let - nurseMessages = - Dict.get data.nurse model.resilienceMessagesByNurse - |> Maybe.andThen RemoteData.toMaybe - - resilienceMessagesByNurse = - Maybe.map - (\messages -> - let - updatedMessages = - Dict.insert uuid data messages - in - Dict.insert data.nurse (Success updatedMessages) model.resilienceMessagesByNurse - ) - nurseMessages - |> Maybe.withDefault (Dict.insert data.nurse (Success (Dict.singleton uuid data)) model.resilienceMessagesByNurse) - in - ( { model | resilienceMessagesByNurse = resilienceMessagesByNurse } - , recalc - ) - ResilienceSurveyRevision uuid data -> let nurseSurveys = diff --git a/client/src/elm/Pages/MessagingCenter/Fetch.elm b/client/src/elm/Pages/MessagingCenter/Fetch.elm index c1f0e00223..839a7f7ca0 100644 --- a/client/src/elm/Pages/MessagingCenter/Fetch.elm +++ b/client/src/elm/Pages/MessagingCenter/Fetch.elm @@ -7,5 +7,4 @@ import Gizra.NominalDate exposing (NominalDate) fetch : NominalDate -> NurseId -> ModelIndexedDb -> List MsgIndexedDb fetch currentDate nurseId db = - [ FetchResilienceMessagesForNurse nurseId - ] + [] diff --git a/client/src/elm/Pages/PinCode/Fetch.elm b/client/src/elm/Pages/PinCode/Fetch.elm index 8886018fe2..a5692e5bc2 100644 --- a/client/src/elm/Pages/PinCode/Fetch.elm +++ b/client/src/elm/Pages/PinCode/Fetch.elm @@ -10,8 +10,3 @@ fetch nurseId = , FetchClinics , FetchVillages ] - ++ -- Need to fetch resilience messages to be able to - -- display number of unread messages on Wellbeing activity. - (Maybe.map (FetchResilienceMessagesForNurse >> List.singleton) nurseId - |> Maybe.withDefault [] - ) diff --git a/client/src/elm/SyncManager/Decoder.elm b/client/src/elm/SyncManager/Decoder.elm index 6054e9f327..0907a6e91f 100644 --- a/client/src/elm/SyncManager/Decoder.elm +++ b/client/src/elm/SyncManager/Decoder.elm @@ -355,9 +355,6 @@ decodeBackendGeneralEntity uuidDecoder identifierDecoder = "village" -> doDecode Backend.Village.Decoder.decodeVillage BackendGeneralVillage - "resilience_message" -> - doDecode Backend.ResilienceMessage.Decoder.decodeResilienceMessage BackendGeneralResilienceMessage - "resilience_survey" -> doDecode Backend.ResilienceSurvey.Decoder.decodeResilienceSurvey BackendGeneralResilienceSurvey diff --git a/client/src/elm/SyncManager/Model.elm b/client/src/elm/SyncManager/Model.elm index ba2bc3813b..705438b370 100644 --- a/client/src/elm/SyncManager/Model.elm +++ b/client/src/elm/SyncManager/Model.elm @@ -52,7 +52,6 @@ type BackendGeneralEntity | BackendGeneralNurse (BackendEntity Nurse) | BackendGeneralParticipantForm (BackendEntity ParticipantForm) | BackendGeneralVillage (BackendEntity Village) - | BackendGeneralResilienceMessage (BackendEntity ResilienceMessage) | BackendGeneralResilienceSurvey (BackendEntity ResilienceSurvey) diff --git a/client/src/elm/SyncManager/Utils.elm b/client/src/elm/SyncManager/Utils.elm index 57b656e70d..2048ba8450 100644 --- a/client/src/elm/SyncManager/Utils.elm +++ b/client/src/elm/SyncManager/Utils.elm @@ -438,9 +438,6 @@ getBackendGeneralEntityIdentifier backendGeneralEntity = BackendGeneralVillage identifier -> getIdentifier identifier "village" - BackendGeneralResilienceMessage identifier -> - getIdentifier identifier "resilience_message" - BackendGeneralResilienceSurvey identifier -> getIdentifier identifier "resilience_survey" @@ -1216,9 +1213,6 @@ encodeBackendGeneralEntity backendGeneralEntity = BackendGeneralVillage identifier -> encode Backend.Village.Encoder.encodeVillage identifier - BackendGeneralResilienceMessage identifier -> - encode Backend.ResilienceMessage.Encoder.encodeResilienceMessage identifier - BackendGeneralResilienceSurvey identifier -> encode Backend.ResilienceSurvey.Encoder.encodeResilienceSurvey identifier @@ -2044,9 +2038,6 @@ backendGeneralEntityToRevision backendGeneralEntity = BackendGeneralVillage identifier -> VillageRevision (toEntityUuid identifier.uuid) identifier.entity - BackendGeneralResilienceMessage identifier -> - ResilienceMessageRevision (toEntityUuid identifier.uuid) identifier.entity - BackendGeneralResilienceSurvey identifier -> ResilienceSurveyRevision (toEntityUuid identifier.uuid) identifier.entity diff --git a/client/src/elm/SyncManager/View.elm b/client/src/elm/SyncManager/View.elm index d749340826..bee65178eb 100644 --- a/client/src/elm/SyncManager/View.elm +++ b/client/src/elm/SyncManager/View.elm @@ -246,9 +246,6 @@ viewGeneralEntity language backendGeneralEntity = BackendGeneralVillage identifier -> text <| "Village " ++ identifier.entity.name - BackendGeneralResilienceMessage identifier -> - text <| "Resilience Message " ++ identifier.uuid - BackendGeneralResilienceSurvey identifier -> text <| "Resilience Survey " ++ identifier.uuid ] diff --git a/client/src/js/nodes.js b/client/src/js/nodes.js index 50e94bb208..48dbd9146b 100644 --- a/client/src/js/nodes.js +++ b/client/src/js/nodes.js @@ -1035,9 +1035,9 @@ } } - // Resilience surveys and messages are pulled for a nurse, + // Resilience surveys are pulled for a nurse, // so we add criteria to filter by provided nurse ID. - if (type === 'resilience_survey' || type === 'resilience_message') { + if (type === 'resilience_survey') { var nurseId = params.get('nurse'); if (nurseId) { modifyQuery = modifyQuery.then(function () { diff --git a/client/src/js/sw.js b/client/src/js/sw.js index 10cf99a92c..3deb5036da 100644 --- a/client/src/js/sw.js +++ b/client/src/js/sw.js @@ -180,7 +180,6 @@ var tableForType = { prenatal_tetanus_immunisation: 'shards', prenatal_urine_dipstick_test: 'shards', relationship: 'shards', - resilience_message: 'nodes', resilience_survey: 'nodes', resource: 'shards', send_to_hc: 'shards', diff --git a/server/hedley/hedley.install b/server/hedley/hedley.install index fdee4cf08b..f15ea1df70 100644 --- a/server/hedley/hedley.install +++ b/server/hedley/hedley.install @@ -712,4 +712,11 @@ function hedley_update_7042() { */ function hedley_update_7043() { module_enable(['hedley_hiv']); +} + +/** + * Deletes Resilience Message content type. + */ +function hedley_update_7044() { + node_type_delete('resilience_message'); } \ No newline at end of file diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc index 67481939af..38deb6517f 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc @@ -11,111 +11,6 @@ function hedley_resilience_field_default_field_bases() { $field_bases = array(); - // Exported field_base: 'field_display_day'. - $field_bases['field_display_day'] = array( - 'active' => 1, - 'cardinality' => 1, - 'deleted' => 0, - 'entity_id_type' => NULL, - 'entity_types' => array(), - 'field_name' => 'field_display_day', - 'indexes' => array(), - 'locked' => 0, - 'module' => 'number', - 'settings' => array(), - 'translatable' => 0, - 'type' => 'number_integer', - ); - - // Exported field_base: 'field_favorite_message'. - $field_bases['field_favorite_message'] = array( - 'active' => 1, - 'cardinality' => 1, - 'deleted' => 0, - 'entity_id_type' => NULL, - 'entity_types' => array(), - 'field_name' => 'field_favorite_message', - 'indexes' => array( - 'value' => array( - 0 => 'value', - ), - ), - 'locked' => 0, - 'module' => 'list', - 'settings' => array( - 'allowed_values' => array( - 0 => 'No', - 1 => 'Yes', - ), - 'allowed_values_function' => '', - ), - 'translatable' => 0, - 'type' => 'list_boolean', - ); - - // Exported field_base: 'field_resilience_category'. - $field_bases['field_resilience_category'] = array( - 'active' => 1, - 'cardinality' => 1, - 'deleted' => 0, - 'entity_id_type' => NULL, - 'entity_types' => array(), - 'field_name' => 'field_resilience_category', - 'indexes' => array( - 'value' => array( - 0 => 'value', - ), - ), - 'locked' => 0, - 'module' => 'list', - 'settings' => array( - 'allowed_values' => array( - 'introduction' => 'Introduction', - 'growth' => 'Growth', - 'stress-management' => 'Stress Management', - 'mindfulness' => 'Mindfulness', - 'connecting' => 'Connecting', - 'self-care' => 'Self Care', - 'end-of-period' => 'End of Period', - ), - 'allowed_values_function' => '', - ), - 'translatable' => 0, - 'type' => 'list_text', - ); - - // Exported field_base: 'field_resilience_order'. - $field_bases['field_resilience_order'] = array( - 'active' => 1, - 'cardinality' => 1, - 'deleted' => 0, - 'entity_id_type' => NULL, - 'entity_types' => array(), - 'field_name' => 'field_resilience_order', - 'indexes' => array( - 'value' => array( - 0 => 'value', - ), - ), - 'locked' => 0, - 'module' => 'list', - 'settings' => array( - 'allowed_values' => array( - 1 => 1, - 2 => 2, - 3 => 3, - 4 => 4, - 5 => 5, - 6 => 6, - 7 => 7, - 8 => 8, - ), - 'allowed_values_function' => '', - ), - 'translatable' => 0, - 'type' => 'list_text', - ); - // Exported field_base: 'field_resilience_survey_signs'. $field_bases['field_resilience_survey_signs'] = array( 'active' => 1, @@ -191,37 +86,5 @@ function hedley_resilience_field_default_field_bases() { 'type' => 'list_text', ); - // Exported field_base: 'field_time_read'. - $field_bases['field_time_read'] = array( - 'active' => 1, - 'cardinality' => 1, - 'deleted' => 0, - 'entity_id_type' => NULL, - 'entity_types' => array(), - 'field_name' => 'field_time_read', - 'indexes' => array( - 'value' => array( - 0 => 'value', - ), - ), - 'locked' => 0, - 'module' => 'date', - 'settings' => array( - 'granularity' => array( - 'day' => 'day', - 'hour' => 'hour', - 'minute' => 'minute', - 'month' => 'month', - 'second' => 'second', - 'year' => 'year', - ), - 'timezone_db' => '', - 'todate' => '', - 'tz_handling' => 'none', - ), - 'translatable' => 0, - 'type' => 'datestamp', - ); - return $field_bases; } diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_instance.inc b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_instance.inc index da836add5e..a9318db5ea 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_instance.inc +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_instance.inc @@ -11,366 +11,6 @@ function hedley_resilience_field_default_field_instances() { $field_instances = array(); - // Exported field_instance: 'node-resilience_message-field_display_day'. - $field_instances['node-resilience_message-field_display_day'] = array( - 'bundle' => 'resilience_message', - 'default_value' => NULL, - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'number', - 'settings' => array( - 'decimal_separator' => '.', - 'prefix_suffix' => TRUE, - 'scale' => 0, - 'thousand_separator' => '', - ), - 'type' => 'number_integer', - 'weight' => 4, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_display_day', - 'label' => 'Display Day', - 'required' => 1, - 'settings' => array( - 'max' => '', - 'min' => '', - 'prefix' => '', - 'suffix' => '', - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 0, - 'module' => 'number', - 'settings' => array(), - 'type' => 'number', - 'weight' => 4, - ), - ); - - // Exported field_instance: 'node-resilience_message-field_favorite_message'. - $field_instances['node-resilience_message-field_favorite_message'] = array( - 'bundle' => 'resilience_message', - 'default_value' => array( - 0 => array( - 'value' => 0, - ), - ), - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'list', - 'settings' => array(), - 'type' => 'list_default', - 'weight' => 7, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_favorite_message', - 'label' => 'Favorite Message', - 'required' => 0, - 'settings' => array( - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'options', - 'settings' => array( - 'display_label' => 1, - ), - 'type' => 'options_onoff', - 'weight' => 7, - ), - ); - - // Exported field_instance: 'node-resilience_message-field_next_reminder'. - $field_instances['node-resilience_message-field_next_reminder'] = array( - 'bundle' => 'resilience_message', - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'date', - 'settings' => array( - 'custom_date_format' => '', - 'format_type' => 'long', - 'fromto' => 'both', - 'multiple_from' => '', - 'multiple_number' => '', - 'multiple_to' => '', - 'show_remaining_days' => FALSE, - ), - 'type' => 'date_default', - 'weight' => 6, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_next_reminder', - 'label' => 'Resilience Next Reminder', - 'required' => 0, - 'settings' => array( - 'default_value' => 'blank', - 'default_value2' => 'same', - 'default_value_code' => '', - 'default_value_code2' => '', - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'date', - 'settings' => array( - 'increment' => 1, - 'input_format' => 'm/d/Y - H:i:s', - 'input_format_custom' => '', - 'label_position' => 'above', - 'no_fieldset' => 0, - 'text_parts' => array(), - 'year_range' => '-3:+3', - ), - 'type' => 'date_text', - 'weight' => 6, - ), - ); - - // Exported field_instance: 'node-resilience_message-field_nurse'. - $field_instances['node-resilience_message-field_nurse'] = array( - 'bundle' => 'resilience_message', - 'default_value' => NULL, - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'entityreference', - 'settings' => array( - 'bypass_access' => FALSE, - 'link' => FALSE, - ), - 'type' => 'entityreference_label', - 'weight' => 2, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_nurse', - 'label' => 'Nurse', - 'required' => 1, - 'settings' => array( - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'entityreference', - 'settings' => array( - 'match_operator' => 'CONTAINS', - 'path' => '', - 'size' => 60, - ), - 'type' => 'entityreference_autocomplete', - 'weight' => 1, - ), - ); - - // Exported field_instance: - // 'node-resilience_message-field_resilience_category'. - $field_instances['node-resilience_message-field_resilience_category'] = array( - 'bundle' => 'resilience_message', - 'default_value' => NULL, - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'list', - 'settings' => array(), - 'type' => 'list_default', - 'weight' => 0, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_resilience_category', - 'label' => 'Resilience Category', - 'required' => 1, - 'settings' => array( - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'options', - 'settings' => array(), - 'type' => 'options_select', - 'weight' => 2, - ), - ); - - // Exported field_instance: 'node-resilience_message-field_resilience_order'. - $field_instances['node-resilience_message-field_resilience_order'] = array( - 'bundle' => 'resilience_message', - 'default_value' => NULL, - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'list', - 'settings' => array(), - 'type' => 'list_default', - 'weight' => 1, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_resilience_order', - 'label' => 'Resilience Order', - 'required' => 1, - 'settings' => array( - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'options', - 'settings' => array(), - 'type' => 'options_select', - 'weight' => 3, - ), - ); - - // Exported field_instance: 'node-resilience_message-field_time_read'. - $field_instances['node-resilience_message-field_time_read'] = array( - 'bundle' => 'resilience_message', - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'date', - 'settings' => array( - 'custom_date_format' => '', - 'format_type' => 'long', - 'fromto' => 'both', - 'multiple_from' => '', - 'multiple_number' => '', - 'multiple_to' => '', - 'show_remaining_days' => FALSE, - ), - 'type' => 'date_default', - 'weight' => 5, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_time_read', - 'label' => 'Time Read', - 'required' => 0, - 'settings' => array( - 'default_value' => 'blank', - 'default_value2' => 'same', - 'default_value_code' => '', - 'default_value_code2' => '', - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'date', - 'settings' => array( - 'increment' => 1, - 'input_format' => 'm/d/Y - H:i:s', - 'input_format_custom' => '', - 'label_position' => 'above', - 'no_fieldset' => 0, - 'text_parts' => array(), - 'year_range' => '-3:+3', - ), - 'type' => 'date_text', - 'weight' => 5, - ), - ); - - // Exported field_instance: 'node-resilience_message-field_uuid'. - $field_instances['node-resilience_message-field_uuid'] = array( - 'bundle' => 'resilience_message', - 'default_value' => NULL, - 'deleted' => 0, - 'description' => '', - 'display' => array( - 'default' => array( - 'label' => 'above', - 'module' => 'text', - 'settings' => array(), - 'type' => 'text_default', - 'weight' => 3, - ), - 'teaser' => array( - 'label' => 'above', - 'settings' => array(), - 'type' => 'hidden', - 'weight' => 0, - ), - ), - 'entity_type' => 'node', - 'field_name' => 'field_uuid', - 'label' => 'UUID', - 'required' => 0, - 'settings' => array( - 'text_processing' => 0, - 'user_register_form' => FALSE, - ), - 'widget' => array( - 'active' => 1, - 'module' => 'text', - 'settings' => array( - 'size' => 60, - ), - 'type' => 'text_textfield', - 'weight' => 8, - ), - ); - // Exported field_instance: 'node-resilience_survey-field_date_measured'. $field_instances['node-resilience_survey-field_date_measured'] = array( 'bundle' => 'resilience_survey', @@ -590,15 +230,9 @@ function hedley_resilience_field_default_field_instances() { // Translatables // Included for use with string extractors like potx. t('Date Measured'); - t('Display Day'); - t('Favorite Message'); t('Nurse'); - t('Resilience Category'); - t('Resilience Next Reminder'); - t('Resilience Order'); t('Resilience Survey Signs'); t('Resilience Survey Type'); - t('Time Read'); t('UUID'); return $field_instances; diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.inc b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.inc index 765b06f992..76384080d0 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.inc +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.inc @@ -19,14 +19,6 @@ function hedley_resilience_ctools_plugin_api($module = NULL, $api = NULL) { */ function hedley_resilience_node_info() { $items = array( - 'resilience_message' => array( - 'name' => t('Resilience Message'), - 'base' => 'node_content', - 'description' => '', - 'has_title' => '1', - 'title_label' => t('Title'), - 'help' => '', - ), 'resilience_survey' => array( 'name' => t('Resilience Survey'), 'base' => 'node_content', diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.user_permission.inc b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.user_permission.inc index e7f70adc5d..e39c0ef730 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.user_permission.inc +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.user_permission.inc @@ -11,16 +11,6 @@ function hedley_resilience_user_default_permissions() { $permissions = array(); - // Exported permission: 'create resilience_message content'. - $permissions['create resilience_message content'] = array( - 'name' => 'create resilience_message content', - 'roles' => array( - 'administrator' => 'administrator', - 'sync' => 'sync', - ), - 'module' => 'node', - ); - // Exported permission: 'create resilience_survey content'. $permissions['create resilience_survey content'] = array( 'name' => 'create resilience_survey content', @@ -31,15 +21,6 @@ function hedley_resilience_user_default_permissions() { 'module' => 'node', ); - // Exported permission: 'delete any resilience_message content'. - $permissions['delete any resilience_message content'] = array( - 'name' => 'delete any resilience_message content', - 'roles' => array( - 'administrator' => 'administrator', - ), - 'module' => 'node', - ); - // Exported permission: 'delete any resilience_survey content'. $permissions['delete any resilience_survey content'] = array( 'name' => 'delete any resilience_survey content', @@ -49,15 +30,6 @@ function hedley_resilience_user_default_permissions() { 'module' => 'node', ); - // Exported permission: 'delete own resilience_message content'. - $permissions['delete own resilience_message content'] = array( - 'name' => 'delete own resilience_message content', - 'roles' => array( - 'administrator' => 'administrator', - ), - 'module' => 'node', - ); - // Exported permission: 'delete own resilience_survey content'. $permissions['delete own resilience_survey content'] = array( 'name' => 'delete own resilience_survey content', @@ -67,16 +39,6 @@ function hedley_resilience_user_default_permissions() { 'module' => 'node', ); - // Exported permission: 'edit any resilience_message content'. - $permissions['edit any resilience_message content'] = array( - 'name' => 'edit any resilience_message content', - 'roles' => array( - 'administrator' => 'administrator', - 'sync' => 'sync', - ), - 'module' => 'node', - ); - // Exported permission: 'edit any resilience_survey content'. $permissions['edit any resilience_survey content'] = array( 'name' => 'edit any resilience_survey content', @@ -87,16 +49,6 @@ function hedley_resilience_user_default_permissions() { 'module' => 'node', ); - // Exported permission: 'edit own resilience_message content'. - $permissions['edit own resilience_message content'] = array( - 'name' => 'edit own resilience_message content', - 'roles' => array( - 'administrator' => 'administrator', - 'sync' => 'sync', - ), - 'module' => 'node', - ); - // Exported permission: 'edit own resilience_survey content'. $permissions['edit own resilience_survey content'] = array( 'name' => 'edit own resilience_survey content', diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.info b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.info index 32684e890d..2afb95cd06 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.info +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.info @@ -16,54 +16,26 @@ dependencies[] = strongarm dependencies[] = text features[ctools][] = strongarm:strongarm:1 features[features_api][] = api:2 -features[field_base][] = field_display_day -features[field_base][] = field_favorite_message -features[field_base][] = field_resilience_category -features[field_base][] = field_resilience_order features[field_base][] = field_resilience_survey_signs features[field_base][] = field_resilience_survey_type -features[field_base][] = field_time_read -features[field_instance][] = node-resilience_message-field_display_day -features[field_instance][] = node-resilience_message-field_favorite_message -features[field_instance][] = node-resilience_message-field_next_reminder -features[field_instance][] = node-resilience_message-field_nurse -features[field_instance][] = node-resilience_message-field_resilience_category -features[field_instance][] = node-resilience_message-field_resilience_order -features[field_instance][] = node-resilience_message-field_time_read -features[field_instance][] = node-resilience_message-field_uuid features[field_instance][] = node-resilience_survey-field_date_measured features[field_instance][] = node-resilience_survey-field_nurse features[field_instance][] = node-resilience_survey-field_resilience_survey_signs features[field_instance][] = node-resilience_survey-field_resilience_survey_type features[field_instance][] = node-resilience_survey-field_uuid -features[node][] = resilience_message features[node][] = resilience_survey -features[user_permission][] = create resilience_message content features[user_permission][] = create resilience_survey content -features[user_permission][] = delete any resilience_message content features[user_permission][] = delete any resilience_survey content -features[user_permission][] = delete own resilience_message content features[user_permission][] = delete own resilience_survey content -features[user_permission][] = edit any resilience_message content features[user_permission][] = edit any resilience_survey content -features[user_permission][] = edit own resilience_message content features[user_permission][] = edit own resilience_survey content -features[variable][] = auto_entitylabel_node_resilience_message features[variable][] = auto_entitylabel_node_resilience_survey -features[variable][] = auto_entitylabel_pattern_node_resilience_message features[variable][] = auto_entitylabel_pattern_node_resilience_survey -features[variable][] = auto_entitylabel_php_node_resilience_message features[variable][] = auto_entitylabel_php_node_resilience_survey -features[variable][] = field_bundle_settings_node__resilience_message features[variable][] = field_bundle_settings_node__resilience_survey -features[variable][] = menu_options_resilience_message features[variable][] = menu_options_resilience_survey -features[variable][] = menu_parent_resilience_message features[variable][] = menu_parent_resilience_survey -features[variable][] = node_options_resilience_message features[variable][] = node_options_resilience_survey -features[variable][] = node_preview_resilience_message features[variable][] = node_preview_resilience_survey -features[variable][] = node_submitted_resilience_message features[variable][] = node_submitted_resilience_survey features_exclude[dependencies][number] = number diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.module b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.module index 947ebef986..551b47b3f1 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.module +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.module @@ -6,191 +6,3 @@ */ include_once 'hedley_resilience.features.inc'; - -/** - * Implements hook_node_insert(). - */ -function hedley_resilience_node_insert($node) { - if ($node->type != 'nurse') { - return; - } - - $wrapper = entity_metadata_wrapper('node', $node); - $resilience_program = $wrapper->field_resilience_program->value(); - - if (!$resilience_program) { - // Program not enabled - no need to create messages for nurse. - return; - } - - hedley_resilience_create_messages($node); -} - -/** - * Implements hook_node_update(). - */ -function hedley_resilience_node_update($node) { - if ($node->type != 'nurse') { - return; - } - - $wrapper_orig = entity_metadata_wrapper('node', $node->original); - $resilience_program_orig = $wrapper_orig->field_resilience_program->value(); - $wrapper = entity_metadata_wrapper('node', $node); - $resilience_program = $wrapper->field_resilience_program->value(); - - if ($resilience_program_orig !== FALSE && $resilience_program !== TRUE) { - // Update did not include enabling of resilience program, so, - // for sure, messages creation is not required. - return; - } - - $query = new EntityFieldQuery(); - $query - ->entityCondition('entity_type', 'node') - ->entityCondition('bundle', 'resilience_message') - ->fieldCondition('field_nurse', 'target_id', $node->nid); - $count = $query->count()->execute(); - - if ($count > 0) { - // Messages already exist for nurse. No need to - // create new ones. - return; - } - - hedley_resilience_create_messages($node); -} - -/** - * Implements hook_node_presave(). - */ -function hedley_resilience_node_presave($node) { - if ($node->type != 'nurse') { - return; - } - - $resilience_enabled = variable_get('hedley_admin_feature_resilience_enabled', FALSE); - if ($resilience_enabled) { - return; - } - - $wrapper = entity_metadata_wrapper('node', $node); - // For now, we want to keep the feature disabled. - // Therefore, we force FALSE at program enabled field. - // Also, we make sure that program start date and next reminder - // fields are empty. - // When launching the feature, we'll allow any value at program enabled - // field, and will verify that program start date and next reminder - // fields are empty only for newly created nurses. - $wrapper->field_resilience_program->set(FALSE); - $wrapper->field_resilience_start_date->set(NULL); - $wrapper->field_next_reminder->set(NULL); -} - -/** - * Creates 36 resilience messages for given nurse. - * - * @param object $node - * Node of Nurse, for whom messages are created. - */ -function hedley_resilience_create_messages($node) { - $account = user_load($node->uid); - if (empty($account)) { - global $user; - $account = $user; - } - - // Resilience messages are divided into 7 categories, - // For each category, there are several messages which need to be - // presented on day X, counting from the start date of the program. - // If X = 0, the message is immediate. - // So, the keys of config array are the categories, and value are - // arrays, where key is the number of the message, and value is the - // day on which messages should be displayed. - $config = [ - 'introduction' => [ - '1' => 0, - '2' => 0, - '3' => 0, - '4' => 0, - '5' => 2, - '6' => 2, - '7' => 2, - '8' => 2, - ], - 'growth' => [ - '1' => 5, - '2' => 28, - '3' => 49, - '4' => 61, - ], - 'stress-management' => [ - '1' => 7, - '2' => 9, - '3' => 33, - '4' => 44, - '5' => 54, - '6' => 63, - '7' => 65, - ], - 'mindfulness' => [ - '1' => 12, - '2' => 14, - '3' => 19, - '4' => 35, - '5' => 37, - '6' => 47, - ], - 'connecting' => [ - '1' => 16, - '2' => 23, - '3' => 26, - '4' => 40, - '5' => 51, - '6' => 68, - ], - 'self-care' => [ - '1' => 21, - '2' => 42, - '3' => 58, - ], - 'end-of-period' => [ - '1' => 30, - '2' => 56, - ], - ]; - - foreach ($config as $category => $values) { - foreach ($values as $order => $display_day) { - hedley_resilience_create_message($node->nid, $category, $order, $display_day, $account); - } - } -} - -/** - * Creates resilience message using Restful handler. - * - * @param int $nurse_id - * Node ID of Nurse, for whom messages are created. - * @param string $category - * Message category. - * @param string $order - * Message order. - * @param int $display_day - * The day on which message is displayed (counting from program start day). - * @param object $account - * User account which is set as owner of the message. - */ -function hedley_resilience_create_message($nurse_id, $category, $order, $display_day, $account) { - $handler = restful_get_restful_handler('resilience-message'); - $handler->setAccount($account); - - $data = [ - 'nurse' => $nurse_id, - 'resilience_category' => $category, - 'resilience_order' => $order, - 'display_day' => $display_day, - ]; - - $handler->post('', $data); -} diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.strongarm.inc b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.strongarm.inc index 9e15ea45ba..5724cda664 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.strongarm.inc +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.strongarm.inc @@ -11,13 +11,6 @@ function hedley_resilience_strongarm() { $export = array(); - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'auto_entitylabel_node_resilience_message'; - $strongarm->value = '1'; - $export['auto_entitylabel_node_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -25,13 +18,6 @@ function hedley_resilience_strongarm() { $strongarm->value = '1'; $export['auto_entitylabel_node_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'auto_entitylabel_pattern_node_resilience_message'; - $strongarm->value = '[node:content-type] - [node:field-resilience-category] - [node:field-resilience-order] - [node:field-nurse:title] '; - $export['auto_entitylabel_pattern_node_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -39,13 +25,6 @@ function hedley_resilience_strongarm() { $strongarm->value = '[node:content-type] - [node:field-nurse:title] - [node:field-date-measured:custom:Y-m-d] '; $export['auto_entitylabel_pattern_node_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'auto_entitylabel_php_node_resilience_message'; - $strongarm->value = 0; - $export['auto_entitylabel_php_node_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -53,23 +32,6 @@ function hedley_resilience_strongarm() { $strongarm->value = 0; $export['auto_entitylabel_php_node_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'field_bundle_settings_node__resilience_message'; - $strongarm->value = array( - 'view_modes' => array(), - 'extra_fields' => array( - 'form' => array( - 'title' => array( - 'weight' => '0', - ), - ), - 'display' => array(), - ), - ); - $export['field_bundle_settings_node__resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -87,15 +49,6 @@ function hedley_resilience_strongarm() { ); $export['field_bundle_settings_node__resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'menu_options_resilience_message'; - $strongarm->value = array( - 0 => 'main-menu', - ); - $export['menu_options_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -105,13 +58,6 @@ function hedley_resilience_strongarm() { ); $export['menu_options_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'menu_parent_resilience_message'; - $strongarm->value = 'main-menu:0'; - $export['menu_parent_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -119,16 +65,6 @@ function hedley_resilience_strongarm() { $strongarm->value = 'main-menu:0'; $export['menu_parent_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'node_options_resilience_message'; - $strongarm->value = array( - 0 => 'status', - 1 => 'promote', - ); - $export['node_options_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -139,13 +75,6 @@ function hedley_resilience_strongarm() { ); $export['node_options_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'node_preview_resilience_message'; - $strongarm->value = '1'; - $export['node_preview_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -153,13 +82,6 @@ function hedley_resilience_strongarm() { $strongarm->value = '1'; $export['node_preview_resilience_survey'] = $strongarm; - $strongarm = new stdClass(); - $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ - $strongarm->api_version = 1; - $strongarm->name = 'node_submitted_resilience_message'; - $strongarm->value = 1; - $export['node_submitted_resilience_message'] = $strongarm; - $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; diff --git a/server/hedley/modules/custom/hedley_restful/hedley_restful.module b/server/hedley/modules/custom/hedley_restful/hedley_restful.module index 21ce77154b..a7fa4aa0ef 100644 --- a/server/hedley/modules/custom/hedley_restful/hedley_restful.module +++ b/server/hedley/modules/custom/hedley_restful/hedley_restful.module @@ -23,7 +23,6 @@ const HEDLEY_RESTFUL_ALL_DEVICES = [ 'participant_form' => 'participants-form', 'village' => 'villages', 'resilience_survey' => 'resilience-survey', - 'resilience_message' => 'resilience-message', ]; /** diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulResilienceMessage.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulResilienceMessage.class.php deleted file mode 100644 index 0482c6412d..0000000000 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulResilienceMessage.class.php +++ /dev/null @@ -1,103 +0,0 @@ -fields as $field_name) { - $public_name = str_replace('field_', '', $field_name); - - $public_fields[$public_name] = [ - 'property' => $field_name, - ]; - - if (in_array($field_name, $this->entityFields)) { - $public_fields[$public_name]['sub_property'] = 'field_uuid'; - } - } - - return $public_fields; - } - - /** - * {@inheritdoc} - */ - protected function alterQueryForViewWithDbSelect(SelectQuery $query) { - $query = parent::alterQueryForViewWithDbSelect($query); - - foreach ($this->fields as $field_name) { - hedley_general_join_field_to_query($query, 'node', $field_name, FALSE); - } - - foreach ($this->entityFields as $field_name) { - $public_name = str_replace('field_', '', $field_name); - hedley_general_join_field_to_query($query, 'node', 'field_uuid', FALSE, "$field_name.{$field_name}_target_id", "uuid_$public_name"); - } - - $query->groupBy('node.nid'); - - return $query; - } - - /** - * {@inheritdoc} - */ - protected function postExecuteQueryForViewWithDbSelect(array $items = []) { - $items = parent::postExecuteQueryForViewWithDbSelect($items); - - foreach ($items as &$item) { - unset($item->label); - - foreach ($this->entityFields as $field_name) { - $public_name = str_replace('field_', '', $field_name); - $uuid_name = "uuid_$public_name"; - $item->{$public_name} = $item->{$uuid_name}; - unset($item->{$uuid_name}); - } - - $item->favorite_message = (bool) $item->favorite_message; - } - - return $items; - } - -} diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/resilience-message.inc b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/resilience-message.inc deleted file mode 100644 index b40ce2b0ee..0000000000 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/resilience-message.inc +++ /dev/null @@ -1,17 +0,0 @@ - t('Resilience Message'), - 'resource' => 'resilience-message', - 'name' => 'resilience-message', - 'entity_type' => 'node', - 'bundle' => 'resilience_message', - 'description' => t('Exports the Resilience Message bundle.'), - 'class' => 'HedleyRestfulResilienceMessage', - 'authentication_types' => TRUE, -); From 1b65e3bbdaef2e0fb468f75f421b9b219ef80860 Mon Sep 17 00:00:00 2001 From: anvmn Date: Mon, 13 May 2024 12:03:56 +0300 Subject: [PATCH 12/63] Drop unneeded code --- .../elm/Backend/ResilienceMessage/Decoder.elm | 1 - .../elm/Backend/ResilienceMessage/Encoder.elm | 5 +---- .../elm/Backend/ResilienceMessage/Model.elm | 4 +--- .../elm/Backend/ResilienceMessage/Utils.elm | 21 +++++++++---------- .../src/elm/Pages/MessagingCenter/Utils.elm | 18 +++++++--------- client/src/elm/Pages/MessagingCenter/View.elm | 4 ++-- client/src/elm/Pages/PinCode/View.elm | 4 ++-- client/src/elm/Pages/Wellbeing/View.elm | 2 +- 8 files changed, 25 insertions(+), 34 deletions(-) diff --git a/client/src/elm/Backend/ResilienceMessage/Decoder.elm b/client/src/elm/Backend/ResilienceMessage/Decoder.elm index 515ae8e198..cbe25c8bc3 100644 --- a/client/src/elm/Backend/ResilienceMessage/Decoder.elm +++ b/client/src/elm/Backend/ResilienceMessage/Decoder.elm @@ -24,7 +24,6 @@ decodeResilienceMessages = decodeResilienceMessage : Decoder ResilienceMessage decodeResilienceMessage = succeed ResilienceMessage - |> required "nurse" decodeEntityUuid |> required "resilience_category" decodeResilienceCategory |> required "resilience_order" decodeResilienceMessageOrder |> required "display_day" decodeInt diff --git a/client/src/elm/Backend/ResilienceMessage/Encoder.elm b/client/src/elm/Backend/ResilienceMessage/Encoder.elm index 79d24a68c9..9c59b66130 100644 --- a/client/src/elm/Backend/ResilienceMessage/Encoder.elm +++ b/client/src/elm/Backend/ResilienceMessage/Encoder.elm @@ -10,13 +10,10 @@ import Utils.Json exposing (encodeNullable) encodeResilienceMessage : ResilienceMessage -> List ( String, Value ) encodeResilienceMessage message = - [ ( "nurse", encodeEntityUuid message.nurse ) - , ( "resilience_category", encodeResilienceCategory message.category ) + [ ( "resilience_category", encodeResilienceCategory message.category ) , ( "resilience_order", encodeResilienceMessageOrder message.order ) , ( "display_day", int message.displayDay ) , ( "favorite_message", bool message.isFavorite ) - , ( "deleted", bool False ) - , ( "type", string "resilience_message" ) ] ++ encodeNullable "time_read" message.timeRead encodePosixAsSeconds ++ encodeNullable "next_reminder" message.nextReminder encodePosixAsSeconds diff --git a/client/src/elm/Backend/ResilienceMessage/Model.elm b/client/src/elm/Backend/ResilienceMessage/Model.elm index 210edf25e3..09332bd401 100644 --- a/client/src/elm/Backend/ResilienceMessage/Model.elm +++ b/client/src/elm/Backend/ResilienceMessage/Model.elm @@ -6,9 +6,7 @@ import Time type alias ResilienceMessage = - { -- @todo: Remove - nurse : NurseId - , category : ResilienceCategory + { category : ResilienceCategory , order : ResilienceMessageOrder , displayDay : Int , timeRead : Maybe Time.Posix diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index fcc65d2daf..1f12d6853d 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -119,17 +119,17 @@ resilienceMessageOrderFromString value = Nothing -generateEmptyMessagesByProgramStartDate : NurseId -> NominalDate -> NominalDate -> Dict ResilienceMessageNEWId ResilienceMessage -generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate = - generateEmptyMessages nurseId - |> Dict.filter - (\_ message -> - Date.compare currentDate (Date.add Days (message.displayDay - 1) programStartDate) == LT - ) +generateEmptyMessagesByProgramStartDate : NominalDate -> NominalDate -> Dict ResilienceMessageNEWId ResilienceMessage +generateEmptyMessagesByProgramStartDate currentDate programStartDate = + Dict.filter + (\_ message -> + Date.compare currentDate (Date.add Days (message.displayDay - 1) programStartDate) == LT + ) + emptyMessagesDict -generateEmptyMessages : NurseId -> Dict ResilienceMessageNEWId ResilienceMessage -generateEmptyMessages nurseId = +emptyMessagesDict : Dict ResilienceMessageNEWId ResilienceMessage +emptyMessagesDict = Dict.toList numberOfMessagesByCategory |> List.map (\( category, numberOfMessages ) -> @@ -143,8 +143,7 @@ generateEmptyMessages nurseId = |> Maybe.map (\displayDay -> ( generateResilienceMessageId category order - , { nurse = nurseId - , category = category + , { category = category , order = order , displayDay = displayDay , timeRead = Nothing diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 8c07869139..3b0dd80f55 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -5,7 +5,7 @@ import Backend.Entities exposing (..) import Backend.Model exposing (ModelIndexedDb) import Backend.Nurse.Model exposing (Nurse) import Backend.ResilienceMessage.Model exposing (ResilienceMessage) -import Backend.ResilienceMessage.Utils exposing (generateEmptyMessages, generateEmptyMessagesByProgramStartDate) +import Backend.ResilienceMessage.Utils exposing (emptyMessagesDict, generateEmptyMessagesByProgramStartDate) import Backend.ResilienceSurvey.Model exposing (ResilienceSurveyQuestion(..)) import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) @@ -22,9 +22,9 @@ monthlySurveyQuestions = ] -generateInboxMessages : NurseId -> NominalDate -> NominalDate -> Dict String ResilienceMessage -> Dict String ResilienceMessage -generateInboxMessages nurseId currentDate programStartDate recordedMessage = - generateEmptyMessagesByProgramStartDate nurseId currentDate programStartDate +generateInboxMessages : NominalDate -> NominalDate -> Dict String ResilienceMessage -> Dict String ResilienceMessage +generateInboxMessages currentDate programStartDate recordedMessage = + generateEmptyMessagesByProgramStartDate currentDate programStartDate |> Dict.foldl (\key value accum -> Dict.get key recordedMessage @@ -37,18 +37,16 @@ generateInboxMessages nurseId currentDate programStartDate recordedMessage = Dict.empty -resolveNumberOfUnreadMessages : Time.Posix -> NurseId -> NominalDate -> Nurse -> Int -resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse = +resolveNumberOfUnreadMessages : Time.Posix -> NominalDate -> Nurse -> Int +resolveNumberOfUnreadMessages currentTime currentDate nurse = Maybe.map (\programStartDate -> - generateInboxMessages nurseId currentDate programStartDate nurse.resilienceMessages + generateInboxMessages currentDate programStartDate nurse.resilienceMessages |> Dict.filter (\_ message -> isMessageUnread currentTime message) ) nurse.resilienceProgramStartDate |> Maybe.withDefault - (generateEmptyMessages nurseId - |> Dict.filter (\_ message -> message.displayDay == 0) - ) + (Dict.filter (\_ message -> message.displayDay == 0) emptyMessagesDict) |> Dict.size diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 895512c693..2f25b41f9f 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -50,7 +50,7 @@ view language currentTime nurseId nurse db model = fromLocalDateTime currentTime numberOfUnreadMessages = - resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse + resolveNumberOfUnreadMessages currentTime currentDate nurse header = div [ class "ui basic head segment" ] @@ -319,7 +319,7 @@ viewMessagingCenter language currentTime currentDate programStartDate nurseId nu -- appear at inbox on current date. { nurse_ | resilienceMessages = - generateInboxMessages nurseId currentDate programStartDate nurse_.resilienceMessages + generateInboxMessages currentDate programStartDate nurse_.resilienceMessages } ( unread, read ) = diff --git a/client/src/elm/Pages/PinCode/View.elm b/client/src/elm/Pages/PinCode/View.elm index abd05c2eee..d120a656dc 100644 --- a/client/src/elm/Pages/PinCode/View.elm +++ b/client/src/elm/Pages/PinCode/View.elm @@ -276,7 +276,7 @@ viewLoggedInContent language currentTime features nurseId nurse ( healthCenterId viewCardFunc = if activity == MenuWellbeing then - resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse + resolveNumberOfUnreadMessages currentTime currentDate nurse |> activityCardWithCounter else @@ -451,7 +451,7 @@ resilienceNotificationDialog language currentTime currentDate nurseId nurse db m if notificationTimeReached && isJust nurse.resilienceProgramStartDate then let numberOfUnreadMessages = - resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse + resolveNumberOfUnreadMessages currentTime currentDate nurse in if numberOfUnreadMessages > 0 then Just <| diff --git a/client/src/elm/Pages/Wellbeing/View.elm b/client/src/elm/Pages/Wellbeing/View.elm index 7a2ae545a5..ea5cd43994 100644 --- a/client/src/elm/Pages/Wellbeing/View.elm +++ b/client/src/elm/Pages/Wellbeing/View.elm @@ -21,7 +21,7 @@ view language currentTime nurseId nurse db model = fromLocalDateTime currentTime numberOfUnreadMessages = - resolveNumberOfUnreadMessages currentTime nurseId currentDate nurse + resolveNumberOfUnreadMessages currentTime currentDate nurse header = div [ class "ui basic head segment" ] From 2aa63f84b9b00bd1e1f772b3135fc217f2529367 Mon Sep 17 00:00:00 2001 From: anvmn Date: Mon, 13 May 2024 12:12:18 +0300 Subject: [PATCH 13/63] ResilienceMessageNEWId => ResilienceMessageId --- client/src/elm/Backend/Entities.elm | 10 +--------- client/src/elm/Backend/Nurse/Model.elm | 2 +- client/src/elm/Backend/ResilienceMessage/Utils.elm | 8 ++++---- client/src/elm/Pages/MessagingCenter/Model.elm | 14 +++++++------- client/src/elm/Pages/MessagingCenter/Update.elm | 4 ++-- client/src/elm/Pages/MessagingCenter/View.elm | 2 +- 6 files changed, 16 insertions(+), 24 deletions(-) diff --git a/client/src/elm/Backend/Entities.elm b/client/src/elm/Backend/Entities.elm index ee1227ec8d..7e6338c224 100644 --- a/client/src/elm/Backend/Entities.elm +++ b/client/src/elm/Backend/Entities.elm @@ -1399,16 +1399,8 @@ type ResilienceSurveyUuidType = ResilienceSurveyUuidType -type alias ResilienceMessageNEWId = - String - - type alias ResilienceMessageId = - EntityUuid ResilienceMessageUuidType - - -type ResilienceMessageUuidType - = ResilienceMessageUuidType + String type alias PrenatalPartnerHIVTestId = diff --git a/client/src/elm/Backend/Nurse/Model.elm b/client/src/elm/Backend/Nurse/Model.elm index 98c98ca411..ae5bb2cc16 100644 --- a/client/src/elm/Backend/Nurse/Model.elm +++ b/client/src/elm/Backend/Nurse/Model.elm @@ -27,7 +27,7 @@ type alias Nurse = , resilienceUbudehe : Maybe Ubudehe , resilienceMaritalStatus : Maybe MaritalStatus , resilienceNextReminder : Maybe Time.Posix - , resilienceMessages : Dict ResilienceMessageNEWId ResilienceMessage + , resilienceMessages : Dict ResilienceMessageId ResilienceMessage } diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index 1f12d6853d..bc6212a741 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -1,7 +1,7 @@ module Backend.ResilienceMessage.Utils exposing (..) import AssocList as Dict exposing (Dict) -import Backend.Entities exposing (NurseId, ResilienceMessageNEWId) +import Backend.Entities exposing (NurseId, ResilienceMessageId) import Backend.ResilienceMessage.Model exposing (..) import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) @@ -119,7 +119,7 @@ resilienceMessageOrderFromString value = Nothing -generateEmptyMessagesByProgramStartDate : NominalDate -> NominalDate -> Dict ResilienceMessageNEWId ResilienceMessage +generateEmptyMessagesByProgramStartDate : NominalDate -> NominalDate -> Dict ResilienceMessageId ResilienceMessage generateEmptyMessagesByProgramStartDate currentDate programStartDate = Dict.filter (\_ message -> @@ -128,7 +128,7 @@ generateEmptyMessagesByProgramStartDate currentDate programStartDate = emptyMessagesDict -emptyMessagesDict : Dict ResilienceMessageNEWId ResilienceMessage +emptyMessagesDict : Dict ResilienceMessageId ResilienceMessage emptyMessagesDict = Dict.toList numberOfMessagesByCategory |> List.map @@ -159,7 +159,7 @@ emptyMessagesDict = |> Dict.fromList -generateResilienceMessageId : ResilienceCategory -> ResilienceMessageOrder -> ResilienceMessageNEWId +generateResilienceMessageId : ResilienceCategory -> ResilienceMessageOrder -> ResilienceMessageId generateResilienceMessageId category order = resilienceCategoryToString category ++ "-" ++ resilienceMessageOrderToString order diff --git a/client/src/elm/Pages/MessagingCenter/Model.elm b/client/src/elm/Pages/MessagingCenter/Model.elm index 85e6c03310..2ca37d00ee 100644 --- a/client/src/elm/Pages/MessagingCenter/Model.elm +++ b/client/src/elm/Pages/MessagingCenter/Model.elm @@ -21,7 +21,7 @@ import Pages.Page exposing (Page) type alias Model = { activeTab : MessagingTab , tabScrollPosition : Int - , expandedMessages : EverySet ResilienceMessageNEWId + , expandedMessages : EverySet ResilienceMessageId , messageOptionsDialogState : Maybe MessageOptionsDialogState , kickOffForm : KickOffForm , monthlySurveyForm : MonthlySurveyForm @@ -52,8 +52,8 @@ type MessagingTab type MessageOptionsDialogState - = MessageOptionsStateMain ( ResilienceMessageNEWId, ResilienceMessage ) - | MessageOptionsStateReminder ( ResilienceMessageNEWId, ResilienceMessage ) + = MessageOptionsStateMain ( ResilienceMessageId , ResilienceMessage ) + | MessageOptionsStateReminder ( ResilienceMessageId , ResilienceMessage ) type alias KickOffForm = @@ -107,8 +107,8 @@ type Msg | SetSurveyScoreDialogState (Maybe SurveyScoreDialogState) | SetActiveTab MessagingTab | ScrollTab Int - | ResilienceMessageClicked ResilienceMessageNEWId NurseId Nurse Bool + | ResilienceMessageClicked ResilienceMessageId NurseId Nurse Bool | SetMessageOptionsDialogState (Maybe MessageOptionsDialogState) - | ToggleMessageRead ResilienceMessageNEWId NurseId Nurse Bool - | ToggleMessageFavorite ResilienceMessageNEWId NurseId Nurse - | ScheduleMessageReminder Int ResilienceMessageNEWId NurseId Nurse + | ToggleMessageRead ResilienceMessageId NurseId Nurse Bool + | ToggleMessageFavorite ResilienceMessageId NurseId Nurse + | ScheduleMessageReminder Int ResilienceMessageId NurseId Nurse diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index 78f2993a0a..e943a45f27 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -323,7 +323,7 @@ update currentTime currentDate msg model = ) -updateMessageAction : ResilienceMessageNEWId -> NurseId -> Nurse -> (ResilienceMessage -> ResilienceMessage) -> List App.Model.Msg +updateMessageAction : ResilienceMessageId -> NurseId -> Nurse -> (ResilienceMessage -> ResilienceMessage) -> List App.Model.Msg updateMessageAction messageId nurseId nurse updateFunc = Dict.get messageId nurse.resilienceMessages |> Maybe.map @@ -346,7 +346,7 @@ updateMessageAction messageId nurseId nurse updateFunc = |> Maybe.withDefault [] -markMessageReadAction : Time.Posix -> ResilienceMessageNEWId -> NurseId -> Nurse -> List App.Model.Msg +markMessageReadAction : Time.Posix -> ResilienceMessageId -> NurseId -> Nurse -> List App.Model.Msg markMessageReadAction currentTime messageId nurseId nurse = updateMessageAction messageId nurseId diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 2f25b41f9f..04ab9701e2 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -448,7 +448,7 @@ viewTabs language model = ++ [ scrollRightButton ] -viewResilienceMessage : Language -> NurseId -> Nurse -> Model -> ( ResilienceMessageNEWId, ResilienceMessage ) -> Html Msg +viewResilienceMessage : Language -> NurseId -> Nurse -> Model -> ( ResilienceMessageId, ResilienceMessage ) -> Html Msg viewResilienceMessage language nurseId nurse model ( messageId, message ) = let ( extraClass, ( head, body ) ) = From 1719221274d6dbee558f86b34e3ed197040558d2 Mon Sep 17 00:00:00 2001 From: anvmn Date: Mon, 13 May 2024 12:15:17 +0300 Subject: [PATCH 14/63] Satisfy coder --- client/src/elm/Backend/Nurse/Model.elm | 2 +- client/src/elm/Pages/MessagingCenter/Model.elm | 14 +++++++------- client/src/elm/Pages/MessagingCenter/Update.elm | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/src/elm/Backend/Nurse/Model.elm b/client/src/elm/Backend/Nurse/Model.elm index ae5bb2cc16..197765da48 100644 --- a/client/src/elm/Backend/Nurse/Model.elm +++ b/client/src/elm/Backend/Nurse/Model.elm @@ -27,7 +27,7 @@ type alias Nurse = , resilienceUbudehe : Maybe Ubudehe , resilienceMaritalStatus : Maybe MaritalStatus , resilienceNextReminder : Maybe Time.Posix - , resilienceMessages : Dict ResilienceMessageId ResilienceMessage + , resilienceMessages : Dict ResilienceMessageId ResilienceMessage } diff --git a/client/src/elm/Pages/MessagingCenter/Model.elm b/client/src/elm/Pages/MessagingCenter/Model.elm index 2ca37d00ee..415d98cacc 100644 --- a/client/src/elm/Pages/MessagingCenter/Model.elm +++ b/client/src/elm/Pages/MessagingCenter/Model.elm @@ -21,7 +21,7 @@ import Pages.Page exposing (Page) type alias Model = { activeTab : MessagingTab , tabScrollPosition : Int - , expandedMessages : EverySet ResilienceMessageId + , expandedMessages : EverySet ResilienceMessageId , messageOptionsDialogState : Maybe MessageOptionsDialogState , kickOffForm : KickOffForm , monthlySurveyForm : MonthlySurveyForm @@ -52,8 +52,8 @@ type MessagingTab type MessageOptionsDialogState - = MessageOptionsStateMain ( ResilienceMessageId , ResilienceMessage ) - | MessageOptionsStateReminder ( ResilienceMessageId , ResilienceMessage ) + = MessageOptionsStateMain ( ResilienceMessageId, ResilienceMessage ) + | MessageOptionsStateReminder ( ResilienceMessageId, ResilienceMessage ) type alias KickOffForm = @@ -107,8 +107,8 @@ type Msg | SetSurveyScoreDialogState (Maybe SurveyScoreDialogState) | SetActiveTab MessagingTab | ScrollTab Int - | ResilienceMessageClicked ResilienceMessageId NurseId Nurse Bool + | ResilienceMessageClicked ResilienceMessageId NurseId Nurse Bool | SetMessageOptionsDialogState (Maybe MessageOptionsDialogState) - | ToggleMessageRead ResilienceMessageId NurseId Nurse Bool - | ToggleMessageFavorite ResilienceMessageId NurseId Nurse - | ScheduleMessageReminder Int ResilienceMessageId NurseId Nurse + | ToggleMessageRead ResilienceMessageId NurseId Nurse Bool + | ToggleMessageFavorite ResilienceMessageId NurseId Nurse + | ScheduleMessageReminder Int ResilienceMessageId NurseId Nurse diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index e943a45f27..177a97e651 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -323,7 +323,7 @@ update currentTime currentDate msg model = ) -updateMessageAction : ResilienceMessageId -> NurseId -> Nurse -> (ResilienceMessage -> ResilienceMessage) -> List App.Model.Msg +updateMessageAction : ResilienceMessageId -> NurseId -> Nurse -> (ResilienceMessage -> ResilienceMessage) -> List App.Model.Msg updateMessageAction messageId nurseId nurse updateFunc = Dict.get messageId nurse.resilienceMessages |> Maybe.map @@ -346,7 +346,7 @@ updateMessageAction messageId nurseId nurse updateFunc = |> Maybe.withDefault [] -markMessageReadAction : Time.Posix -> ResilienceMessageId -> NurseId -> Nurse -> List App.Model.Msg +markMessageReadAction : Time.Posix -> ResilienceMessageId -> NurseId -> Nurse -> List App.Model.Msg markMessageReadAction currentTime messageId nurseId nurse = updateMessageAction messageId nurseId From 975ea0fb5850ea5f1759eb42444e599ab2db934d Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 15 May 2024 22:45:22 +0300 Subject: [PATCH 15/63] Drop Debug.log [ci skip] --- client/src/elm/Pages/PinCode/View.elm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/src/elm/Pages/PinCode/View.elm b/client/src/elm/Pages/PinCode/View.elm index d120a656dc..7b85f05717 100644 --- a/client/src/elm/Pages/PinCode/View.elm +++ b/client/src/elm/Pages/PinCode/View.elm @@ -347,10 +347,6 @@ viewLoggedInContent language currentTime features nurseId nurse ( healthCenterId resilienceReminderDialog : Language -> Time.Posix -> NominalDate -> NurseId -> Nurse -> Maybe (Html Msg) resilienceReminderDialog language currentTime currentDate nurseId nurse = - let - _ = - Debug.log "" nurse - in Maybe.andThen (\programStartDate -> resolveResilienceReminderType currentDate programStartDate From 76039fe06e0ea49815b9f2cb7447ff479841e0fc Mon Sep 17 00:00:00 2001 From: Diama1 Date: Fri, 31 May 2024 10:17:58 +0200 Subject: [PATCH 16/63] Kirundi translation for TB --- client/src/elm/Translate.elm | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 468d9419c1..60ab025102 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -4876,7 +4876,7 @@ translationSet trans = Diagnostics -> { english = "Diagnostics" , kinyarwanda = Just "Gusuzuma uburwayi" - , kirundi = Nothing + , kirundi = Just "Gusuzuma uburwayi" } Diarrhea -> @@ -5472,7 +5472,7 @@ translationSet trans = TuberculosisEncounter -> { english = "Do you want to start a Tuberculosis Management encounter for" , kinyarwanda = Just "Urashaka gutangira isura ryo gukurikirana umurwayi w'igituntu witwa" - , kirundi = Nothing + , kirundi = Just "Urashaka gutangura itunganywa ry'imibonano n'umurwayi w'igituntu kuri" } WellChildEncounter -> @@ -7510,7 +7510,7 @@ translationSet trans = TuberculosisEncounter -> { english = "First Tuberculosis Encounter" , kinyarwanda = Just "Isura rya mbere ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Umubonano wa mbere werekeye indwara y'igituntu" } WellChildEncounter -> @@ -7572,7 +7572,7 @@ translationSet trans = TuberculosisEncounter -> { english = "Tuberculosis Encounter" , kinyarwanda = Just "Isura ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Umubonano werekeye indwara y'igituntu" } WellChildEncounter -> @@ -7641,7 +7641,7 @@ translationSet trans = TuberculosisEncounter -> { english = "Select Tuberculosis Visit" , kinyarwanda = Just "Hitamo isura ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Hitamwo umubonano kuvyerekeye indwara y'igituntu" } WellChildEncounter -> @@ -7710,7 +7710,7 @@ translationSet trans = TuberculosisEncounter -> { english = "Subsequent Tuberculosis Visit" , kinyarwanda = Just "Isura rilkurikira ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Umubonano ukurikira kuvyerekeye indwara y'igituntu" } WellChildEncounter -> @@ -7757,7 +7757,7 @@ translationSet trans = TuberculosisEncounter -> { english = "TB Management" , kinyarwanda = Just "Kwita ku murwayi w'igituntu" - , kirundi = Nothing + , kirundi = Just "Itunganywa rijanye n'indwara y'igituntu" } WellChildEncounter -> @@ -15809,7 +15809,7 @@ translationSet trans = PrescribedMedication -> { english = "Prescribed Medication" , kinyarwanda = Just "Imiti yatanzwe" - , kirundi = Nothing + , kirundi = Just "Imiti yasabwe" } PrenatalRecurrentNextStepsTask task -> @@ -22145,7 +22145,7 @@ translationSet trans = TuberculosisDiagnosedQuestion -> { english = "Was this person diagnosed with Tuberculosis" , kinyarwanda = Just "Uyu murwayi yaba yaragaragaweho uburwayi bw'igituntu" - , kirundi = Nothing + , kirundi = Just "Uyu muntu baramusanganye indwara y'igituntu" } TuberculosisDiagnosis sign -> @@ -22153,13 +22153,13 @@ translationSet trans = TuberculosisPulmonary -> { english = "Pulmonary (in the lungs)" , kinyarwanda = Just "Igituntu cyo mu bihaha" - , kirundi = Nothing + , kirundi = Just "Igituntu co mu mahaha" } TuberculosisExtrapulmonary -> { english = "Extrapulmonary (outside the lungs)" , kinyarwanda = Just "Igituntu gifata imyanya yo hanze y'ibihaha" - , kirundi = Nothing + , kirundi = Just "Igituntu gifatira inyuma y'amahaha" } NoTuberculosis -> @@ -22169,13 +22169,13 @@ translationSet trans = TuberculosisDistributeMedicationsQuestion -> { english = "Did you distribute the following medications" , kinyarwanda = Just "Waba watanze iyi miti ikurikira" - , kirundi = Nothing + , kirundi = Just "Woba waratanze imiti ikurikira" } TuberculosisFollowUpLabel -> { english = "Tuberculosis Follow up" , kinyarwanda = Just "Gukurikirana umurwayi w'igituntu" - , kirundi = Nothing + , kirundi = Just "Gukurikirana umurwayi w'igituntu" } TuberculosisFollowUpTestingStageInstructions stage -> @@ -22183,7 +22183,7 @@ translationSet trans = FollowUpTestingMonth1 -> { english = "Reassess treatment according to results, continue first-line treatment if drug susceptible." , kinyarwanda = Just "Genzura imiti ugendeye ku bisubizo byabonetse, ukomeze imiti y'ikiciro cya mbere niba ari koroherwa." - , kirundi = Nothing + , kirundi = Just "Suzuma imiti ufatiye ku nyishu zabonetse, bandanya umurongo wa mbere w'imiti mugihe habaye akarusho" } FollowUpTestingMonth2 -> @@ -22192,19 +22192,19 @@ translationSet trans = FollowUpTestingEndMonth2 -> { english = "If positive, Culture and DST - Continuation phase." , kinyarwanda = Just "Niba akigaragaza igituntu, kilitire na DST ari negatifu, umurwayi akomeza imiti yo mu cyiciro gikurikiyeho(RH mu mezi ane)." - , kirundi = Nothing + , kirundi = Just "If positive, Culture and DST, and retest after 15 days." } FollowUpTestingEndMonth5 -> { english = "If positive, Culture and DST, and retest after 15 days." , kinyarwanda = Just "Niba akigaragaza igituntu, ikizamini cya Kilitire na DSt cyogera gukorwa mu minsi 15." - , kirundi = Nothing + , kirundi = Just "Niba akigaragaza igituntu, igipimo ca culture na DST congera gukorwa mu misi 15" } FollowUpTestingEndMonth6 -> { english = "If positive, Culture and DST, and retest after 15 days, if negative - cured." , kinyarwanda = Just "Niba yarakigargaza igituntu ariko ikizamini cy akilitire na DST bikaba negatifu nyuma y'iminsi 15, uwo murwayi aba yarakize." - , kirundi = Nothing + , kirundi = Just "Niba akigaragaza igituntu ariko igipimo ca culture na DST congeye gukorwa bikaba bitacigaragaza inyuma y'imisi 15, uwo murwayi aba yarakize" } TuberculosisFollowUpTestingStageLabel stage -> @@ -22212,31 +22212,31 @@ translationSet trans = FollowUpTestingMonth1 -> { english = "Month 1" , kinyarwanda = Just "Ukwezi kwa 1" - , kirundi = Nothing + , kirundi = Just "Ukwezi kwa 1" } FollowUpTestingMonth2 -> { english = "Month 2" , kinyarwanda = Just "Ukwezi kwa 2" - , kirundi = Nothing + , kirundi = Just "Ukwezi kwa 2" } FollowUpTestingEndMonth2 -> { english = "End Month 2" , kinyarwanda = Just "Arangije ukwezi kwa 2" - , kirundi = Nothing + , kirundi = Just "Arangije ukwezi kwa kabiri " } FollowUpTestingEndMonth5 -> { english = "End Month 5" , kinyarwanda = Just "Arangije ukwezi kwa 5" - , kirundi = Nothing + , kirundi = Just "Arangije ukwezi kwa gatanu" } FollowUpTestingEndMonth6 -> { english = "End Month 6" , kinyarwanda = Just "Arangije ukwezi kwa 6" - , kirundi = Nothing + , kirundi = Just "arangije ukwezi kwa gatandatu" } TuberculosisFollowUpTestingStageTest stage -> @@ -22244,7 +22244,7 @@ translationSet trans = FollowUpTestingMonth1 -> { english = "xPert, Culture, and DST" , kinyarwanda = Just "Ikizamini cya Jenexpati, Kilitire na DST" - , kirundi = Nothing + , kirundi = Just "Igipimo ca GenexPert, Culture na DST" } FollowUpTestingMonth2 -> @@ -22253,13 +22253,13 @@ translationSet trans = FollowUpTestingEndMonth2 -> { english = "Smear microposy at the end of the intensive phase" , kinyarwanda = Just "Gupima igituntu hakoreshejwe mikorosikopi umurwayi arangije imiti y'ikiciro cya mbere" - , kirundi = Nothing + , kirundi = Just "Gupima igituntu hakoreshejwe mikorosikopi (rugagamisha) umurwayi arangije imiti y'igice gikomeye ca mbere" } FollowUpTestingEndMonth5 -> { english = "Smear microposy" , kinyarwanda = Just "Gupima hakoreshejwe mikorosikopi" - , kirundi = Nothing + , kirundi = Just "Gupima hakoreshejwe mikorosikopi" } FollowUpTestingEndMonth6 -> @@ -22270,7 +22270,7 @@ translationSet trans = EducationFollowUpTesting -> { english = "Have you provided the guidance for follow up testing" , kinyarwanda = Just "Waba watanze ubujyanama ku bijyanye no gukoresha ibizaminii" - , kirundi = Nothing + , kirundi = Just "Woba waratanze ubufasha kubijanye no gukoresha ibipimo" } NoTuberculosisHealthEducationSigns -> @@ -22291,7 +22291,7 @@ translationSet trans = TuberculosisLocationQuestion -> { english = "Where is the Tuberculosis located" , kinyarwanda = Just "Ni uwuhe mwanaya w'umubiri wagaragawemo igituntu" - , kirundi = Nothing + , kirundi = Just "Indwara y'igituntu iherereye hehe" } TuberculosisMedicationTask task -> @@ -22302,7 +22302,7 @@ translationSet trans = Pages.Tuberculosis.Activity.Model.TaskDOT -> { english = "DOT" , kinyarwanda = Just "Umuti unywerwa imbere y'ugukurikirana" - , kirundi = Nothing + , kirundi = Just "Umuti unywerwa imbere y'uwugukurikirana" } Pages.Tuberculosis.Activity.Model.TaskTreatmentReview -> @@ -22330,19 +22330,19 @@ translationSet trans = MedicationRHZE -> { english = "RHZE x 2 months (Initiation phase)" , kinyarwanda = Just "Atangira afata imiti ya RHZE mu gihe cy'amezi abiri" - , kirundi = Nothing + , kirundi = Just "Atangura afata RHZE mu kiringo c'amezi abiri" } MedicationRH -> { english = "RH x 4 months (Continuation phase)" , kinyarwanda = Just "Akomeza afata imiti ya RH mu gihe cy'amezi 4" - , kirundi = Nothing + , kirundi = Just "Akomeza afata imiti ya RH mu kiringo c'amezi ane" } MedicationOther -> { english = "Other - include HIV dosing, Pediatric dosing, etc" , kinyarwanda = Just "Indi miti - harimo Iya Virusi iteera SIDA, imiti y'abana,..." - , kirundi = Nothing + , kirundi = Just "Iyindi miti harimwo iyipfupfahaza umugera wa SIDA, iy'abana,..." } NoTuberculosisPrescribedMedications -> @@ -22351,7 +22351,7 @@ translationSet trans = TuberculosisPrescribedMedicationsQuestion -> { english = "What are the medications that were prescribed" , kinyarwanda = Just "Ni iyihe miti yatanzwe" - , kirundi = Nothing + , kirundi = Just "Ni iyihe miti yandikiwe" } TuberculosisPresent -> @@ -22363,7 +22363,7 @@ translationSet trans = TuberculosisProvideDOTTodayQuestion -> { english = "Will you provide DOT/TDO today" , kinyarwanda = Just "Urakurikirana uko umurwayi afata imiti uyu munsi" - , kirundi = Nothing + , kirundi = Just "Uraza gukurikirana uko umurwayi afata umuti uyu munsi" } TuberculosisReasonNotProvidedToday reason -> @@ -22375,19 +22375,19 @@ translationSet trans = DOTNegativeTakenToday -> { english = "Meds already taken today" , kinyarwanda = Just "Imiti y'uyu munsi yafashwe" - , kirundi = Nothing + , kirundi = Just "Meds unavailable" } DOTNegativeUnavailable -> { english = "Meds unavailable" , kinyarwanda = Just "Nta miti ihari" - , kirundi = Nothing + , kirundi = Just "Nta miti ihari" } DOTNegativeSideEffects -> { english = "Advised to hold b/c of side effects" , kinyarwanda = Just "Yagiriwe inama yo kuba aretse gufata imiti kuko iri kumutera ingaruka" - , kirundi = Nothing + , kirundi = Just "Yagiriwe inama yo kuba arahagarika gufata imiti kuko iriko iramugirako ingaruka" } DOTNegativePatientRefused -> @@ -23877,7 +23877,7 @@ translateActivePage page = TuberculosisEncounter -> { english = "Tuberculosis Participants" , kinyarwanda = Just "Abitabiriye muri service y'indwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Abitabiriye serivisi z' igisata c'indwara y'igituntu" } WellChildEncounter -> @@ -24161,19 +24161,19 @@ translateActivePage page = TuberculosisParticipantPage _ -> { english = "Tuberculosis Encounter" , kinyarwanda = Just "Isura ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Umubonano werekeye indwara y'igituntu" } TuberculosisEncounterPage _ -> { english = "Tuberculosis Encounter" , kinyarwanda = Just "Isura ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Umubonano werekeye indwara y'igituntu" } TuberculosisActivityPage _ _ -> { english = "Tuberculosis Activity" , kinyarwanda = Just "Igikorwa ku ndwara y'igituntu" - , kirundi = Nothing + , kirundi = Just "Igikorwa ku ndwara y'igituntu" } EducationSessionPage _ -> From af5e5b611be2f282be389fb021c796d80df168f6 Mon Sep 17 00:00:00 2001 From: anvmn Date: Tue, 18 Jun 2024 13:16:12 +0300 Subject: [PATCH 17/63] Fixes [ci skip] --- client/src/elm/App/Model.elm | 1 + client/src/elm/App/Update.elm | 23 ++++++++++++++++--- .../elm/Backend/ResilienceMessage/Utils.elm | 2 +- .../src/elm/Pages/MessagingCenter/Fetch.elm | 5 ++-- client/src/elm/Pages/Wellbeing/Fetch.elm | 3 +-- .../hedley_resilience.features.field_base.inc | 1 - 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/client/src/elm/App/Model.elm b/client/src/elm/App/Model.elm index 0236d0fedb..028d8208df 100644 --- a/client/src/elm/App/Model.elm +++ b/client/src/elm/App/Model.elm @@ -386,6 +386,7 @@ type Msg | MsgPagePinCode Pages.PinCode.Model.Msg | TryPinCode String | SetLoggedIn (WebData ( NurseId, Nurse )) + | UpdateNurseData ( NurseId, Nurse ) -- Manage device pairing | MsgPageDevice Pages.Device.Model.Msg | TryPairingCode String diff --git a/client/src/elm/App/Update.elm b/client/src/elm/App/Update.elm index 5fab7ccdc5..4159557d11 100644 --- a/client/src/elm/App/Update.elm +++ b/client/src/elm/App/Update.elm @@ -882,8 +882,7 @@ update msg model = MsgPageClinicalProgressReport id subMsg -> let ( subModel, subCmd, extraMsgs ) = - data.clinicalProgressReportPages - |> Dict.get id + Dict.get id data.clinicalProgressReportPages |> Maybe.withDefault Pages.Prenatal.ProgressReport.Model.emptyModel |> Pages.Prenatal.ProgressReport.Update.update subMsg in @@ -1262,6 +1261,24 @@ update msg model = ) model + UpdateNurseData nurse -> + updateConfigured + (\configured -> + let + updatedLoggedIn = + RemoteData.map + (\loggedIn -> + { loggedIn | nurse = nurse } + ) + configured.loggedIn + in + ( { configured | loggedIn = updatedLoggedIn } + , Cmd.none + , [] + ) + ) + model + CheckDataWanted -> -- Note that we will be called repeatedly. So, it's vitally important that -- the `fetch` implementations use a `WebData`-like strategy to indicate @@ -1426,7 +1443,7 @@ handleRevision model revision = Maybe.andThen (\( _, loggedIn ) -> if Tuple.first loggedIn.nurse == uuid then - Just (SetLoggedIn (Success ( uuid, data ))) + Just (UpdateNurseData ( uuid, data )) else Nothing diff --git a/client/src/elm/Backend/ResilienceMessage/Utils.elm b/client/src/elm/Backend/ResilienceMessage/Utils.elm index bc6212a741..78b314f568 100644 --- a/client/src/elm/Backend/ResilienceMessage/Utils.elm +++ b/client/src/elm/Backend/ResilienceMessage/Utils.elm @@ -123,7 +123,7 @@ generateEmptyMessagesByProgramStartDate : NominalDate -> NominalDate -> Dict Res generateEmptyMessagesByProgramStartDate currentDate programStartDate = Dict.filter (\_ message -> - Date.compare currentDate (Date.add Days (message.displayDay - 1) programStartDate) == LT + Date.compare (Date.add Days (message.displayDay - 1) programStartDate) currentDate == LT ) emptyMessagesDict diff --git a/client/src/elm/Pages/MessagingCenter/Fetch.elm b/client/src/elm/Pages/MessagingCenter/Fetch.elm index 839a7f7ca0..dcb98a021c 100644 --- a/client/src/elm/Pages/MessagingCenter/Fetch.elm +++ b/client/src/elm/Pages/MessagingCenter/Fetch.elm @@ -3,8 +3,9 @@ module Pages.MessagingCenter.Fetch exposing (fetch) import Backend.Entities exposing (..) import Backend.Model exposing (ModelIndexedDb, MsgIndexedDb(..)) import Gizra.NominalDate exposing (NominalDate) +import Pages.Wellbeing.Fetch fetch : NominalDate -> NurseId -> ModelIndexedDb -> List MsgIndexedDb -fetch currentDate nurseId db = - [] +fetch = + Pages.Wellbeing.Fetch.fetch diff --git a/client/src/elm/Pages/Wellbeing/Fetch.elm b/client/src/elm/Pages/Wellbeing/Fetch.elm index f8252408ce..57b9bf4532 100644 --- a/client/src/elm/Pages/Wellbeing/Fetch.elm +++ b/client/src/elm/Pages/Wellbeing/Fetch.elm @@ -7,5 +7,4 @@ import Gizra.NominalDate exposing (NominalDate) fetch : NominalDate -> NurseId -> ModelIndexedDb -> List MsgIndexedDb fetch currentDate nurseId db = - [ FetchResilienceSurveysForNurse nurseId - ] + [ FetchResilienceSurveysForNurse nurseId ] diff --git a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc index b282d598b2..952d3df41b 100644 --- a/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc +++ b/server/hedley/modules/custom/hedley_resilience/hedley_resilience.features.field_base.inc @@ -88,7 +88,6 @@ function hedley_resilience_field_default_field_bases() { 'q12-2' => 'Question 12 - 2', 'q12-3' => 'Question 12 - 3', 'q12-4' => 'Question 12 - 4', - ), 'allowed_values_function' => '', ), From 23eb31c6c7406c7d0f4c3339e194e60eb3674ae2 Mon Sep 17 00:00:00 2001 From: anvmn Date: Tue, 18 Jun 2024 23:11:09 +0300 Subject: [PATCH 18/63] Changes from https://github.com/TIP-Global-Health/eheza-app/pull/1192 --- client/src/assets/scss/_new.scss | 2 +- client/src/elm/Translate.elm | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index b750c95baf..ba0d813a6d 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -5136,7 +5136,7 @@ div.page-activity.messaging-center { } } - .ui.report.unstackable.items .guide-message { + .ui.report.unstackable.items .guide { background: $color-white; padding: 30px 25px 30px 25px; color: $color-text; diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 468d9419c1..4a95219e18 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -2985,7 +2985,7 @@ translationSet trans = AdoptionSurveyScoreInterpretation score -> if score < 36 then - { english = "Law effort to adopt resilience activities: Please, learn and integrate resilience activities in your daily life" + { english = "Low effort to adopt resilience activities: Please, learn and integrate resilience activities in your daily life" , kinyarwanda = Just "Ugira imbaraga nke mu gushyira mu ngiro ibikorwa bigufasha kumererwa neza. Gerageza kwiga no kongera mu bikorwa byawe bya buri munsi ibikorwa bigufasha kumererwa neza." , kirundi = Nothing } @@ -5961,7 +5961,7 @@ translationSet trans = else { english = "Favorite" - , kinyarwanda = Nothing + , kinyarwanda = Just "Ishimire ubutumwa" , kirundi = Nothing } @@ -6377,7 +6377,7 @@ translationSet trans = Guide -> { english = "Guide" - , kinyarwanda = Nothing + , kinyarwanda = Just "Ifashayobora" , kirundi = Nothing } @@ -10694,31 +10694,31 @@ translationSet trans = TabFavorites -> { english = "Favorites" - , kinyarwanda = Nothing + , kinyarwanda = Just "Ubutumwa wishimiye" , kirundi = Nothing } TabGrowth -> { english = "Growth" - , kinyarwanda = Nothing + , kinyarwanda = Just "Terimbere" , kirundi = Nothing } TabConnecting -> { english = "Connecting" - , kinyarwanda = Nothing + , kinyarwanda = Just "Gusabana" , kirundi = Nothing } TabSelfcare -> { english = "Selfcare" - , kinyarwanda = Nothing + , kinyarwanda = Just "Kwiyitaho" , kirundi = Nothing } TabStress -> { english = "Stress" - , kinyarwanda = Nothing + , kinyarwanda = Just "Kunanirwa" , kirundi = Nothing } @@ -18184,13 +18184,13 @@ translationSet trans = RemindMe -> { english = "Remind Me" - , kinyarwanda = Nothing + , kinyarwanda = Just "Unyibutse" , kirundi = Just "Nyibutsa" } RemindMePhrase -> { english = "Remind me of this message in:" - , kinyarwanda = Nothing + , kinyarwanda = Just "Nyibutsa ubu butumwa mu:" , kirundi = Just "Unyibutse ubu butumwa mu:" } @@ -18384,7 +18384,7 @@ translationSet trans = ResilienceCategoryMindfulness -> { english = "Mindfulness" - , kinyarwanda = Just "Zirikana ibi" + , kinyarwanda = Nothing , kirundi = Nothing } @@ -18762,19 +18762,19 @@ translationSet trans = ResilienceGuideSection3Bullet5 -> { english = "Stress Management" - , kinyarwanda = Just "Kwiyitaho" + , kinyarwanda = Just "Kunanirwa" , kirundi = Nothing } ResilienceGuideSection3Bullet6 -> { english = "Self-care" - , kinyarwanda = Just "Kunanirwa" + , kinyarwanda = Just "Kwiyitaho" , kirundi = Nothing } ResilienceGuideSection3Bullet7 -> { english = "Mindfulness" - , kinyarwanda = Just "Zirikana ibi" + , kinyarwanda = Nothing , kirundi = Nothing } From e5f4ab778934b92e71b7de3140d95e63495a3af5 Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 26 Jun 2024 19:32:13 +0300 Subject: [PATCH 19/63] Page infrastructure [ci skip] --- client/src/elm/App/Fetch.elm | 5 + client/src/elm/App/Model.elm | 4 + client/src/elm/App/Update.elm | 15 + client/src/elm/App/View.elm | 18 + client/src/elm/Pages/Page.elm | 1 + client/src/elm/Pages/Router.elm | 4 + .../Tuberculosis/ProgressReport/Fetch.elm | 11 + .../Tuberculosis/ProgressReport/Model.elm | 32 + .../Tuberculosis/ProgressReport/Update.elm | 61 ++ .../Tuberculosis/ProgressReport/View.elm | 862 ++++++++++++++++++ client/src/elm/Translate.elm | 6 + 11 files changed, 1019 insertions(+) create mode 100644 client/src/elm/Pages/Tuberculosis/ProgressReport/Fetch.elm create mode 100644 client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm create mode 100644 client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm create mode 100644 client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm diff --git a/client/src/elm/App/Fetch.elm b/client/src/elm/App/Fetch.elm index 8263e7b563..9d682bb6fc 100644 --- a/client/src/elm/App/Fetch.elm +++ b/client/src/elm/App/Fetch.elm @@ -62,6 +62,7 @@ import Pages.TraceContact.Fetch import Pages.Tuberculosis.Activity.Fetch import Pages.Tuberculosis.Encounter.Fetch import Pages.Tuberculosis.Participant.Fetch +import Pages.Tuberculosis.ProgressReport.Fetch import Pages.WellChild.Activity.Fetch import Pages.WellChild.Encounter.Fetch import Pages.WellChild.Participant.Fetch @@ -411,6 +412,10 @@ fetch model = Pages.WellChild.ProgressReport.Fetch.fetch id model.indexedDb |> List.map MsgIndexedDb + UserPage (TuberculosisProgressReportPage id) -> + Pages.Tuberculosis.ProgressReport.Fetch.fetch id model.indexedDb + |> List.map MsgIndexedDb + UserPage (NCDProgressReportPage initiator) -> let encounterId = diff --git a/client/src/elm/App/Model.elm b/client/src/elm/App/Model.elm index 0236d0fedb..96c4bf9022 100644 --- a/client/src/elm/App/Model.elm +++ b/client/src/elm/App/Model.elm @@ -79,6 +79,7 @@ import Pages.StockManagement.Model import Pages.TraceContact.Model import Pages.Tuberculosis.Activity.Model import Pages.Tuberculosis.Encounter.Model +import Pages.Tuberculosis.ProgressReport.Model import Pages.WellChild.Activity.Model import Pages.WellChild.Encounter.Model import Pages.WellChild.ProgressReport.Model @@ -311,6 +312,7 @@ type alias LoggedInModel = , childScoreboardReportPages : Dict ChildScoreboardEncounterId Pages.ChildScoreboard.ProgressReport.Model.Model , tuberculosisEncounterPages : Dict TuberculosisEncounterId Pages.Tuberculosis.Encounter.Model.Model , tuberculosisActivityPages : Dict ( TuberculosisEncounterId, TuberculosisActivity ) Pages.Tuberculosis.Activity.Model.Model + , tuberculosisProgressReportPages : Dict TuberculosisEncounterId Pages.Tuberculosis.ProgressReport.Model.Model , educationSessionPages : Dict EducationSessionId Pages.EducationSession.Model.Model , hivEncounterPages : Dict HIVEncounterId Pages.HIV.Encounter.Model.Model , hivActivityPages : Dict ( HIVEncounterId, HIVActivity ) Pages.HIV.Activity.Model.Model @@ -364,6 +366,7 @@ emptyLoggedInModel site villageId nurse = , childScoreboardReportPages = Dict.empty , tuberculosisEncounterPages = Dict.empty , tuberculosisActivityPages = Dict.empty + , tuberculosisProgressReportPages = Dict.empty , educationSessionPages = Dict.empty , hivEncounterPages = Dict.empty , hivActivityPages = Dict.empty @@ -452,6 +455,7 @@ type MsgLoggedIn | MsgPageWellChildProgressReport WellChildEncounterId Pages.WellChild.ProgressReport.Model.Msg | MsgPageNCDProgressReport NCDEncounterId Pages.NCD.ProgressReport.Model.Msg | MsgPageChildScoreboardReport ChildScoreboardEncounterId Pages.ChildScoreboard.ProgressReport.Model.Msg + | MsgPageTuberculosisProgressReport TuberculosisEncounterId Pages.Tuberculosis.ProgressReport.Model.Msg | MsgPageAcuteIllnessOutcome IndividualEncounterParticipantId Pages.AcuteIllness.Outcome.Model.Msg | MsgPageTraceContact AcuteIllnessTraceContactId Pages.TraceContact.Model.Msg | MsgPageClinicalProgressReport PrenatalEncounterId Pages.Prenatal.ProgressReport.Model.Msg diff --git a/client/src/elm/App/Update.elm b/client/src/elm/App/Update.elm index 5fab7ccdc5..33d1ba8437 100644 --- a/client/src/elm/App/Update.elm +++ b/client/src/elm/App/Update.elm @@ -112,6 +112,8 @@ import Pages.Tuberculosis.Activity.Model import Pages.Tuberculosis.Activity.Update import Pages.Tuberculosis.Encounter.Model import Pages.Tuberculosis.Encounter.Update +import Pages.Tuberculosis.ProgressReport.Model +import Pages.Tuberculosis.ProgressReport.Update import Pages.WellChild.Activity.Model import Pages.WellChild.Activity.Update import Pages.WellChild.Encounter.Model @@ -854,6 +856,19 @@ update msg model = , extraMsgs ) + MsgPageTuberculosisProgressReport id subMsg -> + let + ( subModel, subCmd, extraMsgs ) = + data.tuberculosisProgressReportPages + |> Dict.get id + |> Maybe.withDefault Pages.Tuberculosis.ProgressReport.Model.emptyModel + |> Pages.Tuberculosis.ProgressReport.Update.update subMsg + in + ( { data | tuberculosisProgressReportPages = Dict.insert id subModel data.tuberculosisProgressReportPages } + , Cmd.map (MsgLoggedIn << MsgPageTuberculosisProgressReport id) subCmd + , extraMsgs + ) + MsgPageAcuteIllnessOutcome id subMsg -> let ( subModel, subCmd, appMsgs ) = diff --git a/client/src/elm/App/View.elm b/client/src/elm/App/View.elm index c8bebce8de..63c278c3ec 100644 --- a/client/src/elm/App/View.elm +++ b/client/src/elm/App/View.elm @@ -109,6 +109,8 @@ import Pages.Tuberculosis.Activity.View import Pages.Tuberculosis.Encounter.Model import Pages.Tuberculosis.Encounter.View import Pages.Tuberculosis.Participant.View +import Pages.Tuberculosis.ProgressReport.Model +import Pages.Tuberculosis.ProgressReport.View import Pages.WellChild.Activity.Model import Pages.WellChild.Activity.View import Pages.WellChild.Encounter.Model @@ -986,6 +988,22 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur |> Html.map (MsgLoggedIn << MsgPageTuberculosisActivity id activity) |> flexPageWrapper configured.config model + TuberculosisProgressReportPage encounterId -> + let + page_ = + Dict.get encounterId loggedInModel.tuberculosisProgressReportPages + |> Maybe.withDefault Pages.Tuberculosis.ProgressReport.Model.emptyModel + in + Pages.Tuberculosis.ProgressReport.View.view model.language + currentDate + site + features + encounterId + model.indexedDb + page_ + |> Html.map (MsgLoggedIn << MsgPageTuberculosisProgressReport encounterId) + |> flexPageWrapper configured.config model + EducationSessionPage id -> let page_ = diff --git a/client/src/elm/Pages/Page.elm b/client/src/elm/Pages/Page.elm index 4bd9010096..aacfd9a747 100644 --- a/client/src/elm/Pages/Page.elm +++ b/client/src/elm/Pages/Page.elm @@ -196,6 +196,7 @@ type UserPage | TuberculosisParticipantPage PersonId | TuberculosisEncounterPage TuberculosisEncounterId -- Tuberculosis activities index. | TuberculosisActivityPage TuberculosisEncounterId TuberculosisActivity -- record Tuberculosis activity. + | TuberculosisProgressReportPage TuberculosisEncounterId -- Tuberculosis progress report. | EducationSessionPage EducationSessionId -- Education Session page. | HIVParticipantPage PersonId | HIVEncounterPage HIVEncounterId -- HIV activities index. diff --git a/client/src/elm/Pages/Router.elm b/client/src/elm/Pages/Router.elm index c309c5cbfc..d1f69ef3bf 100644 --- a/client/src/elm/Pages/Router.elm +++ b/client/src/elm/Pages/Router.elm @@ -354,6 +354,9 @@ pageToFragment current = TuberculosisActivityPage id activity -> Just <| "tuberculosis-activity/" ++ fromEntityUuid id ++ "/" ++ Backend.TuberculosisActivity.Utils.activityToString activity + TuberculosisProgressReportPage id -> + Just <| "tuberculosis-progress-report/" ++ fromEntityUuid id + EducationSessionPage id -> Just <| "education-session/" ++ fromEntityUuid id @@ -443,6 +446,7 @@ parser = , map (\initiator -> UserPage <| NCDProgressReportPage initiator) (s "ncd-progress-report" parseNCDProgressReportInitiator) , map (\id -> UserPage <| TuberculosisEncounterPage id) (s "tuberculosis-encounter" parseUuid) , map (\id activity -> UserPage <| TuberculosisActivityPage id activity) (s "tuberculosis-activity" parseUuid parseTuberculosisActivity) + , map (\id -> UserPage <| TuberculosisProgressReportPage id) (s "tuberculosis-progress-report" parseUuid) , map (\id -> UserPage <| EducationSessionPage id) (s "education-session" parseUuid) , map (\id -> UserPage <| HIVEncounterPage id) (s "hiv-encounter" parseUuid) , map (\id activity -> UserPage <| HIVActivityPage id activity) (s "hiv-activity" parseUuid parseHIVActivity) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Fetch.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Fetch.elm new file mode 100644 index 0000000000..eeabb0f016 --- /dev/null +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Fetch.elm @@ -0,0 +1,11 @@ +module Pages.Tuberculosis.ProgressReport.Fetch exposing (fetch) + +import AssocList as Dict +import Backend.Entities exposing (..) +import Backend.Model exposing (ModelIndexedDb, MsgIndexedDb(..)) +import Pages.Tuberculosis.Encounter.Fetch + + +fetch : TuberculosisEncounterId -> ModelIndexedDb -> List MsgIndexedDb +fetch = + Pages.Tuberculosis.Encounter.Fetch.fetch diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm new file mode 100644 index 0000000000..3677aa0db5 --- /dev/null +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm @@ -0,0 +1,32 @@ +module Pages.Tuberculosis.ProgressReport.Model exposing (..) + +import Backend.Entities exposing (..) +import Components.ReportToWhatsAppDialog.Model +import EverySet exposing (EverySet) +import Pages.Page exposing (Page) + + +type alias Model = + { showEndEncounterDialog : Bool + , reportToWhatsAppDialog : Components.ReportToWhatsAppDialog.Model.Model + + -- , components : Maybe (EverySet Components.ReportToWhatsAppDialog.Model.ReportComponentTuberculosis) + } + + +emptyModel : Model +emptyModel = + { showEndEncounterDialog = False + , reportToWhatsAppDialog = Components.ReportToWhatsAppDialog.Model.emptyModel + + -- , components = Nothing + } + + +type Msg + = NoOp + | CloseEncounter TuberculosisEncounterId + | SetActivePage Page + | SetEndEncounterDialogState Bool + | MsgReportToWhatsAppDialog (Components.ReportToWhatsAppDialog.Model.Msg Msg) + | SetReportComponents (Maybe Components.ReportToWhatsAppDialog.Model.ReportComponentsList) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm new file mode 100644 index 0000000000..ca13610f15 --- /dev/null +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm @@ -0,0 +1,61 @@ +module Pages.Tuberculosis.ProgressReport.Update exposing (update) + +import App.Model +import Backend.Model +import Backend.TuberculosisEncounter.Model +import Components.ReportToWhatsAppDialog.Model +import Components.ReportToWhatsAppDialog.Update +import Gizra.Update exposing (sequenceExtra) +import Pages.Page exposing (Page(..)) +import Pages.Tuberculosis.ProgressReport.Model exposing (..) + + +update : Msg -> Model -> ( Model, Cmd Msg, List App.Model.Msg ) +update msg model = + case msg of + NoOp -> + ( model, Cmd.none, [] ) + + CloseEncounter id -> + ( { model | showEndEncounterDialog = False } + , Cmd.none + , [ Backend.TuberculosisEncounter.Model.CloseTuberculosisEncounter + |> Backend.Model.MsgTuberculosisEncounter id + |> App.Model.MsgIndexedDb + , App.Model.SetActivePage PinCodePage + ] + ) + + SetActivePage page -> + ( model, Cmd.none, [ App.Model.SetActivePage page ] ) + + SetEndEncounterDialogState isOpen -> + ( { model | showEndEncounterDialog = isOpen }, Cmd.none, [] ) + + MsgReportToWhatsAppDialog subMsg -> + let + ( dialogUpdated, cmd, ( extraMsgs, appMsgs ) ) = + Components.ReportToWhatsAppDialog.Update.update subMsg model.reportToWhatsAppDialog + in + ( { model | reportToWhatsAppDialog = dialogUpdated }, cmd, appMsgs ) + |> sequenceExtra update extraMsgs + + SetReportComponents maybeComponents -> + let + updatedModel = + -- @todo + -- Maybe.map + -- (\components -> + -- case components of + -- Components.ReportToWhatsAppDialog.Model.Tuberculosis wellChildComponents -> + -- { model | components = Just wellChildComponents } + -- + -- -- We should never get here. + -- _ -> + -- model + -- ) + -- maybeComponents + -- |> Maybe.withDefault { model | components = Nothing } + model + in + ( updatedModel, Cmd.none, [] ) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm new file mode 100644 index 0000000000..e218d40ad1 --- /dev/null +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -0,0 +1,862 @@ +module Pages.Tuberculosis.ProgressReport.View exposing (view) + +import AssocList as Dict +import Backend.Entities exposing (..) +import Backend.IndividualEncounterParticipant.Model exposing (IndividualEncounterParticipant) +import Backend.Measurement.Model +import Backend.Measurement.Utils exposing (getMeasurementValueFunc) +import Backend.Model exposing (ModelIndexedDb) +import Backend.Person.Model exposing (Person) +import Backend.TuberculosisActivity.Utils exposing (allActivities) +import Components.ReportToWhatsAppDialog.Model +import Components.ReportToWhatsAppDialog.Utils +import Components.ReportToWhatsAppDialog.View +import EverySet exposing (EverySet) +import Gizra.Html exposing (emptyNode, showIf) +import Gizra.NominalDate exposing (NominalDate, formatDDMMYYYY) +import Html exposing (..) +import Html.Attributes exposing (..) +import Html.Events exposing (..) +import Maybe.Extra exposing (isNothing) +import Measurement.Model exposing (LaboratoryTask(..)) +import Pages.AcuteIllness.Participant.Utils exposing (isAcuteIllnessActive) +import Pages.Page exposing (Page(..), UserPage(..)) +import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData) +import Pages.Tuberculosis.ProgressReport.Model exposing (..) +import Pages.Utils + exposing + ( viewEndEncounterDialog + , viewEndEncounterMenuForProgressReport + , viewPersonDetailsExtended + ) +import RemoteData +import SyncManager.Model exposing (Site, SiteFeature) +import Translate exposing (Language, TranslationId, translate) +import Utils.Html exposing (viewModal) +import Utils.NominalDate exposing (sortTuplesByDateDesc) +import Utils.WebData exposing (viewWebData) + + +view : + Language + -> NominalDate + -> Site + -> EverySet SiteFeature + -> TuberculosisEncounterId + -> ModelIndexedDb + -> Model + -> Html Msg +view language currentDate site features id db model = + let + assembled = + generateAssembledData id db + + -- header = + -- viewHeader language initiator model + -- + -- content = + -- viewWebData language (viewContent language currentDate site features initiator db model) identity assembled + -- endEncounterDialog = + -- if model.showEndEncounterDialog then + -- Just <| + -- viewEndEncounterDialog language + -- Translate.EndEncounterQuestion + -- Translate.OnceYouEndTheEncounter + -- (CloseEncounter id) + -- (SetEndEncounterDialogState False) + -- + -- else + -- Nothing + in + div [ class "page-report ncd" ] <| + [-- header + -- , content + -- , viewModal endEncounterDialog + ] + + + +-- viewHeader : Language -> TuberculosisProgressReportInitiator -> Model -> Html Msg +-- viewHeader language initiator model = +-- let +-- label = +-- Maybe.map +-- (\mode -> +-- case mode of +-- LabResultsCurrent _ -> +-- Translate.LabResults +-- +-- LabResultsHistory _ -> +-- Translate.LabHistory +-- ) +-- model.labResultsMode +-- |> Maybe.withDefault Translate.TuberculosisProgressReport +-- +-- backIcon = +-- let +-- iconForView action = +-- span +-- [ class "link-back" ] +-- [ span +-- [ class "icon-back" +-- , onClick action +-- ] +-- [] +-- ] +-- +-- goBackAction defaultAction = +-- Maybe.map goBackActionByLabResultsState model.labResultsMode +-- |> Maybe.withDefault (goBackActionByDiagnosisMode defaultAction) +-- +-- goBackActionByLabResultsState mode = +-- let +-- backToCurrentMsg targetMode = +-- SetLabResultsMode (Just (LabResultsCurrent targetMode)) +-- in +-- case mode of +-- LabResultsCurrent currentMode -> +-- case currentMode of +-- LabResultsCurrentMain -> +-- SetLabResultsMode Nothing +-- +-- LabResultsCurrentDipstickShort -> +-- backToCurrentMsg LabResultsCurrentMain +-- +-- LabResultsCurrentDipstickLong -> +-- backToCurrentMsg LabResultsCurrentMain +-- +-- LabResultsCurrentLipidPanel -> +-- backToCurrentMsg LabResultsCurrentMain +-- +-- LabResultsHistory _ -> +-- SetLabResultsMode model.labResultsHistoryOrigin +-- +-- goBackActionByDiagnosisMode defaultAction = +-- case model.diagnosisMode of +-- ModeActiveDiagnosis -> +-- defaultAction +-- +-- ModeCompletedDiagnosis -> +-- SetDiagnosisMode ModeActiveDiagnosis +-- in +-- case initiator of +-- Backend.TuberculosisEncounter.Types.InitiatorEncounterPage id -> +-- iconForView <| goBackAction (SetActivePage <| UserPage <| TuberculosisEncounterPage id) +-- +-- Backend.TuberculosisEncounter.Types.InitiatorRecurrentEncounterPage id -> +-- iconForView <| goBackAction (SetActivePage <| UserPage <| TuberculosisRecurrentEncounterPage id) +-- in +-- div +-- [ class "ui basic segment head" ] +-- [ h1 [ class "ui header" ] +-- [ text <| translate language label ] +-- , backIcon +-- ] +-- +-- +-- viewContent : +-- Language +-- -> NominalDate +-- -> Site +-- -> EverySet SiteFeature +-- -> TuberculosisProgressReportInitiator +-- -> ModelIndexedDb +-- -> Model +-- -> AssembledData +-- -> Html Msg +-- viewContent language currentDate site features initiator db model assembled = +-- let +-- derivedContent = +-- let +-- isLabTech = +-- -- For now, Tuberculosis does not allow access for lab technicians. +-- False +-- +-- isResultsReviewer = +-- -- For now, Tuberculosis does not allow access for labs results reviewers. +-- False +-- +-- labResultsConfig = +-- { hivPCR = False +-- , partnerHIV = False +-- , syphilis = False +-- , hepatitisB = False +-- , malaria = False +-- , hemoglobin = False +-- , bloodGpRs = False +-- , creatinine = True +-- , liverFunction = True +-- , pregnancy = expectLaboratoryTask currentDate assembled TaskPregnancyTest +-- , hba1c = True +-- , lipidPanel = True +-- } +-- in +-- case model.labResultsMode of +-- Just mode -> +-- case mode of +-- LabResultsCurrent currentMode -> +-- [ generateLabsResultsPaneData currentDate assembled +-- |> viewLabResultsPane language +-- currentDate +-- (isLabTech || isResultsReviewer) +-- currentMode +-- SetLabResultsMode +-- labResultsConfig +-- ] +-- +-- LabResultsHistory historyMode -> +-- [ viewLabResultsHistoryPane language currentDate historyMode ] +-- +-- Nothing -> +-- let +-- acuteIllnesses = +-- Dict.get assembled.participant.person db.individualParticipantsByPerson +-- |> Maybe.andThen RemoteData.toMaybe +-- |> Maybe.map Dict.toList +-- |> Maybe.withDefault [] +-- |> List.filter +-- (\( _, participant ) -> +-- participant.encounterType == Backend.IndividualEncounterParticipant.Model.AcuteIllnessEncounter +-- ) +-- in +-- case model.diagnosisMode of +-- ModeActiveDiagnosis -> +-- let +-- -- Drawing SVG charts causes major slowness, specially when +-- -- typing new phone number. Therefore, we do not show it when +-- -- 'Send via WhatsApp' dialog is open, until its final +-- -- confirmation steps. +-- showPatientProgressPaneByWhatsAppDialog = +-- Maybe.map +-- (\state -> +-- case state of +-- Components.ReportToWhatsAppDialog.Model.ConfirmationBeforeExecuting _ -> +-- True +-- +-- Components.ReportToWhatsAppDialog.Model.ExecutionResult _ -> +-- True +-- +-- _ -> +-- False +-- ) +-- model.reportToWhatsAppDialog.state +-- |> Maybe.withDefault True +-- +-- patientProgressPane = +-- if showPatientProgressPaneByWhatsAppDialog then +-- viewPatientProgressPane language currentDate assembled +-- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisPatientProgress) +-- +-- else +-- emptyNode +-- +-- labsPane = +-- Maybe.map +-- (\_ -> +-- generateLabsResultsPaneData currentDate assembled +-- |> viewLabResultsPane language +-- currentDate +-- (isLabTech || isResultsReviewer) +-- LabResultsCurrentMain +-- SetLabResultsMode +-- labResultsConfig +-- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisLabsResults) +-- ) +-- model.components +-- |> Maybe.withDefault (viewLabsPane language currentDate SetLabResultsMode) +-- +-- actions = +-- case initiator of +-- Backend.TuberculosisEncounter.Types.InitiatorEncounterPage _ -> +-- let +-- ( _, pendingActivities ) = +-- List.filter (Pages.Tuberculosis.Activity.Utils.expectActivity currentDate assembled) allActivities +-- |> List.partition (Pages.Tuberculosis.Activity.Utils.activityCompleted currentDate assembled) +-- +-- allowEndEncounter = +-- List.isEmpty pendingActivities +-- in +-- viewEndEncounterMenuForProgressReport language +-- features +-- allowEndEncounter +-- SetEndEncounterDialogState +-- (MsgReportToWhatsAppDialog <| +-- Components.ReportToWhatsAppDialog.Model.SetState <| +-- Just Components.ReportToWhatsAppDialog.Model.Consent +-- ) +-- +-- Backend.TuberculosisEncounter.Types.InitiatorRecurrentEncounterPage _ -> +-- viewEndEncounterMenuForProgressReport language +-- features +-- True +-- (always (SetActivePage <| UserPage GlobalCaseManagementPage)) +-- (MsgReportToWhatsAppDialog <| +-- Components.ReportToWhatsAppDialog.Model.SetState <| +-- Just Components.ReportToWhatsAppDialog.Model.Consent +-- ) +-- +-- showComponent = +-- Components.ReportToWhatsAppDialog.Utils.showComponent model.components +-- in +-- [ viewRiskFactorsPane language currentDate assembled +-- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisRiskFactors) +-- , viewAcuteIllnessPane language currentDate initiator acuteIllnesses model.diagnosisMode db +-- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisActiveDiagnosis) +-- , viewMedicalDiagnosisPane language currentDate assembled +-- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisMedicalDiagnosis) +-- , patientProgressPane +-- , labsPane +-- , -- Actions are hidden when viewing for sharing via WhatsApp. +-- showIf (isNothing model.components) actions +-- ] +-- +-- ModeCompletedDiagnosis -> +-- [ viewAcuteIllnessPane language currentDate initiator acuteIllnesses model.diagnosisMode db ] +-- +-- componentsConfig = +-- Just { setReportComponentsMsg = SetReportComponents } +-- in +-- div +-- [ class "ui unstackable items" +-- , Html.Attributes.id "report-content" +-- ] +-- <| +-- viewPersonInfoPane language currentDate assembled.person +-- :: (derivedContent +-- ++ [ Html.map MsgReportToWhatsAppDialog +-- (Components.ReportToWhatsAppDialog.View.view +-- language +-- currentDate +-- site +-- ( assembled.participant.person, assembled.person ) +-- Components.ReportToWhatsAppDialog.Model.ReportTuberculosis +-- componentsConfig +-- model.reportToWhatsAppDialog +-- ) +-- ] +-- ) +-- +-- +-- viewPersonInfoPane : Language -> NominalDate -> Person -> Html any +-- viewPersonInfoPane language currentDate person = +-- div [ class "pane person-details" ] +-- [ viewPaneHeading language Translate.PatientInformation +-- , div [ class "patient-info" ] <| +-- viewPersonDetailsExtended language currentDate person +-- ] +-- +-- +-- viewPaneHeading : Language -> TranslationId -> Html any +-- viewPaneHeading language label = +-- div [ class <| "pane-heading" ] +-- [ text <| translate language label ] +-- +-- +-- viewRiskFactorsPane : Language -> NominalDate -> AssembledData -> Html Msg +-- viewRiskFactorsPane language currentDate assembled = +-- let +-- allMeasurements = +-- assembled.measurements +-- :: List.map .measurements assembled.previousEncountersData +-- +-- content = +-- List.map (Translate.TuberculosisRiskFactor >> translate language >> text >> List.singleton >> li []) +-- riskFactors +-- |> ul [] +-- |> List.singleton +-- +-- riskFactors = +-- List.concatMap +-- (\measurements -> +-- let +-- familyRisks = +-- getMeasurementValueFunc measurements.familyHistory +-- |> Maybe.map (.signs >> generateFamilyHistoryRiskFactors) +-- |> Maybe.withDefault [] +-- +-- socialRisks = +-- getMeasurementValueFunc measurements.socialHistory +-- |> Maybe.map (.signs >> generateSocialHistoryRiskFactors) +-- |> Maybe.withDefault [] +-- in +-- familyRisks ++ socialRisks +-- ) +-- allMeasurements +-- |> Pages.Utils.unique +-- in +-- div [ class "risk-factors" ] +-- [ div [ class <| "pane-heading red" ] +-- [ img [ src "assets/images/exclamation-white-outline.png" ] [] +-- , span [] [ text <| translate language Translate.RiskFactors ] +-- ] +-- , div [ class "pane-content" ] content +-- ] +-- +-- +-- generateFamilyHistoryRiskFactors : EverySet TuberculosisFamilyHistorySign -> List TuberculosisRiskFactor +-- generateFamilyHistoryRiskFactors signs = +-- List.filter +-- (\riskFactor -> +-- case riskFactor of +-- RiskFactorHypertensionHistory -> +-- EverySet.member SignHypertensionHistory signs +-- +-- RiskFactorHearProblemHistory -> +-- EverySet.member SignHeartProblemHistory signs +-- +-- RiskFactorDiabetesHistory -> +-- EverySet.member SignDiabetesHistory signs +-- +-- _ -> +-- False +-- ) +-- familyHistoryRiskFactors +-- +-- +-- generateSocialHistoryRiskFactors : EverySet TuberculosisSocialHistorySign -> List TuberculosisRiskFactor +-- generateSocialHistoryRiskFactors signs = +-- List.filter +-- (\riskFactor -> +-- case riskFactor of +-- RiskFactorSmokeCigarettes -> +-- EverySet.member SignSmokeCigarettes signs +-- +-- RiskFactorConsumeSalt -> +-- EverySet.member SignConsumeSalt signs +-- +-- _ -> +-- False +-- ) +-- socialHistoryRiskFactors +-- +-- +-- familyHistoryRiskFactors : List TuberculosisRiskFactor +-- familyHistoryRiskFactors = +-- [ RiskFactorHypertensionHistory +-- , RiskFactorHearProblemHistory +-- , RiskFactorDiabetesHistory +-- ] +-- +-- +-- socialHistoryRiskFactors : List TuberculosisRiskFactor +-- socialHistoryRiskFactors = +-- [ RiskFactorSmokeCigarettes +-- , RiskFactorConsumeSalt +-- ] +-- +-- +-- viewMedicalDiagnosisPane : Language -> NominalDate -> AssembledData -> Html Msg +-- viewMedicalDiagnosisPane language currentDate assembled = +-- let +-- allEncountersData = +-- { id = assembled.id +-- , startDate = assembled.encounter.startDate +-- , diagnoses = assembled.encounter.diagnoses +-- , measurements = assembled.measurements +-- } +-- :: assembled.previousEncountersData +-- +-- content = +-- List.map (Translate.MedicalCondition >> translate language >> text >> List.singleton >> li []) coMorbidities +-- ++ dignoses +-- |> ul [] +-- |> List.singleton +-- +-- coMorbidities = +-- List.map .measurements allEncountersData +-- |> List.concatMap +-- (.coMorbidities +-- >> getMeasurementValueFunc +-- >> Maybe.map +-- (EverySet.toList +-- >> List.filter +-- (\mdecicalCondition -> +-- List.member mdecicalCondition +-- [ MedicalConditionHIV +-- , MedicalConditionDiabetes +-- , MedicalConditionKidneyDisease +-- , MedicalConditionPregnancy +-- , MedicalConditionHypertension +-- , MedicalConditionGestationalDiabetes +-- , MedicalConditionPregnancyRelatedHypertension +-- ] +-- ) +-- ) +-- >> Maybe.withDefault [] +-- ) +-- |> Pages.Utils.unique +-- +-- dignoses = +-- List.concatMap +-- (\data -> +-- let +-- diagnosesIncludingChronic = +-- updateChronicDiagnoses data.startDate data.diagnoses assembled +-- +-- withRenalComplications = +-- List.member DiagnosisRenalComplications diagnosesIncludingChronic +-- +-- withDiabetes = +-- List.any (\diagnosis -> List.member diagnosis diagnosesIncludingChronic) diabetesDiagnoses +-- in +-- List.map (viewTreatmentForDiagnosis language data.startDate data.measurements withRenalComplications withDiabetes) diagnosesIncludingChronic +-- ) +-- allEncountersData +-- in +-- div [ class "medical-diagnosis" ] +-- [ viewItemHeading language Translate.MedicalDiagnosis "blue" +-- , div [ class "pane-content" ] content +-- ] +-- +-- +-- viewTreatmentForDiagnosis : +-- Language +-- -> NominalDate +-- -> TuberculosisMeasurements +-- -> Bool +-- -> Bool +-- -> TuberculosisDiagnosis +-- -> Html any +-- viewTreatmentForDiagnosis language date measurements withRenalComplications withDiabetes diagnosis = +-- let +-- diagnosisForProgressReport = +-- translate language <| Translate.TuberculosisDiagnosisForProgressReport withRenalComplications isPregnant diagnosis +-- +-- isPregnant = +-- patientIsPregnant measurements +-- +-- hypertensionMessage = +-- let +-- treatmentPhrase = +-- getMeasurementValueFunc measurements.medicationDistribution +-- |> Maybe.map +-- (\value -> +-- let +-- recordedTreatmentSignsForHypertension = +-- EverySet.toList value.recommendedTreatmentSigns +-- |> List.filter (\sign -> List.member sign allRecommendedTreatmentSignsForHypertension) +-- in +-- case recordedTreatmentSignsForHypertension of +-- [ NoTreatmentForHypertension ] -> +-- String.toLower <| translate language Translate.NoTreatmentAdministered +-- +-- _ -> +-- let +-- treatment = +-- List.map (Translate.RecommendedTreatmentSignLabel >> translate language) recordedTreatmentSignsForHypertension +-- |> List.intersperse (translate language Translate.And) +-- |> String.join " " +-- in +-- (String.toLower <| translate language Translate.TreatedWith) +-- ++ " " +-- ++ treatment +-- ) +-- |> Maybe.withDefault +-- (getMeasurementValueFunc measurements.healthEducation +-- |> Maybe.map +-- (\signs -> +-- case EverySet.toList signs of +-- [ NoTuberculosisHealthEducationSigns ] -> +-- String.toLower <| translate language Translate.HealthEducationNotProvided +-- +-- _ -> +-- String.toLower <| translate language Translate.HealthEducationProvided +-- ) +-- |> Maybe.withDefault (String.toLower <| translate language Translate.NoTreatmentRecorded) +-- ) +-- +-- referralPhrase = +-- if +-- -- These are conditions when referral is needed, when +-- -- combined with Hypertension diagnosis. +-- isPregnant || withRenalComplications || withDiabetes || diagnosis == DiagnosisHypertensionStage3 +-- then +-- let +-- phrase = +-- getMeasurementValueFunc measurements.referral +-- |> Maybe.map +-- (\value -> +-- let +-- ( facility, referralSign, nonReferralSign ) = +-- if isPregnant then +-- ( FacilityANCServices, ReferToANCServices, NonReferralReasonANCServices ) +-- +-- else +-- ( FacilityHospital, ReferToHospital, NonReferralReasonHospital ) +-- in +-- if EverySet.member referralSign value.referralSigns then +-- String.toLower <| translate language <| Translate.ReferredToFacility facility +-- +-- else +-- let +-- nonReferralReason = +-- getCurrentReasonForNonReferral nonReferralSign value.nonReferralReasons +-- |> Maybe.map +-- (\reason -> +-- if reason == NoReasonForNonReferral then +-- "" +-- +-- else +-- " - " ++ (String.toLower <| translate language <| Translate.ReasonForNonReferral reason) +-- ) +-- |> Maybe.withDefault "" +-- in +-- (String.toLower <| translate language <| Translate.ReferredToFacilityNot facility) ++ nonReferralReason +-- ) +-- |> Maybe.withDefault (translate language Translate.NoReferralRecorded) +-- in +-- (String.toLower <| translate language Translate.And) +-- ++ " " +-- ++ phrase +-- ++ " " +-- +-- else +-- "" +-- in +-- diagnosisForProgressReport +-- ++ " - " +-- ++ treatmentPhrase +-- ++ " " +-- ++ referralPhrase +-- ++ (String.toLower <| translate language Translate.On) +-- ++ " " +-- ++ formatDDMMYYYY date +-- |> wrapWithLI +-- +-- diabetesMessage = +-- let +-- treatmentPhrase = +-- getMeasurementValueFunc measurements.medicationDistribution +-- |> Maybe.andThen +-- (.recommendedTreatmentSigns +-- >> EverySet.toList +-- >> List.filter (\sign -> List.member sign recommendedTreatmentSignsForDiabetes) +-- >> List.head +-- ) +-- |> Maybe.map +-- (\treatmentSign -> +-- if treatmentSign == NoTreatmentForDiabetes then +-- String.toLower <| translate language Translate.NoTreatmentAdministered +-- +-- else +-- (String.toLower <| translate language Translate.TreatedWith) +-- ++ " " +-- ++ (translate language <| Translate.RecommendedTreatmentSignLabel treatmentSign) +-- ) +-- |> Maybe.withDefault (String.toLower <| translate language Translate.NoTreatmentRecorded) +-- in +-- diagnosisForProgressReport +-- ++ " - " +-- ++ treatmentPhrase +-- ++ " " +-- ++ (String.toLower <| translate language Translate.On) +-- ++ " " +-- ++ formatDDMMYYYY date +-- |> wrapWithLI +-- +-- wrapWithLI = +-- text >> List.singleton >> li [] +-- in +-- case diagnosis of +-- DiagnosisHypertensionStage1 -> +-- hypertensionMessage +-- +-- DiagnosisHypertensionStage2 -> +-- hypertensionMessage +-- +-- DiagnosisHypertensionStage3 -> +-- hypertensionMessage +-- +-- DiagnosisDiabetesInitial -> +-- diabetesMessage +-- +-- DiagnosisDiabetesRecurrent -> +-- diabetesMessage +-- +-- DiagnosisRenalComplications -> +-- emptyNode +-- +-- NoTuberculosisDiagnosis -> +-- emptyNode +-- +-- +-- viewPatientProgressPane : Language -> NominalDate -> AssembledData -> Html Msg +-- viewPatientProgressPane language currentDate assembled = +-- let +-- allMeasurements = +-- assembled.measurements +-- :: List.map .measurements assembled.previousEncountersData +-- +-- sysMeasurements = +-- List.map Tuple.first bloodPressure +-- +-- diaMeasurements = +-- List.map Tuple.second bloodPressure +-- +-- bloodPressure = +-- List.map +-- (.vitals +-- >> getMeasurementValueFunc +-- >> Maybe.andThen +-- (\value -> +-- Maybe.map2 (\sys dia -> ( sys, dia )) +-- value.sys +-- value.dia +-- ) +-- ) +-- allMeasurements +-- |> Maybe.Extra.values +-- |> List.take 12 +-- |> List.reverse +-- +-- sugarCountMeasurements = +-- List.map +-- (.randomBloodSugarTest +-- >> getMeasurementValueFunc +-- >> Maybe.andThen randomBloodSugarResultFromValue +-- >> Maybe.andThen Tuple.second +-- ) +-- allMeasurements +-- |> Maybe.Extra.values +-- |> List.take 12 +-- |> List.reverse +-- +-- hba1cMeasurements = +-- List.map +-- (.hba1cTest >> getMeasurementValueFunc) +-- allMeasurements +-- |> Maybe.Extra.values +-- |> List.filterMap +-- (\value -> +-- Maybe.map2 Tuple.pair +-- value.executionDate +-- value.hba1cResult +-- ) +-- -- We do this to have a unique value for each date. +-- |> Dict.fromList +-- |> Dict.values +-- |> List.take 12 +-- |> List.reverse +-- in +-- div [ class "patient-progress" ] +-- [ viewItemHeading language Translate.PatientProgress "blue" +-- , div [ class "pane-content" ] +-- [ viewMarkers +-- , div [ class "chart-section" ] +-- [ div [ class "heading" ] [ text <| translate language Translate.BloodPressure ] +-- , viewBloodPressureByTime language sysMeasurements diaMeasurements +-- ] +-- , div [ class "chart-section" ] +-- [ div [ class "heading" ] [ text <| translate language Translate.BloodGlucose ] +-- , viewBloodGlucoseByTime language sugarCountMeasurements +-- ] +-- , div [ class "chart-section" ] +-- [ div [ class "heading" ] [ text <| translate language Translate.HbA1c ] +-- , viewHbA1cByTime language hba1cMeasurements +-- ] +-- ] +-- ] +-- +-- +-- viewAcuteIllnessPane : +-- Language +-- -> NominalDate +-- -> TuberculosisProgressReportInitiator +-- -> List ( IndividualEncounterParticipantId, IndividualEncounterParticipant ) +-- -> DiagnosisMode +-- -> ModelIndexedDb +-- -> Html Msg +-- viewAcuteIllnessPane language currentDate initiator acuteIllnesses diagnosisMode db = +-- let +-- ( activeIllnesses, completedIllnesses ) = +-- List.partition (Tuple.second >> isAcuteIllnessActive currentDate) acuteIllnesses +-- +-- entriesHeading = +-- div [ class "heading diagnosis" ] +-- [ div [ class "assesment" ] [ text <| translate language Translate.Assessment ] +-- , div [ class "status" ] [ text <| translate language Translate.StatusLabel ] +-- , div [ class "date" ] [ text <| translate language Translate.DiagnosisDate ] +-- , div [ class "see-more" ] [ text <| translate language Translate.SeeMore ] +-- ] +-- +-- ( label, priorDiagniosisButton ) = +-- case diagnosisMode of +-- ModeActiveDiagnosis -> +-- ( Translate.ActiveDiagnosis +-- , div [ class "pane-action" ] +-- [ button +-- [ class "ui primary button" +-- , onClick <| SetDiagnosisMode ModeCompletedDiagnosis +-- ] +-- [ text <| translate language Translate.ReviewPriorDiagnosis ] +-- ] +-- ) +-- +-- ModeCompletedDiagnosis -> +-- ( Translate.PriorDiagnosis +-- , emptyNode +-- ) +-- +-- daignosisEntries = +-- List.map +-- (\( data, _ ) -> +-- let +-- acuteIllnessProgressReportInitiator = +-- InitiatorTuberculosisProgressReport initiator +-- in +-- viewAcuteIllnessDiagnosisEntry language acuteIllnessProgressReportInitiator db SetActivePage data +-- ) +-- selectedDiagnosisEntries +-- |> Maybe.Extra.values +-- +-- selectedDiagnosisEntries = +-- case diagnosisMode of +-- ModeActiveDiagnosis -> +-- List.map (\( participantId, data ) -> ( ( participantId, StatusOngoing ), data )) activeIllnesses +-- +-- ModeCompletedDiagnosis -> +-- List.map (\( participantId, data ) -> ( ( participantId, StatusResolved ), data )) completedIllnesses +-- +-- entries = +-- List.sortWith sortTuplesByDateDesc daignosisEntries +-- |> List.map Tuple.second +-- in +-- div [ class "pane diagnosis" ] +-- [ viewPaneHeading language label +-- , div [ class "pane-content" ] <| +-- entriesHeading +-- :: viewEntries language entries +-- , priorDiagniosisButton +-- ] +-- +-- +-- generateLabsResultsPaneData : +-- NominalDate +-- -> AssembledData +-- -> LabsResultsValues TuberculosisEncounterId +-- generateLabsResultsPaneData currentDate assembled = +-- let +-- allMeasurements = +-- assembled.measurements +-- :: List.map .measurements assembled.previousEncountersData +-- +-- extractValues getMeasurementFunc = +-- List.filterMap (getMeasurementFunc >> getMeasurementValueFunc) +-- allMeasurements +-- in +-- { hiv = extractValues .hivTest +-- , urineDipstick = extractValues .urineDipstickTest +-- , randomBloodSugar = extractValues .randomBloodSugarTest +-- , hivPCR = [] +-- , partnerHIV = [] +-- , syphilis = [] +-- , hepatitisB = [] +-- , malaria = [] +-- , hemoglobin = [] +-- , bloodGpRs = [] +-- , creatinine = extractValues .creatinineTest +-- , liverFunction = extractValues .liverFunctionTest +-- , pregnancy = extractValues .pregnancyTest +-- , hba1c = extractValues .hba1cTest +-- , lipidPanel = extractValues .lipidPanelTest +-- } diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 468d9419c1..b3788e3986 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -24176,6 +24176,12 @@ translateActivePage page = , kirundi = Nothing } + TuberculosisProgressReportPage _ -> + { english = "Tuberculosis Progress Report" + , kinyarwanda = Nothing + , kirundi = Nothing + } + EducationSessionPage _ -> translationSet GroupEducation From eeff0ba914e7a54fc4b3220b66ce84727b2dd877 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 27 Jun 2024 10:46:40 +0300 Subject: [PATCH 20/63] Header and Patient info pane [ci skip] --- client/src/assets/scss/_new.scss | 8 +- .../AcuteIllness/ProgressReport/View.elm | 7 +- .../elm/Pages/Tuberculosis/Encounter/View.elm | 13 +- .../Tuberculosis/ProgressReport/View.elm | 141 ++++++------------ 4 files changed, 54 insertions(+), 115 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index b750c95baf..f919fa9b1b 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -1148,12 +1148,11 @@ div.page-activity { } } -// Prenatal Encounter, Nutrition Encounter and -// Acute Illness Encounter pages div.page-encounter.nutrition, div.page-encounter.prenatal, div.page-encounter.acute-illness, -div.page-encounter.ncd { +div.page-encounter.ncd, +div.page-encounter.tuberculosis { .ui.full.segment { @@ -4039,7 +4038,8 @@ div.page-report.clinical, div.page-report.demographics, div.page-activity.patient-record, div.page-report.child-scoreboard, -div.page-report.ncd { +div.page-report.ncd, +div.page-report.tuberculosis { background: unset; .pane-heading { diff --git a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm index cad8b0945d..5f8c0846a1 100644 --- a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm +++ b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm @@ -186,15 +186,12 @@ viewHeader language id initiator = in div [ class "ui basic segment head" ] [ h1 [ class "ui header" ] - [ text <| translate language label - ] + [ text <| translate language label ] , span [ class "link-back" , onClick <| SetActivePage (UserPage goBackPage) ] - [ span [ class "icon-back" ] [] - , span [] [] - ] + [ span [ class "icon-back" ] [] ] ] diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/View.elm b/client/src/elm/Pages/Tuberculosis/Encounter/View.elm index 1f23e13251..2a9d920ffc 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/View.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/View.elm @@ -136,13 +136,12 @@ viewMainPageContent language currentDate db assembled model = innerContent = if model.selectedTab == Reports then div [ class "reports-wrapper" ] - [-- @todo: - -- viewReportLink language - -- Translate.ProgressReport - -- (SetActivePage <| - -- UserPage <| - -- TuberculosisProgressReportPage (InitiatorEncounterPage assembled.id) - -- ) + [ viewReportLink language + Translate.ProgressReport + (SetActivePage <| + UserPage <| + TuberculosisProgressReportPage assembled.id + ) ] else diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index e218d40ad1..0073766d7f 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -19,8 +19,8 @@ import Html.Attributes exposing (..) import Html.Events exposing (..) import Maybe.Extra exposing (isNothing) import Measurement.Model exposing (LaboratoryTask(..)) -import Pages.AcuteIllness.Participant.Utils exposing (isAcuteIllnessActive) import Pages.Page exposing (Page(..), UserPage(..)) +import Pages.Tuberculosis.Encounter.Model exposing (AssembledData) import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData) import Pages.Tuberculosis.ProgressReport.Model exposing (..) import Pages.Utils @@ -29,6 +29,7 @@ import Pages.Utils , viewEndEncounterMenuForProgressReport , viewPersonDetailsExtended ) +import Pages.WellChild.ProgressReport.View exposing (viewPaneHeading, viewPersonInfoPane) import RemoteData import SyncManager.Model exposing (Site, SiteFeature) import Translate exposing (Language, TranslationId, translate) @@ -51,11 +52,12 @@ view language currentDate site features id db model = assembled = generateAssembledData id db - -- header = - -- viewHeader language initiator model - -- - -- content = - -- viewWebData language (viewContent language currentDate site features initiator db model) identity assembled + header = + viewHeader language id + + content = + viewWebData language (viewContent language currentDate site features model) identity assembled + -- endEncounterDialog = -- if model.showEndEncounterDialog then -- Just <| @@ -68,103 +70,44 @@ view language currentDate site features id db model = -- else -- Nothing in - div [ class "page-report ncd" ] <| - [-- header - -- , content - -- , viewModal endEncounterDialog + div [ class "page-report tuberculosis" ] <| + [ header + , content + + -- , viewModal endEncounterDialog ] +viewHeader : Language -> TuberculosisEncounterId -> Html Msg +viewHeader language id = + div [ class "ui basic segment head" ] + [ h1 [ class "ui header" ] + [ text <| translate language Translate.ProgressReport ] + , span + [ class "link-back" + , onClick <| SetActivePage (UserPage <| TuberculosisEncounterPage id) + ] + [ span [ class "icon-back" ] [] ] + ] + + +viewContent : + Language + -> NominalDate + -> Site + -> EverySet SiteFeature + -> Model + -> AssembledData + -> Html Msg +viewContent language currentDate site features model assembled = + div + [ class "ui report unstackable items" + , Html.Attributes.id "report-content" + ] + [ viewPersonInfoPane language currentDate assembled.person ] + + --- viewHeader : Language -> TuberculosisProgressReportInitiator -> Model -> Html Msg --- viewHeader language initiator model = --- let --- label = --- Maybe.map --- (\mode -> --- case mode of --- LabResultsCurrent _ -> --- Translate.LabResults --- --- LabResultsHistory _ -> --- Translate.LabHistory --- ) --- model.labResultsMode --- |> Maybe.withDefault Translate.TuberculosisProgressReport --- --- backIcon = --- let --- iconForView action = --- span --- [ class "link-back" ] --- [ span --- [ class "icon-back" --- , onClick action --- ] --- [] --- ] --- --- goBackAction defaultAction = --- Maybe.map goBackActionByLabResultsState model.labResultsMode --- |> Maybe.withDefault (goBackActionByDiagnosisMode defaultAction) --- --- goBackActionByLabResultsState mode = --- let --- backToCurrentMsg targetMode = --- SetLabResultsMode (Just (LabResultsCurrent targetMode)) --- in --- case mode of --- LabResultsCurrent currentMode -> --- case currentMode of --- LabResultsCurrentMain -> --- SetLabResultsMode Nothing --- --- LabResultsCurrentDipstickShort -> --- backToCurrentMsg LabResultsCurrentMain --- --- LabResultsCurrentDipstickLong -> --- backToCurrentMsg LabResultsCurrentMain --- --- LabResultsCurrentLipidPanel -> --- backToCurrentMsg LabResultsCurrentMain --- --- LabResultsHistory _ -> --- SetLabResultsMode model.labResultsHistoryOrigin --- --- goBackActionByDiagnosisMode defaultAction = --- case model.diagnosisMode of --- ModeActiveDiagnosis -> --- defaultAction --- --- ModeCompletedDiagnosis -> --- SetDiagnosisMode ModeActiveDiagnosis --- in --- case initiator of --- Backend.TuberculosisEncounter.Types.InitiatorEncounterPage id -> --- iconForView <| goBackAction (SetActivePage <| UserPage <| TuberculosisEncounterPage id) --- --- Backend.TuberculosisEncounter.Types.InitiatorRecurrentEncounterPage id -> --- iconForView <| goBackAction (SetActivePage <| UserPage <| TuberculosisRecurrentEncounterPage id) --- in --- div --- [ class "ui basic segment head" ] --- [ h1 [ class "ui header" ] --- [ text <| translate language label ] --- , backIcon --- ] --- --- --- viewContent : --- Language --- -> NominalDate --- -> Site --- -> EverySet SiteFeature --- -> TuberculosisProgressReportInitiator --- -> ModelIndexedDb --- -> Model --- -> AssembledData --- -> Html Msg --- viewContent language currentDate site features initiator db model assembled = -- let -- derivedContent = -- let From 6d5fef29a380cd50d0935d28eae1d7ed3e91bc46 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 27 Jun 2024 12:35:56 +0300 Subject: [PATCH 21/63] Add Empty panes [ci skip] --- .../Tuberculosis/ProgressReport/View.elm | 55 ++++++++++++++++++- client/src/elm/Translate.elm | 32 ++++++++++- 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 0073766d7f..9cade4d6d1 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -104,7 +104,60 @@ viewContent language currentDate site features model assembled = [ class "ui report unstackable items" , Html.Attributes.id "report-content" ] - [ viewPersonInfoPane language currentDate assembled.person ] + [ viewPersonInfoPane language currentDate assembled.person + , viewSummaryPane language currentDate assembled + , viewTreatmentTimelinePane language currentDate assembled + , viewAdverseEventsPane language currentDate assembled + , viewEncountersPane language currentDate assembled + ] + + +viewSummaryPane : Language -> NominalDate -> AssembledData -> Html any +viewSummaryPane language currentDate assembled = + let + content = + [] + in + div [ class "pane summary" ] + [ viewPaneHeading language Translate.Summary + , div [ class "pane-content" ] content + ] + + +viewTreatmentTimelinePane : Language -> NominalDate -> AssembledData -> Html any +viewTreatmentTimelinePane language currentDate assembled = + let + content = + [] + in + div [ class "pane treatment-timeline" ] + [ viewPaneHeading language Translate.TreatmentTimeline + , div [ class "pane-content" ] content + ] + + +viewAdverseEventsPane : Language -> NominalDate -> AssembledData -> Html any +viewAdverseEventsPane language currentDate assembled = + let + content = + [] + in + div [ class "pane adverse-events" ] + [ viewPaneHeading language Translate.AdverseEvents + , div [ class "pane-content" ] content + ] + + +viewEncountersPane : Language -> NominalDate -> AssembledData -> Html any +viewEncountersPane language currentDate assembled = + let + content = + [] + in + div [ class "pane encounters" ] + [ viewPaneHeading language Translate.Encounters + , div [ class "pane-content" ] content + ] diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index b3788e3986..de3b2b7342 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -388,6 +388,7 @@ type TranslationId | AdministeredOneOfAboveMedicinesQuestion | AddressInformation | AdoptionSurveyScoreInterpretation Int + | AdverseEvents | AdverseEventSinglePlural Int | AfterEachLiquidStool | AgeWord @@ -628,6 +629,7 @@ type TranslationId | DangerSignsTask DangerSignsTask | EmptyString | EncounterDate + | Encounters | EncounterTypes | EncounterTypePageLabel DashboardPage | EncounterTypeFollowUpQuestion IndividualEncounterType @@ -1689,6 +1691,7 @@ type TranslationId | SubsequentEncounterReferral AcuteIllnessEncounterType | SuccessiveAbortions | SuccessivePrematureDeliveries + | Summary | SuspectedCovid19CaseAlert | SuspectedCovid19CaseAlertHelper | SuspectedCovid19CaseIsolate @@ -1770,6 +1773,7 @@ type TranslationId | TreatmentReviewTask Bool TreatmentReviewTask | TreatmentReviewWarningPopupMessage | TreatmentReviewWarningPopupInstructions + | TreatmentTimeline | TrySyncing | Tuberculosis | TuberculosisActivityTitle TuberculosisActivity @@ -2965,7 +2969,7 @@ translationSet trans = AcuteIllnessLaboratory -> { english = "Laboratory" , kinyarwanda = Just "Ibizamini" - , kirundi = Just "Icumba c'ipimiro/" + , kirundi = Just "Icumba c'ipimiro" } AcuteIllnessExposure -> @@ -3002,6 +3006,12 @@ translationSet trans = , kirundi = Nothing } + AdverseEvents -> + { english = "AdverseEvents" + , kinyarwanda = Nothing + , kirundi = Nothing + } + AdverseEventSinglePlural val -> if val == 1 then { english = "Adverse event" @@ -5415,7 +5425,7 @@ translationSet trans = EmptyString -> { english = "" - , kinyarwanda = Just "" + , kinyarwanda =Nothing , kirundi = Nothing } @@ -5425,6 +5435,12 @@ translationSet trans = , kirundi = Just "Itarike y'umubonano" } + Encounters -> + { english = "Encounters" + , kinyarwanda = Nothing + , kirundi = Nothing + } + EncounterTypes -> { english = "Encounter Types" , kinyarwanda = Nothing @@ -21315,6 +21331,12 @@ translationSet trans = , kirundi = Just "Ukwibaruka hataragera kwakurikiranye" } + Summary -> + { english = "Summary" + , kinyarwanda = Nothing + , kirundi = Nothing + } + SuspectedCovid19CaseAlert -> { english = "Suspected COVID-19 case" , kinyarwanda = Just "Acyekwaho kwandura COVID-19" @@ -22116,6 +22138,12 @@ translationSet trans = , kirundi = Just "Umugwayi atubahiriza ivyo bamubwiye" } + TreatmentTimeline -> + { english = "Treatment Timeline" + , kinyarwanda = Nothing + , kirundi = Nothing + } + TrySyncing -> { english = "Try syncing with backend" , kinyarwanda = Just "Gerageza guhuza amakuru y'iki gikoresho cy'ikoranabuhanga n'abakoze E-Heza" From 31b7f961f83fb24f7979921aa6901cd582107700 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 27 Jun 2024 13:32:32 +0300 Subject: [PATCH 22/63] View Summary pane [ci skip] --- client/src/assets/scss/_new.scss | 18 + .../Pages/Tuberculosis/Encounter/Model.elm | 4 +- .../Pages/Tuberculosis/Encounter/Utils.elm | 2 +- .../Tuberculosis/ProgressReport/View.elm | 765 ++---------------- client/src/elm/Translate.elm | 21 + 5 files changed, 105 insertions(+), 705 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index f919fa9b1b..9a592b5fc9 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3871,6 +3871,24 @@ div.page-report.acute-illness { } } +div.page-report.tuberculosis { + + .pane.summary .pane-content { + color: $color-text; + padding: 20px; + } + + .pane.summary .pane-content .entry { + line-height: 40px; + } + + .pane.summary .pane-content .entry .label { + float: left; + width: 35%; + } + +} + div.page-report.acute-illness, div.page-activity.trace-contact, div.page-encounter.well-child, diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/Model.elm b/client/src/elm/Pages/Tuberculosis/Encounter/Model.elm index 8186ebfdc8..e5ae6d5a0c 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/Model.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/Model.elm @@ -34,14 +34,14 @@ type alias AssembledData = , participant : IndividualEncounterParticipant , person : Person , measurements : TuberculosisMeasurements - , previousEncountersData : List PreviousEncounterData + , previousEncountersData : List EncounterData -- Intial encounter is the one where initial diagnosis is made. , initialEncounter : Bool } -type alias PreviousEncounterData = +type alias EncounterData = { id : TuberculosisEncounterId , startDate : NominalDate , measurements : TuberculosisMeasurements diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm b/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm index 034dc0542a..a0e9a8a197 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm @@ -76,7 +76,7 @@ generateAssembledData id db = |> RemoteData.andMap (Success initialEncounter) -generatePreviousEncountersData : Maybe TuberculosisEncounterId -> IndividualEncounterParticipantId -> ModelIndexedDb -> List PreviousEncounterData +generatePreviousEncountersData : Maybe TuberculosisEncounterId -> IndividualEncounterParticipantId -> ModelIndexedDb -> List EncounterData generatePreviousEncountersData currentEncounterId participantId db = getTuberculosisEncountersForParticipant db participantId |> List.filterMap diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 9cade4d6d1..6b7678fb9a 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -11,13 +11,14 @@ import Backend.TuberculosisActivity.Utils exposing (allActivities) import Components.ReportToWhatsAppDialog.Model import Components.ReportToWhatsAppDialog.Utils import Components.ReportToWhatsAppDialog.View +import Date exposing (Unit(..)) import EverySet exposing (EverySet) import Gizra.Html exposing (emptyNode, showIf) import Gizra.NominalDate exposing (NominalDate, formatDDMMYYYY) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) -import Maybe.Extra exposing (isNothing) +import Maybe.Extra exposing (isJust, isNothing) import Measurement.Model exposing (LaboratoryTask(..)) import Pages.Page exposing (Page(..), UserPage(..)) import Pages.Tuberculosis.Encounter.Model exposing (AssembledData) @@ -115,12 +116,70 @@ viewContent language currentDate site features model assembled = viewSummaryPane : Language -> NominalDate -> AssembledData -> Html any viewSummaryPane language currentDate assembled = let - content = - [] + allEncountersData = + { id = assembled.id + , startDate = assembled.encounter.startDate + , measurements = assembled.measurements + } + :: assembled.previousEncountersData + + firstEncounterData = + List.filter (.measurements >> .diagnostics >> isJust) + allEncountersData + |> List.reverse + |> List.head + + initiationDate = + Maybe.map .startDate firstEncounterData + + completionDate = + Maybe.map (Date.add Months 6) + initiationDate + + diagnosis = + Maybe.andThen (.measurements >> .diagnostics >> getMeasurementValueFunc) + firstEncounterData + + currentMedications = + List.filter (.measurements >> .medication >> isJust) allEncountersData + |> List.head + |> Maybe.andThen (.measurements >> .medication >> getMeasurementValueFunc) + + viewEntry label value = + div [ class "entry" ] + [ div [ class "label" ] [ text <| translate language label ] + , div [ class "value" ] [ text value ] + ] + + diagnosisForView = + Maybe.map (Translate.TuberculosisDiagnosis >> translate language) diagnosis + |> Maybe.withDefault "" + + initiationDateForView = + Maybe.map formatDDMMYYYY initiationDate + |> Maybe.withDefault "" + + completionDateForView = + Maybe.map formatDDMMYYYY completionDate + |> Maybe.withDefault "" + + currentMedicationsForView = + Maybe.map + (EverySet.toList + >> List.map (Translate.TuberculosisPrescribedMedication >> translate language) + >> String.join ", " + ) + currentMedications + |> Maybe.withDefault "" in div [ class "pane summary" ] [ viewPaneHeading language Translate.Summary - , div [ class "pane-content" ] content + , div [ class "pane-content" ] + [ viewEntry Translate.Diagnosis diagnosisForView + , viewEntry Translate.InitiationDate initiationDateForView + , viewEntry Translate.CompletionDate completionDateForView + , viewEntry Translate.CurrentMedication currentMedicationsForView + ] ] @@ -158,701 +217,3 @@ viewEncountersPane language currentDate assembled = [ viewPaneHeading language Translate.Encounters , div [ class "pane-content" ] content ] - - - --- let --- derivedContent = --- let --- isLabTech = --- -- For now, Tuberculosis does not allow access for lab technicians. --- False --- --- isResultsReviewer = --- -- For now, Tuberculosis does not allow access for labs results reviewers. --- False --- --- labResultsConfig = --- { hivPCR = False --- , partnerHIV = False --- , syphilis = False --- , hepatitisB = False --- , malaria = False --- , hemoglobin = False --- , bloodGpRs = False --- , creatinine = True --- , liverFunction = True --- , pregnancy = expectLaboratoryTask currentDate assembled TaskPregnancyTest --- , hba1c = True --- , lipidPanel = True --- } --- in --- case model.labResultsMode of --- Just mode -> --- case mode of --- LabResultsCurrent currentMode -> --- [ generateLabsResultsPaneData currentDate assembled --- |> viewLabResultsPane language --- currentDate --- (isLabTech || isResultsReviewer) --- currentMode --- SetLabResultsMode --- labResultsConfig --- ] --- --- LabResultsHistory historyMode -> --- [ viewLabResultsHistoryPane language currentDate historyMode ] --- --- Nothing -> --- let --- acuteIllnesses = --- Dict.get assembled.participant.person db.individualParticipantsByPerson --- |> Maybe.andThen RemoteData.toMaybe --- |> Maybe.map Dict.toList --- |> Maybe.withDefault [] --- |> List.filter --- (\( _, participant ) -> --- participant.encounterType == Backend.IndividualEncounterParticipant.Model.AcuteIllnessEncounter --- ) --- in --- case model.diagnosisMode of --- ModeActiveDiagnosis -> --- let --- -- Drawing SVG charts causes major slowness, specially when --- -- typing new phone number. Therefore, we do not show it when --- -- 'Send via WhatsApp' dialog is open, until its final --- -- confirmation steps. --- showPatientProgressPaneByWhatsAppDialog = --- Maybe.map --- (\state -> --- case state of --- Components.ReportToWhatsAppDialog.Model.ConfirmationBeforeExecuting _ -> --- True --- --- Components.ReportToWhatsAppDialog.Model.ExecutionResult _ -> --- True --- --- _ -> --- False --- ) --- model.reportToWhatsAppDialog.state --- |> Maybe.withDefault True --- --- patientProgressPane = --- if showPatientProgressPaneByWhatsAppDialog then --- viewPatientProgressPane language currentDate assembled --- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisPatientProgress) --- --- else --- emptyNode --- --- labsPane = --- Maybe.map --- (\_ -> --- generateLabsResultsPaneData currentDate assembled --- |> viewLabResultsPane language --- currentDate --- (isLabTech || isResultsReviewer) --- LabResultsCurrentMain --- SetLabResultsMode --- labResultsConfig --- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisLabsResults) --- ) --- model.components --- |> Maybe.withDefault (viewLabsPane language currentDate SetLabResultsMode) --- --- actions = --- case initiator of --- Backend.TuberculosisEncounter.Types.InitiatorEncounterPage _ -> --- let --- ( _, pendingActivities ) = --- List.filter (Pages.Tuberculosis.Activity.Utils.expectActivity currentDate assembled) allActivities --- |> List.partition (Pages.Tuberculosis.Activity.Utils.activityCompleted currentDate assembled) --- --- allowEndEncounter = --- List.isEmpty pendingActivities --- in --- viewEndEncounterMenuForProgressReport language --- features --- allowEndEncounter --- SetEndEncounterDialogState --- (MsgReportToWhatsAppDialog <| --- Components.ReportToWhatsAppDialog.Model.SetState <| --- Just Components.ReportToWhatsAppDialog.Model.Consent --- ) --- --- Backend.TuberculosisEncounter.Types.InitiatorRecurrentEncounterPage _ -> --- viewEndEncounterMenuForProgressReport language --- features --- True --- (always (SetActivePage <| UserPage GlobalCaseManagementPage)) --- (MsgReportToWhatsAppDialog <| --- Components.ReportToWhatsAppDialog.Model.SetState <| --- Just Components.ReportToWhatsAppDialog.Model.Consent --- ) --- --- showComponent = --- Components.ReportToWhatsAppDialog.Utils.showComponent model.components --- in --- [ viewRiskFactorsPane language currentDate assembled --- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisRiskFactors) --- , viewAcuteIllnessPane language currentDate initiator acuteIllnesses model.diagnosisMode db --- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisActiveDiagnosis) --- , viewMedicalDiagnosisPane language currentDate assembled --- |> showIf (showComponent Components.ReportToWhatsAppDialog.Model.ComponentTuberculosisMedicalDiagnosis) --- , patientProgressPane --- , labsPane --- , -- Actions are hidden when viewing for sharing via WhatsApp. --- showIf (isNothing model.components) actions --- ] --- --- ModeCompletedDiagnosis -> --- [ viewAcuteIllnessPane language currentDate initiator acuteIllnesses model.diagnosisMode db ] --- --- componentsConfig = --- Just { setReportComponentsMsg = SetReportComponents } --- in --- div --- [ class "ui unstackable items" --- , Html.Attributes.id "report-content" --- ] --- <| --- viewPersonInfoPane language currentDate assembled.person --- :: (derivedContent --- ++ [ Html.map MsgReportToWhatsAppDialog --- (Components.ReportToWhatsAppDialog.View.view --- language --- currentDate --- site --- ( assembled.participant.person, assembled.person ) --- Components.ReportToWhatsAppDialog.Model.ReportTuberculosis --- componentsConfig --- model.reportToWhatsAppDialog --- ) --- ] --- ) --- --- --- viewPersonInfoPane : Language -> NominalDate -> Person -> Html any --- viewPersonInfoPane language currentDate person = --- div [ class "pane person-details" ] --- [ viewPaneHeading language Translate.PatientInformation --- , div [ class "patient-info" ] <| --- viewPersonDetailsExtended language currentDate person --- ] --- --- --- viewPaneHeading : Language -> TranslationId -> Html any --- viewPaneHeading language label = --- div [ class <| "pane-heading" ] --- [ text <| translate language label ] --- --- --- viewRiskFactorsPane : Language -> NominalDate -> AssembledData -> Html Msg --- viewRiskFactorsPane language currentDate assembled = --- let --- allMeasurements = --- assembled.measurements --- :: List.map .measurements assembled.previousEncountersData --- --- content = --- List.map (Translate.TuberculosisRiskFactor >> translate language >> text >> List.singleton >> li []) --- riskFactors --- |> ul [] --- |> List.singleton --- --- riskFactors = --- List.concatMap --- (\measurements -> --- let --- familyRisks = --- getMeasurementValueFunc measurements.familyHistory --- |> Maybe.map (.signs >> generateFamilyHistoryRiskFactors) --- |> Maybe.withDefault [] --- --- socialRisks = --- getMeasurementValueFunc measurements.socialHistory --- |> Maybe.map (.signs >> generateSocialHistoryRiskFactors) --- |> Maybe.withDefault [] --- in --- familyRisks ++ socialRisks --- ) --- allMeasurements --- |> Pages.Utils.unique --- in --- div [ class "risk-factors" ] --- [ div [ class <| "pane-heading red" ] --- [ img [ src "assets/images/exclamation-white-outline.png" ] [] --- , span [] [ text <| translate language Translate.RiskFactors ] --- ] --- , div [ class "pane-content" ] content --- ] --- --- --- generateFamilyHistoryRiskFactors : EverySet TuberculosisFamilyHistorySign -> List TuberculosisRiskFactor --- generateFamilyHistoryRiskFactors signs = --- List.filter --- (\riskFactor -> --- case riskFactor of --- RiskFactorHypertensionHistory -> --- EverySet.member SignHypertensionHistory signs --- --- RiskFactorHearProblemHistory -> --- EverySet.member SignHeartProblemHistory signs --- --- RiskFactorDiabetesHistory -> --- EverySet.member SignDiabetesHistory signs --- --- _ -> --- False --- ) --- familyHistoryRiskFactors --- --- --- generateSocialHistoryRiskFactors : EverySet TuberculosisSocialHistorySign -> List TuberculosisRiskFactor --- generateSocialHistoryRiskFactors signs = --- List.filter --- (\riskFactor -> --- case riskFactor of --- RiskFactorSmokeCigarettes -> --- EverySet.member SignSmokeCigarettes signs --- --- RiskFactorConsumeSalt -> --- EverySet.member SignConsumeSalt signs --- --- _ -> --- False --- ) --- socialHistoryRiskFactors --- --- --- familyHistoryRiskFactors : List TuberculosisRiskFactor --- familyHistoryRiskFactors = --- [ RiskFactorHypertensionHistory --- , RiskFactorHearProblemHistory --- , RiskFactorDiabetesHistory --- ] --- --- --- socialHistoryRiskFactors : List TuberculosisRiskFactor --- socialHistoryRiskFactors = --- [ RiskFactorSmokeCigarettes --- , RiskFactorConsumeSalt --- ] --- --- --- viewMedicalDiagnosisPane : Language -> NominalDate -> AssembledData -> Html Msg --- viewMedicalDiagnosisPane language currentDate assembled = --- let --- allEncountersData = --- { id = assembled.id --- , startDate = assembled.encounter.startDate --- , diagnoses = assembled.encounter.diagnoses --- , measurements = assembled.measurements --- } --- :: assembled.previousEncountersData --- --- content = --- List.map (Translate.MedicalCondition >> translate language >> text >> List.singleton >> li []) coMorbidities --- ++ dignoses --- |> ul [] --- |> List.singleton --- --- coMorbidities = --- List.map .measurements allEncountersData --- |> List.concatMap --- (.coMorbidities --- >> getMeasurementValueFunc --- >> Maybe.map --- (EverySet.toList --- >> List.filter --- (\mdecicalCondition -> --- List.member mdecicalCondition --- [ MedicalConditionHIV --- , MedicalConditionDiabetes --- , MedicalConditionKidneyDisease --- , MedicalConditionPregnancy --- , MedicalConditionHypertension --- , MedicalConditionGestationalDiabetes --- , MedicalConditionPregnancyRelatedHypertension --- ] --- ) --- ) --- >> Maybe.withDefault [] --- ) --- |> Pages.Utils.unique --- --- dignoses = --- List.concatMap --- (\data -> --- let --- diagnosesIncludingChronic = --- updateChronicDiagnoses data.startDate data.diagnoses assembled --- --- withRenalComplications = --- List.member DiagnosisRenalComplications diagnosesIncludingChronic --- --- withDiabetes = --- List.any (\diagnosis -> List.member diagnosis diagnosesIncludingChronic) diabetesDiagnoses --- in --- List.map (viewTreatmentForDiagnosis language data.startDate data.measurements withRenalComplications withDiabetes) diagnosesIncludingChronic --- ) --- allEncountersData --- in --- div [ class "medical-diagnosis" ] --- [ viewItemHeading language Translate.MedicalDiagnosis "blue" --- , div [ class "pane-content" ] content --- ] --- --- --- viewTreatmentForDiagnosis : --- Language --- -> NominalDate --- -> TuberculosisMeasurements --- -> Bool --- -> Bool --- -> TuberculosisDiagnosis --- -> Html any --- viewTreatmentForDiagnosis language date measurements withRenalComplications withDiabetes diagnosis = --- let --- diagnosisForProgressReport = --- translate language <| Translate.TuberculosisDiagnosisForProgressReport withRenalComplications isPregnant diagnosis --- --- isPregnant = --- patientIsPregnant measurements --- --- hypertensionMessage = --- let --- treatmentPhrase = --- getMeasurementValueFunc measurements.medicationDistribution --- |> Maybe.map --- (\value -> --- let --- recordedTreatmentSignsForHypertension = --- EverySet.toList value.recommendedTreatmentSigns --- |> List.filter (\sign -> List.member sign allRecommendedTreatmentSignsForHypertension) --- in --- case recordedTreatmentSignsForHypertension of --- [ NoTreatmentForHypertension ] -> --- String.toLower <| translate language Translate.NoTreatmentAdministered --- --- _ -> --- let --- treatment = --- List.map (Translate.RecommendedTreatmentSignLabel >> translate language) recordedTreatmentSignsForHypertension --- |> List.intersperse (translate language Translate.And) --- |> String.join " " --- in --- (String.toLower <| translate language Translate.TreatedWith) --- ++ " " --- ++ treatment --- ) --- |> Maybe.withDefault --- (getMeasurementValueFunc measurements.healthEducation --- |> Maybe.map --- (\signs -> --- case EverySet.toList signs of --- [ NoTuberculosisHealthEducationSigns ] -> --- String.toLower <| translate language Translate.HealthEducationNotProvided --- --- _ -> --- String.toLower <| translate language Translate.HealthEducationProvided --- ) --- |> Maybe.withDefault (String.toLower <| translate language Translate.NoTreatmentRecorded) --- ) --- --- referralPhrase = --- if --- -- These are conditions when referral is needed, when --- -- combined with Hypertension diagnosis. --- isPregnant || withRenalComplications || withDiabetes || diagnosis == DiagnosisHypertensionStage3 --- then --- let --- phrase = --- getMeasurementValueFunc measurements.referral --- |> Maybe.map --- (\value -> --- let --- ( facility, referralSign, nonReferralSign ) = --- if isPregnant then --- ( FacilityANCServices, ReferToANCServices, NonReferralReasonANCServices ) --- --- else --- ( FacilityHospital, ReferToHospital, NonReferralReasonHospital ) --- in --- if EverySet.member referralSign value.referralSigns then --- String.toLower <| translate language <| Translate.ReferredToFacility facility --- --- else --- let --- nonReferralReason = --- getCurrentReasonForNonReferral nonReferralSign value.nonReferralReasons --- |> Maybe.map --- (\reason -> --- if reason == NoReasonForNonReferral then --- "" --- --- else --- " - " ++ (String.toLower <| translate language <| Translate.ReasonForNonReferral reason) --- ) --- |> Maybe.withDefault "" --- in --- (String.toLower <| translate language <| Translate.ReferredToFacilityNot facility) ++ nonReferralReason --- ) --- |> Maybe.withDefault (translate language Translate.NoReferralRecorded) --- in --- (String.toLower <| translate language Translate.And) --- ++ " " --- ++ phrase --- ++ " " --- --- else --- "" --- in --- diagnosisForProgressReport --- ++ " - " --- ++ treatmentPhrase --- ++ " " --- ++ referralPhrase --- ++ (String.toLower <| translate language Translate.On) --- ++ " " --- ++ formatDDMMYYYY date --- |> wrapWithLI --- --- diabetesMessage = --- let --- treatmentPhrase = --- getMeasurementValueFunc measurements.medicationDistribution --- |> Maybe.andThen --- (.recommendedTreatmentSigns --- >> EverySet.toList --- >> List.filter (\sign -> List.member sign recommendedTreatmentSignsForDiabetes) --- >> List.head --- ) --- |> Maybe.map --- (\treatmentSign -> --- if treatmentSign == NoTreatmentForDiabetes then --- String.toLower <| translate language Translate.NoTreatmentAdministered --- --- else --- (String.toLower <| translate language Translate.TreatedWith) --- ++ " " --- ++ (translate language <| Translate.RecommendedTreatmentSignLabel treatmentSign) --- ) --- |> Maybe.withDefault (String.toLower <| translate language Translate.NoTreatmentRecorded) --- in --- diagnosisForProgressReport --- ++ " - " --- ++ treatmentPhrase --- ++ " " --- ++ (String.toLower <| translate language Translate.On) --- ++ " " --- ++ formatDDMMYYYY date --- |> wrapWithLI --- --- wrapWithLI = --- text >> List.singleton >> li [] --- in --- case diagnosis of --- DiagnosisHypertensionStage1 -> --- hypertensionMessage --- --- DiagnosisHypertensionStage2 -> --- hypertensionMessage --- --- DiagnosisHypertensionStage3 -> --- hypertensionMessage --- --- DiagnosisDiabetesInitial -> --- diabetesMessage --- --- DiagnosisDiabetesRecurrent -> --- diabetesMessage --- --- DiagnosisRenalComplications -> --- emptyNode --- --- NoTuberculosisDiagnosis -> --- emptyNode --- --- --- viewPatientProgressPane : Language -> NominalDate -> AssembledData -> Html Msg --- viewPatientProgressPane language currentDate assembled = --- let --- allMeasurements = --- assembled.measurements --- :: List.map .measurements assembled.previousEncountersData --- --- sysMeasurements = --- List.map Tuple.first bloodPressure --- --- diaMeasurements = --- List.map Tuple.second bloodPressure --- --- bloodPressure = --- List.map --- (.vitals --- >> getMeasurementValueFunc --- >> Maybe.andThen --- (\value -> --- Maybe.map2 (\sys dia -> ( sys, dia )) --- value.sys --- value.dia --- ) --- ) --- allMeasurements --- |> Maybe.Extra.values --- |> List.take 12 --- |> List.reverse --- --- sugarCountMeasurements = --- List.map --- (.randomBloodSugarTest --- >> getMeasurementValueFunc --- >> Maybe.andThen randomBloodSugarResultFromValue --- >> Maybe.andThen Tuple.second --- ) --- allMeasurements --- |> Maybe.Extra.values --- |> List.take 12 --- |> List.reverse --- --- hba1cMeasurements = --- List.map --- (.hba1cTest >> getMeasurementValueFunc) --- allMeasurements --- |> Maybe.Extra.values --- |> List.filterMap --- (\value -> --- Maybe.map2 Tuple.pair --- value.executionDate --- value.hba1cResult --- ) --- -- We do this to have a unique value for each date. --- |> Dict.fromList --- |> Dict.values --- |> List.take 12 --- |> List.reverse --- in --- div [ class "patient-progress" ] --- [ viewItemHeading language Translate.PatientProgress "blue" --- , div [ class "pane-content" ] --- [ viewMarkers --- , div [ class "chart-section" ] --- [ div [ class "heading" ] [ text <| translate language Translate.BloodPressure ] --- , viewBloodPressureByTime language sysMeasurements diaMeasurements --- ] --- , div [ class "chart-section" ] --- [ div [ class "heading" ] [ text <| translate language Translate.BloodGlucose ] --- , viewBloodGlucoseByTime language sugarCountMeasurements --- ] --- , div [ class "chart-section" ] --- [ div [ class "heading" ] [ text <| translate language Translate.HbA1c ] --- , viewHbA1cByTime language hba1cMeasurements --- ] --- ] --- ] --- --- --- viewAcuteIllnessPane : --- Language --- -> NominalDate --- -> TuberculosisProgressReportInitiator --- -> List ( IndividualEncounterParticipantId, IndividualEncounterParticipant ) --- -> DiagnosisMode --- -> ModelIndexedDb --- -> Html Msg --- viewAcuteIllnessPane language currentDate initiator acuteIllnesses diagnosisMode db = --- let --- ( activeIllnesses, completedIllnesses ) = --- List.partition (Tuple.second >> isAcuteIllnessActive currentDate) acuteIllnesses --- --- entriesHeading = --- div [ class "heading diagnosis" ] --- [ div [ class "assesment" ] [ text <| translate language Translate.Assessment ] --- , div [ class "status" ] [ text <| translate language Translate.StatusLabel ] --- , div [ class "date" ] [ text <| translate language Translate.DiagnosisDate ] --- , div [ class "see-more" ] [ text <| translate language Translate.SeeMore ] --- ] --- --- ( label, priorDiagniosisButton ) = --- case diagnosisMode of --- ModeActiveDiagnosis -> --- ( Translate.ActiveDiagnosis --- , div [ class "pane-action" ] --- [ button --- [ class "ui primary button" --- , onClick <| SetDiagnosisMode ModeCompletedDiagnosis --- ] --- [ text <| translate language Translate.ReviewPriorDiagnosis ] --- ] --- ) --- --- ModeCompletedDiagnosis -> --- ( Translate.PriorDiagnosis --- , emptyNode --- ) --- --- daignosisEntries = --- List.map --- (\( data, _ ) -> --- let --- acuteIllnessProgressReportInitiator = --- InitiatorTuberculosisProgressReport initiator --- in --- viewAcuteIllnessDiagnosisEntry language acuteIllnessProgressReportInitiator db SetActivePage data --- ) --- selectedDiagnosisEntries --- |> Maybe.Extra.values --- --- selectedDiagnosisEntries = --- case diagnosisMode of --- ModeActiveDiagnosis -> --- List.map (\( participantId, data ) -> ( ( participantId, StatusOngoing ), data )) activeIllnesses --- --- ModeCompletedDiagnosis -> --- List.map (\( participantId, data ) -> ( ( participantId, StatusResolved ), data )) completedIllnesses --- --- entries = --- List.sortWith sortTuplesByDateDesc daignosisEntries --- |> List.map Tuple.second --- in --- div [ class "pane diagnosis" ] --- [ viewPaneHeading language label --- , div [ class "pane-content" ] <| --- entriesHeading --- :: viewEntries language entries --- , priorDiagniosisButton --- ] --- --- --- generateLabsResultsPaneData : --- NominalDate --- -> AssembledData --- -> LabsResultsValues TuberculosisEncounterId --- generateLabsResultsPaneData currentDate assembled = --- let --- allMeasurements = --- assembled.measurements --- :: List.map .measurements assembled.previousEncountersData --- --- extractValues getMeasurementFunc = --- List.filterMap (getMeasurementFunc >> getMeasurementValueFunc) --- allMeasurements --- in --- { hiv = extractValues .hivTest --- , urineDipstick = extractValues .urineDipstickTest --- , randomBloodSugar = extractValues .randomBloodSugarTest --- , hivPCR = [] --- , partnerHIV = [] --- , syphilis = [] --- , hepatitisB = [] --- , malaria = [] --- , hemoglobin = [] --- , bloodGpRs = [] --- , creatinine = extractValues .creatinineTest --- , liverFunction = extractValues .liverFunctionTest --- , pregnancy = extractValues .pregnancyTest --- , hba1c = extractValues .hba1cTest --- , lipidPanel = extractValues .lipidPanelTest --- } diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index de3b2b7342..8393d74643 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -520,6 +520,7 @@ type TranslationId | ColorYellow | Commune | CompleteFacilityReferralForm ReferralFacility + | CompletionDate | Contacted114 | ContactedHC | ContactedHCQuestion @@ -536,6 +537,7 @@ type TranslationId | ConvulsionsAndUnconsciousPreviousDelivery | ConvulsionsPreviousDelivery | CSectionScar CSectionScar + | CurrentMedication | Dashboard Dashboard | Group | Groups @@ -815,6 +817,7 @@ type TranslationId | InfrastructureEnvironment | InfrastructureEnvironmentWash | InitialResultsDisplay InitialResultsDisplay + | InitiationDate | IntractableVomiting Bool | IntractableVomitingQuestion | InstructionsChooseOneMedication @@ -4242,6 +4245,12 @@ translationSet trans = , kirundi = Nothing } + CompletionDate -> + { english = "Completion Date" + , kinyarwanda = Nothing + , kirundi = Nothing + } + Contacted114 -> { english = "Contacted 114" , kinyarwanda = Just "Namenyesheje 114" @@ -4372,6 +4381,12 @@ translationSet trans = NoScar -> translationSet None + CurrentMedication -> + { english = "Current Medication" + , kinyarwanda = Nothing + , kirundi = Nothing + } + Group -> { english = "Group" , kinyarwanda = Just "Itsinda" @@ -7815,6 +7830,12 @@ translationSet trans = , kirundi = Just "Hisha ababyeyi / abarezi bose" } + InitiationDate -> + { english = "Initiation Date" + , kinyarwanda = Nothing + , kirundi = Nothing + } + IntractableVomiting isIntractable -> if isIntractable then { english = "Intractable Vomiting" From 640a85dbb5c552a0b0524326c6f5a7034913c639 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 27 Jun 2024 20:07:37 +0300 Subject: [PATCH 23/63] Adverse event pane + WIP Encounters pane [ci skip] --- client/src/assets/scss/_new.scss | 9 ++- client/src/elm/Measurement/Utils.elm | 2 +- .../AcuteIllness/ProgressReport/View.elm | 2 +- .../Tuberculosis/ProgressReport/View.elm | 72 +++++++++++++++---- client/src/elm/Translate.elm | 66 ++++++++--------- 5 files changed, 103 insertions(+), 48 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index 9a592b5fc9..296af1f5b3 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3873,12 +3873,12 @@ div.page-report.acute-illness { div.page-report.tuberculosis { - .pane.summary .pane-content { + .pane .pane-content { color: $color-text; padding: 20px; } - .pane.summary .pane-content .entry { + .pane .pane-content .entry { line-height: 40px; } @@ -3887,6 +3887,11 @@ div.page-report.tuberculosis { width: 35%; } + .pane.adverse-events .pane-content .entry .label { + float: left; + width: 70%; + } + } div.page-report.acute-illness, diff --git a/client/src/elm/Measurement/Utils.elm b/client/src/elm/Measurement/Utils.elm index cdceddb3b3..22414939d3 100644 --- a/client/src/elm/Measurement/Utils.elm +++ b/client/src/elm/Measurement/Utils.elm @@ -1536,7 +1536,7 @@ treatmentReviewCustomReasonsForNotTakingInputsAndTasks language currentDate ( re (Maybe.withDefault [] form.adverseEvents) Nothing setAdverseEventMsg - Translate.AcuteIllnessAdverseEvent + Translate.AdverseEvent ] , [ maybeToBoolTask form.adverseEvents ] ) diff --git a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm index 5f8c0846a1..33260c9aca 100644 --- a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm +++ b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm @@ -763,7 +763,7 @@ viewTreatmentSigns language currentDate initialEncounter firstInitialWithSubsequ events = EverySet.toList treatmentOngoing.adverseEvents - |> List.map (Translate.AcuteIllnessAdverseEvent >> translate language) + |> List.map (Translate.AdverseEvent >> translate language) in [ div [ class "treatment-comment" ] [ text "- " diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 6b7678fb9a..618770e923 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -21,7 +21,7 @@ import Html.Events exposing (..) import Maybe.Extra exposing (isJust, isNothing) import Measurement.Model exposing (LaboratoryTask(..)) import Pages.Page exposing (Page(..), UserPage(..)) -import Pages.Tuberculosis.Encounter.Model exposing (AssembledData) +import Pages.Tuberculosis.Encounter.Model exposing (AssembledData, EncounterData) import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData) import Pages.Tuberculosis.ProgressReport.Model exposing (..) import Pages.Utils @@ -117,11 +117,7 @@ viewSummaryPane : Language -> NominalDate -> AssembledData -> Html any viewSummaryPane language currentDate assembled = let allEncountersData = - { id = assembled.id - , startDate = assembled.encounter.startDate - , measurements = assembled.measurements - } - :: assembled.previousEncountersData + generateAllEncounters assembled firstEncounterData = List.filter (.measurements >> .diagnostics >> isJust) @@ -198,22 +194,74 @@ viewTreatmentTimelinePane language currentDate assembled = viewAdverseEventsPane : Language -> NominalDate -> AssembledData -> Html any viewAdverseEventsPane language currentDate assembled = let - content = - [] + allEncountersData = + generateAllEncounters assembled + + adverseEventsWithDates = + List.filterMap + (\data -> + getMeasurementValueFunc data.measurements.treatmentReview + |> Maybe.map + (\value -> + ( data.startDate, value.adverseEvents ) + ) + ) + allEncountersData + + entries = + List.map + (\( date, events ) -> + let + eventsForView = + EverySet.toList events + |> List.map (Translate.AdverseEvent >> translate language) + |> String.join ", " + in + viewEntry eventsForView (formatDDMMYYYY date) + ) + adverseEventsWithDates + + viewEntry label value = + div [ class "entry" ] + [ div [ class "label" ] [ text label ] + , div [ class "value" ] [ text value ] + ] in div [ class "pane adverse-events" ] [ viewPaneHeading language Translate.AdverseEvents - , div [ class "pane-content" ] content + , div [ class "pane-content" ] entries ] viewEncountersPane : Language -> NominalDate -> AssembledData -> Html any viewEncountersPane language currentDate assembled = let - content = - [] + allEncountersData = + generateAllEncounters assembled + + entries = + List.map + (\data -> + viewEntry (formatDDMMYYYY data.startDate) emptyNode + ) + allEncountersData + + viewEntry label htmlValue = + div [ class "entry" ] + [ div [ class "label" ] [ text label ] + , div [ class "value" ] [ htmlValue ] + ] in div [ class "pane encounters" ] [ viewPaneHeading language Translate.Encounters - , div [ class "pane-content" ] content + , div [ class "pane-content" ] entries ] + + +generateAllEncounters : AssembledData -> List EncounterData +generateAllEncounters assembled = + { id = assembled.id + , startDate = assembled.encounter.startDate + , measurements = assembled.measurements + } + :: assembled.previousEncountersData diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 8393d74643..280b62a2ff 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -337,7 +337,6 @@ type TranslationId | AcuteFindingsGeneralSign AcuteFindingsGeneralSign | AcuteFindingsRespiratorySign AcuteFindingsRespiratorySign | AcuteIllness - | AcuteIllnessAdverseEvent AdverseEvent | AcuteIllnessAdverseEventKindsQuestion | AcuteIllnessDangerSign AcuteIllnessDangerSign | AcuteIllnessDiagnosis AcuteIllnessDiagnosis @@ -388,6 +387,7 @@ type TranslationId | AdministeredOneOfAboveMedicinesQuestion | AddressInformation | AdoptionSurveyScoreInterpretation Int + | AdverseEvent AdverseEvent | AdverseEvents | AdverseEventSinglePlural Int | AfterEachLiquidStool @@ -2106,37 +2106,7 @@ translationSet trans = , kirundi = Just "Ingwara ikaze" } - AcuteIllnessAdverseEvent event -> - case event of - AdverseEventRashOrItching -> - { english = "Rash or Itching" - , kinyarwanda = Just "Kwishima cyangwa gusesa uduheri (turyaryata)" - , kirundi = Just "Amaherehere canke kwiyagaza" - } - - AdverseEventFever -> - translationSet Fever - - AdverseEventDiarrhea -> - translationSet Diarrhea - - AdverseEventVomiting -> - translationSet VomitingLabel - AdverseEventFatigue -> - translationSet Fatigue - - AdverseEventOther -> - { english = "Other" - , kinyarwanda = Just "Ibindi" - , kirundi = Just "Ibindi" - } - - NoAdverseEvent -> - { english = "None of the above" - , kinyarwanda = Just "Nta na kimwe mu byavuzwe haruguru" - , kirundi = Just "Nta nimwe muri izo ziri hejuru" - } AcuteIllnessAdverseEventKindsQuestion -> { english = "What kind of adverse events" @@ -3009,8 +2979,40 @@ translationSet trans = , kirundi = Nothing } + AdverseEvent event -> + case event of + AdverseEventRashOrItching -> + { english = "Rash or Itching" + , kinyarwanda = Just "Kwishima cyangwa gusesa uduheri (turyaryata)" + , kirundi = Just "Amaherehere canke kwiyagaza" + } + + AdverseEventFever -> + translationSet Fever + + AdverseEventDiarrhea -> + translationSet Diarrhea + + AdverseEventVomiting -> + translationSet VomitingLabel + + AdverseEventFatigue -> + translationSet Fatigue + + AdverseEventOther -> + { english = "Other" + , kinyarwanda = Just "Ibindi" + , kirundi = Just "Ibindi" + } + + NoAdverseEvent -> + { english = "None of the above" + , kinyarwanda = Just "Nta na kimwe mu byavuzwe haruguru" + , kirundi = Just "Nta nimwe muri izo ziri hejuru" + } + AdverseEvents -> - { english = "AdverseEvents" + { english = "Adverse Events" , kinyarwanda = Nothing , kirundi = Nothing } From d07702734eff3b8d266e2a52b142654dc877e24d Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 27 Jun 2024 23:33:21 +0300 Subject: [PATCH 24/63] Complete Encounters pane [ci skip] --- client/src/assets/scss/_new.scss | 37 +++++++++++++++++++ .../Tuberculosis/ProgressReport/View.elm | 17 +++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index 296af1f5b3..e89a383a90 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3878,6 +3878,16 @@ div.page-report.tuberculosis { padding: 20px; } + .pane .pane-content .heading { + border-bottom: 1px solid $color-text; + color: $color-dark-gray; + display: flex; + font-size: 20px; + font-weight: 600; + padding: 15px 30px; + width: 100%; + } + .pane .pane-content .entry { line-height: 40px; } @@ -3892,6 +3902,33 @@ div.page-report.tuberculosis { width: 70%; } + .pane.encounters .pane-content .heading .date { + width: 80%; + } + + .pane.encounters .pane-content .entry { + border-bottom: 1px solid $color-text; + display: flex; + padding: 15px 30px; + } + + .pane.encounters .pane-content .entry:last-child { + border-bottom: none; + } + + .pane.encounters .pane-content .entry .label { + float: left; + width: 80%; + } + + .pane.encounters .pane-content .entry .icon .icon-forward { + align-self: center; + background: url(#{$img-path}icon-forward-blue.svg) center center no-repeat; + background-size: 45px 50px; + height: 50px; + margin-left: 20px; + width: 50px; + } } div.page-report.acute-illness, diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 618770e923..2ff87c124e 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -239,22 +239,31 @@ viewEncountersPane language currentDate assembled = allEncountersData = generateAllEncounters assembled + heading = + div [ class "heading" ] + [ div [ class "date" ] [ text <| translate language Translate.EncounterDate ] + , div [ class "icon" ] [ text <| translate language Translate.SeeMore ] + ] + entries = List.map (\data -> - viewEntry (formatDDMMYYYY data.startDate) emptyNode + viewEntry (formatDDMMYYYY data.startDate) data.id ) allEncountersData - viewEntry label htmlValue = + viewEntry label encounterId = div [ class "entry" ] [ div [ class "label" ] [ text label ] - , div [ class "value" ] [ htmlValue ] + , div [ class "icon" ] + [ div [ class "icon-forward" ] [] ] ] in div [ class "pane encounters" ] [ viewPaneHeading language Translate.Encounters - , div [ class "pane-content" ] entries + , div [ class "pane-content" ] <| + heading + :: entries ] From b5a761d3026016749184eb3ec8ef9406cb805c3f Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 13:20:33 +0300 Subject: [PATCH 25/63] Add missed doses [ci skip] --- .../AcuteIllness/ProgressReport/View.elm | 2 +- .../Tuberculosis/ProgressReport/View.elm | 22 ++++++++++++++----- client/src/elm/Translate.elm | 11 ++++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm index 33260c9aca..8985e078c5 100644 --- a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm +++ b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm @@ -749,7 +749,7 @@ viewTreatmentSigns language currentDate initialEncounter firstInitialWithSubsequ viewMissedDoses = div [ class "treatment-comment" ] [ text "- " - , text <| translate language <| Translate.MissedDosesOfMedicatgion missedDoses + , text <| translate language <| Translate.MissedDosesOfMedication missedDoses , text "." ] diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 2ff87c124e..e14aced672 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -136,17 +136,20 @@ viewSummaryPane language currentDate assembled = Maybe.andThen (.measurements >> .diagnostics >> getMeasurementValueFunc) firstEncounterData + missedDoses = + List.filterMap + (\data -> + getMeasurementValueFunc data.measurements.treatmentReview + |> Maybe.map .missedDoses + ) + allEncountersData + |> List.sum + currentMedications = List.filter (.measurements >> .medication >> isJust) allEncountersData |> List.head |> Maybe.andThen (.measurements >> .medication >> getMeasurementValueFunc) - viewEntry label value = - div [ class "entry" ] - [ div [ class "label" ] [ text <| translate language label ] - , div [ class "value" ] [ text value ] - ] - diagnosisForView = Maybe.map (Translate.TuberculosisDiagnosis >> translate language) diagnosis |> Maybe.withDefault "" @@ -167,12 +170,19 @@ viewSummaryPane language currentDate assembled = ) currentMedications |> Maybe.withDefault "" + + viewEntry label value = + div [ class "entry" ] + [ div [ class "label" ] [ text <| translate language label ] + , div [ class "value" ] [ text value ] + ] in div [ class "pane summary" ] [ viewPaneHeading language Translate.Summary , div [ class "pane-content" ] [ viewEntry Translate.Diagnosis diagnosisForView , viewEntry Translate.InitiationDate initiationDateForView + , viewEntry Translate.MissedDoses (String.fromInt missedDoses) , viewEntry Translate.CompletionDate completionDateForView , viewEntry Translate.CurrentMedication currentMedicationsForView ] diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 280b62a2ff..8014f85ed7 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -998,7 +998,8 @@ type TranslationId | MMHGUnit | Minutes Int | MinutesAgo Int - | MissedDosesOfMedicatgion Int + | MissedDoses + | MissedDosesOfMedication Int | ModeOfDelivery ModeOfDelivery | ModeOfDeliveryLabel | ModeratePreeclampsia @@ -10814,7 +10815,13 @@ translationSet trans = Just <| String.fromInt minutes ++ " iminota iheze" } - MissedDosesOfMedicatgion val -> + MissedDoses -> + { english = "Missed Doses" + , kinyarwanda = Nothing + , kirundi = Nothing + } + + MissedDosesOfMedication val -> if val == 0 then { english = "No missed doses of medication" , kinyarwanda = Just "Yafashe kandi arangiza neza imiti uko yayandikiwe" From f47b3ce2409602a6d5b8f3c6caefe787a9691a4e Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 13:55:11 +0300 Subject: [PATCH 26/63] Timeline pane [ci skip] --- client/src/assets/scss/_new.scss | 24 +++++- client/src/assets/scss/_variables.scss | 1 + .../Tuberculosis/ProgressReport/View.elm | 83 ++++++++++--------- 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index e89a383a90..6b181758fa 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3889,6 +3889,7 @@ div.page-report.tuberculosis { } .pane .pane-content .entry { + display: flex; line-height: 40px; } @@ -3897,6 +3898,28 @@ div.page-report.tuberculosis { width: 35%; } + .pane.treatment-timeline .pane-content { + padding: 30px 10px; + } + + .pane.treatment-timeline .pane-content .timeline { + display: flex; + justify-content: space-between; + } + + .pane.treatment-timeline .pane-content .timeline div { + border-top: 10px solid $color-text; + font-size: 18px; + height: 40px; + padding-top: 10px; + text-align: center; + width: 15%; + } + + .pane.treatment-timeline .pane-content .timeline div.green { + border-top: 10px solid $color-green-dark; + } + .pane.adverse-events .pane-content .entry .label { float: left; width: 70%; @@ -3908,7 +3931,6 @@ div.page-report.tuberculosis { .pane.encounters .pane-content .entry { border-bottom: 1px solid $color-text; - display: flex; padding: 15px 30px; } diff --git a/client/src/assets/scss/_variables.scss b/client/src/assets/scss/_variables.scss index 9aa309c2b4..a02565a71b 100644 --- a/client/src/assets/scss/_variables.scss +++ b/client/src/assets/scss/_variables.scss @@ -19,6 +19,7 @@ $color-velvet: #D4145A; $color-orange: #FFB60D; $color-green: #25D625; $color-green-alert: #86A156; +$color-green-dark: #1DBDB3; $color-light-blue: #29C2FF; $color-lighter-blue: #E0E7FF; $color-white: #FFFFFF; diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index e14aced672..a425e662ae 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -101,23 +101,13 @@ viewContent : -> AssembledData -> Html Msg viewContent language currentDate site features model assembled = - div - [ class "ui report unstackable items" - , Html.Attributes.id "report-content" - ] - [ viewPersonInfoPane language currentDate assembled.person - , viewSummaryPane language currentDate assembled - , viewTreatmentTimelinePane language currentDate assembled - , viewAdverseEventsPane language currentDate assembled - , viewEncountersPane language currentDate assembled - ] - - -viewSummaryPane : Language -> NominalDate -> AssembledData -> Html any -viewSummaryPane language currentDate assembled = let allEncountersData = - generateAllEncounters assembled + { id = assembled.id + , startDate = assembled.encounter.startDate + , measurements = assembled.measurements + } + :: assembled.previousEncountersData firstEncounterData = List.filter (.measurements >> .diagnostics >> isJust) @@ -127,7 +117,28 @@ viewSummaryPane language currentDate assembled = initiationDate = Maybe.map .startDate firstEncounterData + in + div + [ class "ui report unstackable items" + , Html.Attributes.id "report-content" + ] + [ viewPersonInfoPane language currentDate assembled.person + , viewSummaryPane language currentDate allEncountersData firstEncounterData initiationDate + , viewTreatmentTimelinePane language currentDate initiationDate + , viewAdverseEventsPane language currentDate allEncountersData + , viewEncountersPane language currentDate allEncountersData + ] + +viewSummaryPane : + Language + -> NominalDate + -> List EncounterData + -> Maybe EncounterData + -> Maybe NominalDate + -> Html any +viewSummaryPane language currentDate allEncountersData firstEncounterData initiationDate = + let completionDate = Maybe.map (Date.add Months 6) initiationDate @@ -189,24 +200,32 @@ viewSummaryPane language currentDate assembled = ] -viewTreatmentTimelinePane : Language -> NominalDate -> AssembledData -> Html any -viewTreatmentTimelinePane language currentDate assembled = +viewTreatmentTimelinePane : Language -> NominalDate -> Maybe NominalDate -> Html any +viewTreatmentTimelinePane language currentDate initiationDate = let content = - [] + Maybe.map + (\initDate -> + List.range 1 6 + |> List.map + (\index -> + div [ classList [ ( "green", Date.diff Months initDate currentDate >= index ) ] ] + [ text <| translate language Translate.Month ++ " " ++ String.fromInt index ] + ) + |> div [ class "timeline" ] + ) + initiationDate + |> Maybe.withDefault emptyNode in div [ class "pane treatment-timeline" ] [ viewPaneHeading language Translate.TreatmentTimeline - , div [ class "pane-content" ] content + , div [ class "pane-content" ] [ content ] ] -viewAdverseEventsPane : Language -> NominalDate -> AssembledData -> Html any -viewAdverseEventsPane language currentDate assembled = +viewAdverseEventsPane : Language -> NominalDate -> List EncounterData -> Html any +viewAdverseEventsPane language currentDate allEncountersData = let - allEncountersData = - generateAllEncounters assembled - adverseEventsWithDates = List.filterMap (\data -> @@ -243,12 +262,9 @@ viewAdverseEventsPane language currentDate assembled = ] -viewEncountersPane : Language -> NominalDate -> AssembledData -> Html any -viewEncountersPane language currentDate assembled = +viewEncountersPane : Language -> NominalDate -> List EncounterData -> Html any +viewEncountersPane language currentDate allEncountersData = let - allEncountersData = - generateAllEncounters assembled - heading = div [ class "heading" ] [ div [ class "date" ] [ text <| translate language Translate.EncounterDate ] @@ -275,12 +291,3 @@ viewEncountersPane language currentDate assembled = heading :: entries ] - - -generateAllEncounters : AssembledData -> List EncounterData -generateAllEncounters assembled = - { id = assembled.id - , startDate = assembled.encounter.startDate - , measurements = assembled.measurements - } - :: assembled.previousEncountersData From 435fb3465c8f9854dae86cd56004f1bcc3383c33 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 16:31:18 +0300 Subject: [PATCH 27/63] WIP: Encounter details view [ci skip] --- client/src/assets/scss/_new.scss | 20 ++ .../Pages/AcuteIllness/Participant/View.elm | 4 +- .../Tuberculosis/ProgressReport/Model.elm | 12 +- .../Tuberculosis/ProgressReport/Update.elm | 3 + .../Tuberculosis/ProgressReport/View.elm | 209 ++++++++++++++++-- client/src/elm/Translate.elm | 14 ++ 6 files changed, 239 insertions(+), 23 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index 6b181758fa..fa12d1b821 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3951,6 +3951,26 @@ div.page-report.tuberculosis { margin-left: 20px; width: 50px; } + + .pane.encounter-details .pane-content .entry { + justify-content: space-between; + } + + .pane.encounter-details .pane-content .entry .label { + float: left; + width: 30%; + } + + .pane.encounter-details .pane-content .entry .confirmation { + float: left; + width: 20%; + } + + .pane.encounter-details .pane-content .entry .value { + float: left; + font-size: 18px; + width: 50%; + } } div.page-report.acute-illness, diff --git a/client/src/elm/Pages/AcuteIllness/Participant/View.elm b/client/src/elm/Pages/AcuteIllness/Participant/View.elm index a9483e9650..bd364a0e5c 100644 --- a/client/src/elm/Pages/AcuteIllness/Participant/View.elm +++ b/client/src/elm/Pages/AcuteIllness/Participant/View.elm @@ -80,9 +80,7 @@ viewHeader language initiator model = [ class "link-back" , onClick action ] - [ span [ class "icon-back" ] [] - , span [] [] - ] + [ span [ class "icon-back" ] [] ] ] diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm index 3677aa0db5..79790223b0 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm @@ -7,7 +7,8 @@ import Pages.Page exposing (Page) type alias Model = - { showEndEncounterDialog : Bool + { viewMode : ViewMode + , showEndEncounterDialog : Bool , reportToWhatsAppDialog : Components.ReportToWhatsAppDialog.Model.Model -- , components : Maybe (EverySet Components.ReportToWhatsAppDialog.Model.ReportComponentTuberculosis) @@ -16,17 +17,24 @@ type alias Model = emptyModel : Model emptyModel = - { showEndEncounterDialog = False + { viewMode = ViewModeGlobal + , showEndEncounterDialog = False , reportToWhatsAppDialog = Components.ReportToWhatsAppDialog.Model.emptyModel -- , components = Nothing } +type ViewMode + = ViewModeGlobal + | ViewModeEncounter TuberculosisEncounterId + + type Msg = NoOp | CloseEncounter TuberculosisEncounterId | SetActivePage Page + | SetViewMode ViewMode | SetEndEncounterDialogState Bool | MsgReportToWhatsAppDialog (Components.ReportToWhatsAppDialog.Model.Msg Msg) | SetReportComponents (Maybe Components.ReportToWhatsAppDialog.Model.ReportComponentsList) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm index ca13610f15..a0a5ee3fb8 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm @@ -29,6 +29,9 @@ update msg model = SetActivePage page -> ( model, Cmd.none, [ App.Model.SetActivePage page ] ) + SetViewMode mode -> + ( { model | viewMode = mode }, Cmd.none, [] ) + SetEndEncounterDialogState isOpen -> ( { model | showEndEncounterDialog = isOpen }, Cmd.none, [] ) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index a425e662ae..3b699eb0af 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -3,7 +3,7 @@ module Pages.Tuberculosis.ProgressReport.View exposing (view) import AssocList as Dict import Backend.Entities exposing (..) import Backend.IndividualEncounterParticipant.Model exposing (IndividualEncounterParticipant) -import Backend.Measurement.Model +import Backend.Measurement.Model exposing (TreatmentOngoingSign(..), TuberculosisDOTSign(..)) import Backend.Measurement.Utils exposing (getMeasurementValueFunc) import Backend.Model exposing (ModelIndexedDb) import Backend.Person.Model exposing (Person) @@ -54,7 +54,7 @@ view language currentDate site features id db model = generateAssembledData id db header = - viewHeader language id + viewHeader language id model content = viewWebData language (viewContent language currentDate site features model) identity assembled @@ -79,14 +79,23 @@ view language currentDate site features id db model = ] -viewHeader : Language -> TuberculosisEncounterId -> Html Msg -viewHeader language id = +viewHeader : Language -> TuberculosisEncounterId -> Model -> Html Msg +viewHeader language id model = + let + action = + case model.viewMode of + ViewModeGlobal -> + SetActivePage (UserPage <| TuberculosisEncounterPage id) + + ViewModeEncounter _ -> + SetViewMode ViewModeGlobal + in div [ class "ui basic segment head" ] [ h1 [ class "ui header" ] [ text <| translate language Translate.ProgressReport ] , span [ class "link-back" - , onClick <| SetActivePage (UserPage <| TuberculosisEncounterPage id) + , onClick action ] [ span [ class "icon-back" ] [] ] ] @@ -108,7 +117,37 @@ viewContent language currentDate site features model assembled = , measurements = assembled.measurements } :: assembled.previousEncountersData - + in + div + [ class "ui report unstackable items" + , Html.Attributes.id "report-content" + ] + <| + case model.viewMode of + ViewModeGlobal -> + viewGlobalContent language + currentDate + model + allEncountersData + assembled + + ViewModeEncounter encounterId -> + viewEncounterDetailsContent language + currentDate + encounterId + model + allEncountersData + + +viewGlobalContent : + Language + -> NominalDate + -> Model + -> List EncounterData + -> AssembledData + -> List (Html Msg) +viewGlobalContent language currentDate model allEncountersData assembled = + let firstEncounterData = List.filter (.measurements >> .diagnostics >> isJust) allEncountersData @@ -118,16 +157,12 @@ viewContent language currentDate site features model assembled = initiationDate = Maybe.map .startDate firstEncounterData in - div - [ class "ui report unstackable items" - , Html.Attributes.id "report-content" - ] - [ viewPersonInfoPane language currentDate assembled.person - , viewSummaryPane language currentDate allEncountersData firstEncounterData initiationDate - , viewTreatmentTimelinePane language currentDate initiationDate - , viewAdverseEventsPane language currentDate allEncountersData - , viewEncountersPane language currentDate allEncountersData - ] + [ viewPersonInfoPane language currentDate assembled.person + , viewSummaryPane language currentDate allEncountersData firstEncounterData initiationDate + , viewTreatmentTimelinePane language currentDate initiationDate + , viewAdverseEventsPane language currentDate allEncountersData + , viewEncountersPane language currentDate allEncountersData + ] viewSummaryPane : @@ -262,7 +297,7 @@ viewAdverseEventsPane language currentDate allEncountersData = ] -viewEncountersPane : Language -> NominalDate -> List EncounterData -> Html any +viewEncountersPane : Language -> NominalDate -> List EncounterData -> Html Msg viewEncountersPane language currentDate allEncountersData = let heading = @@ -282,7 +317,12 @@ viewEncountersPane language currentDate allEncountersData = div [ class "entry" ] [ div [ class "label" ] [ text label ] , div [ class "icon" ] - [ div [ class "icon-forward" ] [] ] + [ div + [ class "icon-forward" + , onClick <| SetViewMode <| ViewModeEncounter encounterId + ] + [] + ] ] in div [ class "pane encounters" ] @@ -291,3 +331,136 @@ viewEncountersPane language currentDate allEncountersData = heading :: entries ] + + +viewEncounterDetailsContent : + Language + -> NominalDate + -> TuberculosisEncounterId + -> Model + -> List EncounterData + -> List (Html Msg) +viewEncounterDetailsContent language currentDate encounterId model allEncountersData = + List.filter (.id >> (==) encounterId) allEncountersData + |> List.head + |> Maybe.map + (\data -> + let + currentMedications = + List.filterMap + (\encounterData -> + if not <| Date.compare encounterData.startDate data.startDate == GT then + getMeasurementValueFunc encounterData.measurements.medication + + else + Nothing + ) + allEncountersData + |> List.head + + currentMedicationsForView = + Maybe.map + (EverySet.toList + >> List.map (Translate.TuberculosisPrescribedMedication >> translate language) + >> String.join ", " + ) + currentMedications + |> Maybe.withDefault "" + + medicationDistributed = + getMeasurementValueFunc data.measurements.dot + |> Maybe.map (.medicationDistributionSign >> (==) DOTPositive) + + treatmentReviewEntriesData = + getMeasurementValueFunc data.measurements.treatmentReview + |> Maybe.map + (\value -> + let + takenAsPrescribed = + EverySet.member TakenAsPrescribed value.signs + + missedDoses = + EverySet.member MissedDoses value.signs + + adverseEvents = + EverySet.member SideEffects value.signs + in + { takenAsPrescribedData = + ( Just takenAsPrescribed + , if takenAsPrescribed then + "" + + else + translate language <| Translate.ReasonForNotTaking value.reasonForNotTaking + ) + , feelingBetterData = ( Just <| EverySet.member FeelingBetter value.signs, "" ) + , missedDosesData = + ( Just missedDoses + , if missedDoses then + String.fromInt value.missedDoses + + else + "" + ) + , adverseEventsData = + ( Just adverseEvents + , if adverseEvents then + EverySet.toList value.adverseEvents + |> List.map (Translate.AdverseEvent >> translate language) + |> String.join ", " + + else + "" + ) + } + ) + + viewTreatmentReviewEntry label mValue = + let + ( confirmed, value ) = + Maybe.withDefault ( Nothing, "" ) mValue + in + viewEntry label confirmed value + + viewEntry label confirmation value = + let + confirmationForView = + Maybe.map + (\confirmed -> + let + transId = + if confirmed then + Translate.Yes + + else + Translate.No + in + translate language transId + ) + confirmation + |> Maybe.withDefault "" + in + div [ class "entry" ] + [ div [ class "label" ] [ text <| translate language label ] + , div [ class "confiration" ] [ text confirmationForView ] + , div [ class "value" ] [ text value ] + ] + in + [ div [ class "pane encounter-details" ] + [ div [ class <| "pane-heading" ] + [ text <| translate language Translate.EncounterDate ++ ": " ++ formatDDMMYYYY data.startDate ] + , div [ class <| "pane-content" ] + [ viewEntry Translate.Medication medicationDistributed currentMedicationsForView + , Maybe.map .takenAsPrescribedData treatmentReviewEntriesData + |> viewTreatmentReviewEntry Translate.TakenAsPrescribed + , Maybe.map .feelingBetterData treatmentReviewEntriesData + |> viewTreatmentReviewEntry Translate.FeelingBetter + , Maybe.map .missedDosesData treatmentReviewEntriesData + |> viewTreatmentReviewEntry Translate.MissedDoses + , Maybe.map .adverseEventsData treatmentReviewEntriesData + |> viewTreatmentReviewEntry Translate.AdverseEvents + ] + ] + ] + ) + >> Maybe.withDefault [] diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 8014f85ed7..e0ab12504f 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -673,6 +673,7 @@ type TranslationId | FavoriteToggle Bool | FbfDistribution ClinicType | Feeding + | FeelingBetter | FetalHeartRate | FetalMovement | FetalPresentationLabel @@ -1734,6 +1735,7 @@ type TranslationId | Success | SyncGeneral | TabletSinglePlural String + | TakenAsPrescribed | TakingMedicationAsPrescribed Bool | TasksCompleted Int Int | TargetedInterventions @@ -5999,6 +6001,12 @@ translationSet trans = , kirundi = Nothing } + FeelingBetter -> + { english = "Feeling Better" + , kinyarwanda = Nothing + , kirundi = Nothing + } + FetalHeartRate -> { english = "Fetal Heart Rate" , kinyarwanda = Just "Uko umutima w'umwana utera" @@ -21830,6 +21838,12 @@ translationSet trans = , kirundi = Just <| "ibinini " ++ value } + TakenAsPrescribed -> + { english = "Taken as prescribed" + , kinyarwanda = Nothing + , kirundi = Nothing + } + TakingMedicationAsPrescribed taking -> if taking then { english = "Taking medication as prescribed" From bc79be2bbb85bfba97365496bbf81461c80f4cb1 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 18:24:46 +0300 Subject: [PATCH 28/63] Styling [ci skip] --- client/src/assets/scss/_new.scss | 16 ++++++++++++++-- .../Pages/Tuberculosis/ProgressReport/View.elm | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index fa12d1b821..f568acab3a 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3953,17 +3953,29 @@ div.page-report.tuberculosis { } .pane.encounter-details .pane-content .entry { + border-bottom: 1px solid $color-text; justify-content: space-between; + line-height: normal; + padding: 15px 0; + } + + .pane.encounter-details .pane-content .entry:last-child { + border-bottom: none; } + .pane.encounter-details .pane-content .entry .label { float: left; - width: 30%; + margin-bottom: auto; + margin-top: auto; + width: 35%; } .pane.encounter-details .pane-content .entry .confirmation { float: left; - width: 20%; + margin-bottom: auto; + margin-top: auto; + width: 15%; } .pane.encounter-details .pane-content .entry .value { diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 3b699eb0af..484ea1792e 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -442,7 +442,7 @@ viewEncounterDetailsContent language currentDate encounterId model allEncounters in div [ class "entry" ] [ div [ class "label" ] [ text <| translate language label ] - , div [ class "confiration" ] [ text confirmationForView ] + , div [ class "confirmation" ] [ text confirmationForView ] , div [ class "value" ] [ text value ] ] in From 3f1462ff7661f07c6709ae46fbe9c2f5ae346d75 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 22:45:28 +0300 Subject: [PATCH 29/63] Symptoms & Actions taken entries --- client/src/assets/scss/_new.scss | 10 ++ .../Tuberculosis/ProgressReport/View.elm | 94 ++++++++++++++++++- client/src/elm/Translate.elm | 38 +++++++- 3 files changed, 137 insertions(+), 5 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index f568acab3a..65f4b77dc4 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -3983,6 +3983,16 @@ div.page-report.tuberculosis { font-size: 18px; width: 50%; } + + .pane.encounter-details .pane-content .entry .value { + float: left; + font-size: 18px; + width: 50%; + } + + .pane.encounter-details .pane-content .entry .value.long { + width: 65%; + } } div.page-report.acute-illness, diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 484ea1792e..51e0256007 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -3,7 +3,16 @@ module Pages.Tuberculosis.ProgressReport.View exposing (view) import AssocList as Dict import Backend.Entities exposing (..) import Backend.IndividualEncounterParticipant.Model exposing (IndividualEncounterParticipant) -import Backend.Measurement.Model exposing (TreatmentOngoingSign(..), TuberculosisDOTSign(..)) +import Backend.Measurement.Model + exposing + ( FollowUpOption(..) + , ReferralFacility(..) + , SendToHCSign(..) + , TreatmentOngoingSign(..) + , TuberculosisDOTSign(..) + , TuberculosisHealthEducationSign(..) + , TuberculosisSymptom(..) + ) import Backend.Measurement.Utils exposing (getMeasurementValueFunc) import Backend.Model exposing (ModelIndexedDb) import Backend.Person.Model exposing (Person) @@ -415,6 +424,87 @@ viewEncounterDetailsContent language currentDate encounterId model allEncounters } ) + symptomsEntry = + getMeasurementValueFunc data.measurements.symptomReview + |> Maybe.map + (\symptoms -> + let + symptomsForView = + EverySet.toList symptoms + |> List.map (Translate.TuberculosisSymptom >> translate language) + |> String.join ", " + in + div [ class "entry" ] + [ div [ class "label" ] [ text <| translate language Translate.SymptomReview ] + , div [ class "value long" ] [ text symptomsForView ] + ] + ) + |> Maybe.withDefault emptyNode + + actionsTakenEntry = + let + sendToHCSignsSection = + getMeasurementValueFunc data.measurements.referral + |> Maybe.map + (\value -> + let + completedForm = + EverySet.member HandReferrerForm value.signs + + sentToHC = + EverySet.member ReferToHealthCenter value.signs + in + [ if completedForm then + li [] [ text <| translate language (Translate.CompleteFacilityReferralForm FacilityHealthCenter) ] + + else + emptyNode + , if sentToHC then + li [] [ text <| translate language (Translate.SendPatientToFacility FacilityHealthCenter) ] + + else + emptyNode + ] + ) + |> Maybe.withDefault [] + + healthEducationSection = + getMeasurementValueFunc data.measurements.healthEducation + |> Maybe.map + (\value -> + if EverySet.member EducationFollowUpTesting value then + [ li [] [ text <| translate language Translate.ProvidedHealthEducationAction ] ] + + else + [] + ) + |> Maybe.withDefault [] + + followUpSection = + getMeasurementValueFunc data.measurements.followUp + |> Maybe.map + (\value -> + let + filtered = + EverySet.toList value.options + |> List.filter ((/=) FollowUpNotNeeded) + in + if not <| List.isEmpty filtered then + [ li [] [ text <| translate language Translate.ScheduleFollowUp ] ] + + else + [] + ) + |> Maybe.withDefault [] + in + div [ class "entry" ] + [ div [ class "label" ] [ text <| translate language Translate.ActionsTaken ] + , ul [ class "value long" ] <| + sendToHCSignsSection + ++ healthEducationSection + ++ followUpSection + ] + viewTreatmentReviewEntry label mValue = let ( confirmed, value ) = @@ -459,6 +549,8 @@ viewEncounterDetailsContent language currentDate encounterId model allEncounters |> viewTreatmentReviewEntry Translate.MissedDoses , Maybe.map .adverseEventsData treatmentReviewEntriesData |> viewTreatmentReviewEntry Translate.AdverseEvents + , symptomsEntry + , actionsTakenEntry ] ] ] diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index e0ab12504f..e657c2e347 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -449,6 +449,7 @@ type TranslationId | BloodSmearLabel | BloodSmearResult BloodSmearResult | BloodSmearTestResult + | BloodInSputumLabel | BloodInSputumQuestion | BMI | BMIHelper @@ -1627,6 +1628,7 @@ type TranslationId | Send | SendToHC | SevereAbdominalPainLabel + | SevereFatigue | SevereFatigueQuestion | ReportToWhatsApp | ReportToWhatsAppComponentsSelectionHeader Components.ReportToWhatsAppDialog.Model.ReportType @@ -1804,6 +1806,7 @@ type TranslationId | TuberculosisReasonNotProvidedToday TuberculosisDOTSign | TuberculosisReasonMedicationsNotDistributed TuberculosisDOTSign | TuberculosisSuspect + | TuberculosisSymptom TuberculosisSymptom | TuberculosisSymptomQuestion TuberculosisSymptom | TuberculosisWarning | TwoVisits @@ -3564,6 +3567,12 @@ translationSet trans = , kirundi = Nothing } + BloodInSputumLabel -> + { english = "Blood in Sputum" + , kinyarwanda = Just "Amaraso mu gikororwa" + , kirundi = Just "Amaraso mu bikororwa" + } + BloodInSputumQuestion -> { english = "Do you have blood in sputum" , kinyarwanda = Just "Waba ugira ikororwa kirimo amaraso" @@ -20807,6 +20816,12 @@ translationSet trans = , kirundi = Just "Kurimba cane mu bwena" } + SevereFatigue -> + { english = "Severe Fatigue" + , kinyarwanda = Nothing + , kirundi = Nothing + } + SevereFatigueQuestion -> { english = "Do you have severe fatigue" , kinyarwanda = Just "Waba ugira umunaniro ukabije" @@ -21587,10 +21602,8 @@ translationSet trans = SymptomsRespiratorySign sign -> case sign of BloodInSputum -> - { english = "Blood in Sputum" - , kinyarwanda = Just "Amaraso mu gikororwa" - , kirundi = Just "Amaraso mu bikororwa" - } + translationSet BloodInSputumLabel + Cough -> { english = "Cough" @@ -22477,6 +22490,23 @@ translationSet trans = , kirundi = Nothing } + TuberculosisSymptom symptom -> + case symptom of + TuberculosisSymptomNightSweats -> + translationSet NightSweatsLabel + + TuberculosisSymptomBloodInSputum -> + translationSet BloodInSputumLabel + + TuberculosisSymptomWeightLoss -> + translationSet WeightLossLabel + + TuberculosisSymptomSevereFatigue -> + translationSet SevereFatigue + + NoTuberculosisSymptoms -> + translationSet None + TuberculosisSymptomQuestion symptom -> case symptom of TuberculosisSymptomNightSweats -> From 09c530ba12ce100aa161e59a63b917be074b4812 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 22:59:54 +0300 Subject: [PATCH 30/63] Elm format --- client/src/elm/Translate.elm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index e657c2e347..bb686510f9 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -2112,8 +2112,6 @@ translationSet trans = , kirundi = Just "Ingwara ikaze" } - - AcuteIllnessAdverseEventKindsQuestion -> { english = "What kind of adverse events" , kinyarwanda = Just "Ni ibihe bintu wabonye bidasanzwe (bitewe n'imiti wafashe)" @@ -5454,7 +5452,7 @@ translationSet trans = EmptyString -> { english = "" - , kinyarwanda =Nothing + , kinyarwanda = Nothing , kirundi = Nothing } @@ -7851,10 +7849,10 @@ translationSet trans = } InitiationDate -> - { english = "Initiation Date" - , kinyarwanda = Nothing - , kirundi = Nothing - } + { english = "Initiation Date" + , kinyarwanda = Nothing + , kirundi = Nothing + } IntractableVomiting isIntractable -> if isIntractable then @@ -21604,7 +21602,6 @@ translationSet trans = BloodInSputum -> translationSet BloodInSputumLabel - Cough -> { english = "Cough" , kinyarwanda = Just "Inkorora" @@ -22195,7 +22192,7 @@ translationSet trans = , kirundi = Just "Umugwayi atubahiriza ivyo bamubwiye" } - TreatmentTimeline -> + TreatmentTimeline -> { english = "Treatment Timeline" , kinyarwanda = Nothing , kirundi = Nothing From 0a08f18200ad110a0fe1ea495b4197784617cef0 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 23:24:20 +0300 Subject: [PATCH 31/63] End encounter dialog --- .../Tuberculosis/ProgressReport/View.elm | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 0073766d7f..be572daee3 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -58,23 +58,22 @@ view language currentDate site features id db model = content = viewWebData language (viewContent language currentDate site features model) identity assembled - -- endEncounterDialog = - -- if model.showEndEncounterDialog then - -- Just <| - -- viewEndEncounterDialog language - -- Translate.EndEncounterQuestion - -- Translate.OnceYouEndTheEncounter - -- (CloseEncounter id) - -- (SetEndEncounterDialogState False) - -- - -- else - -- Nothing + endEncounterDialog = + if model.showEndEncounterDialog then + Just <| + viewEndEncounterDialog language + Translate.EndEncounterQuestion + Translate.OnceYouEndTheEncounter + (CloseEncounter id) + (SetEndEncounterDialogState False) + + else + Nothing in div [ class "page-report tuberculosis" ] <| [ header , content - - -- , viewModal endEncounterDialog + , viewModal endEncounterDialog ] From f8773a40cf1ab4d49e7cd680345dd7680ae1f289 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 30 Jun 2024 23:25:09 +0300 Subject: [PATCH 32/63] Elm format --- client/src/elm/Translate.elm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 8014f85ed7..cabddc956a 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -2107,8 +2107,6 @@ translationSet trans = , kirundi = Just "Ingwara ikaze" } - - AcuteIllnessAdverseEventKindsQuestion -> { english = "What kind of adverse events" , kinyarwanda = Just "Ni ibihe bintu wabonye bidasanzwe (bitewe n'imiti wafashe)" @@ -5443,7 +5441,7 @@ translationSet trans = EmptyString -> { english = "" - , kinyarwanda =Nothing + , kinyarwanda = Nothing , kirundi = Nothing } @@ -7834,10 +7832,10 @@ translationSet trans = } InitiationDate -> - { english = "Initiation Date" - , kinyarwanda = Nothing - , kirundi = Nothing - } + { english = "Initiation Date" + , kinyarwanda = Nothing + , kirundi = Nothing + } IntractableVomiting isIntractable -> if isIntractable then @@ -22168,7 +22166,7 @@ translationSet trans = , kirundi = Just "Umugwayi atubahiriza ivyo bamubwiye" } - TreatmentTimeline -> + TreatmentTimeline -> { english = "Treatment Timeline" , kinyarwanda = Nothing , kirundi = Nothing From 3d196818869846cc7aa559caeb332506d77e3de3 Mon Sep 17 00:00:00 2001 From: anvmn Date: Tue, 2 Jul 2024 10:13:44 +0300 Subject: [PATCH 33/63] Send report to WhatsApp --- .../ReportToWhatsAppDialog/Model.elm | 5 +- .../ReportToWhatsAppDialog/Utils.elm | 26 +++--- .../ReportToWhatsAppDialog/View.elm | 82 ++++++++++--------- .../elm/Pages/AcuteIllness/Encounter/View.elm | 8 +- .../AcuteIllness/ProgressReport/View.elm | 4 +- client/src/elm/Pages/HIV/Encounter/View.elm | 6 +- client/src/elm/Pages/NCD/Encounter/View.elm | 6 +- .../elm/Pages/Nutrition/Encounter/View.elm | 8 +- .../Pages/Nutrition/ProgressReport/View.elm | 4 +- .../elm/Pages/Tuberculosis/Encounter/View.elm | 17 ++-- .../Tuberculosis/ProgressReport/Model.elm | 5 -- .../Tuberculosis/ProgressReport/Update.elm | 20 ----- .../Tuberculosis/ProgressReport/View.elm | 63 ++++++++++---- .../elm/Pages/WellChild/Encounter/Utils.elm | 4 +- .../elm/Pages/WellChild/Encounter/View.elm | 4 +- .../Pages/WellChild/ProgressReport/View.elm | 4 +- client/src/elm/Translate.elm | 25 +++--- .../hedley_whatsapp.features.field_base.inc | 5 +- 18 files changed, 166 insertions(+), 130 deletions(-) diff --git a/client/src/elm/Components/ReportToWhatsAppDialog/Model.elm b/client/src/elm/Components/ReportToWhatsAppDialog/Model.elm index 6dd6381a43..5497195660 100644 --- a/client/src/elm/Components/ReportToWhatsAppDialog/Model.elm +++ b/client/src/elm/Components/ReportToWhatsAppDialog/Model.elm @@ -57,10 +57,11 @@ type alias ReportComponentsConfig msg = type ReportType - = ReportWellChild + = ReportAcuteIllness | ReportAntenatal - | ReportAcuteIllness | ReportNCD + | ReportTuberculosis + | ReportWellChild type ReportComponentsList diff --git a/client/src/elm/Components/ReportToWhatsAppDialog/Utils.elm b/client/src/elm/Components/ReportToWhatsAppDialog/Utils.elm index cddb2e0e3e..d1ac3d8ae7 100644 --- a/client/src/elm/Components/ReportToWhatsAppDialog/Utils.elm +++ b/client/src/elm/Components/ReportToWhatsAppDialog/Utils.elm @@ -8,34 +8,40 @@ import SyncManager.Model exposing (Site(..)) reportTypeToString : ReportType -> String reportTypeToString reportType = case reportType of - ReportWellChild -> - "well-child" + ReportAcuteIllness -> + "acute-illness" ReportAntenatal -> "antenatal" - ReportAcuteIllness -> - "acute-illness" - ReportNCD -> "ncd" + ReportTuberculosis -> + "tuberculosis" + + ReportWellChild -> + "well-child" + reportTypeFromString : String -> Maybe ReportType reportTypeFromString reportType = case reportType of - "well-child" -> - Just ReportWellChild + "acute-illness" -> + Just ReportAcuteIllness "antenatal" -> Just ReportAntenatal - "acute-illness" -> - Just ReportAcuteIllness - "ncd" -> Just ReportNCD + "tuberculosis" -> + Just ReportTuberculosis + + "well-child" -> + Just ReportWellChild + _ -> Nothing diff --git a/client/src/elm/Components/ReportToWhatsAppDialog/View.elm b/client/src/elm/Components/ReportToWhatsAppDialog/View.elm index 265d3c414f..6dd9c49949 100644 --- a/client/src/elm/Components/ReportToWhatsAppDialog/View.elm +++ b/client/src/elm/Components/ReportToWhatsAppDialog/View.elm @@ -272,13 +272,17 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy let componentsSelectionInput = case reportType of - ReportWellChild -> + -- Not in use. + ReportAcuteIllness -> + emptyNode + + ReportAntenatal -> let currentValue = Maybe.map (\list -> case list of - WellChild components -> + Antenatal components -> EverySet.toList components -- We should never get here. @@ -301,32 +305,34 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy else EverySet.insert component currentComponents in - WellChild updatedComponents + Antenatal updatedComponents |> Just |> ComponentsSelection phoneNumber |> Just |> SetState in viewCheckBoxMultipleSelectInput language - [ ComponentWellChildActiveDiagnoses - , ComponentWellChildImmunizationHistory - , ComponentWellChildECD - , ComponentWellChildGrowth - , ComponentWellChildNextAppointment + [ ComponentAntenatalRiskFactors + , ComponentAntenatalMedicalDiagnosis + , ComponentAntenatalObstetricalDiagnosis + , ComponentAntenatalCHWActivity + , ComponentAntenatalPatientProgress + , ComponentAntenatalLabsResults + , ComponentAntenatalProgressPhotos ] [] currentValue Nothing setMsg - Translate.ReportComponentWellChild + Translate.ReportComponentAntenatal - ReportAntenatal -> + ReportNCD -> let currentValue = Maybe.map (\list -> case list of - Antenatal components -> + NCD components -> EverySet.toList components -- We should never get here. @@ -349,38 +355,36 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy else EverySet.insert component currentComponents in - Antenatal updatedComponents + NCD updatedComponents |> Just |> ComponentsSelection phoneNumber |> Just |> SetState in viewCheckBoxMultipleSelectInput language - [ ComponentAntenatalRiskFactors - , ComponentAntenatalMedicalDiagnosis - , ComponentAntenatalObstetricalDiagnosis - , ComponentAntenatalCHWActivity - , ComponentAntenatalPatientProgress - , ComponentAntenatalLabsResults - , ComponentAntenatalProgressPhotos + [ ComponentNCDRiskFactors + , ComponentNCDActiveDiagnosis + , ComponentNCDMedicalDiagnosis + , ComponentNCDPatientProgress + , ComponentNCDLabsResults ] [] currentValue Nothing setMsg - Translate.ReportComponentAntenatal + Translate.ReportComponentNCD -- Not in use. - ReportAcuteIllness -> + ReportTuberculosis -> emptyNode - ReportNCD -> + ReportWellChild -> let currentValue = Maybe.map (\list -> case list of - NCD components -> + WellChild components -> EverySet.toList components -- We should never get here. @@ -403,24 +407,24 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy else EverySet.insert component currentComponents in - NCD updatedComponents + WellChild updatedComponents |> Just |> ComponentsSelection phoneNumber |> Just |> SetState in viewCheckBoxMultipleSelectInput language - [ ComponentNCDRiskFactors - , ComponentNCDActiveDiagnosis - , ComponentNCDMedicalDiagnosis - , ComponentNCDPatientProgress - , ComponentNCDLabsResults + [ ComponentWellChildActiveDiagnoses + , ComponentWellChildImmunizationHistory + , ComponentWellChildECD + , ComponentWellChildGrowth + , ComponentWellChildNextAppointment ] [] currentValue Nothing setMsg - Translate.ReportComponentNCD + Translate.ReportComponentWellChild continueButtonAction = if componentsSelected then @@ -433,18 +437,22 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy Maybe.map (\list -> case reportType of - ReportWellChild -> + -- Not in use. + ReportAcuteIllness -> + False + + ReportAntenatal -> case list of - WellChild components -> + Antenatal components -> not <| EverySet.isEmpty components -- We should never get here. _ -> False - ReportAntenatal -> + ReportNCD -> case list of - Antenatal components -> + NCD components -> not <| EverySet.isEmpty components -- We should never get here. @@ -452,12 +460,12 @@ viewComponentsSelection language currentDate phoneNumber componentsList reportTy False -- Not in use. - ReportAcuteIllness -> + ReportTuberculosis -> False - ReportNCD -> + ReportWellChild -> case list of - NCD components -> + WellChild components -> not <| EverySet.isEmpty components -- We should never get here. diff --git a/client/src/elm/Pages/AcuteIllness/Encounter/View.elm b/client/src/elm/Pages/AcuteIllness/Encounter/View.elm index 2ec65b6b87..8a703e88c8 100644 --- a/client/src/elm/Pages/AcuteIllness/Encounter/View.elm +++ b/client/src/elm/Pages/AcuteIllness/Encounter/View.elm @@ -1,4 +1,4 @@ -module Pages.AcuteIllness.Encounter.View exposing (allowEndingEcounter, partitionActivities, view, viewPersonDetailsWithAlert, warningPopup) +module Pages.AcuteIllness.Encounter.View exposing (allowEndingEncounter, partitionActivities, view, viewPersonDetailsWithAlert, warningPopup) import Backend.AcuteIllnessActivity.Model exposing (AcuteIllnessActivity(..)) import Backend.AcuteIllnessActivity.Utils exposing (getActivityIcon, getAllActivities) @@ -362,7 +362,7 @@ viewMainPageContent language currentDate id isChw assembled model = ] allowEndEncounter = - allowEndingEcounter currentDate isChw assembled pendingActivities + allowEndingEncounter currentDate isChw assembled pendingActivities content = div [ class "ui full segment" ] @@ -382,8 +382,8 @@ partitionActivities currentDate isChw assembled = |> List.partition (activityCompleted currentDate isChw assembled) -allowEndingEcounter : NominalDate -> Bool -> AssembledData -> List AcuteIllnessActivity -> Bool -allowEndingEcounter currentDate isChw assembled pendingActivities = +allowEndingEncounter : NominalDate -> Bool -> AssembledData -> List AcuteIllnessActivity -> Bool +allowEndingEncounter currentDate isChw assembled pendingActivities = if not assembled.initialEncounter then List.isEmpty pendingActivities diff --git a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm index 8985e078c5..406b9a06c2 100644 --- a/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm +++ b/client/src/elm/Pages/AcuteIllness/ProgressReport/View.elm @@ -39,7 +39,7 @@ import Pages.AcuteIllness.Activity.View ) import Pages.AcuteIllness.Encounter.Model exposing (AcuteIllnessEncounterData, AssembledData) import Pages.AcuteIllness.Encounter.Utils exposing (generateAssembledData) -import Pages.AcuteIllness.Encounter.View exposing (allowEndingEcounter, partitionActivities) +import Pages.AcuteIllness.Encounter.View exposing (allowEndingEncounter, partitionActivities) import Pages.AcuteIllness.ProgressReport.Model exposing (..) import Pages.GlobalCaseManagement.Utils exposing (calculateDueDate) import Pages.Page exposing (Page(..), SessionPage(..), UserPage(..)) @@ -104,7 +104,7 @@ viewContent language currentDate site features id isChw initiator model assemble partitionActivities currentDate isChw assembled allowEndEncounter = - allowEndingEcounter currentDate isChw assembled pendingActivities + allowEndingEncounter currentDate isChw assembled pendingActivities in viewEndEncounterMenuForProgressReport language features diff --git a/client/src/elm/Pages/HIV/Encounter/View.elm b/client/src/elm/Pages/HIV/Encounter/View.elm index 600569c091..9edfd710f1 100644 --- a/client/src/elm/Pages/HIV/Encounter/View.elm +++ b/client/src/elm/Pages/HIV/Encounter/View.elm @@ -158,7 +158,7 @@ viewMainPageContent language currentDate db assembled model = ] allowEndEncounter = - allowEndingEcounter pendingActivities + allowEndingEncounter pendingActivities content = div [ class "ui full segment" ] @@ -171,6 +171,6 @@ viewMainPageContent language currentDate db assembled model = ] -allowEndingEcounter : List HIVActivity -> Bool -allowEndingEcounter pendingActivities = +allowEndingEncounter : List HIVActivity -> Bool +allowEndingEncounter pendingActivities = List.isEmpty pendingActivities diff --git a/client/src/elm/Pages/NCD/Encounter/View.elm b/client/src/elm/Pages/NCD/Encounter/View.elm index b18a1e36a4..8e4a848df1 100644 --- a/client/src/elm/Pages/NCD/Encounter/View.elm +++ b/client/src/elm/Pages/NCD/Encounter/View.elm @@ -155,7 +155,7 @@ viewMainPageContent language currentDate db assembled model = ] allowEndEncounter = - allowEndingEcounter pendingActivities + allowEndingEncounter pendingActivities content = div [ class "ui full segment" ] @@ -168,6 +168,6 @@ viewMainPageContent language currentDate db assembled model = ] -allowEndingEcounter : List NCDActivity -> Bool -allowEndingEcounter pendingActivities = +allowEndingEncounter : List NCDActivity -> Bool +allowEndingEncounter pendingActivities = List.isEmpty pendingActivities diff --git a/client/src/elm/Pages/Nutrition/Encounter/View.elm b/client/src/elm/Pages/Nutrition/Encounter/View.elm index 9246f82fdc..69d67e87e4 100644 --- a/client/src/elm/Pages/Nutrition/Encounter/View.elm +++ b/client/src/elm/Pages/Nutrition/Encounter/View.elm @@ -1,4 +1,4 @@ -module Pages.Nutrition.Encounter.View exposing (allowEndingEcounter, partitionActivities, view) +module Pages.Nutrition.Encounter.View exposing (allowEndingEncounter, partitionActivities, view) import Backend.Entities exposing (..) import Backend.IndividualEncounterParticipant.Model exposing (IndividualParticipantInitiator(..)) @@ -206,7 +206,7 @@ viewMainPageContent language currentDate zscores features id isChw db data model action allowEndEncounter = - allowEndingEcounter isChw pendingActivities + allowEndingEncounter isChw pendingActivities content = div [ class "ui full segment" ] @@ -246,8 +246,8 @@ partitionActivitiesConsideringSkipped currentDate zscores features isChw db asse |> List.partition (activityCompleted currentDate zscores features isChw assembled db) -allowEndingEcounter : Bool -> List NutritionActivity -> Bool -allowEndingEcounter isChw pendingActivities = +allowEndingEncounter : Bool -> List NutritionActivity -> Bool +allowEndingEncounter isChw pendingActivities = let mandatoryActivities = allMandatoryActivities isChw diff --git a/client/src/elm/Pages/Nutrition/ProgressReport/View.elm b/client/src/elm/Pages/Nutrition/ProgressReport/View.elm index 59cfebf995..bb7dab51a8 100644 --- a/client/src/elm/Pages/Nutrition/ProgressReport/View.elm +++ b/client/src/elm/Pages/Nutrition/ProgressReport/View.elm @@ -8,7 +8,7 @@ import Gizra.NominalDate exposing (NominalDate) import Html exposing (..) import Pages.Nutrition.Activity.Utils exposing (mandatoryActivitiesCompleted) import Pages.Nutrition.Encounter.Utils exposing (generateAssembledData) -import Pages.Nutrition.Encounter.View exposing (allowEndingEcounter, partitionActivities) +import Pages.Nutrition.Encounter.View exposing (allowEndingEncounter, partitionActivities) import Pages.Nutrition.ProgressReport.Model exposing (..) import Pages.WellChild.ProgressReport.Model exposing (WellChildProgressReportInitiator(..)) import Pages.WellChild.ProgressReport.View exposing (viewProgressReport) @@ -66,7 +66,7 @@ view language currentDate zscores site features id isChw db model = in ( Just <| { showEndEncounterDialog = model.showEndEncounterDialog - , allowEndEncounter = allowEndingEcounter isChw pendingActivities + , allowEndEncounter = allowEndingEncounter isChw pendingActivities , closeEncounterMsg = CloseEncounter id , setEndEncounterDialogStateMsg = SetEndEncounterDialogState , startEncounterMsg = NoOp diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/View.elm b/client/src/elm/Pages/Tuberculosis/Encounter/View.elm index 2a9d920ffc..2df237926e 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/View.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/View.elm @@ -1,4 +1,4 @@ -module Pages.Tuberculosis.Encounter.View exposing (view) +module Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter, partitionActivities, view) import Backend.Entities exposing (..) import Backend.IndividualEncounterParticipant.Model @@ -97,8 +97,7 @@ viewMainPageContent : Language -> NominalDate -> ModelIndexedDb -> AssembledData viewMainPageContent language currentDate db assembled model = let ( completedActivities, pendingActivities ) = - List.filter (expectActivity currentDate assembled) allActivities - |> List.partition (activityCompleted currentDate assembled) + partitionActivities currentDate assembled pendingTabTitle = translate language <| Translate.ActivitiesToComplete <| List.length pendingActivities @@ -157,7 +156,7 @@ viewMainPageContent language currentDate db assembled model = ] allowEndEncounter = - allowEndingEcounter pendingActivities + allowEndingEncounter pendingActivities content = div [ class "ui full segment" ] @@ -170,6 +169,12 @@ viewMainPageContent language currentDate db assembled model = ] -allowEndingEcounter : List TuberculosisActivity -> Bool -allowEndingEcounter pendingActivities = +partitionActivities : NominalDate -> AssembledData -> ( List TuberculosisActivity, List TuberculosisActivity ) +partitionActivities currentDate assembled = + List.filter (expectActivity currentDate assembled) allActivities + |> List.partition (activityCompleted currentDate assembled) + + +allowEndingEncounter : List TuberculosisActivity -> Bool +allowEndingEncounter pendingActivities = List.isEmpty pendingActivities diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm index 79790223b0..39852e0b57 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Model.elm @@ -10,8 +10,6 @@ type alias Model = { viewMode : ViewMode , showEndEncounterDialog : Bool , reportToWhatsAppDialog : Components.ReportToWhatsAppDialog.Model.Model - - -- , components : Maybe (EverySet Components.ReportToWhatsAppDialog.Model.ReportComponentTuberculosis) } @@ -20,8 +18,6 @@ emptyModel = { viewMode = ViewModeGlobal , showEndEncounterDialog = False , reportToWhatsAppDialog = Components.ReportToWhatsAppDialog.Model.emptyModel - - -- , components = Nothing } @@ -37,4 +33,3 @@ type Msg | SetViewMode ViewMode | SetEndEncounterDialogState Bool | MsgReportToWhatsAppDialog (Components.ReportToWhatsAppDialog.Model.Msg Msg) - | SetReportComponents (Maybe Components.ReportToWhatsAppDialog.Model.ReportComponentsList) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm index a0a5ee3fb8..8381041310 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/Update.elm @@ -42,23 +42,3 @@ update msg model = in ( { model | reportToWhatsAppDialog = dialogUpdated }, cmd, appMsgs ) |> sequenceExtra update extraMsgs - - SetReportComponents maybeComponents -> - let - updatedModel = - -- @todo - -- Maybe.map - -- (\components -> - -- case components of - -- Components.ReportToWhatsAppDialog.Model.Tuberculosis wellChildComponents -> - -- { model | components = Just wellChildComponents } - -- - -- -- We should never get here. - -- _ -> - -- model - -- ) - -- maybeComponents - -- |> Maybe.withDefault { model | components = Nothing } - model - in - ( updatedModel, Cmd.none, [] ) diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index b13c1bd026..91f64db4ee 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -32,6 +32,7 @@ import Measurement.Model exposing (LaboratoryTask(..)) import Pages.Page exposing (Page(..), UserPage(..)) import Pages.Tuberculosis.Encounter.Model exposing (AssembledData, EncounterData) import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData) +import Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter, partitionActivities) import Pages.Tuberculosis.ProgressReport.Model exposing (..) import Pages.Utils exposing @@ -125,26 +126,60 @@ viewContent language currentDate site features model assembled = , measurements = assembled.measurements } :: assembled.previousEncountersData + + panes = + case model.viewMode of + ViewModeGlobal -> + viewGlobalContent language + currentDate + model + allEncountersData + assembled + + ViewModeEncounter encounterId -> + viewEncounterDetailsContent language + currentDate + encounterId + model + allEncountersData + + endEncounterMenu = + let + ( _, pendingActivities ) = + partitionActivities currentDate assembled + + allowEndEncounter = + allowEndingEncounter pendingActivities + in + viewEndEncounterMenuForProgressReport language + features + allowEndEncounter + SetEndEncounterDialogState + (MsgReportToWhatsAppDialog <| + Components.ReportToWhatsAppDialog.Model.SetState <| + Just Components.ReportToWhatsAppDialog.Model.Consent + ) in div [ class "ui report unstackable items" , Html.Attributes.id "report-content" ] <| - case model.viewMode of - ViewModeGlobal -> - viewGlobalContent language - currentDate - model - allEncountersData - assembled - - ViewModeEncounter encounterId -> - viewEncounterDetailsContent language - currentDate - encounterId - model - allEncountersData + panes + ++ [ -- Actions are hidden when 'Share via WhatsApp' dialog is open, + -- so they do not appear on generated screenshot. + showIf (isNothing model.reportToWhatsAppDialog.state) endEncounterMenu + , Html.map MsgReportToWhatsAppDialog + (Components.ReportToWhatsAppDialog.View.view + language + currentDate + site + ( assembled.participant.person, assembled.person ) + Components.ReportToWhatsAppDialog.Model.ReportTuberculosis + Nothing + model.reportToWhatsAppDialog + ) + ] viewGlobalContent : diff --git a/client/src/elm/Pages/WellChild/Encounter/Utils.elm b/client/src/elm/Pages/WellChild/Encounter/Utils.elm index 1d09659fa9..ff2d6db54a 100644 --- a/client/src/elm/Pages/WellChild/Encounter/Utils.elm +++ b/client/src/elm/Pages/WellChild/Encounter/Utils.elm @@ -131,8 +131,8 @@ pediatricCareMilestoneToComparable milestone = 10 -allowEndingEcounter : NominalDate -> List WellChildActivity -> AssembledData -> Bool -allowEndingEcounter currentDate pendingActivities assembled = +allowEndingEncounter : NominalDate -> List WellChildActivity -> AssembledData -> Bool +allowEndingEncounter currentDate pendingActivities assembled = List.filter (\activity -> not <| List.member activity [ WellChildNCDA, WellChildPhoto ]) pendingActivities |> (\pending -> case pending of diff --git a/client/src/elm/Pages/WellChild/Encounter/View.elm b/client/src/elm/Pages/WellChild/Encounter/View.elm index a0a58e2747..2c672de647 100644 --- a/client/src/elm/Pages/WellChild/Encounter/View.elm +++ b/client/src/elm/Pages/WellChild/Encounter/View.elm @@ -14,7 +14,7 @@ import Pages.Page exposing (Page(..), UserPage(..)) import Pages.Utils exposing (viewPersonDetailsExtended, viewSkipNCDADialog) import Pages.WellChild.Activity.Utils exposing (activityCompleted, expectActivity) import Pages.WellChild.Encounter.Model exposing (..) -import Pages.WellChild.Encounter.Utils exposing (allowEndingEcounter, generateAssembledData) +import Pages.WellChild.Encounter.Utils exposing (allowEndingEncounter, generateAssembledData) import SyncManager.Model exposing (Site, SiteFeature) import Translate exposing (Language, translate) import Utils.Html exposing (activityCard, tabItem, viewModal) @@ -239,7 +239,7 @@ viewMainPageContent language currentDate zscores site features id isChw db assem action allowEndEncounter = - allowEndingEcounter currentDate pendingActivities assembled + allowEndingEncounter currentDate pendingActivities assembled endEcounterButtonAttributes = if allowEndEncounter then diff --git a/client/src/elm/Pages/WellChild/ProgressReport/View.elm b/client/src/elm/Pages/WellChild/ProgressReport/View.elm index a6edb1f877..42ff94feae 100644 --- a/client/src/elm/Pages/WellChild/ProgressReport/View.elm +++ b/client/src/elm/Pages/WellChild/ProgressReport/View.elm @@ -88,7 +88,7 @@ import Pages.WellChild.Activity.View exposing (viewVaccinationOverview) import Pages.WellChild.Encounter.Model exposing (AssembledData) import Pages.WellChild.Encounter.Utils exposing - ( allowEndingEcounter + ( allowEndingEncounter , generateAssembledData , pediatricCareMilestoneToComparable , resolveDateForPediatricCareMilestone @@ -163,7 +163,7 @@ view language currentDate zscores site features id isChw db model = in ( Just <| { showEndEncounterDialog = model.showEndEncounterDialog - , allowEndEncounter = allowEndingEcounter currentDate pendingActivities assembled + , allowEndEncounter = allowEndingEncounter currentDate pendingActivities assembled , closeEncounterMsg = CloseEncounter id , setEndEncounterDialogStateMsg = SetEndEncounterDialogState , startEncounterMsg = NoOp diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index bb686510f9..9cf45d094a 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -20834,11 +20834,10 @@ translationSet trans = ReportToWhatsAppComponentsSelectionHeader reportType -> case reportType of - Components.ReportToWhatsAppDialog.Model.ReportWellChild -> - { english = "Please select which sections of the Standard Pediatric Visit Report you would like to send:" - , kinyarwanda = Nothing - , kirundi = Just "Hitamwo ibice vy'ivyegeranyo bisanzwe vyo kuramutsa/vyo kugendera abana ushaka kurungika:" - } + -- Not in use, because Acute Illness report does not allow + -- components selection. + Components.ReportToWhatsAppDialog.Model.ReportAcuteIllness -> + translationSet EmptyString Components.ReportToWhatsAppDialog.Model.ReportAntenatal -> { english = "Please select which sections of the Antenatal Report you would like to send:" @@ -20846,17 +20845,23 @@ translationSet trans = , kirundi = Just "Hitamwo ibice vy'ivyegeranyo vy'abibungenze canke vy'imvyaro wipfuza kurungika:" } - -- Not in use, because AcuteIllness does not allow - -- components selection. - Components.ReportToWhatsAppDialog.Model.ReportAcuteIllness -> - translationSet EmptyString - Components.ReportToWhatsAppDialog.Model.ReportNCD -> { english = "Please select which sections of the NCD Report you would like to send:" , kinyarwanda = Nothing , kirundi = Just "Hitamwo ibice vy'ivyegeranyo vy'ingwara zitandukira ushaka kurungika:" } + -- Not in use, because Tuberculosis report does not allow + -- components selection. + Components.ReportToWhatsAppDialog.Model.ReportTuberculosis -> + translationSet EmptyString + + Components.ReportToWhatsAppDialog.Model.ReportWellChild -> + { english = "Please select which sections of the Standard Pediatric Visit Report you would like to send:" + , kinyarwanda = Nothing + , kirundi = Just "Hitamwo ibice vy'ivyegeranyo bisanzwe vyo kuramutsa/vyo kugendera abana ushaka kurungika:" + } + ReportToWhatsAppConfirmationBeforeExecutingHeader -> { english = "By pressing send you are releasing the selected documents to:" , kinyarwanda = Nothing diff --git a/server/hedley/modules/custom/hedley_whatsapp/hedley_whatsapp.features.field_base.inc b/server/hedley/modules/custom/hedley_whatsapp/hedley_whatsapp.features.field_base.inc index 2165de3a89..b60b7d2302 100644 --- a/server/hedley/modules/custom/hedley_whatsapp/hedley_whatsapp.features.field_base.inc +++ b/server/hedley/modules/custom/hedley_whatsapp/hedley_whatsapp.features.field_base.inc @@ -44,10 +44,11 @@ function hedley_whatsapp_field_default_field_bases() { 'module' => 'list', 'settings' => array( 'allowed_values' => array( - 'well-child' => 'Well Child', - 'antenatal' => 'Antenatal', 'acute-illness' => 'Acute Illness', + 'antenatal' => 'Antenatal', 'ncd' => 'NCD', + 'tuberculosis' => 'Tuberculosis', + 'well-child' => 'Well Child', ), 'allowed_values_function' => '', ), From 3353f6f296ad4ff9efa0c450c2a67af9a1bc73a6 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Fri, 5 Jul 2024 23:17:49 +0200 Subject: [PATCH 34/63] setting up the adoption survey progress --- client/src/elm/Translate.elm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 4a95219e18..3e883feeca 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -388,6 +388,9 @@ type TranslationId | AdministeredOneOfAboveMedicinesQuestion | AddressInformation | AdoptionSurveyScoreInterpretation Int + | AdoptionSurveyProgressImproving + | AdoptionSurveyProgressNotImproving + | AdoptionSurveyProgressSame | AdverseEventSinglePlural Int | AfterEachLiquidStool | AgeWord @@ -3002,6 +3005,24 @@ translationSet trans = , kirundi = Nothing } + AdoptionSurveyProgressImproving -> + { english = "Congratulations; you've improved." + , kinyarwanda = Just "Wabikoze neza, Komereza aho," + , kirundi = Nothing + } + + AdoptionSurveyProgressNotImproving -> + { english = "You slid back compared to your last performance" + , kinyarwanda = Just "Wasubiye inyuma ugereranyije n'ubushize." + , kirundi = Nothing + } + + AdoptionSurveyProgressSame -> + { english = "You remained in the same category." + , kinyarwanda = Just "Wagumye mu cyiciro kimwe." + , kirundi = Nothing + } + AdverseEventSinglePlural val -> if val == 1 then { english = "Adverse event" From 359ecb1351b2bcb48062dcb3eac8f6de7ebdc89a Mon Sep 17 00:00:00 2001 From: Diama1 Date: Sat, 6 Jul 2024 00:06:50 +0200 Subject: [PATCH 35/63] add progress message --- client/src/elm/Pages/MessagingCenter/View.elm | 101 ++++++++++++++++-- 1 file changed, 92 insertions(+), 9 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index fa70726870..541d073f5e 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -142,7 +142,7 @@ view language currentTime nurseId nurse db model = [ header , content , viewModal <| - surveyScoreDialog language model.surveyScoreDialogState + surveyScoreDialog language nurseId db model.surveyScoreDialogState ] @@ -369,31 +369,114 @@ viewAdoptionSurvey language currentDate nurseId form = surveyScoreDialog : Language + -> NurseId + -> ModelIndexedDb -> Maybe SurveyScoreDialogState -> Maybe (Html Msg) -surveyScoreDialog language = +surveyScoreDialog language nurseId db = Maybe.map (\dialogState -> let - ( scoreText, interpretationFunction ) = + surveys = + Dict.get nurseId db.resilienceSurveysByNurse + |> Maybe.andThen RemoteData.toMaybe + |> Maybe.map Dict.values + |> Maybe.withDefault [] + + adoptionSurveys = + List.filter (\survey -> survey.surveyType == ResilienceSurveyAdoption) surveys + + sortedSurveys = + List.sortWith (\survey1 survey2 -> Date.compare survey1.dateMeasured survey2.dateMeasured) adoptionSurveys + + survey1Score = + case List.head sortedSurveys of + Just survey -> + Dict.values survey.signs + |> List.map + (\answer -> + case answer of + ResilienceSurveyQuestionOption0 -> + 1 + + ResilienceSurveyQuestionOption1 -> + 2 + + ResilienceSurveyQuestionOption2 -> + 3 + + ResilienceSurveyQuestionOption3 -> + 4 + + ResilienceSurveyQuestionOption4 -> + 5 + ) + |> List.sum + + Nothing -> + 0 + + adoptionSurveyCount = + List.filter (\survey -> survey.surveyType == ResilienceSurveyAdoption) surveys + |> List.length + + ( scoreText, interpretationFunction, additionalMessage ) = case dialogState of QuarterlySurveyScore score -> ( String.fromInt score ++ "/20" , Translate.QuarterlySurveyScoreInterpretation score + , Nothing ) AdoptionSurveyScore score -> + let + message = + if adoptionSurveyCount == 2 then + if score > survey1Score then + Just Translate.AdoptionSurveyProgressImproving + + else if score < survey1Score then + Just Translate.AdoptionSurveyProgressNotImproving + + else + Just Translate.AdoptionSurveyProgressSame + + else if adoptionSurveyCount == 3 then + Nothing + + else + Nothing + in ( String.fromInt score ++ "/60" , Translate.AdoptionSurveyScoreInterpretation score + , message ) - data = - ( p [ class "score" ] [ text scoreText ] - , p [ class "interpretation" ] [ text <| translate language <| interpretationFunction ] - , SetSurveyScoreDialogState Nothing - ) + topMessage = + p [ class "score" ] [ text scoreText ] + + bottomMessage = + p [ class "interpretation" ] [ text <| translate language <| interpretationFunction ] + + additionalMessageElement = + case additionalMessage of + Just msg -> + p [ class "message" ] [ text <| translate language <| msg ] + + Nothing -> + text "" + + dialogContent = + div [] + [ topMessage + , bottomMessage + , additionalMessageElement + ] + + dialogData = + ( dialogContent, div [] [], SetSurveyScoreDialogState Nothing ) in - customPopup language False Translate.Continue "survey-score-popup blue" data + customPopup language False Translate.Continue "survey-score-popup blue" dialogData ) From 01658107ea8ad2f7201beb588f5505bef1a79398 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Sat, 6 Jul 2024 01:36:28 +0200 Subject: [PATCH 36/63] add the summary of previous surveys on the 3rd survey --- client/src/assets/scss/_custom.scss | 4 ++ client/src/elm/Pages/MessagingCenter/View.elm | 56 ++++++++++++------- client/src/elm/Translate.elm | 14 +++++ 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/client/src/assets/scss/_custom.scss b/client/src/assets/scss/_custom.scss index 5d42d9be53..28fbe9c0d0 100644 --- a/client/src/assets/scss/_custom.scss +++ b/client/src/assets/scss/_custom.scss @@ -1391,6 +1391,10 @@ input::placeholder { margin-bottom: 1rem; text-align: center; text-transform: uppercase; + + &.message { + text-align: left; + } } .popup-action { diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 541d073f5e..38045ecb46 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -377,6 +377,23 @@ surveyScoreDialog language nurseId db = Maybe.map (\dialogState -> let + getScore answer = + case answer of + ResilienceSurveyQuestionOption0 -> + 1 + + ResilienceSurveyQuestionOption1 -> + 2 + + ResilienceSurveyQuestionOption2 -> + 3 + + ResilienceSurveyQuestionOption3 -> + 4 + + ResilienceSurveyQuestionOption4 -> + 5 + surveys = Dict.get nurseId db.resilienceSurveysByNurse |> Maybe.andThen RemoteData.toMaybe @@ -393,24 +410,17 @@ surveyScoreDialog language nurseId db = case List.head sortedSurveys of Just survey -> Dict.values survey.signs - |> List.map - (\answer -> - case answer of - ResilienceSurveyQuestionOption0 -> - 1 - - ResilienceSurveyQuestionOption1 -> - 2 - - ResilienceSurveyQuestionOption2 -> - 3 + |> List.map getScore + |> List.sum - ResilienceSurveyQuestionOption3 -> - 4 + Nothing -> + 0 - ResilienceSurveyQuestionOption4 -> - 5 - ) + survey2Score = + case List.drop 1 sortedSurveys |> List.head of + Just survey -> + Dict.values survey.signs + |> List.map getScore |> List.sum Nothing -> @@ -433,16 +443,20 @@ surveyScoreDialog language nurseId db = message = if adoptionSurveyCount == 2 then if score > survey1Score then - Just Translate.AdoptionSurveyProgressImproving + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving) ] else if score < survey1Score then - Just Translate.AdoptionSurveyProgressNotImproving + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving) ] else - Just Translate.AdoptionSurveyProgressSame + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] else if adoptionSurveyCount == 3 then - Nothing + Just <| + ul [] + [ li [] [ text (translate language (Translate.AdoptionSurveyBaselineScore survey1Score)) ] + , li [] [ text (translate language (Translate.AdoptionSurvey3MonthScore survey2Score)) ] + ] else Nothing @@ -461,7 +475,7 @@ surveyScoreDialog language nurseId db = additionalMessageElement = case additionalMessage of Just msg -> - p [ class "message" ] [ text <| translate language <| msg ] + p [ class "message" ] [ msg ] Nothing -> text "" diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 3e883feeca..7c69e9d567 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -387,6 +387,8 @@ type TranslationId | AdministeredMedicationQuestion | AdministeredOneOfAboveMedicinesQuestion | AddressInformation + | AdoptionSurveyBaselineScore Int + | AdoptionSurvey3MonthScore Int | AdoptionSurveyScoreInterpretation Int | AdoptionSurveyProgressImproving | AdoptionSurveyProgressNotImproving @@ -2986,6 +2988,18 @@ translationSet trans = AcuteIllnessDangerSigns -> translationSet DangerSigns + AdoptionSurveyBaselineScore score -> + { english = "Baseline Score: " ++ String.fromInt score ++ "/60" + , kinyarwanda = Just <| "Amanota wagize bwambere: " ++ String.fromInt score ++ "/60" + , kirundi = Nothing + } + + AdoptionSurvey3MonthScore score -> + { english = "Second Survey Score: " ++ String.fromInt score ++ "/60" + , kinyarwanda = Just <| "Amanota y'isuzuma rya kabiri: " ++ String.fromInt score ++ "/60" + , kirundi = Nothing + } + AdoptionSurveyScoreInterpretation score -> if score < 36 then { english = "Low effort to adopt resilience activities: Please, learn and integrate resilience activities in your daily life" From 3617579c64463c40aac14300b1b7253777597a6e Mon Sep 17 00:00:00 2001 From: Diama1 Date: Tue, 9 Jul 2024 15:44:55 +0200 Subject: [PATCH 37/63] style the icons --- client/src/assets/scss/_custom.scss | 16 +++++++++++++++- client/src/elm/Pages/MessagingCenter/View.elm | 10 +++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/client/src/assets/scss/_custom.scss b/client/src/assets/scss/_custom.scss index 28fbe9c0d0..5ca7116c7c 100644 --- a/client/src/assets/scss/_custom.scss +++ b/client/src/assets/scss/_custom.scss @@ -1392,8 +1392,22 @@ input::placeholder { text-align: center; text-transform: uppercase; - &.message { + .summary { text-align: left; + font-size: 25px; + } + + .message { + display: flex; + position: relative; + font-size: 25px; + + .icon-up, + .icon-down { + display: block; + margin-left: auto; + right: 0; + } } } diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 38045ecb46..e3e4ac1e38 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -443,17 +443,17 @@ surveyScoreDialog language nurseId db = message = if adoptionSurveyCount == 2 then if score > survey1Score then - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving) ] + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] else if score < survey1Score then - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving) ] + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] else Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] else if adoptionSurveyCount == 3 then Just <| - ul [] + ul [ class "summary" ] [ li [] [ text (translate language (Translate.AdoptionSurveyBaselineScore survey1Score)) ] , li [] [ text (translate language (Translate.AdoptionSurvey3MonthScore survey2Score)) ] ] @@ -475,10 +475,10 @@ surveyScoreDialog language nurseId db = additionalMessageElement = case additionalMessage of Just msg -> - p [ class "message" ] [ msg ] + msg Nothing -> - text "" + emptyNode dialogContent = div [] From 743a5fcfe87197714a33e2a84879908c3a0cc6a6 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Tue, 9 Jul 2024 20:29:19 +0200 Subject: [PATCH 38/63] set up guide message page [ci skip] --- client/src/elm/App/Fetch.elm | 13 +++++++++++++ client/src/elm/App/View.elm | 18 ++++++++++++++++++ client/src/elm/Pages/Page.elm | 1 + client/src/elm/Pages/Router.elm | 3 +++ client/src/elm/Translate.elm | 11 +++++++---- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/client/src/elm/App/Fetch.elm b/client/src/elm/App/Fetch.elm index 8263e7b563..76c5589c86 100644 --- a/client/src/elm/App/Fetch.elm +++ b/client/src/elm/App/Fetch.elm @@ -466,6 +466,19 @@ fetch model = ) |> Maybe.withDefault [] + UserPage GuideMessagePage -> + getLoggedInData model + |> Maybe.map + (\( _, loggedIn ) -> + let + nurseId = + Tuple.first loggedIn.nurse + in + Pages.MessagingCenter.Fetch.fetch currentDate nurseId model.indexedDb + |> List.map MsgIndexedDb + ) + |> Maybe.withDefault [] + UserPage StockManagementPage -> getLoggedInData model |> Maybe.map diff --git a/client/src/elm/App/View.elm b/client/src/elm/App/View.elm index c8bebce8de..f1aad020b2 100644 --- a/client/src/elm/App/View.elm +++ b/client/src/elm/App/View.elm @@ -1085,6 +1085,24 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur |> Html.map (MsgLoggedIn << MsgPageMessagingCenter nurseId) |> flexPageWrapper configured.config model + GuideMessagePage -> + let + ( nurseId, nurse ) = + loggedInModel.nurse + + page_ = + Dict.get nurseId loggedInModel.messagingCenterPages + |> Maybe.withDefault Pages.MessagingCenter.Model.emptyModel + in + Pages.Wellbeing.View.view model.language + model.currentTime + nurseId + nurse + model.indexedDb + page_ + |> Html.map (MsgLoggedIn << MsgPageMessagingCenter nurseId) + |> flexPageWrapper configured.config model + StockManagementPage -> let ( nurseId, nurse ) = diff --git a/client/src/elm/Pages/Page.elm b/client/src/elm/Pages/Page.elm index 4bd9010096..029f175351 100644 --- a/client/src/elm/Pages/Page.elm +++ b/client/src/elm/Pages/Page.elm @@ -204,6 +204,7 @@ type UserPage | PatientRecordPage PatientRecordInitiator PersonId | MessagingCenterPage | WellbeingPage + | GuideMessagePage | StockManagementPage diff --git a/client/src/elm/Pages/Router.elm b/client/src/elm/Pages/Router.elm index c309c5cbfc..e1279f2e7e 100644 --- a/client/src/elm/Pages/Router.elm +++ b/client/src/elm/Pages/Router.elm @@ -379,6 +379,9 @@ pageToFragment current = WellbeingPage -> Just "wellbeing" + GuideMessagePage -> + Just "guide" + StockManagementPage -> Just "stock-management" diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 7c69e9d567..1a11e278c7 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -716,7 +716,7 @@ type TranslationId | GroupEncounterType GroupEncounterType | GroupOfFoods GroupOfFoods | Growth - | Guide + | GuideMessage | HalfOfDosage String | HandedReferralFormQuestion | HandPallor @@ -6410,8 +6410,8 @@ translationSet trans = GroupEncounterEducation -> translationSet HealthEducation - Guide -> - { english = "Guide" + GuideMessage -> + { english = "Guide Message" , kinyarwanda = Just "Ifashayobora" , kirundi = Nothing } @@ -10722,7 +10722,7 @@ translationSet trans = MessagingTab tab -> case tab of TabGuide -> - translationSet Guide + translationSet GuideMessage TabUnread -> translationSet (ReadToggle True) @@ -24160,6 +24160,9 @@ translateActivePage page = , kirundi = Just "Igihande c'ubutumwa" } + GuideMessagePage -> + translationSet GuideMessage + WellbeingPage -> { english = "Wellbeing" , kinyarwanda = Just "Gubwa neza" From 4e4238b2befdd16107fa85ac8b86599eccc54aba Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 10 Jul 2024 14:14:55 +0300 Subject: [PATCH 39/63] Setting better path for development [ci skip] --- client/src/elm/App/Update.elm | 2 +- .../src/elm/Pages/MessagingCenter/Model.elm | 2 +- .../src/elm/Pages/MessagingCenter/Update.elm | 10 +-- .../src/elm/Pages/MessagingCenter/Utils.elm | 18 ++++- client/src/elm/Pages/MessagingCenter/View.elm | 71 ++++++++++++------- 5 files changed, 66 insertions(+), 37 deletions(-) diff --git a/client/src/elm/App/Update.elm b/client/src/elm/App/Update.elm index 4159557d11..efcc6ad0b0 100644 --- a/client/src/elm/App/Update.elm +++ b/client/src/elm/App/Update.elm @@ -908,7 +908,7 @@ update msg model = ( subModel, subCmd, appMsgs ) = Dict.get id data.messagingCenterPages |> Maybe.withDefault Pages.MessagingCenter.Model.emptyModel - |> Pages.MessagingCenter.Update.update model.currentTime currentDate subMsg + |> Pages.MessagingCenter.Update.update model.currentTime currentDate model.indexedDb subMsg in ( { data | messagingCenterPages = Dict.insert id subModel data.messagingCenterPages } , Cmd.map (MsgLoggedIn << MsgPageMessagingCenter id) subCmd diff --git a/client/src/elm/Pages/MessagingCenter/Model.elm b/client/src/elm/Pages/MessagingCenter/Model.elm index 13d27f29fd..148205e8d9 100644 --- a/client/src/elm/Pages/MessagingCenter/Model.elm +++ b/client/src/elm/Pages/MessagingCenter/Model.elm @@ -92,7 +92,7 @@ emptySurveyForm = type SurveyScoreDialogState = QuarterlySurveyScore Int - | AdoptionSurveyScore Int + | AdoptionSurveyScore (List Int) type Msg diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index 95af624d9d..e82adb1e02 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -3,7 +3,7 @@ module Pages.MessagingCenter.Update exposing (update) import App.Model import AssocList as Dict import Backend.Entities exposing (..) -import Backend.Model +import Backend.Model exposing (ModelIndexedDb) import Backend.Nurse.Model exposing (Nurse) import Backend.Nurse.Utils exposing (resilienceRoleFromString) import Backend.Person.Utils @@ -30,8 +30,8 @@ import Time import Time.Extra -update : Time.Posix -> NominalDate -> Msg -> Model -> ( Model, Cmd Msg, List App.Model.Msg ) -update currentTime currentDate msg model = +update : Time.Posix -> NominalDate -> ModelIndexedDb -> Msg -> Model -> ( Model, Cmd Msg, List App.Model.Msg ) +update currentTime currentDate db msg model = case msg of SetActivePage page -> ( model @@ -212,7 +212,7 @@ update currentTime currentDate msg model = |> Backend.Model.MsgResilienceSurvey nurseId |> App.Model.MsgIndexedDb ] - , [ resolveSurveyScoreDialogState surveyType surveyScore + , [ resolveSurveyScoreDialogState nurseId surveyType surveyScore db |> Just |> SetSurveyScoreDialogState ] @@ -225,7 +225,7 @@ update currentTime currentDate msg model = , Cmd.none , msgs ) - |> sequenceExtra (update currentTime currentDate) extraMsgs + |> sequenceExtra (update currentTime currentDate db) extraMsgs SetSurveyScoreDialogState state -> ( { model | surveyScoreDialogState = state } diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 8c0b28bf69..3e2224a4ab 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -108,11 +108,23 @@ surveyQuestionsAnswered surveyType surveyForm = Dict.size surveyForm == List.length surveyQuestions -resolveSurveyScoreDialogState : ResilienceSurveyType -> Int -> SurveyScoreDialogState -resolveSurveyScoreDialogState surveyType score = +resolveSurveyScoreDialogState : NurseId -> ResilienceSurveyType -> Int -> ModelIndexedDb -> SurveyScoreDialogState +resolveSurveyScoreDialogState nurseId surveyType score db = case surveyType of ResilienceSurveyQuarterly -> QuarterlySurveyScore score ResilienceSurveyAdoption -> - AdoptionSurveyScore score + let + -- Ordered from first to last. + -- Also, making sure we don't include current survey score + -- and there are up to 2 surveys (which should be the case, + -- as there can be up to 3 surveys filled, but verification is + -- required nevertheless). + previousSurveysScores = + -- @todo + [] + in + previousSurveysScores + ++ [ score ] + |> AdoptionSurveyScore diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index e3e4ac1e38..fa25a884cb 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -438,33 +438,50 @@ surveyScoreDialog language nurseId db = , Nothing ) - AdoptionSurveyScore score -> - let - message = - if adoptionSurveyCount == 2 then - if score > survey1Score then - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] - - else if score < survey1Score then - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] - - else - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] - - else if adoptionSurveyCount == 3 then - Just <| - ul [ class "summary" ] - [ li [] [ text (translate language (Translate.AdoptionSurveyBaselineScore survey1Score)) ] - , li [] [ text (translate language (Translate.AdoptionSurvey3MonthScore survey2Score)) ] - ] - - else - Nothing - in - ( String.fromInt score ++ "/60" - , Translate.AdoptionSurveyScoreInterpretation score - , message - ) + AdoptionSurveyScore scores -> + -- @todo : delete + -- let + -- message = + -- if adoptionSurveyCount == 2 then + -- if score > survey1Score then + -- Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] + -- + -- else if score < survey1Score then + -- Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] + -- + -- else + -- Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] + -- + -- else if adoptionSurveyCount == 3 then + -- Just <| + -- ul [ class "summary" ] + -- [ li [] [ text (translate language (Translate.AdoptionSurveyBaselineScore survey1Score)) ] + -- , li [] [ text (translate language (Translate.AdoptionSurvey3MonthScore survey2Score)) ] + -- ] + -- + -- else + -- Nothing + -- in + -- ( String.fromInt score ++ "/60" + -- , Translate.AdoptionSurveyScoreInterpretation score + -- , message + -- ) + case scores of + [ first ] -> + -- @todo + ( "", Translate.EmptyString, Nothing ) + + [ first, second ] -> + -- @todo + ( "", Translate.EmptyString, Nothing ) + + [ first, second, third ] -> + -- @todo + ( "", Translate.EmptyString, Nothing ) + + _ -> + -- We shold never get here. + ( "", Translate.EmptyString, Nothing ) topMessage = p [ class "score" ] [ text scoreText ] From c67bd969b0ae44d4341c7ecea95fcb07472f0d82 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Wed, 10 Jul 2024 13:20:55 +0200 Subject: [PATCH 40/63] add guide message [ci skip] --- client/src/assets/scss/_new.scss | 46 +++++++++--- client/src/elm/App/View.elm | 3 +- client/src/elm/Pages/GuideMessage/View.elm | 85 ++++++++++++++++++++++ client/src/elm/Pages/Router.elm | 1 + client/src/elm/Pages/Wellbeing/View.elm | 9 +++ 5 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 client/src/elm/Pages/GuideMessage/View.elm diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index ba0d813a6d..ef768189e0 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -4860,18 +4860,40 @@ div.page-activity.ncd { div.page-activity.wellbeing { - .ui.button .counter { - background-color: $color-velvet; - border-radius: 50%; - display: inline-block; - font-size: 16px; - font-weight: bold; - height: 30px; - left: 5px; - line-height: 30px; - position: relative; - top: -15px; - width: 30px; + .ui.button { + margin-bottom: 20px; + + .counter { + background-color: $color-velvet; + border-radius: 50%; + display: inline-block; + font-size: 16px; + font-weight: bold; + height: 30px; + left: 5px; + line-height: 30px; + position: relative; + top: -15px; + width: 30px; + } + } +} + +div.page-activity.guideMessage { + height: auto; + + .guide { + background: $color-white; + padding: 30px 25px; + color: $color-text; + + .title { + font-weight: bold; + + &.note { + font-style: italic; + } + } } } diff --git a/client/src/elm/App/View.elm b/client/src/elm/App/View.elm index f1aad020b2..31942ac485 100644 --- a/client/src/elm/App/View.elm +++ b/client/src/elm/App/View.elm @@ -42,6 +42,7 @@ import Pages.EducationSession.Model import Pages.EducationSession.View import Pages.GlobalCaseManagement.View import Pages.GroupEncounterTypes.View +import Pages.GuideMessage.View import Pages.HIV.Activity.Model import Pages.HIV.Activity.View import Pages.HIV.Encounter.Model @@ -1094,7 +1095,7 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur Dict.get nurseId loggedInModel.messagingCenterPages |> Maybe.withDefault Pages.MessagingCenter.Model.emptyModel in - Pages.Wellbeing.View.view model.language + Pages.GuideMessage.View.view model.language model.currentTime nurseId nurse diff --git a/client/src/elm/Pages/GuideMessage/View.elm b/client/src/elm/Pages/GuideMessage/View.elm new file mode 100644 index 0000000000..e92c512059 --- /dev/null +++ b/client/src/elm/Pages/GuideMessage/View.elm @@ -0,0 +1,85 @@ +module Pages.GuideMessage.View exposing (..) + +import Backend.Entities exposing (..) +import Backend.Model exposing (ModelIndexedDb) +import Backend.Nurse.Model exposing (Nurse) +import Gizra.NominalDate exposing (fromLocalDateTime) +import Html exposing (..) +import Html.Attributes exposing (..) +import Html.Events exposing (onClick) +import Pages.MessagingCenter.Model exposing (..) +import Pages.MessagingCenter.Utils exposing (..) +import Pages.Page exposing (Page(..), UserPage(..)) +import Time +import Translate exposing (Language, translate, translateText) + + +view : Language -> Time.Posix -> NurseId -> Nurse -> ModelIndexedDb -> Model -> Html Msg +view language currentTime nurseId nurse db model = + let + header = + div [ class "ui basic head segment" ] + [ h1 [ class "ui header" ] + [ translateText language Translate.GuideMessage + ] + , span + [ class "link-back" + , onClick <| SetActivePage <| UserPage WellbeingPage + ] + [ span [ class "icon-back" ] [] ] + ] + in + div [ class "page-activity guideMessage" ] + [ header + , viewGuide language + ] + + +viewGuide : Language -> Html Msg +viewGuide language = + div [ class "guide" ] + [ p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection1Title ] + , ul [] + [ li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet1 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet2 ] + ] + , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection2Title ] + , ul [] + [ li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet1 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet2 ] + ] + , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection3Title ] + , ul [] + [ li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet1 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet2 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet3 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet4 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet5 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet6 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet7 ] + ] + , p [ class "title note" ] [ text <| translate language Translate.ResilienceGuideSection3Note ] + , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection4Title ] + , p [] [ text <| translate language Translate.ResilienceGuideSection4Text ] + , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection6Title ] + , ul [] + [ li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet1 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet2 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet3 ] + ] + , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection6Title ] + , ul [] + [ li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet1 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet2 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet3 ] + , li [] + [ text <| translate language Translate.ResilienceGuideSection6Bullet4 + , ul [] + [ li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet5 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet6 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet7 ] + ] + ] + ] + , p [ class "title note" ] [ text <| translate language Translate.ResilienceGuideSection6Note ] + ] diff --git a/client/src/elm/Pages/Router.elm b/client/src/elm/Pages/Router.elm index e1279f2e7e..074e206124 100644 --- a/client/src/elm/Pages/Router.elm +++ b/client/src/elm/Pages/Router.elm @@ -453,6 +453,7 @@ parser = , map (\id initiator -> UserPage <| PatientRecordPage initiator id) (s "patient-record" parseUuid parsePatientRecordInitiator) , map (UserPage MessagingCenterPage) (s "messaging-center") , map (UserPage WellbeingPage) (s "wellbeing") + , map (UserPage GuideMessagePage) (s "guide") , map (UserPage StockManagementPage) (s "stock-management") -- `top` represents the page without any segements ... i.e. the root page. diff --git a/client/src/elm/Pages/Wellbeing/View.elm b/client/src/elm/Pages/Wellbeing/View.elm index ea5cd43994..00ea003ac0 100644 --- a/client/src/elm/Pages/Wellbeing/View.elm +++ b/client/src/elm/Pages/Wellbeing/View.elm @@ -43,8 +43,17 @@ view language currentTime nurseId nurse db model = [ span [ class "text" ] [ text <| translate language Translate.ResilienceMessage ] , span [ class "counter" ] [ text <| String.fromInt numberOfUnreadMessages ] ] + + guideMessageButton = + button + [ class "ui primary button" + , onClick <| SetActivePage <| UserPage GuideMessagePage + ] + [ span [ class "text" ] [ text <| translate language Translate.GuideMessage ] + ] in div [ class "page-activity wellbeing" ] [ header , resilienceMessageButton + , guideMessageButton ] From b3c51f78d272a045002c14495548ad17642fbe2e Mon Sep 17 00:00:00 2001 From: Diama1 Date: Wed, 10 Jul 2024 13:43:27 +0200 Subject: [PATCH 41/63] remove the guide in messagingCenter --- .../src/elm/Pages/MessagingCenter/Model.elm | 5 +- client/src/elm/Pages/MessagingCenter/View.elm | 57 +------------------ client/src/elm/Translate.elm | 3 - 3 files changed, 3 insertions(+), 62 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Model.elm b/client/src/elm/Pages/MessagingCenter/Model.elm index 13d27f29fd..32cff221cd 100644 --- a/client/src/elm/Pages/MessagingCenter/Model.elm +++ b/client/src/elm/Pages/MessagingCenter/Model.elm @@ -32,7 +32,7 @@ type alias Model = emptyModel : Model emptyModel = - { activeTab = TabGuide + { activeTab = TabUnread , tabScrollPosition = 0 , expandedMessages = EverySet.empty , messageOptionsDialogState = Nothing @@ -43,8 +43,7 @@ emptyModel = type MessagingTab - = TabGuide - | TabUnread + = TabUnread | TabFavorites | TabGrowth | TabConnecting diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index e3e4ac1e38..1b31c5f046 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -540,9 +540,6 @@ viewMessagingCenter language currentTime currentDate programStartDate nurseId nu |> List.map viewMessage in case model.activeTab of - TabGuide -> - viewGuide language nurse - TabUnread -> List.map viewMessage unread @@ -580,8 +577,7 @@ viewTabs : Language -> Model -> Html Msg viewTabs language model = let allTabs = - [ TabGuide - , TabUnread + [ TabUnread , TabFavorites , TabGrowth , TabConnecting @@ -746,57 +742,6 @@ viewResilienceMessage language nurseId nurse model ( messageId, message ) = ] -viewGuide : Language -> Nurse -> List (Html Msg) -viewGuide language nurse = - [ div [ class "guide" ] - [ p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection1Title ] - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet2 ] - ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection2Title ] - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet2 ] - ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection3Title ] - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet2 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet3 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet4 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet5 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet6 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet7 ] - ] - , p [ class "title note" ] [ text <| translate language Translate.ResilienceGuideSection3Note ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection4Title ] - , p [] [ text <| translate language Translate.ResilienceGuideSection4Text ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection6Title ] - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet2 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet3 ] - ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection6Title ] - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet2 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet3 ] - , li [] - [ text <| translate language Translate.ResilienceGuideSection6Bullet4 - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet5 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet6 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet7 ] - ] - ] - ] - , p [ class "title note" ] [ text <| translate language Translate.ResilienceGuideSection6Note ] - ] - ] - - viewIntroductionMessage : Language -> Nurse -> ResilienceMessageOrder -> ( List (Html Msg), List (Html Msg) ) viewIntroductionMessage language nurse order = case order of diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 1a11e278c7..a7a9fc828e 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -10721,9 +10721,6 @@ translationSet trans = MessagingTab tab -> case tab of - TabGuide -> - translationSet GuideMessage - TabUnread -> translationSet (ReadToggle True) From 52183ecd7ffb0dda1923cf8a279e6e841a5562b2 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Thu, 11 Jul 2024 13:24:35 +0200 Subject: [PATCH 42/63] rephrase the guide message --- client/src/assets/scss/_new.scss | 9 +- client/src/elm/Pages/GuideMessage/View.elm | 33 +--- client/src/elm/Translate.elm | 197 +++++++-------------- 3 files changed, 81 insertions(+), 158 deletions(-) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index ef768189e0..045ae4974e 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -4889,10 +4889,11 @@ div.page-activity.guideMessage { .title { font-weight: bold; - - &.note { - font-style: italic; - } + font-size: 25px; + } + .note { + font-style: italic; + font-weight: bold; } } } diff --git a/client/src/elm/Pages/GuideMessage/View.elm b/client/src/elm/Pages/GuideMessage/View.elm index e92c512059..c94c3cec42 100644 --- a/client/src/elm/Pages/GuideMessage/View.elm +++ b/client/src/elm/Pages/GuideMessage/View.elm @@ -39,47 +39,32 @@ viewGuide : Language -> Html Msg viewGuide language = div [ class "guide" ] [ p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection1Title ] + , p [ class "note" ] [ text <| translate language Translate.ResilienceGuideSection1TitleNote1 ] + , p [] [ text <| translate language Translate.ResilienceGuideSection1TitleNote2 ] , ul [] [ li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet1 ] , li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet2 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection1Bullet3 ] ] , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection2Title ] , ul [] [ li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet1 ] , li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet2 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection2Bullet3 ] ] , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection3Title ] + , p [] [ text <| translate language Translate.ResilienceGuideSection3Note ] , ul [] [ li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet1 ] , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet2 ] , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet3 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet4 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet5 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet6 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection3Bullet7 ] ] - , p [ class "title note" ] [ text <| translate language Translate.ResilienceGuideSection3Note ] , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection4Title ] , p [] [ text <| translate language Translate.ResilienceGuideSection4Text ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection6Title ] , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet2 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection5Bullet3 ] + [ li [] [ text <| translate language Translate.ResilienceGuideSection4Bullet1 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection4Bullet2 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection4Bullet3 ] + , li [] [ text <| translate language Translate.ResilienceGuideSection4Bullet4 ] ] - , p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection6Title ] - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet1 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet2 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet3 ] - , li [] - [ text <| translate language Translate.ResilienceGuideSection6Bullet4 - , ul [] - [ li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet5 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet6 ] - , li [] [ text <| translate language Translate.ResilienceGuideSection6Bullet7 ] - ] - ] - ] - , p [ class "title note" ] [ text <| translate language Translate.ResilienceGuideSection6Note ] ] diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index a7a9fc828e..476f9affd7 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -1402,35 +1402,26 @@ type TranslationId | ResilienceMessageGrowth4Paragraph1 | ResilienceMessageGrowth4Paragraph2 | ResilienceGuideSection1Title + | ResilienceGuideSection1TitleNote1 + | ResilienceGuideSection1TitleNote2 | ResilienceGuideSection1Bullet1 | ResilienceGuideSection1Bullet2 + | ResilienceGuideSection1Bullet3 | ResilienceGuideSection2Title | ResilienceGuideSection2Bullet1 | ResilienceGuideSection2Bullet2 + | ResilienceGuideSection2Bullet3 | ResilienceGuideSection3Title + | ResilienceGuideSection3Note | ResilienceGuideSection3Bullet1 | ResilienceGuideSection3Bullet2 | ResilienceGuideSection3Bullet3 - | ResilienceGuideSection3Bullet4 - | ResilienceGuideSection3Bullet5 - | ResilienceGuideSection3Bullet6 - | ResilienceGuideSection3Bullet7 - | ResilienceGuideSection3Note | ResilienceGuideSection4Title | ResilienceGuideSection4Text - | ResilienceGuideSection5Title - | ResilienceGuideSection5Bullet1 - | ResilienceGuideSection5Bullet2 - | ResilienceGuideSection5Bullet3 - | ResilienceGuideSection6Title - | ResilienceGuideSection6Bullet1 - | ResilienceGuideSection6Bullet2 - | ResilienceGuideSection6Bullet3 - | ResilienceGuideSection6Bullet4 - | ResilienceGuideSection6Bullet5 - | ResilienceGuideSection6Bullet6 - | ResilienceGuideSection6Bullet7 - | ResilienceGuideSection6Note + | ResilienceGuideSection4Bullet1 + | ResilienceGuideSection4Bullet2 + | ResilienceGuideSection4Bullet3 + | ResilienceGuideSection4Bullet4 | ResilienceMessageStressManagement1Title | ResilienceMessageStressManagement1Paragraph1 | ResilienceMessageStressManagement1Paragraph2 @@ -18727,182 +18718,128 @@ translationSet trans = } ResilienceGuideSection1Title -> - { english = "a. Entering e-Heza Digital Data Solution" - , kinyarwanda = Just "a. Kwinjira muri e-Heza" + { english = "Program Overview" + , kinyarwanda = Just "Ibikubiye muri porogaramu" , kirundi = Nothing } - ResilienceGuideSection1Bullet1 -> - { english = "Input your pin code" - , kinyarwanda = Just "Shyiramo kode (ariyo Pin)" + ResilienceGuideSection1TitleNote1 -> + { english = "This session will assist you in navigating through Resilience Messages." + , kinyarwanda = Just "Iki gice kiragufasha/ kirakuyobora kumenya uko ukoresha iyi porogaramu." , kirundi = Nothing } - ResilienceGuideSection1Bullet2 -> - { english = "Proceed to the \"Well-being\" icon" - , kinyarwanda = Just "Komeza kuri \"Gubwa neza\"" + ResilienceGuideSection1TitleNote2 -> + { english = "After entering the Well Being module and entering the resilience message section you will need to complete the survey, and the healthcare worker will begin receiving resilience messages. On the main page, resilience messages are put into the following categories." + , kinyarwanda = Just "Nyuma yo kwinjira muri module ya \" Gubwa neza\" winjiye no muri gahunda y’ \"Ubutumwa bwo Kwifasha kwiyitaho\", nuko usubiza ibibazo byo kwisuzuma. , Nk’umukozi utanga servisi z’ubuvuzi watangira kubona ubutumwa bugufasha kwiyitaho. Ku ipaje ibanza, urahasanga ubutumwa bwo kwifasha kwiyitaho bugiye buri mubyiciro bikurikira" , kirundi = Nothing } - ResilienceGuideSection2Title -> - { english = "b. Upon entering, find the \"Resilience Messages\" window" - , kinyarwanda = Just "b. Iyo winjiye, ukande ku idirishya ry’“Ubutumwa bwo Kwifasha kumererwa neza”" + ResilienceGuideSection1Bullet1 -> + { english = "Unread: these messages have not yet been read by the healthcare worker." + , kinyarwanda = Just "Ubutumwa utarasoma: Ubu ni ubutumwa umukozi utanga serevisi z’ubuvuzi atarasoma." , kirundi = Nothing } - ResilienceGuideSection2Bullet1 -> - { english = "Respond to the four questions presented." - , kinyarwanda = Just "Subiza ibibazo 16 byatanzwe." + ResilienceGuideSection1Bullet2 -> + { english = "Favourites: these are messages that are saved by the healthcare worker by marking them as \"favourite\"" + , kinyarwanda = Just "Ubutumwa wishimiye: Ubu ni ubutumwa bubikwa muri iki gice mugihe umukozi utanga serevisi z’ubuvuzi yabwishimiye/yabukunze." , kirundi = Nothing } - ResilienceGuideSection2Bullet2 -> - { english = "Receive a score before progressing further." - , kinyarwanda = Just "Akira amanota mbere yo gukomeza." + ResilienceGuideSection1Bullet3 -> + { english = "Message types: After reading, messages are grouped into the following categories for easy reference: Growth, Connecting, Stress Management, Self-care, Mindfulness." + , kinyarwanda = Just "Ibyiciro by’ubutumwa: Nyuma yo gusoma, ubutumwa bujya muri ibi byiciro bikurikira. Terimbere, Gusabana, Kwiyitaho, Kunanirwa, na Mindfulness." , kirundi = Nothing } - ResilienceGuideSection3Title -> - { english = "c. Program Overview" - , kinyarwanda = Just "c. Ibice bigize iyi porogaramu" + ResilienceGuideSection2Title -> + { english = "Reading Unread Messages" + , kinyarwanda = Just "Kubona Ubutumwa utarasoma" , kirundi = Nothing } - ResilienceGuideSection3Bullet1 -> - { english = "Unread" - , kinyarwanda = Just "Ubutumwa utarasoma" + ResilienceGuideSection2Bullet1 -> + { english = "Click on \"Unread\" to locate all unread messages." + , kinyarwanda = Just "Kanda ahanditse \"Ubutumwa utarasoma\" Shakira ubutumwa utarasoma muri icyo gice." , kirundi = Nothing } - ResilienceGuideSection3Bullet2 -> - { english = "Favourites" - , kinyarwanda = Just "Ubutumwa wishimiye" + ResilienceGuideSection2Bullet2 -> + { english = "Click twice on the message to fully open it." + , kinyarwanda = Just "Kanda inshuro ebyili ku butumwa uri gusoma kugirango ubusome neza." , kirundi = Nothing } - ResilienceGuideSection3Bullet3 -> - { english = "Growth" - , kinyarwanda = Just "Terimbere" + ResilienceGuideSection2Bullet3 -> + { english = "After opening, the message will be removed from unread messages." + , kinyarwanda = Just "Nyuma yo kubusoma, ubutumwa buhita buva ku rutonde rw'ubutumwa utarasoma." , kirundi = Nothing } - ResilienceGuideSection3Bullet4 -> - { english = "Connecting" - , kinyarwanda = Just "Gusabana" + ResilienceGuideSection3Title -> + { english = "Adding Favourites" + , kinyarwanda = Just "Kubika Ubutumwa wishimiye" , kirundi = Nothing } - ResilienceGuideSection3Bullet5 -> - { english = "Stress Management" - , kinyarwanda = Just "Kunanirwa" + ResilienceGuideSection3Note -> + { english = "If you find a message particularly relevant, you can add it to your favourites for future reference:" + , kinyarwanda = Just "Niba hari ubutumwa wasomye ukabwishimira/ukabukunda, ushobora kubushyira muri iki gice. Uko bikorwa:" , kirundi = Nothing } - ResilienceGuideSection3Bullet6 -> - { english = "Self-care" - , kinyarwanda = Just "Kwiyitaho" + ResilienceGuideSection3Bullet1 -> + { english = "After reading the message, Click on the three buttons above the message" + , kinyarwanda = Just "Umaze gusoma ubutumwa, Kanda ku tudomo dutatu turi hejuru y’ubutumwa" , kirundi = Nothing } - ResilienceGuideSection3Bullet7 -> - { english = "Mindfulness" - , kinyarwanda = Nothing + ResilienceGuideSection3Bullet2 -> + { english = "Options include \"Read it,\" \"Favourites,\" and \"Remind me\"." + , kinyarwanda = Just "Urasanga harimo: \"Bwasomwe,\" \"Ishimire Ubutumwa,\" na \"Unyibutse\"" , kirundi = Nothing } - ResilienceGuideSection3Note -> - { english = "(Messages are appropriately categorized within each section once done reading)" - , kinyarwanda = Just "(Iyo umaze gusoma ubutumwa, bwijyana muri buri cyiciro cyabwo)" + ResilienceGuideSection3Bullet3 -> + { english = "Choose \"Favourite\" to mark the message, and it will" + , kinyarwanda = Just "Hitamo \"Ishimire Ubutumwa\" (burahita bujya mu gice cy’ubutumwa wishimiye)." , kirundi = Nothing } ResilienceGuideSection4Title -> - { english = "d. Find Unread Section: Click on \"Unread\" " - , kinyarwanda = Just "d. Kubona Ubutumwa utarasoma: Kanda ahanditse \"Umutumwa utarasoma\"" + { english = "Scheduling Reminders" + , kinyarwanda = Just "Guhitamo igihe usomera ubutumwa" , kirundi = Nothing } ResilienceGuideSection4Text -> - { english = "Locate unread messages in that section. Click twice on the message to increase its visibility, and after that it will be removed from unread messages" - , kinyarwanda = Just "Shakira ubutumwa utarasoma muri icyo gice. Kanda inshuro ebyili ku butumwa uri gusoma kugirango ubusome neza. maze buhite buva ku rutonde rw'ubutumwa utarasoma" + { english = "If you don’t have time to read a message fully after opening it, you can schedule a reminder to read it again" + , kinyarwanda = Just "Niba ubuze umwanya wo gusoma ubutumwa, ushobora kubuhitamo ukaba wabusoma igihe uboneye umwanya" , kirundi = Nothing } - ResilienceGuideSection5Title -> - { english = "e. Saving your Favourite Messages: (If a message resonates positively with you, you can designate it as a favourite)" - , kinyarwanda = Just "e. Kubika Ubutumwa wakunze: (Niba hari ubutumwa wasomye ukabwishimira/ukabukunda, ushobora kubushyira muri iki gice) Uko bikorwa" - , kirundi = Nothing - } - - ResilienceGuideSection5Bullet1 -> - { english = "After reading a message Click on the three buttons above a message" - , kinyarwanda = Just "Umaze gusoma ubutumwa, Kanda ku tudomo dutatu turi hejuru y’ubutumwa" - , kirundi = Nothing - } - - ResilienceGuideSection5Bullet2 -> - { english = "Options include \"Read it,\" \"Favourites,\" and \"Remind me.\"" - , kinyarwanda = Just "Amahitamo arimo \"Soma,\" \"Ubwo ukunda,\" na \"Unyibutse.\"" - , kirundi = Nothing - } - - ResilienceGuideSection5Bullet3 -> - { english = "Choose \"Favourite\" to mark the message" - , kinyarwanda = Just " Hitamo \"Ubwo ukunda\" (burahita bujya mu gice cy’ubutumwa ukunda." - , kirundi = Nothing - } - - ResilienceGuideSection6Title -> - { english = "f. Scheduling Reminders: (if you lack time to read a message immediately, schedule a reminder)" - , kinyarwanda = Just "f. Gusaba Kwibutswa gusoma ubutumwa: (Niba ubuze umwanya wo gusoma ubutumwa, ushobora kubuhitamo ukaba wabusoma igihe uboneye umwanya)" - , kirundi = Nothing - } - - ResilienceGuideSection6Bullet1 -> + ResilienceGuideSection4Bullet1 -> { english = "Click on the three buttons above a message." - , kinyarwanda = Just "Kanda ku tudomo dutatu turi hejuru y’ubutumwa" + , kinyarwanda = Just "Kanda ku tudomo dutatu turi hejuru y’ubutumwa." , kirundi = Nothing } - ResilienceGuideSection6Bullet2 -> - { english = "Options include \"Read it,\" \"Favourites,\" and \"Remind me.\"" - , kinyarwanda = Just "Amahitamo arimo \"Soma,\" \"Ubwo ukunda,\" na \"Unyibutse\"" + ResilienceGuideSection4Bullet2 -> + { english = "Options include \"Read it,\" \"Favourites,\" and \"Remind me\"." + , kinyarwanda = Just "Urasanga harimo \"Bwasomwe,\" \"Ishimire Ubutumwa,\" na \"Unyibutse.\"" , kirundi = Nothing } - ResilienceGuideSection6Bullet3 -> + ResilienceGuideSection4Bullet3 -> { english = "Click on \"Remind me\" for messages you cannot read immediately." - , kinyarwanda = Just "Kanda kuri \"Unyibutse\" kubutumwa utagiye gusoma ako kanya." - , kirundi = Nothing - } - - ResilienceGuideSection6Bullet4 -> - { english = "Set a reminder to revisit the message in:" - , kinyarwanda = Just "Hitamo igihe uraba waboneye umwanya waza gusoma ubutumwa. Urahabwa amahitamo yo kuba wabusoma mu gihe cy’:" - , kirundi = Nothing - } - - ResilienceGuideSection6Bullet5 -> - { english = "One hour" - , kinyarwanda = Just "Isaha imwe" - , kirundi = Nothing - } - - ResilienceGuideSection6Bullet6 -> - { english = "Six hours" - , kinyarwanda = Just "Amasaha atandatu" - , kirundi = Nothing - } - - ResilienceGuideSection6Bullet7 -> - { english = "Twelve hours" - , kinyarwanda = Just "Amasaha cumi n'abiri" + , kinyarwanda = Just " Kanda kuri \"Unyibutse\" ku ubutumwa utagiye gusoma ako kanya." , kirundi = Nothing } - ResilienceGuideSection6Note -> - { english = "Note: It is important to note that reading the message requires clicking on it." - , kinyarwanda = Just "Icyitonderwa: Ni ngombwa kumenya ko gusoma ubutumwa bisaba gukanda kuri ubwo butumwa." + ResilienceGuideSection4Bullet4 -> + { english = "Set a reminder to revisit the message in: One hour, Six hours, Twelve hours" + , kinyarwanda = Just "Hitamo igihe uraba waboneye umwanya wo gusoma ubutumwa. Urahabwa amahitamo yo kuba wabusoma; mu gihe cy’isaha imwe, amasaha atandatu cyangwa amasaha cumi n'abiri." , kirundi = Nothing } From 8149e03c22a5c7f50738b0d0cf7d0cb1eb735898 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Mon, 15 Jul 2024 20:55:09 +0200 Subject: [PATCH 43/63] change theh development path --- .../src/elm/Pages/MessagingCenter/Utils.elm | 41 ++++-- client/src/elm/Pages/MessagingCenter/View.elm | 126 +++++------------- 2 files changed, 67 insertions(+), 100 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 3e2224a4ab..a3be541333 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -6,7 +6,7 @@ import Backend.Model exposing (ModelIndexedDb) import Backend.Nurse.Model exposing (Nurse) import Backend.ResilienceMessage.Model exposing (ResilienceMessage) import Backend.ResilienceMessage.Utils exposing (emptyMessagesDict, generateEmptyMessagesByProgramStartDate) -import Backend.ResilienceSurvey.Model exposing (ResilienceSurveyQuestion(..), ResilienceSurveyType(..)) +import Backend.ResilienceSurvey.Model exposing (ResilienceSurveyQuestion(..), ResilienceSurveyQuestionOption(..), ResilienceSurveyType(..)) import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) import Pages.MessagingCenter.Model exposing (SurveyForm, SurveyScoreDialogState(..)) @@ -116,14 +116,39 @@ resolveSurveyScoreDialogState nurseId surveyType score db = ResilienceSurveyAdoption -> let - -- Ordered from first to last. - -- Also, making sure we don't include current survey score - -- and there are up to 2 surveys (which should be the case, - -- as there can be up to 3 surveys filled, but verification is - -- required nevertheless). + surveys = + Dict.get nurseId db.resilienceSurveysByNurse + |> Maybe.andThen RemoteData.toMaybe + |> Maybe.map Dict.values + |> Maybe.withDefault [] + + adoptionSurveys = + List.filter (\survey -> survey.surveyType == ResilienceSurveyAdoption) surveys + + sortedSurveys = + List.sortWith (\survey1 survey2 -> Date.compare survey1.dateMeasured survey2.dateMeasured) adoptionSurveys + + toScore answer = + case answer of + ResilienceSurveyQuestionOption0 -> + 1 + + ResilienceSurveyQuestionOption1 -> + 2 + + ResilienceSurveyQuestionOption2 -> + 3 + + ResilienceSurveyQuestionOption3 -> + 4 + + ResilienceSurveyQuestionOption4 -> + 5 + previousSurveysScores = - -- @todo - [] + sortedSurveys + |> List.map (\survey -> survey.signs |> Dict.values |> List.map toScore |> List.sum) + |> List.take 2 in previousSurveysScores ++ [ score ] diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index fa25a884cb..31c27a9b15 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -142,7 +142,7 @@ view language currentTime nurseId nurse db model = [ header , content , viewModal <| - surveyScoreDialog language nurseId db model.surveyScoreDialogState + surveyScoreDialog language model.surveyScoreDialogState ] @@ -369,67 +369,12 @@ viewAdoptionSurvey language currentDate nurseId form = surveyScoreDialog : Language - -> NurseId - -> ModelIndexedDb -> Maybe SurveyScoreDialogState -> Maybe (Html Msg) -surveyScoreDialog language nurseId db = +surveyScoreDialog language = Maybe.map (\dialogState -> let - getScore answer = - case answer of - ResilienceSurveyQuestionOption0 -> - 1 - - ResilienceSurveyQuestionOption1 -> - 2 - - ResilienceSurveyQuestionOption2 -> - 3 - - ResilienceSurveyQuestionOption3 -> - 4 - - ResilienceSurveyQuestionOption4 -> - 5 - - surveys = - Dict.get nurseId db.resilienceSurveysByNurse - |> Maybe.andThen RemoteData.toMaybe - |> Maybe.map Dict.values - |> Maybe.withDefault [] - - adoptionSurveys = - List.filter (\survey -> survey.surveyType == ResilienceSurveyAdoption) surveys - - sortedSurveys = - List.sortWith (\survey1 survey2 -> Date.compare survey1.dateMeasured survey2.dateMeasured) adoptionSurveys - - survey1Score = - case List.head sortedSurveys of - Just survey -> - Dict.values survey.signs - |> List.map getScore - |> List.sum - - Nothing -> - 0 - - survey2Score = - case List.drop 1 sortedSurveys |> List.head of - Just survey -> - Dict.values survey.signs - |> List.map getScore - |> List.sum - - Nothing -> - 0 - - adoptionSurveyCount = - List.filter (\survey -> survey.surveyType == ResilienceSurveyAdoption) surveys - |> List.length - ( scoreText, interpretationFunction, additionalMessage ) = case dialogState of QuarterlySurveyScore score -> @@ -439,48 +384,45 @@ surveyScoreDialog language nurseId db = ) AdoptionSurveyScore scores -> - -- @todo : delete - -- let - -- message = - -- if adoptionSurveyCount == 2 then - -- if score > survey1Score then - -- Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] - -- - -- else if score < survey1Score then - -- Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] - -- - -- else - -- Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] - -- - -- else if adoptionSurveyCount == 3 then - -- Just <| - -- ul [ class "summary" ] - -- [ li [] [ text (translate language (Translate.AdoptionSurveyBaselineScore survey1Score)) ] - -- , li [] [ text (translate language (Translate.AdoptionSurvey3MonthScore survey2Score)) ] - -- ] - -- - -- else - -- Nothing - -- in - -- ( String.fromInt score ++ "/60" - -- , Translate.AdoptionSurveyScoreInterpretation score - -- , message - -- ) case scores of [ first ] -> - -- @todo - ( "", Translate.EmptyString, Nothing ) + ( String.fromInt first ++ "/60" + , Translate.AdoptionSurveyScoreInterpretation first + , Nothing + ) [ first, second ] -> - -- @todo - ( "", Translate.EmptyString, Nothing ) + let + message = + if first < second then + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] + + else if first > second then + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] + + else + Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] + in + ( String.fromInt second ++ "/60" + , Translate.AdoptionSurveyScoreInterpretation second + , message + ) [ first, second, third ] -> - -- @todo - ( "", Translate.EmptyString, Nothing ) + let + message = + Just <| + ul [ class "summary" ] + [ li [] [ text (translate language (Translate.AdoptionSurveyBaselineScore first)) ] + , li [] [ text (translate language (Translate.AdoptionSurvey3MonthScore second)) ] + ] + in + ( String.fromInt third ++ "/60" + , Translate.AdoptionSurveyScoreInterpretation third + , message + ) _ -> - -- We shold never get here. ( "", Translate.EmptyString, Nothing ) topMessage = @@ -495,7 +437,7 @@ surveyScoreDialog language nurseId db = msg Nothing -> - emptyNode + text "" dialogContent = div [] From 7134630871bc3183f5cbb096f4713b366346030e Mon Sep 17 00:00:00 2001 From: Diama1 Date: Mon, 15 Jul 2024 21:00:46 +0200 Subject: [PATCH 44/63] fix --- client/src/assets/scss/_custom.scss | 9 ++++----- client/src/elm/Translate.elm | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/assets/scss/_custom.scss b/client/src/assets/scss/_custom.scss index 5ca7116c7c..079a287654 100644 --- a/client/src/assets/scss/_custom.scss +++ b/client/src/assets/scss/_custom.scss @@ -1392,11 +1392,6 @@ input::placeholder { text-align: center; text-transform: uppercase; - .summary { - text-align: left; - font-size: 25px; - } - .message { display: flex; position: relative; @@ -1409,6 +1404,10 @@ input::placeholder { right: 0; } } + .summary { + text-align: left; + font-size: 25px; + } } .popup-action { diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 7c69e9d567..e43ad2a975 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -3021,12 +3021,12 @@ translationSet trans = AdoptionSurveyProgressImproving -> { english = "Congratulations; you've improved." - , kinyarwanda = Just "Wabikoze neza, Komereza aho," + , kinyarwanda = Just "Wabikoze neza, Komereza aho." , kirundi = Nothing } AdoptionSurveyProgressNotImproving -> - { english = "You slid back compared to your last performance" + { english = "You slid back compared to your last performance." , kinyarwanda = Just "Wasubiye inyuma ugereranyije n'ubushize." , kirundi = Nothing } From 077e6b4095d4c5337bd110e2c4c71987edfe3971 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Mon, 15 Jul 2024 21:16:27 +0200 Subject: [PATCH 45/63] fix --- client/src/assets/scss/_new.scss | 2 +- client/src/elm/App/Fetch.elm | 2 +- client/src/elm/App/View.elm | 15 +++------------ .../{GuideMessage => MessagingGuide}/View.elm | 8 ++++---- client/src/elm/Pages/Page.elm | 2 +- client/src/elm/Pages/Router.elm | 6 +++--- client/src/elm/Pages/Wellbeing/View.elm | 2 +- client/src/elm/Translate.elm | 2 +- 8 files changed, 15 insertions(+), 24 deletions(-) rename client/src/elm/Pages/{GuideMessage => MessagingGuide}/View.elm (93%) diff --git a/client/src/assets/scss/_new.scss b/client/src/assets/scss/_new.scss index 045ae4974e..a31aa4c103 100644 --- a/client/src/assets/scss/_new.scss +++ b/client/src/assets/scss/_new.scss @@ -4879,7 +4879,7 @@ div.page-activity.wellbeing { } } -div.page-activity.guideMessage { +div.page-activity.messaging-guide { height: auto; .guide { diff --git a/client/src/elm/App/Fetch.elm b/client/src/elm/App/Fetch.elm index 76c5589c86..183b5f10dc 100644 --- a/client/src/elm/App/Fetch.elm +++ b/client/src/elm/App/Fetch.elm @@ -466,7 +466,7 @@ fetch model = ) |> Maybe.withDefault [] - UserPage GuideMessagePage -> + UserPage MessagingGuide -> getLoggedInData model |> Maybe.map (\( _, loggedIn ) -> diff --git a/client/src/elm/App/View.elm b/client/src/elm/App/View.elm index 31942ac485..78c13a0c5c 100644 --- a/client/src/elm/App/View.elm +++ b/client/src/elm/App/View.elm @@ -42,7 +42,6 @@ import Pages.EducationSession.Model import Pages.EducationSession.View import Pages.GlobalCaseManagement.View import Pages.GroupEncounterTypes.View -import Pages.GuideMessage.View import Pages.HIV.Activity.Model import Pages.HIV.Activity.View import Pages.HIV.Encounter.Model @@ -56,6 +55,7 @@ import Pages.IndividualEncounterParticipants.View import Pages.IndividualEncounterTypes.View import Pages.MessagingCenter.Model import Pages.MessagingCenter.View +import Pages.MessagingGuide.View import Pages.MyAccount.View import Pages.NCD.Activity.Model import Pages.NCD.Activity.View @@ -1086,21 +1086,12 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur |> Html.map (MsgLoggedIn << MsgPageMessagingCenter nurseId) |> flexPageWrapper configured.config model - GuideMessagePage -> + MessagingGuide -> let ( nurseId, nurse ) = loggedInModel.nurse - - page_ = - Dict.get nurseId loggedInModel.messagingCenterPages - |> Maybe.withDefault Pages.MessagingCenter.Model.emptyModel in - Pages.GuideMessage.View.view model.language - model.currentTime - nurseId - nurse - model.indexedDb - page_ + Pages.MessagingGuide.View.view model.language |> Html.map (MsgLoggedIn << MsgPageMessagingCenter nurseId) |> flexPageWrapper configured.config model diff --git a/client/src/elm/Pages/GuideMessage/View.elm b/client/src/elm/Pages/MessagingGuide/View.elm similarity index 93% rename from client/src/elm/Pages/GuideMessage/View.elm rename to client/src/elm/Pages/MessagingGuide/View.elm index c94c3cec42..321fa0b5c5 100644 --- a/client/src/elm/Pages/GuideMessage/View.elm +++ b/client/src/elm/Pages/MessagingGuide/View.elm @@ -1,4 +1,4 @@ -module Pages.GuideMessage.View exposing (..) +module Pages.MessagingGuide.View exposing (..) import Backend.Entities exposing (..) import Backend.Model exposing (ModelIndexedDb) @@ -14,8 +14,8 @@ import Time import Translate exposing (Language, translate, translateText) -view : Language -> Time.Posix -> NurseId -> Nurse -> ModelIndexedDb -> Model -> Html Msg -view language currentTime nurseId nurse db model = +view : Language -> Html Msg +view language = let header = div [ class "ui basic head segment" ] @@ -29,7 +29,7 @@ view language currentTime nurseId nurse db model = [ span [ class "icon-back" ] [] ] ] in - div [ class "page-activity guideMessage" ] + div [ class "page-activity messaging-guide" ] [ header , viewGuide language ] diff --git a/client/src/elm/Pages/Page.elm b/client/src/elm/Pages/Page.elm index 029f175351..2d15373f43 100644 --- a/client/src/elm/Pages/Page.elm +++ b/client/src/elm/Pages/Page.elm @@ -204,7 +204,7 @@ type UserPage | PatientRecordPage PatientRecordInitiator PersonId | MessagingCenterPage | WellbeingPage - | GuideMessagePage + | MessagingGuide | StockManagementPage diff --git a/client/src/elm/Pages/Router.elm b/client/src/elm/Pages/Router.elm index 074e206124..0d9a2bee46 100644 --- a/client/src/elm/Pages/Router.elm +++ b/client/src/elm/Pages/Router.elm @@ -379,8 +379,8 @@ pageToFragment current = WellbeingPage -> Just "wellbeing" - GuideMessagePage -> - Just "guide" + MessagingGuide -> + Just "messaging-guide" StockManagementPage -> Just "stock-management" @@ -453,7 +453,7 @@ parser = , map (\id initiator -> UserPage <| PatientRecordPage initiator id) (s "patient-record" parseUuid parsePatientRecordInitiator) , map (UserPage MessagingCenterPage) (s "messaging-center") , map (UserPage WellbeingPage) (s "wellbeing") - , map (UserPage GuideMessagePage) (s "guide") + , map (UserPage MessagingGuide) (s "messaging-guide") , map (UserPage StockManagementPage) (s "stock-management") -- `top` represents the page without any segements ... i.e. the root page. diff --git a/client/src/elm/Pages/Wellbeing/View.elm b/client/src/elm/Pages/Wellbeing/View.elm index 00ea003ac0..f614864e7e 100644 --- a/client/src/elm/Pages/Wellbeing/View.elm +++ b/client/src/elm/Pages/Wellbeing/View.elm @@ -47,7 +47,7 @@ view language currentTime nurseId nurse db model = guideMessageButton = button [ class "ui primary button" - , onClick <| SetActivePage <| UserPage GuideMessagePage + , onClick <| SetActivePage <| UserPage MessagingGuide ] [ span [ class "text" ] [ text <| translate language Translate.GuideMessage ] ] diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 476f9affd7..017ab62a56 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -24094,7 +24094,7 @@ translateActivePage page = , kirundi = Just "Igihande c'ubutumwa" } - GuideMessagePage -> + MessagingGuide -> translationSet GuideMessage WellbeingPage -> From 5962a098bc03e3d60b1779ad51543ab4eced9f9b Mon Sep 17 00:00:00 2001 From: Diama1 Date: Tue, 16 Jul 2024 10:50:24 +0200 Subject: [PATCH 46/63] fix --- client/src/elm/App/Fetch.elm | 12 +----------- client/src/elm/App/View.elm | 5 ----- client/src/elm/Pages/MessagingGuide/View.elm | 14 ++++---------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/client/src/elm/App/Fetch.elm b/client/src/elm/App/Fetch.elm index 183b5f10dc..d8557cdf51 100644 --- a/client/src/elm/App/Fetch.elm +++ b/client/src/elm/App/Fetch.elm @@ -467,17 +467,7 @@ fetch model = |> Maybe.withDefault [] UserPage MessagingGuide -> - getLoggedInData model - |> Maybe.map - (\( _, loggedIn ) -> - let - nurseId = - Tuple.first loggedIn.nurse - in - Pages.MessagingCenter.Fetch.fetch currentDate nurseId model.indexedDb - |> List.map MsgIndexedDb - ) - |> Maybe.withDefault [] + [] UserPage StockManagementPage -> getLoggedInData model diff --git a/client/src/elm/App/View.elm b/client/src/elm/App/View.elm index 78c13a0c5c..37ff1a8d43 100644 --- a/client/src/elm/App/View.elm +++ b/client/src/elm/App/View.elm @@ -1087,12 +1087,7 @@ viewUserPage page deviceName site features geoInfo reverseGeoInfo model configur |> flexPageWrapper configured.config model MessagingGuide -> - let - ( nurseId, nurse ) = - loggedInModel.nurse - in Pages.MessagingGuide.View.view model.language - |> Html.map (MsgLoggedIn << MsgPageMessagingCenter nurseId) |> flexPageWrapper configured.config model StockManagementPage -> diff --git a/client/src/elm/Pages/MessagingGuide/View.elm b/client/src/elm/Pages/MessagingGuide/View.elm index 321fa0b5c5..b64727cf5d 100644 --- a/client/src/elm/Pages/MessagingGuide/View.elm +++ b/client/src/elm/Pages/MessagingGuide/View.elm @@ -1,20 +1,14 @@ module Pages.MessagingGuide.View exposing (..) -import Backend.Entities exposing (..) -import Backend.Model exposing (ModelIndexedDb) -import Backend.Nurse.Model exposing (Nurse) -import Gizra.NominalDate exposing (fromLocalDateTime) +import App.Model exposing (Msg(..)) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (onClick) -import Pages.MessagingCenter.Model exposing (..) -import Pages.MessagingCenter.Utils exposing (..) import Pages.Page exposing (Page(..), UserPage(..)) -import Time import Translate exposing (Language, translate, translateText) -view : Language -> Html Msg +view : Language -> Html App.Model.Msg view language = let header = @@ -24,7 +18,7 @@ view language = ] , span [ class "link-back" - , onClick <| SetActivePage <| UserPage WellbeingPage + , onClick <| App.Model.SetActivePage <| UserPage WellbeingPage ] [ span [ class "icon-back" ] [] ] ] @@ -35,7 +29,7 @@ view language = ] -viewGuide : Language -> Html Msg +viewGuide : Language -> Html App.Model.Msg viewGuide language = div [ class "guide" ] [ p [ class "title" ] [ text <| translate language Translate.ResilienceGuideSection1Title ] From c316e2057ff7c3a6fe15d362d1fcab7f2a7699ba Mon Sep 17 00:00:00 2001 From: Diama1 Date: Tue, 16 Jul 2024 15:38:41 +0200 Subject: [PATCH 47/63] fix the code --- .../src/elm/Pages/MessagingCenter/Update.elm | 29 +-------- .../src/elm/Pages/MessagingCenter/Utils.elm | 60 ++++++++++++------- client/src/elm/Pages/MessagingCenter/View.elm | 47 +++++++-------- 3 files changed, 62 insertions(+), 74 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index e82adb1e02..fadbc7e115 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -19,13 +19,7 @@ import EverySet import Gizra.NominalDate exposing (NominalDate) import Gizra.Update exposing (sequenceExtra) import Pages.MessagingCenter.Model exposing (..) -import Pages.MessagingCenter.Utils - exposing - ( adoptionSurveyQuestions - , quarterlySurveyQuestions - , resolveSurveyScoreDialogState - , surveyQuestionsAnswered - ) +import Pages.MessagingCenter.Utils exposing (resolveSurveyScoreDialogState, surveyQuestionsAnswered, toScore) import Time import Time.Extra @@ -188,31 +182,14 @@ update currentTime currentDate db msg model = surveyScore = Dict.values model.surveyForm - |> List.map - (\answer -> - case answer of - ResilienceSurveyQuestionOption0 -> - 1 - - ResilienceSurveyQuestionOption1 -> - 2 - - ResilienceSurveyQuestionOption2 -> - 3 - - ResilienceSurveyQuestionOption3 -> - 4 - - ResilienceSurveyQuestionOption4 -> - 5 - ) + |> List.map toScore |> List.sum in ( [ Backend.ResilienceSurvey.Model.CreateResilienceSurvey survey |> Backend.Model.MsgResilienceSurvey nurseId |> App.Model.MsgIndexedDb ] - , [ resolveSurveyScoreDialogState nurseId surveyType surveyScore db + , [ resolveSurveyScoreDialogState currentDate nurseId surveyType surveyScore db |> Just |> SetSurveyScoreDialogState ] diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index a3be541333..3a038da3be 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -12,6 +12,7 @@ import Gizra.NominalDate exposing (NominalDate) import Pages.MessagingCenter.Model exposing (SurveyForm, SurveyScoreDialogState(..)) import RemoteData import Time exposing (posixToMillis) +import Utils.NominalDate exposing (sortByDate) quarterlySurveyQuestions : List ResilienceSurveyQuestion @@ -40,6 +41,25 @@ adoptionSurveyQuestions = ] +toScore : ResilienceSurveyQuestionOption -> Int +toScore answer = + case answer of + ResilienceSurveyQuestionOption0 -> + 1 + + ResilienceSurveyQuestionOption1 -> + 2 + + ResilienceSurveyQuestionOption2 -> + 3 + + ResilienceSurveyQuestionOption3 -> + 4 + + ResilienceSurveyQuestionOption4 -> + 5 + + generateInboxMessages : NominalDate -> NominalDate -> Dict String ResilienceMessage -> Dict String ResilienceMessage generateInboxMessages currentDate programStartDate recordedMessage = generateEmptyMessagesByProgramStartDate currentDate programStartDate @@ -108,8 +128,8 @@ surveyQuestionsAnswered surveyType surveyForm = Dict.size surveyForm == List.length surveyQuestions -resolveSurveyScoreDialogState : NurseId -> ResilienceSurveyType -> Int -> ModelIndexedDb -> SurveyScoreDialogState -resolveSurveyScoreDialogState nurseId surveyType score db = +resolveSurveyScoreDialogState : NominalDate -> NurseId -> ResilienceSurveyType -> Int -> ModelIndexedDb -> SurveyScoreDialogState +resolveSurveyScoreDialogState currentDate nurseId surveyType score db = case surveyType of ResilienceSurveyQuarterly -> QuarterlySurveyScore score @@ -121,34 +141,28 @@ resolveSurveyScoreDialogState nurseId surveyType score db = |> Maybe.andThen RemoteData.toMaybe |> Maybe.map Dict.values |> Maybe.withDefault [] + |> List.filter (\survey -> survey.dateMeasured /= currentDate) + |> List.filter (.surveyType >> (==) ResilienceSurveyAdoption) - adoptionSurveys = - List.filter (\survey -> survey.surveyType == ResilienceSurveyAdoption) surveys - - sortedSurveys = - List.sortWith (\survey1 survey2 -> Date.compare survey1.dateMeasured survey2.dateMeasured) adoptionSurveys + uniqueSurveys = + List.foldl + (\survey acc -> + if List.any (\s -> s.dateMeasured == survey.dateMeasured) acc then + acc - toScore answer = - case answer of - ResilienceSurveyQuestionOption0 -> - 1 - - ResilienceSurveyQuestionOption1 -> - 2 - - ResilienceSurveyQuestionOption2 -> - 3 - - ResilienceSurveyQuestionOption3 -> - 4 + else + survey :: acc + ) + [] + surveys - ResilienceSurveyQuestionOption4 -> - 5 + sortedSurveys = + List.sortWith (sortByDate .dateMeasured) uniqueSurveys previousSurveysScores = sortedSurveys - |> List.map (\survey -> survey.signs |> Dict.values |> List.map toScore |> List.sum) |> List.take 2 + |> List.map (\survey -> survey.signs |> Dict.values |> List.map toScore |> List.sum) in previousSurveysScores ++ [ score ] diff --git a/client/src/elm/Pages/MessagingCenter/View.elm b/client/src/elm/Pages/MessagingCenter/View.elm index 31c27a9b15..27a253652c 100644 --- a/client/src/elm/Pages/MessagingCenter/View.elm +++ b/client/src/elm/Pages/MessagingCenter/View.elm @@ -393,19 +393,19 @@ surveyScoreDialog language = [ first, second ] -> let - message = + messageContent = if first < second then - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] + [ text (translate language <| Translate.AdoptionSurveyProgressImproving), span [ class "icon-up" ] [] ] else if first > second then - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] + [ text (translate language <| Translate.AdoptionSurveyProgressNotImproving), span [ class "icon-down" ] [] ] else - Just <| p [ class "message" ] [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] + [ text (translate language <| Translate.AdoptionSurveyProgressSame) ] in ( String.fromInt second ++ "/60" , Translate.AdoptionSurveyScoreInterpretation second - , message + , Just <| p [ class "message" ] messageContent ) [ first, second, third ] -> @@ -425,29 +425,26 @@ surveyScoreDialog language = _ -> ( "", Translate.EmptyString, Nothing ) - topMessage = - p [ class "score" ] [ text scoreText ] - bottomMessage = - p [ class "interpretation" ] [ text <| translate language <| interpretationFunction ] - - additionalMessageElement = - case additionalMessage of - Just msg -> - msg - - Nothing -> - text "" - - dialogContent = - div [] - [ topMessage - , bottomMessage - , additionalMessageElement - ] + let + interpretation = + p [ class "interpretation" ] [ text <| translate language <| interpretationFunction ] + in + Maybe.map + (\message -> + div [] + [ interpretation + , message + ] + ) + additionalMessage + |> Maybe.withDefault interpretation dialogData = - ( dialogContent, div [] [], SetSurveyScoreDialogState Nothing ) + ( p [ class "score" ] [ text scoreText ] + , bottomMessage + , SetSurveyScoreDialogState Nothing + ) in customPopup language False Translate.Continue "survey-score-popup blue" dialogData ) From e6c7aebd69ce8e0acf1910d62cb6939016d520ab Mon Sep 17 00:00:00 2001 From: Diama1 Date: Wed, 17 Jul 2024 11:12:09 +0200 Subject: [PATCH 48/63] fix --- .../src/elm/Pages/MessagingCenter/Update.elm | 4 +-- .../src/elm/Pages/MessagingCenter/Utils.elm | 30 ++++++++----------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index fadbc7e115..6bb718eec2 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -19,7 +19,7 @@ import EverySet import Gizra.NominalDate exposing (NominalDate) import Gizra.Update exposing (sequenceExtra) import Pages.MessagingCenter.Model exposing (..) -import Pages.MessagingCenter.Utils exposing (resolveSurveyScoreDialogState, surveyQuestionsAnswered, toScore) +import Pages.MessagingCenter.Utils exposing (resolveSurveyScoreDialogState, surveyAnswersToScore, surveyQuestionsAnswered) import Time import Time.Extra @@ -182,7 +182,7 @@ update currentTime currentDate db msg model = surveyScore = Dict.values model.surveyForm - |> List.map toScore + |> List.map surveyAnswersToScore |> List.sum in ( [ Backend.ResilienceSurvey.Model.CreateResilienceSurvey survey diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 3a038da3be..4c26323080 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -7,7 +7,6 @@ import Backend.Nurse.Model exposing (Nurse) import Backend.ResilienceMessage.Model exposing (ResilienceMessage) import Backend.ResilienceMessage.Utils exposing (emptyMessagesDict, generateEmptyMessagesByProgramStartDate) import Backend.ResilienceSurvey.Model exposing (ResilienceSurveyQuestion(..), ResilienceSurveyQuestionOption(..), ResilienceSurveyType(..)) -import Date exposing (Unit(..)) import Gizra.NominalDate exposing (NominalDate) import Pages.MessagingCenter.Model exposing (SurveyForm, SurveyScoreDialogState(..)) import RemoteData @@ -41,8 +40,8 @@ adoptionSurveyQuestions = ] -toScore : ResilienceSurveyQuestionOption -> Int -toScore answer = +surveyAnswersToScore : ResilienceSurveyQuestionOption -> Int +surveyAnswersToScore answer = case answer of ResilienceSurveyQuestionOption0 -> 1 @@ -140,29 +139,24 @@ resolveSurveyScoreDialogState currentDate nurseId surveyType score db = Dict.get nurseId db.resilienceSurveysByNurse |> Maybe.andThen RemoteData.toMaybe |> Maybe.map Dict.values + -- Filter out surveys created today (currentDate) as they may not be fully processed yet. + -- This ensures that the survey just saved doesn't cause duplicates in the dialog. + |> Maybe.map (List.filter (\survey -> survey.dateMeasured /= currentDate && survey.surveyType == ResilienceSurveyAdoption)) |> Maybe.withDefault [] - |> List.filter (\survey -> survey.dateMeasured /= currentDate) - |> List.filter (.surveyType >> (==) ResilienceSurveyAdoption) - uniqueSurveys = + uniqueSortedSurveys = List.foldl (\survey acc -> - if List.any (\s -> s.dateMeasured == survey.dateMeasured) acc then - acc - - else - survey :: acc + Dict.insert survey.dateMeasured survey acc ) - [] + Dict.empty surveys - - sortedSurveys = - List.sortWith (sortByDate .dateMeasured) uniqueSurveys + |> Dict.values + |> List.sortWith (sortByDate .dateMeasured) previousSurveysScores = - sortedSurveys - |> List.take 2 - |> List.map (\survey -> survey.signs |> Dict.values |> List.map toScore |> List.sum) + List.take 2 uniqueSortedSurveys + |> List.map (.signs >> Dict.values >> List.map surveyAnswersToScore >> List.sum) in previousSurveysScores ++ [ score ] From 3ebfc265468be8189d3636759349c3cfa91c0121 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Wed, 17 Jul 2024 14:09:58 +0200 Subject: [PATCH 49/63] fix --- client/src/elm/Pages/MessagingCenter/Update.elm | 4 ++-- client/src/elm/Pages/MessagingCenter/Utils.elm | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Update.elm b/client/src/elm/Pages/MessagingCenter/Update.elm index 6bb718eec2..371ca88108 100644 --- a/client/src/elm/Pages/MessagingCenter/Update.elm +++ b/client/src/elm/Pages/MessagingCenter/Update.elm @@ -19,7 +19,7 @@ import EverySet import Gizra.NominalDate exposing (NominalDate) import Gizra.Update exposing (sequenceExtra) import Pages.MessagingCenter.Model exposing (..) -import Pages.MessagingCenter.Utils exposing (resolveSurveyScoreDialogState, surveyAnswersToScore, surveyQuestionsAnswered) +import Pages.MessagingCenter.Utils exposing (resolveSurveyScoreDialogState, surveyAnswerToScore, surveyQuestionsAnswered) import Time import Time.Extra @@ -182,7 +182,7 @@ update currentTime currentDate db msg model = surveyScore = Dict.values model.surveyForm - |> List.map surveyAnswersToScore + |> List.map surveyAnswerToScore |> List.sum in ( [ Backend.ResilienceSurvey.Model.CreateResilienceSurvey survey diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 4c26323080..72d0f46dc4 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -40,8 +40,8 @@ adoptionSurveyQuestions = ] -surveyAnswersToScore : ResilienceSurveyQuestionOption -> Int -surveyAnswersToScore answer = +surveyAnswerToScore : ResilienceSurveyQuestionOption -> Int +surveyAnswerToScore answer = case answer of ResilienceSurveyQuestionOption0 -> 1 @@ -138,10 +138,9 @@ resolveSurveyScoreDialogState currentDate nurseId surveyType score db = surveys = Dict.get nurseId db.resilienceSurveysByNurse |> Maybe.andThen RemoteData.toMaybe - |> Maybe.map Dict.values -- Filter out surveys created today (currentDate) as they may not be fully processed yet. -- This ensures that the survey just saved doesn't cause duplicates in the dialog. - |> Maybe.map (List.filter (\survey -> survey.dateMeasured /= currentDate && survey.surveyType == ResilienceSurveyAdoption)) + |> Maybe.map (Dict.values >> List.filter (\survey -> survey.dateMeasured /= currentDate && survey.surveyType == ResilienceSurveyAdoption)) |> Maybe.withDefault [] uniqueSortedSurveys = @@ -156,7 +155,7 @@ resolveSurveyScoreDialogState currentDate nurseId surveyType score db = previousSurveysScores = List.take 2 uniqueSortedSurveys - |> List.map (.signs >> Dict.values >> List.map surveyAnswersToScore >> List.sum) + |> List.map (.signs >> Dict.values >> List.map surveyAnswerToScore >> List.sum) in previousSurveysScores ++ [ score ] From 0bf6c9c6ce43d05d865b34d27f9424253586f4f2 Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 17 Jul 2024 16:36:57 +0300 Subject: [PATCH 50/63] Format code + comments[ci skip] --- client/src/elm/Pages/MessagingCenter/Utils.elm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 72d0f46dc4..47399bef4b 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -140,7 +140,14 @@ resolveSurveyScoreDialogState currentDate nurseId surveyType score db = |> Maybe.andThen RemoteData.toMaybe -- Filter out surveys created today (currentDate) as they may not be fully processed yet. -- This ensures that the survey just saved doesn't cause duplicates in the dialog. - |> Maybe.map (Dict.values >> List.filter (\survey -> survey.dateMeasured /= currentDate && survey.surveyType == ResilienceSurveyAdoption)) + |> Maybe.map + (Dict.values + >> List.filter + (\survey -> + (survey.dateMeasured /= currentDate) + && (survey.surveyType == ResilienceSurveyAdoption) + ) + ) |> Maybe.withDefault [] uniqueSortedSurveys = From 9f62aeb4bda28a4d2c5c1363616f62ab5db0024a Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 17 Jul 2024 16:44:39 +0300 Subject: [PATCH 51/63] Fix comments [ci skip] --- client/src/elm/Pages/MessagingCenter/Utils.elm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/elm/Pages/MessagingCenter/Utils.elm b/client/src/elm/Pages/MessagingCenter/Utils.elm index 47399bef4b..145a7dcc11 100644 --- a/client/src/elm/Pages/MessagingCenter/Utils.elm +++ b/client/src/elm/Pages/MessagingCenter/Utils.elm @@ -138,8 +138,10 @@ resolveSurveyScoreDialogState currentDate nurseId surveyType score db = surveys = Dict.get nurseId db.resilienceSurveysByNurse |> Maybe.andThen RemoteData.toMaybe - -- Filter out surveys created today (currentDate) as they may not be fully processed yet. - -- This ensures that the survey just saved doesn't cause duplicates in the dialog. + -- This command is executed when new survey is saved. + -- After save is completed, new survey will appear at db.resilienceSurveysByNurse. + -- We can't be sure if it's there, when we display the dialog. + -- Therefore, we filter out a survey, if it was created today. |> Maybe.map (Dict.values >> List.filter @@ -151,6 +153,9 @@ resolveSurveyScoreDialogState currentDate nurseId surveyType score db = |> Maybe.withDefault [] uniqueSortedSurveys = + -- In our system, sometimes we see that measurements are saved more than once. + -- Therefore, we make sure taht take surveys we take got a unique dateMeasured. + -- Use List.foldl. List.foldl (\survey acc -> Dict.insert survey.dateMeasured survey acc From 811c7ec4389a47f3dc44eb79e4b326611a7200ca Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 21 Jul 2024 11:00:18 +0300 Subject: [PATCH 52/63] WIP [ci skip] --- client/src/elm/Backend/Update.elm | 14 +++++++------- .../src/elm/Pages/Tuberculosis/Encounter/Utils.elm | 6 ++++++ .../src/elm/Pages/Tuberculosis/Encounter/View.elm | 10 ++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/src/elm/Backend/Update.elm b/client/src/elm/Backend/Update.elm index b353b40c5d..fd6d05f7eb 100644 --- a/client/src/elm/Backend/Update.elm +++ b/client/src/elm/Backend/Update.elm @@ -2048,7 +2048,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h in ( newModel, extraMsgs ) - processVitalsRevisionAndUpdateLabsResults participantId encounterId value = + processVitalsRevisionAndUpdatePrenatalLabsResults participantId encounterId value = if downloadingContent then ( model, [] ) @@ -2126,7 +2126,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h in ( newModel, extraMsgs ) - processRevisionPossiblyCompletingRecurrentPhase participantId encounterId = + processPrenatalRevisionPossiblyCompletingRecurrentPhase participantId encounterId = if downloadingContent then ( model, [] ) @@ -2789,7 +2789,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h -- it's handled by `processRevisionAndAssessPrenatal` -- activation that comes bellow. ( _, extraMsgsForLabsResults ) = - processVitalsRevisionAndUpdateLabsResults + processVitalsRevisionAndUpdatePrenatalLabsResults data.participantId data.encounterId data.value @@ -2805,7 +2805,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h [ MalariaPreventionRevision _ data ] -> let ( newModel, extraMsgs ) = - processRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId + processPrenatalRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId in ( newModel , Cmd.none @@ -2815,7 +2815,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h [ PrenatalHealthEducationRevision _ data ] -> let ( newModel, extraMsgs ) = - processRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId + processPrenatalRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId in ( newModel , Cmd.none @@ -2825,7 +2825,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h [ PrenatalSendToHCRevision _ data ] -> let ( newModel, extraMsgs ) = - processRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId + processPrenatalRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId in ( newModel , Cmd.none @@ -2835,7 +2835,7 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h [ PrenatalMedicationDistributionRevision _ data ] -> let ( newModel, extraMsgs ) = - processRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId + processPrenatalRevisionPossiblyCompletingRecurrentPhase data.participantId data.encounterId in ( newModel , Cmd.none diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm b/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm index a0e9a8a197..5e56245d34 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm @@ -100,3 +100,9 @@ generatePreviousEncountersData currentEncounterId participantId db = ) -- Most recent date to least recent date. |> List.sortWith sortByStartDateDesc + + +partitionActivities : NominalDate -> AssembledData -> ( List TuberculosisActivity, List TuberculosisActivity ) +partitionActivities currentDate assembled = + List.filter (expectActivity currentDate assembled) allActivities + |> List.partition (activityCompleted currentDate assembled) diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/View.elm b/client/src/elm/Pages/Tuberculosis/Encounter/View.elm index 2df237926e..5e827f6fd3 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/View.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/View.elm @@ -1,4 +1,4 @@ -module Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter, partitionActivities, view) +module Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter, view) import Backend.Entities exposing (..) import Backend.IndividualEncounterParticipant.Model @@ -14,7 +14,7 @@ import Html.Events exposing (..) import Pages.Page exposing (Page(..), UserPage(..)) import Pages.Tuberculosis.Activity.Utils exposing (activityCompleted, expectActivity) import Pages.Tuberculosis.Encounter.Model exposing (..) -import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData) +import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData, partitionActivities) import Pages.Utils exposing ( viewEndEncounterButton @@ -169,12 +169,6 @@ viewMainPageContent language currentDate db assembled model = ] -partitionActivities : NominalDate -> AssembledData -> ( List TuberculosisActivity, List TuberculosisActivity ) -partitionActivities currentDate assembled = - List.filter (expectActivity currentDate assembled) allActivities - |> List.partition (activityCompleted currentDate assembled) - - allowEndingEncounter : List TuberculosisActivity -> Bool allowEndingEncounter pendingActivities = List.isEmpty pendingActivities From 2aa08cc94baef3f09c0262885286e0c406fac845 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 21 Jul 2024 11:38:09 +0300 Subject: [PATCH 53/63] Apply logic --- client/src/elm/Backend/Update.elm | 113 ++++++++++++++++++ .../Pages/Tuberculosis/Encounter/Utils.elm | 3 + .../Tuberculosis/ProgressReport/View.elm | 4 +- 3 files changed, 118 insertions(+), 2 deletions(-) diff --git a/client/src/elm/Backend/Update.elm b/client/src/elm/Backend/Update.elm index fd6d05f7eb..7eb9f92155 100644 --- a/client/src/elm/Backend/Update.elm +++ b/client/src/elm/Backend/Update.elm @@ -137,6 +137,7 @@ import Pages.Prenatal.RecurrentEncounter.Utils import Pages.Prenatal.Utils import Pages.Relationship.Model import Pages.Session.Model +import Pages.Tuberculosis.Encounter.Utils import Pages.WellChild.Activity.Utils import Pages.WellChild.Encounter.Model import Pages.WellChild.Encounter.Utils @@ -2345,6 +2346,25 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h ) encounterId |> Maybe.withDefault [] + + processTuberculosisRevisionAndNavigateToProgressReport encounterId = + if downloadingContent then + ( model, [] ) + + else + let + ( newModel, _ ) = + List.foldl (handleRevision currentDate healthCenterId villageId) ( model, False ) revisions + + extraMsgs = + Maybe.map + (\encounterId_ -> + generateTuberculosisEncounterCompletedMsgs currentDate newModel encounterId_ + ) + encounterId + |> Maybe.withDefault [] + in + ( newModel, extraMsgs ) in case revisions of -- Special handling for a single attendance revision, which means @@ -3569,6 +3589,76 @@ updateIndexedDb language currentDate currentTime zscores site features nurseId h , extraMsgs ) + [ TuberculosisDOTRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + + [ TuberculosisFollowUpRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + + [ TuberculosisHealthEducationRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + + [ TuberculosisMedicationRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + + [ TuberculosisReferralRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + + [ TuberculosisSymptomReviewRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + + [ TuberculosisTreatmentReviewRevision _ data ] -> + let + ( newModel, extraMsgs ) = + processTuberculosisRevisionAndNavigateToProgressReport data.encounterId + in + ( newModel + , Cmd.none + , extraMsgs + ) + _ -> let ( newModel, recalculateEditableSessions ) = @@ -8351,3 +8441,26 @@ generateInitialComputedDashboard currentDate healthCenterId villageId statsRaw d ( programTypeFilter, selectedVillage ) (Pages.Dashboard.Utils.generateAssembledData currentDate healthCenterId statsRaw db programTypeFilter selectedVillage) } + + +generateTuberculosisEncounterCompletedMsgs : + NominalDate + -> ModelIndexedDb + -> TuberculosisEncounterId + -> List App.Model.Msg +generateTuberculosisEncounterCompletedMsgs currentDate after id = + Pages.Tuberculosis.Encounter.Utils.generateAssembledData id after + |> RemoteData.toMaybe + |> Maybe.map + (\assembled -> + let + ( _, pendingActivities ) = + Pages.Tuberculosis.Encounter.Utils.partitionActivities currentDate assembled + in + if List.isEmpty pendingActivities then + [ App.Model.SetActivePage <| UserPage <| TuberculosisProgressReportPage id ] + + else + [] + ) + |> Maybe.withDefault [] diff --git a/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm b/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm index 5e56245d34..cd391af3bb 100644 --- a/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm +++ b/client/src/elm/Pages/Tuberculosis/Encounter/Utils.elm @@ -6,12 +6,15 @@ import Backend.Measurement.Model exposing (..) import Backend.Measurement.Utils exposing (diabetesBySugarCount, diabetesByUrineGlucose, getCurrentReasonForNonReferral, getMeasurementValueFunc) import Backend.Model exposing (ModelIndexedDb) import Backend.NutritionEncounter.Utils exposing (getTuberculosisEncountersForParticipant) +import Backend.TuberculosisActivity.Model exposing (TuberculosisActivity) +import Backend.TuberculosisActivity.Utils exposing (allActivities) import Date import EverySet exposing (EverySet) import Gizra.NominalDate exposing (NominalDate) import Html exposing (..) import Html.Attributes exposing (..) import Maybe.Extra exposing (andMap, isJust, or, unwrap) +import Pages.Tuberculosis.Activity.Utils exposing (activityCompleted, expectActivity) import Pages.Tuberculosis.Encounter.Model exposing (..) import Pages.Utils exposing diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 91f64db4ee..17729f9668 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -31,8 +31,8 @@ import Maybe.Extra exposing (isJust, isNothing) import Measurement.Model exposing (LaboratoryTask(..)) import Pages.Page exposing (Page(..), UserPage(..)) import Pages.Tuberculosis.Encounter.Model exposing (AssembledData, EncounterData) -import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData) -import Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter, partitionActivities) +import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData, partitionActivities) +import Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter) import Pages.Tuberculosis.ProgressReport.Model exposing (..) import Pages.Utils exposing From 377dd264aff978e97f37a740bee832fa1968d165 Mon Sep 17 00:00:00 2001 From: Anatoly Vaitsman Date: Wed, 31 Jul 2024 06:38:52 +0300 Subject: [PATCH 54/63] TB Management - medications update (#1262) * Add 'Medication not changed' option [ci skip] * View task at subsequent encounter + logic + adjustment at progress report [ci skip] * Improve HIV module code [ci skip] * A fix * Do not show entry, if medication does not exist --- client/src/elm/Backend/Measurement/Model.elm | 1 + client/src/elm/Backend/Measurement/Utils.elm | 6 + client/src/elm/Pages/HIV/Activity/Utils.elm | 118 ++++++------ client/src/elm/Pages/HIV/Encounter/Model.elm | 4 +- client/src/elm/Pages/HIV/Encounter/Utils.elm | 2 +- .../elm/Pages/Tuberculosis/Activity/Model.elm | 5 +- .../Pages/Tuberculosis/Activity/Update.elm | 16 +- .../elm/Pages/Tuberculosis/Activity/Utils.elm | 175 ++++++++++++++---- .../elm/Pages/Tuberculosis/Activity/View.elm | 22 +-- .../Tuberculosis/ProgressReport/View.elm | 24 ++- client/src/elm/Translate.elm | 55 +++--- ...edley_tuberculosis.features.field_base.inc | 1 + 12 files changed, 284 insertions(+), 145 deletions(-) diff --git a/client/src/elm/Backend/Measurement/Model.elm b/client/src/elm/Backend/Measurement/Model.elm index 5f2141a733..3ab7dd33fa 100644 --- a/client/src/elm/Backend/Measurement/Model.elm +++ b/client/src/elm/Backend/Measurement/Model.elm @@ -2946,6 +2946,7 @@ type TuberculosisPrescribedMedication = MedicationRHZE | MedicationRH | MedicationOther + | TuberculosisMedicationsNotChanged | NoTuberculosisPrescribedMedications diff --git a/client/src/elm/Backend/Measurement/Utils.elm b/client/src/elm/Backend/Measurement/Utils.elm index ae82bc6ebc..8c08513626 100644 --- a/client/src/elm/Backend/Measurement/Utils.elm +++ b/client/src/elm/Backend/Measurement/Utils.elm @@ -4092,6 +4092,9 @@ tuberculosisPrescribedMedicationToString sign = MedicationOther -> "other" + TuberculosisMedicationsNotChanged -> + "not-changed" + NoTuberculosisPrescribedMedications -> "none" @@ -4108,6 +4111,9 @@ tuberculosisPrescribedMedicationFromString sign = "other" -> Just MedicationOther + "not-changed" -> + Just TuberculosisMedicationsNotChanged + "none" -> Just NoTuberculosisPrescribedMedications diff --git a/client/src/elm/Pages/HIV/Activity/Utils.elm b/client/src/elm/Pages/HIV/Activity/Utils.elm index 0d795f9b6e..ff9a3be732 100644 --- a/client/src/elm/Pages/HIV/Activity/Utils.elm +++ b/client/src/elm/Pages/HIV/Activity/Utils.elm @@ -20,7 +20,7 @@ import Measurement.Utils , treatmentReviewInputsAndTasks ) import Pages.HIV.Activity.Model exposing (..) -import Pages.HIV.Encounter.Model exposing (AssembledData) +import Pages.HIV.Encounter.Model exposing (AssembledData, EncounterData) import Pages.Utils exposing ( ifEverySetEmpty @@ -535,62 +535,47 @@ prescribedMedicationsInputsAndTasks : -> ( List (Html Msg), ( Int, Int ) ) prescribedMedicationsInputsAndTasks language currentDate assembled form = let - mPrescribedMedications = - List.filterMap - (\data -> - getMeasurementValueFunc data.measurements.medication - |> Maybe.andThen - (\value -> - case EverySet.toList value of - [ HIVMedicationsNotChanged ] -> - Nothing - - _ -> - Just value - ) - ) - assembled.previousEncountersData - |> List.head - ( recordMedicationsInputs, recordMedicationsTasks ) = - recordMedicationsInputsAndTasks language Translate.HIVPrescribedMedicationsTakenQuestion form + recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsTakenQuestion form in - Maybe.map - (\prescribedMedication -> - let - ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = - if form.medicationsNotChanged /= Just False then - ( [], ( 0, 0 ) ) - - else - ( recordMedicationsInputs, recordMedicationsTasks ) - - prescribedMedicationForView = - EverySet.toList prescribedMedication - |> List.map - (\medication -> - li [] [ text <| translate language <| Translate.HIVPrescribedMedication medication ] - ) - |> ul [] - in - ( [ viewLabel language Translate.PrescribedMedication - , prescribedMedicationForView - , viewQuestionLabel language Translate.HIVPrescribedMedicationsChangedQuestion - , viewBoolInput - language - form.medicationsNotChanged - SetPrescribedMedicationsNotChanged - "medications-changed" - Nothing - ] - ++ derivedInputs - , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted - , 1 + derivedTasksTotal - ) + generateAllEncountersData assembled + |> resolvePrescribedMedicationSets HIVMedicationsNotChanged + |> Tuple.first + |> Maybe.map + (\prescribedMedication -> + let + ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = + if form.medicationsNotChanged /= Just False then + ( [], ( 0, 0 ) ) + + else + ( recordMedicationsInputs, recordMedicationsTasks ) + + prescribedMedicationForView = + EverySet.toList prescribedMedication + |> List.map + (\medication -> + li [] [ text <| translate language <| Translate.HIVPrescribedMedication medication ] + ) + |> ul [] + in + ( [ viewLabel language Translate.PrescribedMedication + , prescribedMedicationForView + , viewQuestionLabel language Translate.PrescribedMedicationsChangedQuestion + , viewBoolInput + language + form.medicationsNotChanged + SetPrescribedMedicationsNotChanged + "medications-changed" + Nothing + ] + ++ derivedInputs + , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted + , 1 + derivedTasksTotal + ) + ) ) - ) - mPrescribedMedications - |> Maybe.withDefault (recordMedicationsInputsAndTasks language Translate.HIVPrescribedMedicationsQuestion form) + |> Maybe.withDefault (recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsQuestion form) recordMedicationsInputsAndTasks : @@ -628,3 +613,28 @@ recordMedicationsInputsAndTasks language questionTransId form = , 1 ) ) + + +generateAllEncountersData : AssembledData -> List EncounterData +generateAllEncountersData assembled = + { id = assembled.id + , startDate = assembled.encounter.startDate + , measurements = assembled.measurements + } + :: assembled.previousEncountersData + + +resolvePrescribedMedicationSets : + HIVPrescribedMedication + -> List EncounterData + -> ( Maybe (EverySet HIVPrescribedMedication), Maybe (EverySet HIVPrescribedMedication) ) +resolvePrescribedMedicationSets notChangedOption allEncountersData = + let + prescribedMedicationSets = + List.filterMap (.measurements >> .medication >> getMeasurementValueFunc) + allEncountersData + |> List.filter (not << EverySet.member notChangedOption) + in + ( List.head prescribedMedicationSets + , List.drop 1 prescribedMedicationSets |> List.head + ) diff --git a/client/src/elm/Pages/HIV/Encounter/Model.elm b/client/src/elm/Pages/HIV/Encounter/Model.elm index d27975121b..5a79068da4 100644 --- a/client/src/elm/Pages/HIV/Encounter/Model.elm +++ b/client/src/elm/Pages/HIV/Encounter/Model.elm @@ -34,14 +34,14 @@ type alias AssembledData = , participant : IndividualEncounterParticipant , person : Person , measurements : HIVMeasurements - , previousEncountersData : List PreviousEncounterData + , previousEncountersData : List EncounterData -- Intial encounter is the one where initial diagnosis is made. , initialEncounter : Bool } -type alias PreviousEncounterData = +type alias EncounterData = { id : HIVEncounterId , startDate : NominalDate , measurements : HIVMeasurements diff --git a/client/src/elm/Pages/HIV/Encounter/Utils.elm b/client/src/elm/Pages/HIV/Encounter/Utils.elm index c8dd2bf2f5..7dbedebe27 100644 --- a/client/src/elm/Pages/HIV/Encounter/Utils.elm +++ b/client/src/elm/Pages/HIV/Encounter/Utils.elm @@ -76,7 +76,7 @@ generateAssembledData id db = |> RemoteData.andMap (Success initialEncounter) -generatePreviousEncountersData : Maybe HIVEncounterId -> IndividualEncounterParticipantId -> ModelIndexedDb -> List PreviousEncounterData +generatePreviousEncountersData : Maybe HIVEncounterId -> IndividualEncounterParticipantId -> ModelIndexedDb -> List EncounterData generatePreviousEncountersData currentEncounterId participantId db = getHIVEncountersForParticipant db participantId |> List.filterMap diff --git a/client/src/elm/Pages/Tuberculosis/Activity/Model.elm b/client/src/elm/Pages/Tuberculosis/Activity/Model.elm index a811162a91..16c5d19a17 100644 --- a/client/src/elm/Pages/Tuberculosis/Activity/Model.elm +++ b/client/src/elm/Pages/Tuberculosis/Activity/Model.elm @@ -71,14 +71,14 @@ emptyMedicationData = type alias PrescribedMedicationForm = { medications : Maybe (List TuberculosisPrescribedMedication) - , medicationsDirty : Bool + , medicationsNotChanged : Maybe Bool } emptyPrescribedMedicationForm : PrescribedMedicationForm emptyPrescribedMedicationForm = { medications = Nothing - , medicationsDirty = False + , medicationsNotChanged = Nothing } @@ -185,6 +185,7 @@ type Msg | SaveDiagnostics PersonId IndividualEncounterParticipantId (Maybe ( TuberculosisDiagnosticsId, TuberculosisDiagnostics )) -- MEDICATION | SetActiveMedicationTask MedicationTask + | SetPrescribedMedicationsNotChanged Bool | SetPrescribedMedication TuberculosisPrescribedMedication | SavePrescribedMedication PersonId (Maybe ( TuberculosisMedicationId, TuberculosisMedication )) (Maybe MedicationTask) | SetDOTBoolInput (Bool -> DOTForm -> DOTForm) Bool diff --git a/client/src/elm/Pages/Tuberculosis/Activity/Update.elm b/client/src/elm/Pages/Tuberculosis/Activity/Update.elm index 1ab4146577..d7aaa2ff08 100644 --- a/client/src/elm/Pages/Tuberculosis/Activity/Update.elm +++ b/client/src/elm/Pages/Tuberculosis/Activity/Update.elm @@ -143,6 +143,20 @@ update currentDate id db msg model = , [] ) + SetPrescribedMedicationsNotChanged value -> + let + updatedForm = + { medicationForm | medicationsNotChanged = Just value, medications = Nothing } + + updatedData = + model.medicationData + |> (\data -> { data | prescribedMedicationForm = updatedForm }) + in + ( { model | medicationData = updatedData } + , Cmd.none + , [] + ) + SetPrescribedMedication medication -> let form = @@ -150,7 +164,7 @@ update currentDate id db msg model = updatedForm = setMultiSelectInputValue .medications - (\medications -> { form | medications = medications, medicationsDirty = True }) + (\medications -> { form | medications = medications }) NoTuberculosisPrescribedMedications medication form diff --git a/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm b/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm index 5b43f83ae5..81b1138749 100644 --- a/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm +++ b/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm @@ -20,7 +20,7 @@ import Measurement.Utils , treatmentReviewInputsAndTasks ) import Pages.Tuberculosis.Activity.Model exposing (..) -import Pages.Tuberculosis.Encounter.Model exposing (AssembledData) +import Pages.Tuberculosis.Encounter.Model exposing (AssembledData, EncounterData) import Pages.Utils exposing ( ifEverySetEmpty @@ -33,10 +33,11 @@ import Pages.Utils , viewCheckBoxMultipleSelectInput , viewCheckBoxSelectInput , viewCustomLabel + , viewLabel , viewNumberInput , viewQuestionLabel ) -import Translate exposing (translate) +import Translate exposing (TranslationId, translate) import Translate.Model exposing (Language(..)) @@ -104,11 +105,10 @@ expectMedicationTask : NominalDate -> AssembledData -> MedicationTask -> Bool expectMedicationTask currentDate assembled task = case task of TaskPrescribedMedication -> - assembled.initialEncounter + True TaskDOT -> - not assembled.initialEncounter - || isJust assembled.measurements.medication + isJust assembled.measurements.medication TaskTreatmentReview -> expectMedicationTask currentDate assembled TaskDOT @@ -135,9 +135,12 @@ medicationTasksCompletedFromTotal language currentDate assembled data task = form = getMeasurementValueFunc assembled.measurements.medication |> prescribedMedicationFormWithDefault data.prescribedMedicationForm + + ( _, ( tasksCompleted, tasksTotal ) ) = + prescribedMedicationsInputsAndTasks language currentDate assembled form in - ( taskCompleted form.medications - , 1 + ( tasksCompleted + , tasksTotal ) TaskDOT -> @@ -433,15 +436,28 @@ prescribedMedicationFormWithDefault form saved = |> unwrap form (\value -> - { medications = or form.medications (Just <| EverySet.toList value) - , medicationsDirty = form.medicationsDirty + let + ( medicationsNotChangedFromValue, medicationsFromValue ) = + case EverySet.toList value of + [ TuberculosisMedicationsNotChanged ] -> + ( Just True, Nothing ) + + _ -> + ( Just False, Just <| EverySet.toList value ) + in + { medications = or form.medications medicationsFromValue + , medicationsNotChanged = or form.medicationsNotChanged medicationsNotChangedFromValue } ) toPrescribedMedicationValue : PrescribedMedicationForm -> Maybe TuberculosisMedicationValue toPrescribedMedicationValue form = - Maybe.map EverySet.fromList form.medications + if form.medicationsNotChanged == Just True then + EverySet.singleton TuberculosisMedicationsNotChanged |> Just + + else + Maybe.map EverySet.fromList form.medications toDOTValueWithDefault : Maybe TuberculosisDOTValue -> DOTForm -> Maybe TuberculosisDOTValue @@ -579,32 +595,19 @@ dotInputsAndTasks language currentDate assembled form = ( distributeMedicationsInputs, distributeMedicationsTasks ) = let - prescribedMedications = - let - medicationMeasurement = - if assembled.initialEncounter then - assembled.measurements.medication - - else - List.filterMap (.measurements >> .medication) - assembled.previousEncountersData - |> List.head - in - getMeasurementValueFunc medicationMeasurement - |> Maybe.map (EverySet.remove NoTuberculosisPrescribedMedications) - |> Maybe.withDefault EverySet.empty - prescribedMedicationsForView = - if EverySet.isEmpty prescribedMedications then - emptyNode - - else - EverySet.toList prescribedMedications - |> List.map - (\medicatiopn -> - p [] [ text <| translate language <| Translate.TuberculosisPrescribedMedication medicatiopn ] - ) - |> div [ class "prescribed-medications" ] + generateAllEncountersData assembled + |> resolvePrescribedMedicationSets TuberculosisMedicationsNotChanged + |> Tuple.first + |> Maybe.map + (EverySet.toList + >> List.map + (\medicatiopn -> + p [] [ text <| translate language <| Translate.TuberculosisPrescribedMedication medicatiopn ] + ) + >> div [ class "prescribed-medications" ] + ) + |> Maybe.withDefault emptyNode ( derivedInputs, derivedTasks ) = if form.distributeMedications == Just False then @@ -650,3 +653,105 @@ dotInputsAndTasks language currentDate assembled form = ( provideTodayInputs ++ distributeMedicationsInputs , provideTodayTasks ++ distributeMedicationsTasks ) + + +prescribedMedicationsInputsAndTasks : + Language + -> NominalDate + -> AssembledData + -> PrescribedMedicationForm + -> ( List (Html Msg), ( Int, Int ) ) +prescribedMedicationsInputsAndTasks language currentDate assembled form = + let + ( recordMedicationsInputs, recordMedicationsTasks ) = + recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsTakenQuestion form + in + generateAllEncountersData assembled + |> resolvePrescribedMedicationSets TuberculosisMedicationsNotChanged + |> Tuple.first + |> Maybe.map + (\prescribedMedication -> + let + ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = + if form.medicationsNotChanged /= Just False then + ( [], ( 0, 0 ) ) + + else + ( recordMedicationsInputs, recordMedicationsTasks ) + + prescribedMedicationForView = + EverySet.toList prescribedMedication + |> List.map + (\medication -> + li [] [ text <| translate language <| Translate.TuberculosisPrescribedMedication medication ] + ) + |> ul [] + in + ( [ viewLabel language Translate.PrescribedMedication + , prescribedMedicationForView + , viewQuestionLabel language Translate.PrescribedMedicationsChangedQuestion + , viewBoolInput + language + form.medicationsNotChanged + SetPrescribedMedicationsNotChanged + "medications-changed" + Nothing + ] + ++ derivedInputs + , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted + , 1 + derivedTasksTotal + ) + ) + ) + |> Maybe.withDefault (recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsQuestion form) + + +recordMedicationsInputsAndTasks : + Language + -> TranslationId + -> PrescribedMedicationForm + -> ( List (Html Msg), ( Int, Int ) ) +recordMedicationsInputsAndTasks language questionTransId form = + ( [ div [ class "ui form prescribed-medication" ] + [ viewQuestionLabel language questionTransId + , viewCheckBoxMultipleSelectInput language + [ MedicationRHZE + , MedicationRH + , MedicationOther + ] + [] + (Maybe.withDefault [] form.medications) + Nothing + SetPrescribedMedication + Translate.TuberculosisPrescribedMedication + ] + ] + , ( taskCompleted form.medications + , 1 + ) + ) + + +generateAllEncountersData : AssembledData -> List EncounterData +generateAllEncountersData assembled = + { id = assembled.id + , startDate = assembled.encounter.startDate + , measurements = assembled.measurements + } + :: assembled.previousEncountersData + + +resolvePrescribedMedicationSets : + TuberculosisPrescribedMedication + -> List EncounterData + -> ( Maybe (EverySet TuberculosisPrescribedMedication), Maybe (EverySet TuberculosisPrescribedMedication) ) +resolvePrescribedMedicationSets notChangedOption allEncountersData = + let + prescribedMedicationSets = + List.filterMap (.measurements >> .medication >> getMeasurementValueFunc) + allEncountersData + |> List.filter (not << EverySet.member notChangedOption) + in + ( List.head prescribedMedicationSets + , List.drop 1 prescribedMedicationSets |> List.head + ) diff --git a/client/src/elm/Pages/Tuberculosis/Activity/View.elm b/client/src/elm/Pages/Tuberculosis/Activity/View.elm index 5ce0cccabb..69e1b54c61 100644 --- a/client/src/elm/Pages/Tuberculosis/Activity/View.elm +++ b/client/src/elm/Pages/Tuberculosis/Activity/View.elm @@ -279,7 +279,7 @@ viewMedicationContent language currentDate assembled data = Just TaskPrescribedMedication -> getMeasurementValueFunc measurements.medication |> prescribedMedicationFormWithDefault data.prescribedMedicationForm - |> viewPrescribedMedicationForm language currentDate + |> viewPrescribedMedicationForm language currentDate assembled |> List.singleton Just TaskDOT -> @@ -355,21 +355,11 @@ viewMedicationContent language currentDate assembled data = ] -viewPrescribedMedicationForm : Language -> NominalDate -> PrescribedMedicationForm -> Html Msg -viewPrescribedMedicationForm language currentDate form = - div [ class "ui form prescribed-medication" ] - [ viewQuestionLabel language Translate.TuberculosisPrescribedMedicationsQuestion - , viewCheckBoxMultipleSelectInput language - [ MedicationRHZE - , MedicationRH - , MedicationOther - ] - [] - (Maybe.withDefault [] form.medications) - Nothing - SetPrescribedMedication - Translate.TuberculosisPrescribedMedication - ] +viewPrescribedMedicationForm : Language -> NominalDate -> AssembledData -> PrescribedMedicationForm -> Html Msg +viewPrescribedMedicationForm language currentDate assembled form = + prescribedMedicationsInputsAndTasks language currentDate assembled form + |> Tuple.first + |> div [ class "ui form prescribed-medication" ] viewDOTForm : Language -> NominalDate -> AssembledData -> DOTForm -> Html Msg diff --git a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm index 17729f9668..a4641b1603 100644 --- a/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm +++ b/client/src/elm/Pages/Tuberculosis/ProgressReport/View.elm @@ -11,6 +11,7 @@ import Backend.Measurement.Model , TreatmentOngoingSign(..) , TuberculosisDOTSign(..) , TuberculosisHealthEducationSign(..) + , TuberculosisPrescribedMedication(..) , TuberculosisSymptom(..) ) import Backend.Measurement.Utils exposing (getMeasurementValueFunc) @@ -30,6 +31,7 @@ import Html.Events exposing (..) import Maybe.Extra exposing (isJust, isNothing) import Measurement.Model exposing (LaboratoryTask(..)) import Pages.Page exposing (Page(..), UserPage(..)) +import Pages.Tuberculosis.Activity.Utils exposing (generateAllEncountersData, resolvePrescribedMedicationSets) import Pages.Tuberculosis.Encounter.Model exposing (AssembledData, EncounterData) import Pages.Tuberculosis.Encounter.Utils exposing (generateAssembledData, partitionActivities) import Pages.Tuberculosis.Encounter.View exposing (allowEndingEncounter) @@ -121,11 +123,7 @@ viewContent : viewContent language currentDate site features model assembled = let allEncountersData = - { id = assembled.id - , startDate = assembled.encounter.startDate - , measurements = assembled.measurements - } - :: assembled.previousEncountersData + generateAllEncountersData assembled panes = case model.viewMode of @@ -234,10 +232,8 @@ viewSummaryPane language currentDate allEncountersData firstEncounterData initia allEncountersData |> List.sum - currentMedications = - List.filter (.measurements >> .medication >> isJust) allEncountersData - |> List.head - |> Maybe.andThen (.measurements >> .medication >> getMeasurementValueFunc) + ( currentMedications, previousMedications ) = + resolvePrescribedMedicationSets TuberculosisMedicationsNotChanged allEncountersData diagnosisForView = Maybe.map (Translate.TuberculosisDiagnosis >> translate language) diagnosis @@ -251,14 +247,14 @@ viewSummaryPane language currentDate allEncountersData firstEncounterData initia Maybe.map formatDDMMYYYY completionDate |> Maybe.withDefault "" - currentMedicationsForView = + viewMedicationsEntry label = Maybe.map (EverySet.toList >> List.map (Translate.TuberculosisPrescribedMedication >> translate language) >> String.join ", " + >> viewEntry label ) - currentMedications - |> Maybe.withDefault "" + >> Maybe.withDefault emptyNode viewEntry label value = div [ class "entry" ] @@ -273,7 +269,8 @@ viewSummaryPane language currentDate allEncountersData firstEncounterData initia , viewEntry Translate.InitiationDate initiationDateForView , viewEntry Translate.MissedDoses (String.fromInt missedDoses) , viewEntry Translate.CompletionDate completionDateForView - , viewEntry Translate.CurrentMedication currentMedicationsForView + , viewMedicationsEntry Translate.CurrentMedication currentMedications + , viewMedicationsEntry Translate.PreviousMedication previousMedications ] ] @@ -399,6 +396,7 @@ viewEncounterDetailsContent language currentDate encounterId model allEncounters Nothing ) allEncountersData + |> List.filter (not << EverySet.member TuberculosisMedicationsNotChanged) |> List.head currentMedicationsForView = diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 9cf45d094a..c3ee6b6e1c 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -770,9 +770,6 @@ type TranslationId | HIVPositiveDiagnosedQuestion | HIVPositiveTestDateQuestion | HIVPrescribedMedication HIVPrescribedMedication - | HIVPrescribedMedicationsChangedQuestion - | HIVPrescribedMedicationsQuestion - | HIVPrescribedMedicationsTakenQuestion | HIVStatus HIVStatus | HIVStatusLabel | HIVSuggestTakingTestQuestion @@ -1274,11 +1271,15 @@ type TranslationId | PregnancyConcludedLabel | PregnancyOutcomeLabel | PregnancyOutcome PregnancyOutcome + | PrescribedMedicationsChangedQuestion + | PrescribedMedicationsQuestion + | PrescribedMedicationsTakenQuestion | PreviousCSectionScar | PreviousDelivery | PreviousDeliveryPeriods PreviousDeliveryPeriod | PreviousFloatMeasurement Float | PreviousMeasurementNotFound + | PreviousMedication | PriorTreatmentTask Pages.AcuteIllness.Activity.Types.PriorTreatmentTask | Programs | ProgressPhotos @@ -7044,24 +7045,6 @@ translationSet trans = NoHIVPrescribedMedications -> translationSet EmptyString - HIVPrescribedMedicationsChangedQuestion -> - { english = "Please check the medications that were prescribed. Is the patient still taking the medications listed above" - , kinyarwanda = Nothing - , kirundi = Nothing - } - - HIVPrescribedMedicationsQuestion -> - { english = "What are the medications that were prescribed" - , kinyarwanda = Just "Ni iyihe miti yatanzwe" - , kirundi = Nothing - } - - HIVPrescribedMedicationsTakenQuestion -> - { english = "What are the medications being taken" - , kinyarwanda = Nothing - , kirundi = Nothing - } - HIVStatus status -> case status of HIVExposedInfant -> @@ -16913,6 +16896,24 @@ translationSet trans = , kirundi = Just "Ugukoroka kw'imbanyi (imbere y'indwi 24 ugereranije nigihe imbanyi imaze)" } + PrescribedMedicationsChangedQuestion -> + { english = "Please check the medications that were prescribed. Is the patient still taking the medications listed above" + , kinyarwanda = Nothing + , kirundi = Nothing + } + + PrescribedMedicationsQuestion -> + { english = "What are the medications that were prescribed" + , kinyarwanda = Just "Ni iyihe miti yatanzwe" + , kirundi = Nothing + } + + PrescribedMedicationsTakenQuestion -> + { english = "What are the medications being taken" + , kinyarwanda = Nothing + , kirundi = Nothing + } + PreviousCSectionScar -> { english = "Previous C-section scar" , kinyarwanda = Just "Inkovu yaho babaze ubushize" @@ -16957,6 +16958,12 @@ translationSet trans = , kirundi = Just "Nta bipimo vyafashwe ubuherutse" } + PreviousMedication -> + { english = "Previous Medication" + , kinyarwanda = Nothing + , kirundi = Nothing + } + PriorTreatmentTask task -> case task of Pages.AcuteIllness.Activity.Types.TreatmentReview -> @@ -22432,6 +22439,12 @@ translationSet trans = , kirundi = Nothing } + TuberculosisMedicationsNotChanged -> + { english = "Medication not Changed" + , kinyarwanda = Nothing + , kirundi = Nothing + } + NoTuberculosisPrescribedMedications -> translationSet EmptyString diff --git a/server/hedley/modules/custom/hedley_tuberculosis/hedley_tuberculosis.features.field_base.inc b/server/hedley/modules/custom/hedley_tuberculosis/hedley_tuberculosis.features.field_base.inc index 1053fd7ed4..008371ff72 100644 --- a/server/hedley/modules/custom/hedley_tuberculosis/hedley_tuberculosis.features.field_base.inc +++ b/server/hedley/modules/custom/hedley_tuberculosis/hedley_tuberculosis.features.field_base.inc @@ -90,6 +90,7 @@ function hedley_tuberculosis_field_default_field_bases() { 'rhze' => 'RHZE', 'rh' => 'RH', 'other' => 'Other', + 'not-changed' => 'Medications Not Changed', 'none' => 'None', ), 'allowed_values_function' => '', From a977044f2c336cf94272a3694954754ad17b5abd Mon Sep 17 00:00:00 2001 From: Diama1 Date: Thu, 1 Aug 2024 15:01:18 +0200 Subject: [PATCH 55/63] fix some translations --- client/src/elm/Translate.elm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 1064437521..4a2a3b9f9b 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -4027,7 +4027,7 @@ translationSet trans = ChooseOne -> { english = "Choose one" - , kinyarwanda = Nothing + , kinyarwanda = Just "Hitamo kimwe" , kirundi = Just "Hitamwo kimwe" } @@ -17111,19 +17111,19 @@ translationSet trans = QuarterlySurveyScoreInterpretation score -> if score < 14 then { english = "Low resilient copers" - , kinyarwanda = Nothing + , kinyarwanda = Just "Ugira imbaraga nke mu gushakisha ibisubizo no kwihangana" , kirundi = Nothing } else if score < 17 then { english = "Medium resilient copers" - , kinyarwanda = Nothing + , kinyarwanda = Just "Uragerageza mu gushakisha ibisubizo no kwihangana" , kirundi = Nothing } else { english = "High resilient copers" - , kinyarwanda = Nothing + , kinyarwanda = Just "Ufite ubushobozi bwinshi mu gushaka ibisubizo no kwihangana" , kirundi = Nothing } @@ -19741,7 +19741,7 @@ translationSet trans = } ResilienceSurveyQuestionOption4 -> - { english = "Every day (6-7 days)" + { english = "Almost everyday (6-7 days)" , kinyarwanda = Just "Buri munsi (iminsi 6-7)" , kirundi = Nothing } @@ -19770,7 +19770,7 @@ translationSet trans = } ResilienceSurveyQuestionOption4 -> - { english = "Every day (6-7 days)" + { english = "Almost everyday (6-7 days)" , kinyarwanda = Just "Buri munsi (iminsi 6-7)" , kirundi = Nothing } @@ -19794,7 +19794,7 @@ translationSet trans = ResilienceSurveyQuestionOption3 -> { english = "Once in the last two months" - , kinyarwanda = Just "Rimwe mu mezi atatu ashize" + , kinyarwanda = Just "Rimwe mu mezi abiri ashize" , kirundi = Nothing } @@ -19828,7 +19828,7 @@ translationSet trans = } ResilienceSurveyQuestionOption4 -> - { english = "Every day (6-7 days)" + { english = "Almost everyday (6-7 days)" , kinyarwanda = Just "Buri munsi (iminsi 6-7)" , kirundi = Nothing } @@ -19857,7 +19857,7 @@ translationSet trans = } ResilienceSurveyQuestionOption4 -> - { english = "Every day (6-7 days)" + { english = "Almost everyday (6-7 days)" , kinyarwanda = Just "Buri munsi (iminsi 6-7)" , kirundi = Nothing } @@ -19881,7 +19881,7 @@ translationSet trans = ResilienceSurveyQuestionOption3 -> { english = "Once in the last two months" - , kinyarwanda = Just "Rimwe mu mezi atatu ashize" + , kinyarwanda = Just "Rimwe mu mezi abiri ashize" , kirundi = Nothing } @@ -19910,7 +19910,7 @@ translationSet trans = ResilienceSurveyQuestionOption3 -> { english = "Once in the last two months" - , kinyarwanda = Just "Rimwe mu mezi atatu ashize" + , kinyarwanda = Just "Rimwe mu mezi abiri ashize" , kirundi = Nothing } @@ -19944,7 +19944,7 @@ translationSet trans = } ResilienceSurveyQuestionOption4 -> - { english = "Every day (6-7 days)" + { english = "Almost everyday (6-7 days)" , kinyarwanda = Just "Buri munsi (iminsi 6-7)" , kirundi = Nothing } @@ -20157,7 +20157,7 @@ translationSet trans = case option of ResilienceSurveyQuestionOption0 -> { english = "Does not describe me at all" - , kinyarwanda = Just "Ntabwo mbikora na namba" + , kinyarwanda = Just "Ntabwo mbikora namba" , kirundi = Nothing } From 1c80b7fd69916791dccce61bd1bd4c684034213e Mon Sep 17 00:00:00 2001 From: Diama1 Date: Sun, 4 Aug 2024 23:41:12 +0200 Subject: [PATCH 56/63] fix --- client/src/elm/Translate.elm | 305 ++++++++++++++--------------------- 1 file changed, 117 insertions(+), 188 deletions(-) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 4a2a3b9f9b..e93753c467 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -413,6 +413,7 @@ type TranslationId | AILaboratoryTask AILaboratoryTask | All | AllowedValuesRangeHelper FloatInputConstraints + | AlmostEverydayOption | AmbulancArrivalPeriodQuestion | ANCEncountersNotRecordedQuestion | ANCIndicateVisitsMonthsPhrase @@ -699,6 +700,7 @@ type TranslationId | ForIllustrativePurposesOnly | FormError (ErrorValue ValidationError) | FormField String + | FourToFiveDaysAWeek | FundalHeight | FundalPalpableQuestion | FundalPalpableWarning @@ -1128,6 +1130,11 @@ type TranslationId | OK | On | OneVisit + | OnceAMonth + | OnceAWeekOption + | OnceInLastSixMonthsOption + | OnceInLastThreeMonthsOption + | OnceInTheLastTwoMonthsOption | OnceYouEndTheEncounter | OnceYouEndYourGroupEncounter | OngoingTreatmentTask OngoingTreatmentTask @@ -1792,6 +1799,9 @@ type TranslationId | TuberculosisSuspect | TuberculosisSymptomQuestion TuberculosisSymptom | TuberculosisWarning + | TwiceAMonthOption + | TwoAndMoreDaysAWeekOption + | TwoToThreeDaysAWeeksOption | TwoVisits | Type | UbudeheLabel @@ -3160,6 +3170,12 @@ translationSet trans = , kirundi = Just "Akahise ko kugenderwa imbere yo kuvyara" } + AlmostEverydayOption -> + { english = "Almost everyday (6-7 days)" + , kinyarwanda = Just "Buri munsi (iminsi 6-7)" + , kirundi = Nothing + } + AmbulancArrivalPeriodQuestion -> { english = "How long did it take the ambulance to arrive" , kinyarwanda = Just "Bitwara igihe kingana gute ngo imbangukiragutabara ihagere" @@ -6245,6 +6261,12 @@ translationSet trans = FormField field -> translateFormField field + FourToFiveDaysAWeek -> + { english = "4 to 5 days a week" + , kinyarwanda = Just "Kane kugera kuri gatanu mu cyumweru" + , kirundi = Nothing + } + FundalHeight -> { english = "Fundal Height" , kinyarwanda = Just "Uburebure bwa Nyababyeyi" @@ -13066,6 +13088,36 @@ translationSet trans = , kirundi = Just "Urugendo rumwe" } + OnceAMonth -> + { english = "Once a month" + , kinyarwanda = Just "Rimwe mu kwezi" + , kirundi = Nothing + } + + OnceAWeekOption -> + { english = "Once a week" + , kinyarwanda = Just "Rimwe mu cyumweru" + , kirundi = Nothing + } + + OnceInLastSixMonthsOption -> + { english = "Once in last six months" + , kinyarwanda = Just "Rimwe mu mezi atandatu ashize" + , kirundi = Nothing + } + + OnceInLastThreeMonthsOption -> + { english = "Once in last three months" + , kinyarwanda = Just "Rimwe mu mezi atatu ashize" + , kirundi = Nothing + } + + OnceInTheLastTwoMonthsOption -> + { english = "Once in the last two months" + , kinyarwanda = Just "Rimwe mu mezi abiri ashize" + , kirundi = Nothing + } + OnceYouEndTheEncounter -> { english = "Once you end the Encounter, you will no longer be able to edit or add data." , kinyarwanda = Just "Igihe cyose urangije igikorwa ,nta bushobozi wongera kugira bwo guhindura ibyo winjije cyangwa amakuru." @@ -19723,28 +19775,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption2 -> - { english = "2 to 3 days a week" - , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" - , kirundi = Nothing - } + translationSet TwoToThreeDaysAWeeksOption ResilienceSurveyQuestionOption3 -> - { english = "4 to 5 days a week" - , kinyarwanda = Just "Kane kugera kuri gatanu mu cyumweru" - , kirundi = Nothing - } + translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - { english = "Almost everyday (6-7 days)" - , kinyarwanda = Just "Buri munsi (iminsi 6-7)" - , kirundi = Nothing - } + translationSet AlmostEverydayOption ResilienceSurveyQuestion2 -> case option of @@ -19752,28 +19792,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption2 -> - { english = "2 to 3 days a week" - , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" - , kirundi = Nothing - } + translationSet TwoToThreeDaysAWeeksOption ResilienceSurveyQuestionOption3 -> - { english = "4 to 5 days a week" - , kinyarwanda = Just "Kane kugera kuri gatanu mu cyumweru" - , kirundi = Nothing - } + translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - { english = "Almost everyday (6-7 days)" - , kinyarwanda = Just "Buri munsi (iminsi 6-7)" - , kirundi = Nothing - } + translationSet AlmostEverydayOption ResilienceSurveyQuestion3 -> case option of @@ -19781,28 +19809,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once in last six months" - , kinyarwanda = Just "Rimwe mu mezi atandatu ashize" - , kirundi = Nothing - } + translationSet OnceInLastSixMonthsOption ResilienceSurveyQuestionOption2 -> - { english = "Once in last three months" - , kinyarwanda = Just "Rimwe mu mezi atatu ashize" - , kirundi = Nothing - } + translationSet OnceInLastThreeMonthsOption ResilienceSurveyQuestionOption3 -> - { english = "Once in the last two months" - , kinyarwanda = Just "Rimwe mu mezi abiri ashize" - , kirundi = Nothing - } + translationSet OnceInTheLastTwoMonthsOption ResilienceSurveyQuestionOption4 -> - { english = "Once every month" - , kinyarwanda = Just "Rimwe buri kwezi" - , kirundi = Nothing - } + translationSet OnceAMonth ResilienceSurveyQuestion4 -> case option of @@ -19810,28 +19826,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption2 -> - { english = "2 to 3 days a week" - , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" - , kirundi = Nothing - } + translationSet TwoToThreeDaysAWeeksOption ResilienceSurveyQuestionOption3 -> - { english = "4 to 5 days a week" - , kinyarwanda = Just "Kane kugera kuri gatanu mu cyumweru" - , kirundi = Nothing - } + translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - { english = "Almost everyday (6-7 days)" - , kinyarwanda = Just "Buri munsi (iminsi 6-7)" - , kirundi = Nothing - } + translationSet AlmostEverydayOption ResilienceSurveyQuestion5 -> case option of @@ -19839,28 +19843,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption2 -> - { english = "2 to 3 days a week" - , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" - , kirundi = Nothing - } + translationSet TwoToThreeDaysAWeeksOption ResilienceSurveyQuestionOption3 -> - { english = "4 to 5 days a week" - , kinyarwanda = Just "Kane kugera kuri gatanu mu cyumweru" - , kirundi = Nothing - } + translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - { english = "Almost everyday (6-7 days)" - , kinyarwanda = Just "Buri munsi (iminsi 6-7)" - , kirundi = Nothing - } + translationSet AlmostEverydayOption ResilienceSurveyQuestion6 -> case option of @@ -19868,28 +19860,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once in last six months" - , kinyarwanda = Just "Rimwe mu mezi atandatu ashize" - , kirundi = Nothing - } + translationSet OnceInLastSixMonthsOption ResilienceSurveyQuestionOption2 -> - { english = "Once in last three months" - , kinyarwanda = Just "Rimwe mu mezi atatu ashize" - , kirundi = Nothing - } + translationSet OnceInLastThreeMonthsOption ResilienceSurveyQuestionOption3 -> - { english = "Once in the last two months" - , kinyarwanda = Just "Rimwe mu mezi abiri ashize" - , kirundi = Nothing - } + translationSet OnceInTheLastTwoMonthsOption ResilienceSurveyQuestionOption4 -> - { english = "Once every month" - , kinyarwanda = Just "Rimwe buri kwezi" - , kirundi = Nothing - } + translationSet OnceAMonth ResilienceSurveyQuestion7 -> case option of @@ -19897,22 +19877,13 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once in last six months" - , kinyarwanda = Just "Rimwe mu mezi atandatu ashize" - , kirundi = Nothing - } + translationSet OnceInLastSixMonthsOption ResilienceSurveyQuestionOption2 -> - { english = "Once in last three months" - , kinyarwanda = Just "Rimwe mu mezi atatu ashize" - , kirundi = Nothing - } + translationSet OnceInLastThreeMonthsOption ResilienceSurveyQuestionOption3 -> - { english = "Once in the last two months" - , kinyarwanda = Just "Rimwe mu mezi abiri ashize" - , kirundi = Nothing - } + translationSet OnceInTheLastTwoMonthsOption ResilienceSurveyQuestionOption4 -> { english = "Once every month" @@ -19926,28 +19897,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption2 -> - { english = "2 to 3 days a week" - , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" - , kirundi = Nothing - } + translationSet TwoToThreeDaysAWeeksOption ResilienceSurveyQuestionOption3 -> - { english = "4 to 5 days a week" - , kinyarwanda = Just "Kane kugera kuri gatanu mu cyumweru" - , kirundi = Nothing - } + translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - { english = "Almost everyday (6-7 days)" - , kinyarwanda = Just "Buri munsi (iminsi 6-7)" - , kirundi = Nothing - } + translationSet AlmostEverydayOption ResilienceSurveyQuestion9 -> case option of @@ -19955,28 +19914,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a month" - , kinyarwanda = Just "Rimwe mu kwezi" - , kirundi = Nothing - } + translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - { english = "Twice a month" - , kinyarwanda = Just "Kabiri mu kwezi" - , kirundi = Nothing - } + translationSet TwiceAMonthOption ResilienceSurveyQuestionOption3 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption4 -> - { english = "2 and more days a week" - , kinyarwanda = Just "Iminsi 2 kuzamura mu cyumweru" - , kirundi = Nothing - } + translationSet TwoAndMoreDaysAWeekOption ResilienceSurveyQuestion10 -> case option of @@ -19984,28 +19931,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a month" - , kinyarwanda = Just "Rimwe mu kwezi" - , kirundi = Nothing - } + translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - { english = "Twice a month" - , kinyarwanda = Just "Kabiri mu kwezi" - , kirundi = Nothing - } + translationSet TwiceAMonthOption ResilienceSurveyQuestionOption3 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption4 -> - { english = "2 and more days a week" - , kinyarwanda = Just "Iminsi 2 kuzamura mu cyumweru" - , kirundi = Nothing - } + translationSet TwoAndMoreDaysAWeekOption ResilienceSurveyQuestion11 -> case option of @@ -20013,28 +19948,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a month" - , kinyarwanda = Just "Rimwe mu kwezi" - , kirundi = Nothing - } + translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - { english = "Twice a month" - , kinyarwanda = Just "Kabiri mu kwezi" - , kirundi = Nothing - } + translationSet TwiceAMonthOption ResilienceSurveyQuestionOption3 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption4 -> - { english = "2 and more days a week" - , kinyarwanda = Just "Iminsi 2 kuzamura mu cyumweru" - , kirundi = Nothing - } + translationSet TwoAndMoreDaysAWeekOption ResilienceSurveyQuestion12 -> case option of @@ -20042,28 +19965,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - { english = "Once a month" - , kinyarwanda = Just "Rimwe mu kwezi" - , kirundi = Nothing - } + translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - { english = "Twice a month" - , kinyarwanda = Just "Kabiri mu kwezi" - , kirundi = Nothing - } + translationSet TwiceAMonthOption ResilienceSurveyQuestionOption3 -> - { english = "Once a week" - , kinyarwanda = Just "Rimwe mu cyumweru" - , kirundi = Nothing - } + translationSet OnceAWeekOption ResilienceSurveyQuestionOption4 -> - { english = "2 and more days a week" - , kinyarwanda = Just "Iminsi 2 kuzamura mu cyumweru" - , kirundi = Nothing - } + translationSet TwoAndMoreDaysAWeekOption ResilienceReminderHeader name reminderType -> case reminderType of @@ -22397,6 +22308,24 @@ translationSet trans = , kirundi = Just "Umugwayi afise ingorane iri hejuru y'ingwara y'igituntu" } + TwiceAMonthOption -> + { english = "Twice a month" + , kinyarwanda = Just "Kabiri mu kwezi" + , kirundi = Nothing + } + + TwoAndMoreDaysAWeekOption -> + { english = "2 and more days a week" + , kinyarwanda = Just "Iminsi 2 kuzamura mu cyumweru" + , kirundi = Nothing + } + + TwoToThreeDaysAWeeksOption -> + { english = "2 to 3 days a week" + , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" + , kirundi = Nothing + } + TwoVisits -> { english = "Two visits" , kinyarwanda = Just "Inshuro ebyiri" From 7400c4fa55bc14bf6bda128820694db4cdb75d35 Mon Sep 17 00:00:00 2001 From: Diama1 Date: Wed, 7 Aug 2024 10:35:40 +0200 Subject: [PATCH 57/63] fix --- client/src/elm/Translate.elm | 104 +++++++++++++++++------------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index e93753c467..6925e9ab90 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -413,7 +413,7 @@ type TranslationId | AILaboratoryTask AILaboratoryTask | All | AllowedValuesRangeHelper FloatInputConstraints - | AlmostEverydayOption + | AlmostEveryday | AmbulancArrivalPeriodQuestion | ANCEncountersNotRecordedQuestion | ANCIndicateVisitsMonthsPhrase @@ -1131,10 +1131,10 @@ type TranslationId | On | OneVisit | OnceAMonth - | OnceAWeekOption - | OnceInLastSixMonthsOption - | OnceInLastThreeMonthsOption - | OnceInTheLastTwoMonthsOption + | OnceAWeek + | OnceInLastSixMonths + | OnceInLastThreeMonths + | OnceInTheLastTwoMonths | OnceYouEndTheEncounter | OnceYouEndYourGroupEncounter | OngoingTreatmentTask OngoingTreatmentTask @@ -1799,9 +1799,9 @@ type TranslationId | TuberculosisSuspect | TuberculosisSymptomQuestion TuberculosisSymptom | TuberculosisWarning - | TwiceAMonthOption - | TwoAndMoreDaysAWeekOption - | TwoToThreeDaysAWeeksOption + | TwiceAMonth + | TwoAndMoreDaysAWeek + | TwoToThreeDaysAWeek | TwoVisits | Type | UbudeheLabel @@ -3170,7 +3170,7 @@ translationSet trans = , kirundi = Just "Akahise ko kugenderwa imbere yo kuvyara" } - AlmostEverydayOption -> + AlmostEveryday -> { english = "Almost everyday (6-7 days)" , kinyarwanda = Just "Buri munsi (iminsi 6-7)" , kirundi = Nothing @@ -13094,25 +13094,25 @@ translationSet trans = , kirundi = Nothing } - OnceAWeekOption -> + OnceAWeek -> { english = "Once a week" , kinyarwanda = Just "Rimwe mu cyumweru" , kirundi = Nothing } - OnceInLastSixMonthsOption -> + OnceInLastSixMonths -> { english = "Once in last six months" , kinyarwanda = Just "Rimwe mu mezi atandatu ashize" , kirundi = Nothing } - OnceInLastThreeMonthsOption -> + OnceInLastThreeMonths -> { english = "Once in last three months" , kinyarwanda = Just "Rimwe mu mezi atatu ashize" , kirundi = Nothing } - OnceInTheLastTwoMonthsOption -> + OnceInTheLastTwoMonths -> { english = "Once in the last two months" , kinyarwanda = Just "Rimwe mu mezi abiri ashize" , kirundi = Nothing @@ -19775,16 +19775,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption2 -> - translationSet TwoToThreeDaysAWeeksOption + translationSet TwoToThreeDaysAWeek ResilienceSurveyQuestionOption3 -> translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - translationSet AlmostEverydayOption + translationSet AlmostEveryday ResilienceSurveyQuestion2 -> case option of @@ -19792,16 +19792,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption2 -> - translationSet TwoToThreeDaysAWeeksOption + translationSet TwoToThreeDaysAWeek ResilienceSurveyQuestionOption3 -> translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - translationSet AlmostEverydayOption + translationSet AlmostEveryday ResilienceSurveyQuestion3 -> case option of @@ -19809,13 +19809,13 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceInLastSixMonthsOption + translationSet OnceInLastSixMonths ResilienceSurveyQuestionOption2 -> - translationSet OnceInLastThreeMonthsOption + translationSet OnceInLastThreeMonths ResilienceSurveyQuestionOption3 -> - translationSet OnceInTheLastTwoMonthsOption + translationSet OnceInTheLastTwoMonths ResilienceSurveyQuestionOption4 -> translationSet OnceAMonth @@ -19826,16 +19826,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption2 -> - translationSet TwoToThreeDaysAWeeksOption + translationSet TwoToThreeDaysAWeek ResilienceSurveyQuestionOption3 -> translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - translationSet AlmostEverydayOption + translationSet AlmostEveryday ResilienceSurveyQuestion5 -> case option of @@ -19843,16 +19843,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption2 -> - translationSet TwoToThreeDaysAWeeksOption + translationSet TwoToThreeDaysAWeek ResilienceSurveyQuestionOption3 -> translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - translationSet AlmostEverydayOption + translationSet AlmostEveryday ResilienceSurveyQuestion6 -> case option of @@ -19860,13 +19860,13 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceInLastSixMonthsOption + translationSet OnceInLastSixMonths ResilienceSurveyQuestionOption2 -> - translationSet OnceInLastThreeMonthsOption + translationSet OnceInLastThreeMonths ResilienceSurveyQuestionOption3 -> - translationSet OnceInTheLastTwoMonthsOption + translationSet OnceInTheLastTwoMonths ResilienceSurveyQuestionOption4 -> translationSet OnceAMonth @@ -19877,13 +19877,13 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceInLastSixMonthsOption + translationSet OnceInLastSixMonths ResilienceSurveyQuestionOption2 -> - translationSet OnceInLastThreeMonthsOption + translationSet OnceInLastThreeMonths ResilienceSurveyQuestionOption3 -> - translationSet OnceInTheLastTwoMonthsOption + translationSet OnceInTheLastTwoMonths ResilienceSurveyQuestionOption4 -> { english = "Once every month" @@ -19897,16 +19897,16 @@ translationSet trans = translationSet Never ResilienceSurveyQuestionOption1 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption2 -> - translationSet TwoToThreeDaysAWeeksOption + translationSet TwoToThreeDaysAWeek ResilienceSurveyQuestionOption3 -> translationSet FourToFiveDaysAWeek ResilienceSurveyQuestionOption4 -> - translationSet AlmostEverydayOption + translationSet AlmostEveryday ResilienceSurveyQuestion9 -> case option of @@ -19917,13 +19917,13 @@ translationSet trans = translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - translationSet TwiceAMonthOption + translationSet TwiceAMonth ResilienceSurveyQuestionOption3 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption4 -> - translationSet TwoAndMoreDaysAWeekOption + translationSet TwoAndMoreDaysAWeek ResilienceSurveyQuestion10 -> case option of @@ -19934,13 +19934,13 @@ translationSet trans = translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - translationSet TwiceAMonthOption + translationSet TwiceAMonth ResilienceSurveyQuestionOption3 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption4 -> - translationSet TwoAndMoreDaysAWeekOption + translationSet TwoAndMoreDaysAWeek ResilienceSurveyQuestion11 -> case option of @@ -19951,13 +19951,13 @@ translationSet trans = translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - translationSet TwiceAMonthOption + translationSet TwiceAMonth ResilienceSurveyQuestionOption3 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption4 -> - translationSet TwoAndMoreDaysAWeekOption + translationSet TwoAndMoreDaysAWeek ResilienceSurveyQuestion12 -> case option of @@ -19968,13 +19968,13 @@ translationSet trans = translationSet OnceAMonth ResilienceSurveyQuestionOption2 -> - translationSet TwiceAMonthOption + translationSet TwiceAMonth ResilienceSurveyQuestionOption3 -> - translationSet OnceAWeekOption + translationSet OnceAWeek ResilienceSurveyQuestionOption4 -> - translationSet TwoAndMoreDaysAWeekOption + translationSet TwoAndMoreDaysAWeek ResilienceReminderHeader name reminderType -> case reminderType of @@ -22308,19 +22308,19 @@ translationSet trans = , kirundi = Just "Umugwayi afise ingorane iri hejuru y'ingwara y'igituntu" } - TwiceAMonthOption -> + TwiceAMonth -> { english = "Twice a month" , kinyarwanda = Just "Kabiri mu kwezi" , kirundi = Nothing } - TwoAndMoreDaysAWeekOption -> + TwoAndMoreDaysAWeek -> { english = "2 and more days a week" , kinyarwanda = Just "Iminsi 2 kuzamura mu cyumweru" , kirundi = Nothing } - TwoToThreeDaysAWeeksOption -> + TwoToThreeDaysAWeek -> { english = "2 to 3 days a week" , kinyarwanda = Just "Kabiri kugera kuri gatatu mu cyumweru" , kirundi = Nothing From 3320675bc9f5e75c827672625ecceba28e652e95 Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 7 Aug 2024 21:49:28 +0300 Subject: [PATCH 58/63] Implement script --- .../hedley_admin/scripts/muac-report.php | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 server/hedley/modules/custom/hedley_admin/scripts/muac-report.php diff --git a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php new file mode 100644 index 0000000000..cd1650c288 --- /dev/null +++ b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php @@ -0,0 +1,142 @@ +fields('n', ['nid', 'title']); +$query->condition('type', 'health_center'); +$result = $query->execute()->fetchAll(); +$health_centers = []; +foreach ($result as $row) { + $health_centers[$row->nid] = $row->title; +} + +// Resolve all Nurses. We need to determine if measurement was taken +// by nurse or CHW. +$query = db_select('field_data_field_role', 'fr') + ->fields('fr', ['entity_id']); +$query->condition('fr.field_role_value', 'nurse'); +$nurses = $query->execute()->fetchCol(); + +$encounter_types = [ + 'acute_illness_muac', + 'child_scoreboard_ncda', + 'muac', + 'nutrition_muac', + 'well_child_muac', +]; + +$query = db_select('node', 'node'); +$query->fields('node', ['nid', 'type']); +$query->condition('type', $encounter_types, 'IN'); +$query->condition('status', NODE_PUBLISHED); + +$field_to_join = [ + 'field_person', + 'field_muac', + 'field_nurse', + 'field_date_measured', + 'field_shards', +]; + +foreach ($field_to_join as $field) { + hedley_general_join_field_to_query($query, 'node', $field); +} + +$query->leftJoin('field_data_field_district', 'field_district', 'field_person.field_person_target_id = field_district.entity_id'); +$query->addField('field_district', 'field_district_value', 'field_district'); + +$query->leftJoin('field_data_field_birth_date', 'field_birth_date', 'field_person.field_person_target_id = field_birth_date.entity_id'); +$query->addField('field_birth_date', 'field_birth_date_value', 'field_birth_date'); +$two_years_ago = date('Y-m-d', strtotime('-2 years')); +$query->condition('field_date_measured.field_date_measured_value', $two_years_ago, '>='); +$query->range(0, $batch); +$query->orderBy('node.nid'); + +$nid = 0; +$rows[0] = ['Patient ID', 'MUAC Value', 'Date Measured (YYYY-MM-DD)', 'Nurse/CHW', 'Health Center', 'District']; +while (TRUE) { + // Free up memory. + drupal_static_reset(); + + $batch_query = clone $query; + if ($nid) { + $batch_query->condition('node.nid', $nid, '>'); + } + + $result = $batch_query->execute()->fetchAll(); + + if (empty($result)) { + // No more items left. + break; + } + $nid = end($result)->nid; + + foreach ($result as $row) { + $measured_date = explode(' ', $row->field_date_measured)[0]; + $birth_date = explode(' ', $row->field_birth_date)[0]; + + $measured_date_obj = new DateTime($measured_date); + $birth_date_obj = new DateTime($birth_date); + + // Calculate the age at the time of measurement. + $age_interval = $birth_date_obj->diff($measured_date_obj); + // If age is above 5 years, skip the measurement. + if ($age_interval->y >= 5) { + continue; + } + + // If currently recorded measurement for patient is more + // recent that than the one being processed, skip processing. + if ($rows[$row->field_person]) { + $current_measured_date_obj = new DateTime($rows[$row->nid][2]); + if ($current_measured_date_obj >= $measured_date_obj) { + continue; + } + } + + $nurse_type = in_array($row->field_nurse, $nurses) ? 'nurse' : 'chw'; + + $rows[$row->field_person] = [ + $row->field_person, + $row->field_muac, + $measured_date, + $nurse_type, + $health_centers[$row->field_shards], + $row->field_district, + ]; + } + + $total = count($result); +} + +foreach ($rows as $row) { + $row_as_string = implode(',', $row); + drush_print($row_as_string); +} + + + + From f4a1d5e164682cb4a938527c46a53ee46d938274 Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 7 Aug 2024 22:01:52 +0300 Subject: [PATCH 59/63] Satisfy coder --- .../custom/hedley_admin/scripts/muac-report.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php index cd1650c288..2ce0eeee45 100644 --- a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php +++ b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php @@ -76,7 +76,15 @@ $query->orderBy('node.nid'); $nid = 0; -$rows[0] = ['Patient ID', 'MUAC Value', 'Date Measured (YYYY-MM-DD)', 'Nurse/CHW', 'Health Center', 'District']; +$rows[0] = [ + 'Patient ID', + 'MUAC Value', + 'Date Measured (YYYY-MM-DD)', + 'Nurse/CHW', + 'Health Center', + 'District', +]; + while (TRUE) { // Free up memory. drupal_static_reset(); @@ -136,7 +144,3 @@ $row_as_string = implode(',', $row); drush_print($row_as_string); } - - - - From 513711d64be703ea7043ea173bfa3cc77d326791 Mon Sep 17 00:00:00 2001 From: anvmn Date: Wed, 7 Aug 2024 22:04:11 +0300 Subject: [PATCH 60/63] Adjustments --- .../modules/custom/hedley_admin/scripts/muac-report.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php index 2ce0eeee45..fdb927b419 100644 --- a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php +++ b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php @@ -2,11 +2,7 @@ /** * @file - * Locates all Well child encounters where Head Circumferences value was set. - * - * Checks if 'no-head-circumference-warning' warning is set (which is wrong, - * as Head Circumferences has valid value). - * If found, 'no-head-circumference-warning' warning is deleted. + * Genrates MUAC report. * * Drush scr * profiles/hedley/modules/custom/hedley_admin/scripts/muac-report.php. @@ -18,7 +14,7 @@ } // Get the number of nodes to be processed. -$batch = drush_get_option('batch', 50); +$batch = drush_get_option('batch', 500); // Get allowed memory limit. $memory_limit = drush_get_option('memory_limit', 500); From 58fbc29a4d9fc373f69d06458f1f94c928455603 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 8 Aug 2024 09:35:13 +0300 Subject: [PATCH 61/63] Add encounter type --- .../custom/hedley_admin/scripts/muac-report.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php index fdb927b419..56687ea32e 100644 --- a/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php +++ b/server/hedley/modules/custom/hedley_admin/scripts/muac-report.php @@ -37,16 +37,16 @@ $nurses = $query->execute()->fetchCol(); $encounter_types = [ - 'acute_illness_muac', - 'child_scoreboard_ncda', - 'muac', - 'nutrition_muac', - 'well_child_muac', + 'acute_illness_muac' => 'Acute Illness', + 'child_scoreboard_ncda' => 'Child Scorecard', + 'muac' => 'Nutrition Group', + 'nutrition_muac' => 'Nutrition Group', + 'well_child_muac' => 'SPV', ]; $query = db_select('node', 'node'); $query->fields('node', ['nid', 'type']); -$query->condition('type', $encounter_types, 'IN'); +$query->condition('type', array_keys($encounter_types), 'IN'); $query->condition('status', NODE_PUBLISHED); $field_to_join = [ @@ -77,6 +77,7 @@ 'MUAC Value', 'Date Measured (YYYY-MM-DD)', 'Nurse/CHW', + 'Encounter Type', 'Health Center', 'District', ]; @@ -128,6 +129,7 @@ $row->field_muac, $measured_date, $nurse_type, + $encounter_types[$row->type], $health_centers[$row->field_shards], $row->field_district, ]; From 808f41a097a6c3b56a4fbea7c12621a1b1f94259 Mon Sep 17 00:00:00 2001 From: anvmn Date: Thu, 8 Aug 2024 14:14:14 +0300 Subject: [PATCH 62/63] Fix https://github.com/TIP-Global-Health/eheza-app/issues/1253#issuecomment-2275243567, point 2 [ci skip] --- client/src/elm/Pages/HIV/Activity/Utils.elm | 76 ++++++++++--------- .../elm/Pages/Tuberculosis/Activity/Utils.elm | 76 ++++++++++--------- 2 files changed, 80 insertions(+), 72 deletions(-) diff --git a/client/src/elm/Pages/HIV/Activity/Utils.elm b/client/src/elm/Pages/HIV/Activity/Utils.elm index ff9a3be732..9c44477877 100644 --- a/client/src/elm/Pages/HIV/Activity/Utils.elm +++ b/client/src/elm/Pages/HIV/Activity/Utils.elm @@ -538,44 +538,48 @@ prescribedMedicationsInputsAndTasks language currentDate assembled form = ( recordMedicationsInputs, recordMedicationsTasks ) = recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsTakenQuestion form in - generateAllEncountersData assembled - |> resolvePrescribedMedicationSets HIVMedicationsNotChanged - |> Tuple.first - |> Maybe.map - (\prescribedMedication -> - let - ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = - if form.medicationsNotChanged /= Just False then - ( [], ( 0, 0 ) ) + if assembled.initialEncounter then + ( recordMedicationsInputs, recordMedicationsTasks ) - else - ( recordMedicationsInputs, recordMedicationsTasks ) - - prescribedMedicationForView = - EverySet.toList prescribedMedication - |> List.map - (\medication -> - li [] [ text <| translate language <| Translate.HIVPrescribedMedication medication ] - ) - |> ul [] - in - ( [ viewLabel language Translate.PrescribedMedication - , prescribedMedicationForView - , viewQuestionLabel language Translate.PrescribedMedicationsChangedQuestion - , viewBoolInput - language - form.medicationsNotChanged - SetPrescribedMedicationsNotChanged - "medications-changed" - Nothing - ] - ++ derivedInputs - , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted - , 1 + derivedTasksTotal - ) + else + generateAllEncountersData assembled + |> resolvePrescribedMedicationSets HIVMedicationsNotChanged + |> Tuple.first + |> Maybe.map + (\prescribedMedication -> + let + ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = + if form.medicationsNotChanged /= Just False then + ( [], ( 0, 0 ) ) + + else + ( recordMedicationsInputs, recordMedicationsTasks ) + + prescribedMedicationForView = + EverySet.toList prescribedMedication + |> List.map + (\medication -> + li [] [ text <| translate language <| Translate.HIVPrescribedMedication medication ] + ) + |> ul [] + in + ( [ viewLabel language Translate.PrescribedMedication + , prescribedMedicationForView + , viewQuestionLabel language Translate.PrescribedMedicationsChangedQuestion + , viewBoolInput + language + form.medicationsNotChanged + SetPrescribedMedicationsNotChanged + "medications-changed" + Nothing + ] + ++ derivedInputs + , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted + , 1 + derivedTasksTotal + ) + ) ) - ) - |> Maybe.withDefault (recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsQuestion form) + |> Maybe.withDefault ( recordMedicationsInputs, recordMedicationsTasks ) recordMedicationsInputsAndTasks : diff --git a/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm b/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm index 81b1138749..3edec36261 100644 --- a/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm +++ b/client/src/elm/Pages/Tuberculosis/Activity/Utils.elm @@ -666,44 +666,48 @@ prescribedMedicationsInputsAndTasks language currentDate assembled form = ( recordMedicationsInputs, recordMedicationsTasks ) = recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsTakenQuestion form in - generateAllEncountersData assembled - |> resolvePrescribedMedicationSets TuberculosisMedicationsNotChanged - |> Tuple.first - |> Maybe.map - (\prescribedMedication -> - let - ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = - if form.medicationsNotChanged /= Just False then - ( [], ( 0, 0 ) ) + if assembled.initialEncounter then + ( recordMedicationsInputs, recordMedicationsTasks ) - else - ( recordMedicationsInputs, recordMedicationsTasks ) - - prescribedMedicationForView = - EverySet.toList prescribedMedication - |> List.map - (\medication -> - li [] [ text <| translate language <| Translate.TuberculosisPrescribedMedication medication ] - ) - |> ul [] - in - ( [ viewLabel language Translate.PrescribedMedication - , prescribedMedicationForView - , viewQuestionLabel language Translate.PrescribedMedicationsChangedQuestion - , viewBoolInput - language - form.medicationsNotChanged - SetPrescribedMedicationsNotChanged - "medications-changed" - Nothing - ] - ++ derivedInputs - , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted - , 1 + derivedTasksTotal - ) + else + generateAllEncountersData assembled + |> resolvePrescribedMedicationSets TuberculosisMedicationsNotChanged + |> Tuple.first + |> Maybe.map + (\prescribedMedication -> + let + ( derivedInputs, ( derivedTasksCompleted, derivedTasksTotal ) ) = + if form.medicationsNotChanged /= Just False then + ( [], ( 0, 0 ) ) + + else + ( recordMedicationsInputs, recordMedicationsTasks ) + + prescribedMedicationForView = + EverySet.toList prescribedMedication + |> List.map + (\medication -> + li [] [ text <| translate language <| Translate.TuberculosisPrescribedMedication medication ] + ) + |> ul [] + in + ( [ viewLabel language Translate.PrescribedMedication + , prescribedMedicationForView + , viewQuestionLabel language Translate.PrescribedMedicationsChangedQuestion + , viewBoolInput + language + form.medicationsNotChanged + SetPrescribedMedicationsNotChanged + "medications-changed" + Nothing + ] + ++ derivedInputs + , ( taskCompleted form.medicationsNotChanged + derivedTasksCompleted + , 1 + derivedTasksTotal + ) + ) ) - ) - |> Maybe.withDefault (recordMedicationsInputsAndTasks language Translate.PrescribedMedicationsQuestion form) + |> Maybe.withDefault ( recordMedicationsInputs, recordMedicationsTasks ) recordMedicationsInputsAndTasks : From 99a99baa17b4347d5cf3a8bd19b26499541a7aa1 Mon Sep 17 00:00:00 2001 From: anvmn Date: Sun, 11 Aug 2024 10:01:07 +0300 Subject: [PATCH 63/63] A fix --- client/src/elm/Translate.elm | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/elm/Translate.elm b/client/src/elm/Translate.elm index 2059d8cf86..c12bd46b71 100644 --- a/client/src/elm/Translate.elm +++ b/client/src/elm/Translate.elm @@ -3017,6 +3017,7 @@ translationSet trans = AdoptionSurveyProgressSame -> { english = "You remained in the same category." , kinyarwanda = Just "Wagumye mu cyiciro kimwe." + , kirundi = Nothing } AdverseEvent event ->