Skip to content

UArizonaCB2/mdh-ema-generic

Repository files navigation

Readme

This service manages the random invocation of EMA surveys based on various MyDataHelp (MDH) participant custom fields.

Components

  1. MyDataHelp (MDH) - mHealth platform used for this study which provides 3rd API access.
  2. External AWS Service - An external service that packages and runs this code. The easiest solution is to run this on Lambda invoking it periodically each day using AWS Event Scheduler.

Survey Structure and Preparation

  1. Create a single monolithic EMA survey with all the questions you want to ask.
  2. Divide this monolithic survey into categories if needed. Categories can be used to logically divide the surveys into EMA’s meassuring different things - Mood EMAs, Truma EMAs, Sleep EMAs’ etc. A random EMA is picked from each category.
  3. All categories must have the same number of EMA. Variable number of EMA per category is not currently supported.
  4. Each survey question inside a category must be conditioned to only be displayed on category specific custom variable. More on this later in the Survey Question Conditioning Section.

    An image showing individual survey questions categorized by EMA type

Logic Description

This service when run generates a random integer contained within [1, ema_max] where ema_max is a coordinator configured MDH participant custom field. It represents the total number of surveys per EMA category. This service updates a survey category custom field labeled ema_random<a> where <a> category number starting from 1. For example if we have a total of 3 EMA survey categories then we would have 3 custom fields in MDH namely - ema_random1, ema_random2, ema_random3.

Survey Question Conditioning

Each survey question inside the respective category then needs to be conditioned on the corresponding random custom variable for a specific random number. For example the first survey in category 1 can be conditioned to show when the custom field value (ema_random1 == 1). This can be done through the navigation tab in MDH survey.

assets/2025-04-28_22-29-57_screenshot.png

Participant Custom Fields

<x> is a placeholder for category number. For example if there are 3 categories then <x> will range from 1..3, with each category having its own custom field. Any field marked with (**) is coordinator editable.

updated or read by this service

  1. (*)ema_categories (int) - (Read) Stores total number categories inside the complete EMA survey.
  2. (*)ema_max (int) - (Read) Total number of EMA surveys per category.
  3. ema_metadata<x> (string) - (Read / Write) Stores the random numbers already seen in a comma seperated format. Cycles back automatically when no more random numbers can be generated. Example - 1,3,7
  4. ema_random<x> (string) - (Write) Holds the random number generated by this service within [1, ema_max]. Condition your individual surveys for each catgegory on this variable.
  5. ema_status (string) - (Write) Updates to passed or failed <failure message> after this service has run for a particular participant.

Other EMA related fields not used by this service

  1. (*)ema_enabled (string) - yes|no indicating if the EMA logic should be enabled or not.
  2. (*)ema_morning_time (timeofday) - Holds the time on which MDH moring schedules are anchored to send the morning EMA. Allows for coordinators to tune this to the participants liking.
  3. (*)ema_evening_time (timeofday) - Holds the time on which MDH evening schedules are anchored.

Running this code

Configuring Envrionment Variables

Several environment variables hold MDH sercret key credentials, project id and account id need to be configured prior to running this service locally. Check out the example environment file env.local. Once you have edited it, make sure to rename this file as .env before testing this service out. This will allow dotenv package to automatically pick up these values without needing to export them to your terminal session.

Commands to install dependencies and run

npm install node index.mjs

About

EMA service to update MDH fields for random EMA delivery module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors