Richer database context improves LLM-generated EHR phenotyping algorithms.
Mengshuo Ye, Harlin Lee, Selen Gizlice, Madeline Tobias, Shawn O'Neil, Emily Pfaff, Stanley C Ahalt
Key points
From the paper's conclusion- Conclusion: LLMs can generate clinically meaningful T2DM phenotyping SQL when provided with sufficient database context, but limited PPV in real-world data underscores the need for local validation.
Abstract
OBJECTIVE: To evaluate large language model (LLM) generation of type 2 diabetes (T2DM) phenotyping SQL and the effect of database implementation context. MATERIALS AND METHODS: Eight publicly accessible LLM-based systems generated SQL under progressively richer prompts using synthetic and University of North Carolina (UNC) Health electronic health record (EHR) data, both based on the Observational Medical Outcomes Partnership (OMOP) model. Outputs were compared with the Electronic Medical Records and Genomics (eMERGE) T2DM reference phenotype using SQL executability, F1, positive predictive value (PPV), and recall. RESULTS: Fewer than 55% of limited-context synthetic outputs and no limited-context UNC EHR outputs executed without modification. Detailed codebooks (L3) increased executability to 81.3% in synthetic OMOP and 100% in UNC EHR; adding sample rows (L4) increased synthetic executability to 100%. Limited-context recall was as low as 0.01, whereas high-context outputs achieved recall ≥0.99 at synthetic L4 and >0.90 at UNC L3, although UNC PPV remained substantially lower than recall. At the highest available context levels, Beta F1 ranged from 0.72-0.99 in synthetic OMOP and 0.57-0.68 in UNC EHR; all UNC models exceeded the diagnosis-code baseline (F1=0.54). The top synthetic performer fell from F1=0.99 to 0.64 on UNC EHR. DISCUSSION: Richer database context was associated with more consistent SQL executability and recall, while model rankings varied across datasets. CONCLUSION: LLMs can generate clinically meaningful T2DM phenotyping SQL when provided with sufficient database context, but limited PPV in real-world data underscores the need for local validation.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Systematic Benchmarking and Optimization of Retrieval-Augmented Generation (RAG) for Clinical Phenotyping: A Type II Diabetes Case Study in an ICD-Screened CohortmedRxiv · 2026
- Agentic Pipeline for Large-Scale Clinical Data Queries in Enterprise Electronic Health RecordsmedRxiv · 2026
- Personalized Diabetes Treatment Support Using Large Language Models Fine-Tuned on Electronic Health Records: Development and Evaluation StudyJMIR Formative Research · 2026
- Large language models are powerful electronic health record encodersnpj Digital Medicine · 2026
- M3: Conversational LLMs simplify secure clinical data access, understanding, and analysis.PLOS digital health · 2026
- Extracting Social Determinants of Health From Electronic Health Records: Development and Comparison of Rule-Based and Large Language Model MethodsJMIR Medical Informatics · 2026