BIDMCDigitalPsychiatry / LAMP-platform

The LAMP Platform (issues and documentation).
https://docs.lamp.digital/
Other
12 stars 10 forks source link

Setting up push notification if someone gives specific answer to Question 9 on Weekly PHQ-9 Survey #706

Closed lugray1 closed 1 year ago

lugray1 commented 1 year ago

We would like to have participants be sent a push notification if they respond '3 - nearly every day' to question 9 on the Weekly PHQ-9 Survey (question is pictured below).

The push notification would be sent immediately upon completion of the survey, and would direct the participant to a mindLAMP model in Learn for suicide hotline resources (this module has yet to be created).

IMG_1607

carlan1 commented 1 year ago

@mcurbelo-orangeloops Is this something we can do? We are open to ideas on the best way to do this, but we want something like a toggle a researcher can add to a survey, where this toggle would indicate that a notification should be sent if a certain selection is made.

ertjlane commented 1 year ago

@mcurbelo-orangeloops We would like this to be built as a broad functionality, i.e. Any researcher could theoretically assign a push notification to a specific response on a specific survey. We understand this is a more involved and time consuming process.

falmeida-orangeloops commented 1 year ago

Noted!

lugray1 commented 1 year ago

Do you have an estimated time frame for when this may be completed? Given that it's for a broad functionality, we understand that it will be a time-consuming process, but just wanted to ask

falmeida-orangeloops commented 1 year ago

Hi, sorry for the delay! I'll look into this and get back promptly

ertjlane commented 1 year ago

For the time being is it possible to implement this as a specific change for this item on this survey, rather than a comprehensive feature of mindLAMP?

lugray1 commented 1 year ago

Updating this issue to propose a simpler way of doing this (editing Survey question settings to have popup instead of push notification) from #385

Support warnings popups

In addition to these, a new field warnings should be added. This field will contain a dictionary mapping of values to text, as shown below:

"warnings": { "3": "This survey is not being monitored for responses." } If the warnings field is not defined as part of a question's settings, it is ignored, to ensure backwards compatibility. If the response specified by the user exists in this warnings dictionary, then the corresponding text will be shown to the user in a simple alert dialog with an "OK" button. If the user's response is NOT found in this dictionary OR there is no warnings dictionary, it is ignored and no dialog is shown. This applies to ANY question type, including text, rating, or list, etc.

falmeida-orangeloops commented 1 year ago

@lugray1 This seems like a simpler task than push notifications. I will dig into this a little bit more and get back to you!

falmeida-orangeloops commented 1 year ago

@ertjlane @lugray1 I added a 'warnings' field to activity creation options. It is optional. Here is the pull request: BIDMCDigitalPsychiatry/LAMP-dashboard#711

Below is a little demonstration to understand how it works. First, I set up a survey named 'Ad hoc survey', which contains two questions. The first has a 'list' type and is set to show a warning if the participant chooses the last answer. The second has a 'text' type and is set to show a warning if the answer equals some given text.

(click the screenshot to zoom). Here is a video showing what happens when the participant submits answers for this survey, in three different cases:

  1. Both answers imply showing warnings. Both warnings are shown in the dialog at the end.
  2. Neither answer implies showing warnings. No dialog is shown.
  3. Only one of the answers (the first one) implies showing a warning. The corresponding warning is shown in the dialog at the end.

https://user-images.githubusercontent.com/66265155/212225622-a21b852a-9734-4955-a214-591baa88e6a4.mov

It could happen that you want to have the same warning for multiple different questions. In this case, each one appears at most once to avoid being redundant.

Let me know if this looks good to you.

lugray1 commented 1 year ago

This looks great, thank you! I'll approve your pull request.