From 7b167607d1601ab1f024d4fe5aacb93913c47fc2 Mon Sep 17 00:00:00 2001 From: Amy Chen Date: Thu, 21 Mar 2024 09:00:53 -0700 Subject: [PATCH] EMPRO opt out UI (#4335) https://movember.atlassian.net/browse/TN-3252 - Frontend calls the trigger api, i.e. `/api/patient/[userId]/trigger` to retrieve the latest triggers and check if there is any that has `_sequential_hard_trigger_count` > 1 (meaning then that it has been asked previously) (see example triggers JSON): ``` { ... "timestamp": "2023-07-31T23:17:03+00:00", "triggers": { "domains": { "anxious": { "ironman_ss.11": "hard", "ironman_ss.12": "hard", "ironman_ss.13": "hard", "_sequential_hard_trigger_count": 3 }, "fatigue": { "ironman_ss.10": "hard", "ironman_ss.9": "hard", "_sequential_hard_trigger_count": 2 }, "general_pain": { "ironman_ss.1": "hard", "ironman_ss.2": "hard", "ironman_ss.3": "hard", "_sequential_hard_trigger_count": 3 }, "joint_pain": { "ironman_ss.4": "hard", "ironman_ss.5": "hard", "ironman_ss.6": "hard", "_sequential_hard_trigger_count": 2 }, "sad": { "ironman_ss.17": "hard", "ironman_ss.18": "hard", "ironman_ss.19": "hard", "_sequential_hard_trigger_count": 3 }, } } ... } ``` - If it finds any qualifying domains, it will present the OPT-OUT UI modal to the user, with the checkbox(es) that allow user to select which domain(s) to opt out: ![OptoutInputs](https://github.com/uwcirg/truenth-portal/assets/12942714/e4679692-1f3a-4e75-bed0-27a22376d55f) - frontend submits the domain(s) that user has chosen to opt out to the backend API, `/api/patient//triggers/opt_out`, to be saved on the database for later use (e.g. use in clinician email, adherence report) - One user submits the request, the EMPRO thank you modal that follows will display which(s) domains the user has chosen to opt out: ![OptoutChosen](https://github.com/uwcirg/truenth-portal/assets/12942714/5752b438-eb89-4e4c-a113-98d9a8497a40) --------- Co-authored-by: Amy Chen Co-authored-by: Paul Bugni --- .../templates/eproms/assessment_engine.html | 4 + .../eproms/assessment_engine/ae_base.html | 1 + .../eproms/assessment_engine/ae_due.html | 2 +- .../eproms/assessment_engine/ae_macros.html | 78 +- .../test/SubStudyQuestionnaireTestData.json | 371 ++++++++++ .../data/common/test/TestTriggersData.json | 111 +++ portal/static/js/src/empro.js | 693 +++++++++++++----- portal/static/js/src/modules/TnthAjax.js | 16 + portal/static/less/eproms.less | 130 +++- 9 files changed, 1220 insertions(+), 186 deletions(-) create mode 100644 portal/static/js/src/data/common/test/SubStudyQuestionnaireTestData.json create mode 100644 portal/static/js/src/data/common/test/TestTriggersData.json diff --git a/portal/eproms/templates/eproms/assessment_engine.html b/portal/eproms/templates/eproms/assessment_engine.html index aa86fd8526..43aec99d35 100644 --- a/portal/eproms/templates/eproms/assessment_engine.html +++ b/portal/eproms/templates/eproms/assessment_engine.html @@ -31,3 +31,7 @@
{% endif %} +{%- from "eproms/assessment_engine/ae_macros.html" import empro_thankyou_modal, empro_optout_modal -%} +{{empro_optout_modal(user)}} +{{empro_thankyou_modal(user)}} + diff --git a/portal/eproms/templates/eproms/assessment_engine/ae_base.html b/portal/eproms/templates/eproms/assessment_engine/ae_base.html index 58c9df09c4..4c2f8f1ac1 100644 --- a/portal/eproms/templates/eproms/assessment_engine/ae_base.html +++ b/portal/eproms/templates/eproms/assessment_engine/ae_base.html @@ -4,3 +4,4 @@
{%- block body -%}{%- endblock -%}
+
Loading ...
diff --git a/portal/eproms/templates/eproms/assessment_engine/ae_due.html b/portal/eproms/templates/eproms/assessment_engine/ae_due.html index 1352b93c85..7cf88f4ea6 100644 --- a/portal/eproms/templates/eproms/assessment_engine/ae_due.html +++ b/portal/eproms/templates/eproms/assessment_engine/ae_due.html @@ -1,4 +1,4 @@ -{%- from "eproms/assessment_engine/ae_macros.html" import render_header, render_greeting, render_card_content, render_call_to_button, due_card, completed_card, empro_due, empro_completed, empro_expired, completed_cards -%} +{%- from "eproms/assessment_engine/ae_macros.html" import render_header, render_greeting, render_card_content, render_call_to_button, due_card, completed_card, empro_due, empro_completed, empro_expired, completed_cards -%} {% extends "eproms/assessment_engine/ae_base.html" %} {% block head %} diff --git a/portal/eproms/templates/eproms/assessment_engine/ae_macros.html b/portal/eproms/templates/eproms/assessment_engine/ae_macros.html index 48ebd29e45..43e4f678bf 100644 --- a/portal/eproms/templates/eproms/assessment_engine/ae_macros.html +++ b/portal/eproms/templates/eproms/assessment_engine/ae_macros.html @@ -210,9 +210,6 @@

{{_("Completed Questionnaires")}}

{% endif %} {%- endcall -%} - {% if substudy_assessment_status.overall_status == OverallStatus.completed %} - {{empro_thankyou_modal(user)}} - {% endif %} {%- endif -%} {%- endmacro -%} {%- macro empro_thankyou_card(full_name="") -%} @@ -227,6 +224,11 @@

{{_("Your Support Team")}}

{%- endmacro -%} +{%- macro empro_no_contact_notice() -%} +
+ Note: You have chosen not to be contacted about . Your care team will not discuss these issues this month. +
+{%- endmacro -%} {%- macro empro_modal_hardTrigger_supportTeam_block(organization="") -%}

{{_("Your Support Team")}}

@@ -234,6 +236,7 @@

{{_("Your Support Team")}}

+ {{empro_no_contact_notice()}}

{{_("To help address any issues, we've informed your care team and they'll be in contact with you soon.")}}

{% if organization %}

{{_("In the meantime, if you have any questions or need assistance, please contact your team at %(organization)s directly. They're happy to help.", organization=organization)}}

@@ -270,8 +273,8 @@

{{_("Your Health Tips")}}

{%- macro empro_thankyou_modal(user) -%} -