Abstract
Mobile technologies, including applications (apps) and wearable devices, are playing an increasingly important role in health monitoring. In particular, apps are becoming a critical component of m-health, which promises to transform personalized care management, optimize clinical outcomes, and improve patient-provider communication. They may also play a central role in research, to facilitate rapid and inexpensive collection of repeated data, such as momentary clinical, physiological, and/or behavioral assessments and optimize their sampling. This is particularly important for measuring systems/processes with characteristic temporal patterns, e.g., circadian rhythms, which need to be adequately sampled in order to be accurately estimated from discrete measurements. Temporal sampling of these patterns may also be critical for elucidating their modulation by pathological events. This paper presents a novel app, developed with the overarching goal to optimize repeated salivary hormone collection in pediatric patients with epilepsy through improved patient-investigator communication and enhanced alerts. The ultimate goal of the app is to maximize regularity of the data collection (up to 8 samples/day for ~4–5 days of hospitalization) while minimizing intrusion on patients during clinical monitoring. In addition, the app facilitates flexible collection of data on stress and seizure symptoms at the time of saliva sampling, which can then be correlated with hormone levels and physiological changes indicating impending seizures.
I. Introduction
The rapid expansion of mobile technologies and associated applications has dramatically improved almost every aspect of everyday life, from simple communication to safety, fitness, and digital health. Advances in artificial intelligence (AI) and data storage have specifically played a pivotal role in the exponential growth of mobile health (m-health) for personalized, regular or even continuous monitoring and care management. Additional technological advances in sensor/hardware development, tracking devices, and applications (apps) have facilitated the continuous collection of increasingly accurate multi-modal health data. To date, there are more than 300,000 health-related apps with a total market size of over $30 billion. Almost 30% of people in the US use them to monitor health, fitness, nutrition, and overall wellness, and as their primary source of health information. This not only allows people to play an active role in their health, but also improves symptom and adverse event reporting and patient-provider communication.
As mobile phones have become indispensable, their utility for data collection and self-reporting has grown across fields. In particular, health tracking apps are becoming invaluable for monitoring health/conditions. They provide instant feedback to individuals and their providers and help increase awareness and motivation for the former and facilitate diagnosis for the latter [1]. Continuous health tracking can enable rapid disease/adverse event detection and prompt intervention, which in some cases can be life-saving [2–3].
Phone apps can also help monitor physical and mental health and facilitate momentary behavioral adjustments in response to stressors or to prevent risk behaviors, such as substance use [4–11]. They can also be used for alerting a struggling individual’s support network of a mental health crisis or for connecting the individual with trained counselors from the National Suicide Prevention Lifeline or 911. Others provide motivational messages for behavioral self-regulation, e.g., to encourage physical activity, healthy eating and mindfulness [12–14].
Beyond health monitoring, mobile technologies are also playing a growing role in clinical and behavioral research. Studies involving momentary assessments use apps to collect data multiple times per day, thus sampling behavior in ecologically valid settings (outside the tightly controlled environment of a laboratory). This allows for behavioral assessments in realistic settings. In clinical studies that require repeated data collection under complex conditions (e.g., during patient hospitalizations and/or in intensive care units), apps may play a critical role in optimizing data collection while minimizing intrusion on patients and interference with their clinical care. Thus, next-generation clinical/behavioral research protocols will undoubtedly integrate these technologies in their experimental setups.
Research studies that involve measurement of complex processes with characteristic temporal patterns (e.g., circadian rhythms) in humans can leverage mobile apps for optimal sampling. When sparsely sampling these processes at discrete time points, the timing of the data collection is critical to the estimation of these rhythms. Poorly timed or unevenly spaced samples can lead to large estimation errors and miss important features of a temporal pattern.
Here we report the development of a dedicated mobile phone app to improve dynamic data collection in clinical pediatric epilepsy research. The development of this app was inspired by the needs and complexity of a clinical research study that aims to assess the impact of stress hormone fluctuations and deviations from their normative circadian patterns on seizure generation. The study requires repeated hormone measurements in saliva during a patient’s presurgical evaluation (an inpatient study that spans ~ 5 days). Sampling is impacted by multiple factors, including other clinically indicated studies, such as neuroimaging, that may interfere with collection, meals, sleep and/or patients forgetting or being unable (e.g., right after seizures) to provide specimens. Given that the frequency of collection is limited by study costs, the relatively sparse number of daily samples (typically ≤8) need to be optimally spaced in order to measure physiologically meaningful changes in multiple hormone rhythms during each circadian cycle.
Improving and automating remote communication with patients, so that collection is regular and adequately spaced and missing data are minimized, may significantly improve temporal hormone sampling and allow accurate estimation of their circadian patterns and modulations. Furthermore, the app facilitates collection of additional data (on stress level and seizure-related symptoms/auras) at the same time as the saliva collection. In turn, this allows the evaluation of associations between momentary self-reported symptoms and simultaneously measured stress hormone levels. The developed app is also flexible in that it can be easily expanded to include additional data instruments and momentary behavioral/symptom assessments that can be communicated to the investigators in real time.
II. Procedure for Paper Submission
A. App Framework and Distribution
The app was primarily developed using React Native, a Javascript-based programming framework that can be used in both Android and IOS platforms. Furthermore, Android Studio and Xcode were used for Android-specific and IOS-specific development and testing, respectively. Android users can directly download the Android Package Kit file through which the app can be installed, whereas IOS users can install it through TestFlight.
B. App Organization and Components
The organization of the app is summarized in Figure 1.
Figure 1:

Nested organization of developed app.
B1. AuthProvider
The app is wrapped in an AuthProvider object that manages user authentication. It permits users to sign into or out of the app by connecting to MongoDB, a database program that stores data as documents. The app utilizes two MongoDB services, Atltas and Realm. User documents and data are stored on Atlas, the cloud database service. Realm allows for immediate data transfer from the mobile device to the Atlas database, and vice versa. Realm is also used to connect to Firebase Cloud Messaging (FCM) to send remote push notifications. Given the need to ensure patient privacy in human clinical studies, the app verifies users via a custom function, rather than through email or social media accounts. The custom function takes in a payload object consisting of the username and password entered in the login screen. If there is an existing user document (with username and password information), the login will be completed. Each user (participant or investigator) has a unique ID and password. Once a user has been logged in, the app uses the AsyncStorage API to store the user ID and category value (true if investigator, false otherwise).
B2. Push Notification Controller
The PushNotificationController class is a child of the AuthProvider. When this component is created, it generates the Android notification channels and configures Push Notifications for Android and IOS. Additionally, it returns a NavigationContainer object that holds the various screens of the app. The PushNotificationController class has three state variables: alarmTime, accessTime, and subsWaiting. alarmTime is a Date object that keeps track of time (and onset of data collection) in order to trigger each subsequent alarm; accessTime is a Date object representing the earliest time a subject may start submitting data. alarmTime and accessTime are passed as properties to the Participant Home Screen class; subsWaiting is used on the investigator side to monitor which participants are ready for collection. This information is represented as an object array with each entry containing the participant ID and a timestamp. This value is passed to the Investigator Home Screen class.
B3. Navigator
The Navigator contains the app screens for participants and investigators, which are summarized in Figure 2.
Figure 2:

Organization/content of the app screens.
Login:
The first screen in the navigation stack is the login page, the first component loaded on initial app startup. A splash screen appears while the login component checks if there is a user already logged in. If the app was closed by the user, it will attempt to restore the previous state upon reopening. To do so, it first searches for an existing user ID in the AsyncStorage system. If there is no existing user, then the login screen appears. If there is an existing value for the user ID key, it gets the user category key value. If this value is true, it will redirect to the Investigator home screen, otherwise the app will show the Participant home screen. Before redirecting, it will update the state with any other existing data stored in AsyncStorage.
Investigator Home Screen Class:
When an investigator logs into the app, they are subscribed to the FCM topic designated for participant-to-investigator communication. After a participant submits stress and seizure symptom data to the Atlas database, a function is triggered to create a remote notification sent through FCM and alert the investigators that the participant is ready for collection. In addition, their ID and timestamp are added to the subsWaiting array and the investigator’s home screen is updated with this new information. In studies that require laboratory data to be promptly stored (in this case saliva specimens must be collected and rapidly placed in a refrigerator), it is crucial for investigators not to miss these notifications. Therefore, after receipt of the initial one, they must click a confirmation button on their home screen. If the app does not receive the confirmation, up to three more local notifications (sent from the app to investigator) are sent as reminders. When confirmation is received, the subsWaiting array is set to empty and notifications are canceled.
Participant Home Screen Class:
The Participant Home Screen uses the accessTime property to control the use of the ‘Continue collection’ button and alarmTime to set the time for the next alarm. When this button is pressed, it compares the current time to accessTime. If the current time is before access time, a message appears stating it is not yet time for the next collection. Otherwise, it compares the day of alarmTime with the current day. If the last stored alarmTime was from the previous day, it resets the collection schedule. Since it is the first collection of the day, the next alarm will be set for 30 minutes. If the last alarm is from the same day, the alarm will be set for 2 hours. The alarm is sent as a local notification which gives the participant the option to begin collection, snooze for 15 minutes, or stop collection. Three more notifications are scheduled several minutes apart as reminders in the event that the subject misses the initial notification and does not respond. Any response given will cancel the remaining reminders.
During inpatient clinical monitoring studies and/or a presurgical, epilepsy patients often undergo multiple additional evaluations. These typically include multiple neuroimaging studies (MRI, PET, interictal and ictal SPECT), which may interfere with research studies that collect repeated data. In addition, given the specific limitations of saliva collection (patients cannot eat at least 60 min prior to collection) patients may need additional flexibility in the timing of specimens without severely impacting sampling (e.g., missing collections). Thus, although sampling (and associated notifications) are timed at 120-minute intervals, participants are able to enter the data and provide a specimen as early as 90 min after the prior collection. This is another way to minimize missed assessmentpoints and reduce potential rhythm estimation errors. Finally, if the participant wants to stop collection for the day, they can click the Stop Collection button. This sets alarmTime to null, removes the alarmTime key in AsyncStorage, and cancels all scheduled local notifications. The logout button also cancels all notifications, clears all keys in AsyncStorage and then navigates to the login screen.
Data collected through the app:
Once participants indicate their ability to provide a specimen, participants are required to answer a brief, two-question survey on their stress level and seizures symptoms. The first question asks participants to rate their stress level on a Likert-type (1–5) scale, with 1 = none, 2 = mild, 3 = moderate, 4 = high and 5 = extreme stress. The second question asks them to report if they think they are experiencing an aura, or any seizure symptoms. These data are stored as an object containing the user id, their responses, and a timestamp. This object gets sent to Mongodb to be stored in the Atlas database. Mongodb has built-in security features which encrypt all data transferred to and from the app using Transport Layer Security [15].
III. App-based hormone rhythm optimization
Stress hormones, including cortisol and norepinephrine, have characteristic circadian rhythms that can be sampled via repeated measurements in saliva. These rhythms have somewhat different morphological characteristics and are out of phase with each other. Their modulation by abnormal events, such as seizures, remain elusive. Therefore, in order to both estimate normative patterns and pathological changes, frequent sampling is necessary. A realistic optimal number of 8 samples were selected in the design of the study that inspired the app development. However, in practice this number is rarely attainable given previously described interfering factors. For some patients, collection of 6 daily saliva specimens is reasonable but for others sampling is sparser (4–5 specimens/day).
To demonstrate the critical dependence of hormone rhythms sampling on the number, timing and spacing of specimen collection, and thus highlight the potentially critical role of the developed app in maintaining the regularity of hormone sampling, we conducted the following simulation. The theoretical cortical and norepinephrine circadian patterns in adults were sampled using 4, 5 or 6 data points, pseudo-randomly spaced from 6 am to 10 pm (typical span of data collection during the clinical study). Sampling was not entirely at random given that in the clinical study we control the minimum inter-sample interval to be no less than 90 min and consistently sample the first 2 morning samples ~30 min apart in order to capture the characteristic cortisol peak shortly after a participant wakes up. During each simulation (100 draws per set of data points, i.e., a total of 300 runs) the corresponding cortisol and norepinephrine circadian patterns were estimated by fitting a polynomial model to the data using the Smoothing Spline method. For each model, the root mean squared error (RMSE) between the theoretical and estimated rhythms was calculated, separately for cortisol and norepinephrine. The statistics of the RMSE as a function of number of samples are summarized in Table 1. Examples of estimated rhythms (superimposed on their theoretical counterparts) are shown in Figure 3.
TABLE I. SAMPLING-RELATED ESTIMATION ERRORS.
Statistics of RMSE from 100 simulations for 4-, 5- and 6-point sampling, respectively, of cortisol and norepinephrine circadian rhythms.
| Number of samples | Root Mean Squared Error (RMSE) | ||
|---|---|---|---|
| Median over simulations | Min | Max | |
| Cortisol | |||
| 4 | 0.11 | 0.03 | 1.11 |
| 5 | 0.08 | 0.01 | 0.62 |
| 6 | 0.04 | 0.01 | 0.39 |
| Norepinephrine | |||
| 4 | 2.37 | 0.73 | 1.70 |
| 5 | 1.69 | 0.44 | 1.76 |
| 6 | 1.27 | 0.37 | 0.87 |
Figure 3:

Theoretical (solid lines), optimally sampled (8 time points) and sub-optimally sampled cortisol and norepinephrine (NE) rhythms based on different distributions of 4, 5 and 6 samples from 06:00 to 22:00.
Depending on the sample sparsity and temporal distribution (spacing), estimated hormone rhythms deviated significantly from their theoretical values, highlighting the need for regularly spaced samples, particularly in the case of 4–5 samples per day. In turn, this suggests that the developed app may play a significant role in improving the estimation of temporal hormone patterns under the constraints of a clinical research study in an inpatient setting.
IV. Conclusion
We have developed a new mobile phone app that aims to optimize the relatively sparse daily collection of saliva specimens in a complex population of pediatric epilepsy patients during their inpatient (multi-day) presurgical evaluation. During a clinical research study that aims to elucidate the role of stress hormones (measured in saliva) as seizure triggers, the app facilitates the communication between study participants and investigators, optimizes the regularity of data collection via timed alerts to participants, and minimizes missing data, in order to maximize the accuracy of estimated temporal hormone patterns. Beyond timing, the app also collects momentary data on stress level and seizure symptoms, which can then be correlated with hormonal fluctuations and measures from other modalities. These simultaneously collected self-reported data can then be integrated with electrophysiological data (electroencephalograms and electrocardiograms continuously collected during inpatient monitoring) to improve both the field’s fundamental understanding of seizure precipitants and seizure prediction.
Beyond the clinical study that inspired its development, the app can flexibly incorporate multiple surveys and may thus become a valuable research tool for rapid collection of momentary data across domains (behavioral, mental health, activity, and wellness), sampling processes with complex temporal patterns, real-time data sharing with investigators, and even ecologically-valid momentary interventions.
Clinical Relevance—
The developed app will optimize repeated salivary stress hormone measurements during inpatient pediatric epilepsy studies. This optimization can significantly improve the estimation accuracy of patient-specific circadian stress hormone rhythms and their modulations by seizures.
Acknowledgments
Research supported by the National Institute for Neurological Disorders and Stroke, Grant # R03NS119799
References
- [1].Patrick JR, How mHealth will spur consumer-led healthcare, Mhealth, 2015, 1:14. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [2].mSafety: https://www.sonynetworkcom.com/msafety/technology
- [3].Apple watch: https://www.apple.com/watch/
- [4].Sort A, The role of mHealth in mental health, Mhealth, 2017, 3:1. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [5].Chandrashekar P, Do mental health mobile apps work: evidence and recommendations for designing high-efficacy mental health mobile apps, 2018, Mhealth, 4: 6. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [6]. https://apps.apple.com/us/app/whats-up-a-mental-health-app/
- [7]. https://apps.apple.com/us/app/moodkit-mood-improvement-tools/
- [8]. https://apps.apple.com/us/app/notok/
- [9]. https://apps.apple.com/us/app/my3-suicide-lifeline/
- [10].Robbins ML, Kubiak T, Ecological Momentary Assessment in Behavioral Medicine: Research and Practice, 2014, The Handbook of Behavioral Medicine, Wiley & Sons, Inc. [Google Scholar]
- [11].Hufford MR., Shields AL., Shiffman S et al. , Reactivity to ecological momentary assessment: An example using undergraduate problem drinkers, 2002, Psychology of Addictive Behaviors, 16(3), 205–211 [PubMed] [Google Scholar]
- [12].Shingleton RM, Pratt EM, Gorman B et al. , Motivational Text Message Intervention for Eating Disorders: A Single-Case Alternating Treatment Design Using Ecological Momentary Assessment, 2016, Beh Ther, 47(3):325–38. [DOI] [PubMed] [Google Scholar]
- [13].Levesque C, Brown KW, Mindfulness as a moderator of the effect of implicit motivational self-concept on day-to-day behavioral motivation, 2007, Motiv Emot, 31:284–299 [Google Scholar]
- [14].Dunton GF, Liao Y, Intille SS et al. , Investigating Children’s Physical Activity and Sedentary Behavior Using Ecological Momentary Assessment With Mobile Phones, 2011, Obesity, 19(6): 1205–1211. [DOI] [PubMed] [Google Scholar]
- [15]. https://www.mongodb.com/cloud/atlas/security.
