Accepted for/Published in: Journal of Medical Internet Research
Date Submitted: Jan 12, 2026
Date Accepted: Sep 9, 2026
Linking Dispense Data to Electronic Health Orders: A Tutorial for Querying Commercial Pharmacy Databases to Support Systemwide Quality Improvement
ABSTRACT
Background:
Assessing medication adherence is central to quality care, yet linking the electronic health record (EHR) order to outpatient pharmacy fill data can be a complex process Many EHRs integrate commercial pharmacy dispense data (e.g., DrFirst, SureScripts), offering a discrete data source for evaluating prescription fill behavior.
Objective:
To present a practical, reproducible method of linking EHR medication orders to pharmacy dispense data for studying medication adherence at scale, illustrated through a pediatric acute otitis media (AOM) use case.
Methods:
We conducted a retrospective cross-sectional study at a tertiary academic medical center (January 1, 2021–January 1, 2024) of pediatric patients (6 months to <18 years) with AOM. EHR data was extracted from Epic Clarity via SQL. Encounter antibiotic order data was linked to dispense information from Surescripts and/or DrFirst. Linkage identifiers included Generic Control Number (GCN), EHR pharmacy ID or pharmacy phone, and fill date within 14 days from prescribed date.
Results:
Over 98% of pharmacies in our sample historically reported fill data to our EHR. In our sample of 3,404 orders, 2,616 (76.9%) had a recorded fill. DrFirst, our primary fill provider, contributed 2,559 entries (75.2%), SureScripts 271 (8.0%), with 214 (6.3%) overlapping both sources. Most fills (68.6%) occurred at large chains; 29.2% were at the local hospital pharmacy; 2.1% involved small independent pharmacies.
Conclusions:
EHR-integrated pharmacy data provides a feasible, timely proxy for assessing medication adherence. Order-level linkage is achievable with key caveats including dispensed medications may not be taken, vendor linkage variability, and visit-triggered retrieval. This tutorial offers a replicable framework for QI and research. Clinical Trial: NA
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.