Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMPRO opt out UI #4335

Merged
merged 40 commits into from
Mar 21, 2024
Merged

Conversation

achen2401
Copy link
Contributor

@achen2401 achen2401 commented Aug 14, 2023

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

  • frontend submits the domain(s) that user has chosen to opt out to the backend API, /api/patient/<user_id>/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

@achen2401
Copy link
Contributor Author

achen2401 commented Aug 14, 2023

@pbugni this is an example of the data that the frontend will be sending back to the backend to be saved in the database, once the user has selected one or more domains to opt out:

{
    "user_id": 4105,
    "visit_month": 1,
    "opt_out_domains": [
        "fatigue",
        "general_pain"
    ]
}

I am not sure if that is the right format and what API the frontend should submit the chosen options to to be saved in the db?

Amy Chen and others added 17 commits September 5, 2023 12:17
… counts, so the test db can be switched over to a hotfix without this migration.
log rather than blow up, when a finding missing SDC observations.
…g errors.

improve logging when trigger_states become out of sync with qb_timeline due to consent change.
@pep8speaks
Copy link

Hello @achen2401! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 45:101: E501 line too long (105 > 100 characters)
Line 50:101: E501 line too long (103 > 100 characters)
Line 52:1: E302 expected 2 blank lines, found 1
Line 158:101: E501 line too long (118 > 100 characters)

Line 100:101: E501 line too long (105 > 100 characters)
Line 157:101: E501 line too long (109 > 100 characters)

Line 280:101: E501 line too long (101 > 100 characters)

@achen2401 achen2401 changed the base branch from develop to feature/sequential-hard-triggers-fix March 15, 2024 16:32
@achen2401 achen2401 requested a review from pbugni March 15, 2024 16:35
@pbugni
Copy link
Collaborator

pbugni commented Mar 15, 2024

Hi @achen2401 , yes, let's use ad-hoc JSON such as the following. This would set it for the same two domains only, from your example above.

I'm attempting to use the same format you get from https://eproms.truenth.org/api/patient/<id>/triggers, but simplified down to just set the opt-out domains of choice:

{
  "triggers": {
    "domain": {
      "fatigue": {
        "_opt_out_next_visit": "true"
      },
      "general_pain": {
        "_opt_out_next_visit": "true"
      }
    }
  }
  "user_id": 1234,
  "visit_month": 7
}

please PUT/POST that to /api/patient/<user_id>/triggers/opt_out (which isn't ready yet, but will be soon)

@achen2401 achen2401 marked this pull request as ready for review March 19, 2024 17:50
@achen2401
Copy link
Contributor Author

please PUT/POST that to /api/patient/<user_id>/triggers/opt_out (which isn't ready yet, but will be soon)
@pbugni thank you, noting that frontend now calls this API. I have modified the code accordingly.

Copy link
Member

@mcjustin mcjustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @achen2401 just had one question...

emproObj.prototype.handleSubmitOptoutData = function () {
if (!EmproObj.hasSelectedOptOutDomains()) {
EmproObj.setOptoutError(
"Please check at least one checkbox. Otherwise click 'Continue'."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this referring to the button labelled "DISMISS", not "Continue"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @mcjustin. I have fixed the text now so when the user didn't select a checkbox, this is what will show:
Error

Does the "Continue" button seem redundant? If so, I will remove.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems redundant. Thanks for this screenshot... stepping back a bit, I don't recall that they should check at least one checkbox. Do you see that documented anywhere?
If it's not a requirement, then if they click DISMISS and they haven't selected anything yet, perhaps we should show text that says "Are you certain that you don't want to select anything? If so, click DISMISS again."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcjustin right, I don't recall either, that it is a requirement. I made the changes and attached is the latest screenshot after the user clicks DISMISS and hasn't selected anything:
dismiss

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks Amy!

@pbugni pbugni force-pushed the feature/sequential-hard-triggers-fix branch from 9c29d3b to 7f4bb5e Compare March 20, 2024 16:40
Copy link
Collaborator

@pbugni pbugni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @achen2401

@achen2401 achen2401 merged commit 7b16760 into feature/sequential-hard-triggers-fix Mar 21, 2024
2 checks passed
@achen2401 achen2401 deleted the feature/opt-out-UI branch March 21, 2024 16:00
@pbugni pbugni mentioned this pull request Mar 22, 2024
pbugni added a commit that referenced this pull request Mar 27, 2024
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/<user_id>/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 <clone@cesium.cirg.washington.edu>
Co-authored-by: Paul Bugni <pbugni@u.washington.edu>
pbugni added a commit that referenced this pull request Mar 29, 2024
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/<user_id>/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 <clone@cesium.cirg.washington.edu>
Co-authored-by: Paul Bugni <pbugni@u.washington.edu>
pbugni added a commit that referenced this pull request Jul 2, 2024
Monster PR to implement the opt-out feature.
included front end changes from #4335
reused a migration (by altering the order defined within the migration
files `down_revision` variable), and corrected as the previous
sequential counts we not keeping up. (TN-3274)

includes implementations for:
- TN-3236
- TN-3237
- TN-3238
- TN-3243
- TN-3289
- TN-3240

---------

Co-authored-by: Amy Chen <achen2401@gmail.com>
Co-authored-by: Amy Chen <clone@cesium.cirg.washington.edu>
Co-authored-by: Justin McReynolds <mcjustin@uw.edu>
Co-authored-by: Ivan Cvitkovic <ivanc@uw.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants