Using a Semiautomated Procedure (CleanADHdata.R Script) to Clean Electronic Adherence Monitoring Data: Tutorial

JMIR Form Res. 2024 May 22:8:e51013. doi: 10.2196/51013.

Abstract

Background: Patient adherence to medications can be assessed using interactive digital health technologies such as electronic monitors (EMs). Changes in treatment regimens and deviations from EM use over time must be characterized to establish the actual level of medication adherence.

Objective: We developed the computer script CleanADHdata.R to clean raw EM adherence data, and this tutorial is a guide for users.

Methods: In addition to raw EM data, we collected adherence start and stop monitoring dates and identified the prescribed regimens, the expected number of EM openings per day based on the prescribed regimen, EM use deviations, and patients' demographic data. The script formats the data longitudinally and calculates each day's medication implementation.

Results: We provided a simulated data set for 10 patients, for which 15 EMs were used over a median period of 187 (IQR 135-342) days. The median patient implementation before and after EM raw data cleaning was 83.3% (IQR 71.5%-93.9%) and 97.3% (IQR 95.8%-97.6%), respectively (Δ+14%). This difference is substantial enough to consider EM data cleaning to be capable of avoiding data misinterpretation and providing a cleaned data set for the adherence analysis in terms of implementation and persistence.

Conclusions: The CleanADHdata.R script is a semiautomated procedure that increases standardization and reproducibility. This script has broader applicability within the realm of digital health, as it can be used to clean adherence data collected with diverse digital technologies.

Keywords: R; algorithms; code; coding; computer programming; computer science; computer script; data cleaning; data management; digital pharmacy; digital technology; electronic adherence monitoring; medication adherence; medications; research methodology; semiautomated.