Beyond billing codes: a proof-of-concept study of large language models for pregnancy episode reconstruction from clinical notes

Background: Accurate identification of pregnancy episodes from electronic health records (EHRs) is essential for maternal and fetal health research. Existing approaches rely primarily on diagnosis and procedure codes, which may miss pregnancies documented outside the health system and are susceptible to coding errors. Clinical notes contain richer information but remain largely unexplored for this task. Objectives: To evaluate whether a large language model (LLM) can reconstruct complete pregnancy episodes directly from clinical notes. Methods: Chronologically concatenated notes and messages were provided to GPT-5, which identified episodes and extracted variables including assisted reproductive treatment, gestational age, outcome, and complications. Performance was benchmarked against manual chart review (gold standard) and a hierarchical ICD-code algorithm in 30 patients comprising 74 pregnancies (20 patients in a held-out test set). Results: The LLM identified 53 of 54 test-set pregnancies versus 40/54 for a hierarchical ICD-code algorithm, with fewer spurious episodes (3 vs 24), corresponding to an F1 score for pregnancy detection against chart review of 0.96 vs 0.68. Among pregnancies identified by both methods, median absolute error was 0 vs 25.5 days for start dates (p<0.001) and 0 vs 1 day for end dates (p=0.044), and outcome accuracy was numerically but not significantly higher (0.84 vs 0.74 for exact outcome types; 0.92 vs 0.84 with abortion subtypes grouped). It additionally recovered information unavailable in structured data, including reproductive-treatment type and fetus-level outcomes. Conclusions: An LLM applied to clinical narratives identified pregnancy episodes more completely and with more accurate dates than an ICD-code algorithm while capturing richer clinical detail. Because the two approaches used different input data, these gains reflect both the information in clinical notes and the LLM itself. LLM-based extraction from clinical notes is a promising complement to code-based pregnancy phenotyping that warrants evaluation in larger, multi-institutional cohorts.

Authors

Institutions

Publication Details

Journal
medRxiv
Published
2026-11-23
DOI
https://doi.org/10.64898/2026.11.19.26368521
Primary Topic
Machine Learning in Healthcare
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Beyond billing codes: a proof-of-concept study of large language models for pregnancy episode reconstruction from clinical notes

Aryan Ayati, Artur A. Belov, Michelle Wang, Ann‐Kathrin Schalkamp et al.
medRxiv
Machine Learning in Healthcare
preprint

Beyond billing codes: a proof-of-concept study of large language models for pregnancy episode reconstruction from clinical notes

Aryan Ayati, Artur A. Belov, Michelle Wang, Ann‐Kathrin Schalkamp, Vivek Ashok Rudrapatna, Shadera Azzam
preprint en

Abstract

Background: Accurate identification of pregnancy episodes from electronic health records (EHRs) is essential for maternal and fetal health research. Existing approaches rely primarily on diagnosis and procedure codes, which may miss pregnancies documented outside the health system and are susceptible to coding errors. Clinical notes contain richer information but remain largely unexplored for this task. Objectives: To evaluate whether a large language model (LLM) can reconstruct complete pregnancy episodes directly from clinical notes. Methods: Chronologically concatenated notes and messages were provided to GPT-5, which identified episodes and extracted variables including assisted reproductive treatment, gestational age, outcome, and complications. Performance was benchmarked against manual chart review (gold standard) and a hierarchical ICD-code algorithm in 30 patients comprising 74 pregnancies (20 patients in a held-out test set). Results: The LLM identified 53 of 54 test-set pregnancies versus 40/54 for a hierarchical ICD-code algorithm, with fewer spurious episodes (3 vs 24), corresponding to an F1 score for pregnancy detection against chart review of 0.96 vs 0.68. Among pregnancies identified by both methods, median absolute error was 0 vs 25.5 days for start dates (p<0.001) and 0 vs 1 day for end dates (p=0.044), and outcome accuracy was numerically but not significantly higher (0.84 vs 0.74 for exact outcome types; 0.92 vs 0.84 with abortion subtypes grouped). It additionally recovered information unavailable in structured data, including reproductive-treatment type and fetus-level outcomes. Conclusions: An LLM applied to clinical narratives identified pregnancy episodes more completely and with more accurate dates than an ICD-code algorithm while capturing richer clinical detail. Because the two approaches used different input data, these gains reflect both the information in clinical notes and the LLM itself. LLM-based extraction from clinical notes is a promising complement to code-based pregnancy phenotyping that warrants evaluation in larger, multi-institutional cohorts.

medRxiv
Center for Biologics Evaluation and Research (US), University of California, San Francisco (US), Food and Drug Administration (TH)
Machine Learning in Healthcare
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon