Machine learning with routine electronic medical record data to identify people at high risk of disengagement from HIV care in Tanzania

Carolyn A. Fahey, Linqing Wei, Prosper Njau, Siraji Shabani, Sylvester Kwilasa, Werner Maokola, Laura Packel, Zeyu Zheng, Jingshen Wang, Sandra I. McCoyPLOS 2022

Abstract

Machine learning methods for health care delivery optimization have the potential to improve retention in HIV care, a critical target of global efforts to end the epidemic. We used an ensemble decision tree approach to predict risk of disengagement from HIV care (missing an appointment by ≥28 days) in Tanzania. Our approach used routine electronic medical records (EMR) from the time of antiretroviral therapy (ART) initiation through 24 months of follow-up for 178 adults. Models incorporating changes across past clinical visits achieved a mean accuracy of 75.2% for predicting risk of disengagement in the next 6 months. Additionally including survey-based predictors only modestly improved model performance. Machine learning methods applied to existing EMR data in resource-constrained settings can predict individuals' future risk of disengagement, potentially enabling better targeting and efficiency of interventions to promote retention in care.

Introduction: The Challenge of Retention

For people living with HIV, staying on antiretroviral therapy (ART) is a lifelong commitment. However, "disengagement"—missing appointments or stopping treatment—remains a massive hurdle in sub-Saharan Africa, driven by poverty, stigma, and treatment fatigue. When patients drop out of care, their viral load rises, increasing the risk of illness and transmission. While health systems have developed interventions like SMS reminders or specialized counseling, these resources are often too scarce to provide to everyone. The challenge is targeting: identifying exactly who is about to drop out before they disappear. This paper investigates whether high-accuracy predictions can be achieved using only the routine, often incomplete data already available in clinic computers.

Methods and Data

The study followed 178 adults (63% female) initiating ART in the Shinyanga region of Tanzania over 24 months. Researchers utilized the Tanzania National HIV Care and Treatment Center (“CTC3”) database for routine clinical indicators and supplemented this with survey data from the "Afya II" trial for comparison.

The authors employed an ensemble decision tree approach (bagged decision trees). To handle the "holey" nature of routine medical records, the algorithm used "surrogate splits," identifying backup variables to make predictions when primary data like weight or viral load were missing. To simulate real-world clinical use, they used a "one-interval-ahead" prediction strategy, using data from one six-month block to predict disengagement in the following six months. They compared three models: one using only the most recent visit data ("Current EMR"), one capturing changes over time ("Time-Varying EMR"), and one adding detailed sociodemographic research data ("EMR + Survey").

A central finding of the study is that trends are far more predictive than states. A patient’s current weight is less informative than a steady decline in weight over several visits. The time-varying EMR model achieved a mean accuracy of 75.2% for predicting disengagement in the subsequent six months.

Model performance metrics (Accuracy and AUC) across different prediction windows.

As shown in the performance table, incorporating time-varying data significantly improved the Area Under the Curve (AUC) compared to using only the most recent visit data. For example, in the 6–12 month window, the AUC rose from 0.647 to 0.704. The most important variables for prediction were changes in ARV status (starting, stopping, or substituting drugs), body weight, and WHO clinical stage, along with the patient's age.

Sensitivity of different models at varying risk thresholds.

The model also demonstrated significant practical efficiency for resource allocation. By flagging just the top 30% of patients identified as "high risk," clinics could capture nearly 55% of all future disengagements. For the top 10% of highest-risk individuals, the model had a Positive Predictive Value (PPV) of 68%, meaning 2 out of 3 people flagged by the algorithm truly went on to miss their appointments.

Discussion and Future Directions

Surprisingly, adding expensive, hard-to-collect research survey data (like mental health scores or household wealth) only modestly improved the model. This is a major win for scalability, suggesting that the data clinics already collect is sufficient for high-quality risk screening.

However, limitations remain, including the small sample size (n=178) and the "silent transfer" problem, where EMR systems struggle to distinguish between a patient quitting care and one moving to a different clinic. Future work should focus on integrating these algorithms directly into EMR software to provide real-time "High Risk" alerts to clinicians during patient visits, effectively closing the loop between prediction and intervention.

Summary updated

BibTeX
@inproceedings{fahey2022machine,
  author = {Carolyn A. Fahey and Linqing Wei and Prosper Njau and Siraji Shabani and Sylvester Kwilasa and Werner Maokola and Laura Packel and Zeyu Zheng and Jingshen Wang and Sandra I. McCoy},
  title = {{Machine learning with routine electronic medical record data to identify people at high risk of disengagement from HIV care in Tanzania}},
  booktitle = {PLOS},
  year = {2022},
  doi = {10.1371/journal.pgph.0000720},
}
Figure