Natural Language Processing Identification of Nonprescribed Fentanyl Use in Electronic Health Records: Algorithm Development and Validation Study.
Joshua Trujeque, Joseph A Simonetti, Isai Ortiz, Nicholas E Ingraham, Nathan Mesfin, Jeremy Yeung, Rui Zhang, Lisa A Brenner,
Minneapolis Veterans Affairs Healthcare System, Center for Care Delivery and Outcomes Research, One Veterans Drive, Minneapolis, MN, 55417, United States. · Rocky Mountain Mental Illness Research, Education, and Clinical Center for Suicide Prevention, Rocky Mountain Regional VA Medical Center, Aurora, CO, United States.
Key points
From the paper's conclusion- Natural language processing can identify nonprescribed fentanyl use in EHR documentation, although model performance for this class was lower than overall model performance, reflecting the clinical complexity of identifying nonprescribed use and the variable ways in which clinicians document this problem. This approach may support risk prediction and targeting of interventions to patients exposed to nonprescribed fentanyl.
Abstract
BACKGROUND: Overdose and suicide due to nonprescribed fentanyl use have increased significantly, yet health care systems lack reliable methods to identify patients who use nonprescribed fentanyl. International Classification of Diseases codes are inconsistent and do not specify nonprescribed fentanyl use. OBJECTIVE: This study aimed to develop natural language processing approaches to identifying nonprescribed fentanyl use in electronic health record (EHR) documentation. METHODS: This retrospective study included Veterans Health Administration patients seen between April 5, 2023, and December 23, 2024. A term list was developed to identify fentanyl-related mentions in clinical text, and 250-character snippets surrounding identified mentions were extracted. Veterans (n=3878) were randomly sampled from 5 predefined groups based on the presence of 1 of 4 terms ("fent," "blues," "M30s," and "tranq") in their EHR documentation. Physician annotators classified snippets into "nonprescribed fentanyl use," "prescribed fentanyl use," or "other," with interannotator agreement evaluated using the mean pairwise Cohen κ. Cross-validation folds were constructed at the patient level between training and test sets. Penalized logistic regression, Bio-ClinicalBERT, Llama 3-8B, and Mistral-7B were trained on labeled data and compared. Model performance was evaluated using precision, recall, and F1-scores for each class, with a focus on the nonprescribed fentanyl use class as the primary label of clinical interest using bootstrapped 95% CIs. A fairness analysis and Shapley additive explanations analysis were performed using Bio-ClinicalBERT. External validation was performed using Bio-ClinicalBERT on an independent sample of 200 snippets, each representing a unique patient from January 2025 to June 2026, with precision reported as the primary validation metric. RESULTS: Of 7389 snippets, 9.6% (n=709) were classified as "nonprescribed fentanyl use," 40.3% (n=2981) were classified as "prescribed fentanyl use," and 50% (n=3699) were classified as "other." Interannotator agreement was high (κ=0.822). Llama 3-8B achieved the highest F1-score for nonprescribed fentanyl use (0.87, 95% CI 0.83-0.92), followed by Mistral-7B (0.80, 95% CI 0.75-0.84), Bio-ClinicalBERT (0.80, 95% CI 0.74-0.85), and penalized logistic regression (0.74, 95% CI 0.73-0.75). Performance was consistent across demographic subgroups, with lower performance for the nonprescribed fentanyl use class observed in female and Hispanic subgroups. Shapley additive explanations analysis revealed clinically meaningful discriminating terms for each class, although subword tokens required contextual interpretation. External validation of Bio-ClinicalBERT demonstrated a precision of 0.79 for nonprescribed fentanyl use. CONCLUSIONS: Natural language processing can identify nonprescribed fentanyl use in EHR documentation, although model performance for this class was lower than overall model performance, reflecting the clinical complexity of identifying nonprescribed use and the variable ways in which clinicians document this problem. This approach may support risk prediction and targeting of interventions to patients exposed to nonprescribed fentanyl.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- When documentation follows the patient: Unprofessional language and behavioral health referrals in substance use disorder - a retrospective cohort study using LLM-augmented natural language processing.Digital health · 2026
- Cannabis Use Documentation within the Electronic Health Record: A Use Case for Natural Language Processing Methods.Medical cannabis and cannabinoids · 2026
- Artificial Intelligence for Opioid Safety Surveillance from Clinical Text: A Clinically Focused ReviewJournal of Clinical Medicine · 2026
- A generalizable deep learning model for predicting opioid use disorder using language modeling for cross-EHR data harmonizationnpj Digital Medicine · 2026
- Detecting stigmatizing language in clinical notes with large language models for addiction carenpj Health Systems · 2026
- Using Natural Language Processing to Evaluate Differences in Psychotherapeutic Services for Posttraumatic Stress Disorder in a Suicide-Risk-Stratified Veteran SampleThe Journal of Clinical Psychiatry · 2026