Accepted for/Published in: Journal of Medical Internet Research
Date Submitted: May 6, 2025
Date Accepted: Nov 21, 2025
Development and Validation of An Electronic Health Record Based Algorithm for Patients with Long-term Opioid Therapy: A Cross-sectional Study
ABSTRACT
Background:
Healthcare providers must carefully monitor patients receiving long-term opioid therapy (LTOT) to minimize risks and maximize benefits. Yet, algorithms to support timely intervention during patient encounters are lacking, with accurate LTOT identification in routine care being the essential first step.
Objective:
To develop and validate an LTOT identification algorithm using electronic health record (EHR) data.
Methods:
In this cross-sectional study, we used the 2016–2021 OneFlorida+ EHR data linked with Florida Medicaid claims to identify patients aged ≥18 years who received opioid prescriptions. The main outcome was the first LTOT episode in the algorithm development (2016–18) and validation (2019–21) periods. A Medicaid claims-based LTOT algorithm served as the reference standard, defined as ≥90 days of continuous opioid use with ≤15-day gaps. Given strong correlations among covariates, we applied an elastic net regression model to identify LTOT episodes in EHR data using patient characteristics, clinically relevant features, and medication use; and evaluated the model’s classification performance. We randomly split the 2016–2018 cohort into development and internal validation datasets (2:1 ratio), stratified by LTOT incidence. External validation was performed using 2019–2021 data.
Results:
Among 64,206 eligible patients identified in 2016–2018 (mean age: 35.7±12.3, female: 80.1%), 8,899 (13.9%) had LTOT. Among 50,009 eligible patients identified in 2019–2021 (mean age: 37.3±12.5, female: 79.7%), 6,000 (12.0%) had LTOT. The model selected 29 out of 131 candidate features. Among 2,967 individuals with LTOT in the 2016–18 OneFL internal validation dataset, 2,176 (73.3%) individuals were identified in the top three deciles of risk scores. The model achieved a C-statistic of 0.83 (95% confidence interval: 0.82-0.84), with 73.4% (71.8%-75.0%) sensitivity, 76.8% (76.2%-77.4%) specificity, 33.8% (33.1%-34.6%) precision, 76.3% (75.8%-76.9%) accuracy, and an F1 score of 0.46. In the 2019–21 OneFL external validation dataset, 4,527 (75.5%) individuals were correctly captured in the top three risk subgroups. The model achieved a C-statistic of 0.83 (0.83-0.84), with 78.8% (77.8%-79.9%) sensitivity, 73.3% (72.9%-73.7%) specificity, 28.7% (28.3%-29.1%) precision, 73.9% (73.6%-74.3%) accuracy, and an F1 score of 0.42.
Conclusions:
The EHR-based LTOT algorithm showed comparable accuracy to the claims-based reference and may enable timely application during clinical encounters.
Citation
Request queued. Please wait while the file is being generated. It may take some time.
Copyright
© The authors. All rights reserved. This is a privileged document currently under peer-review/community review (or an accepted/rejected manuscript). Authors have provided JMIR Publications with an exclusive license to publish this preprint on it's website for review and ahead-of-print citation purposes only. While the final peer-reviewed paper may be licensed under a cc-by license on publication, at this stage authors and publisher expressively prohibit redistribution of this draft paper other than for review purposes.