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
- Aryan Ayati (ORCID: https://orcid.org/0000-0002-0241-6865)
- Artur A. Belov (ORCID: https://orcid.org/0000-0001-6848-1224)
- Michelle Wang (ORCID: https://orcid.org/0000-0002-3207-1490)
- Ann‐Kathrin Schalkamp (ORCID: https://orcid.org/0000-0002-8609-9165)
- Vivek Ashok Rudrapatna (ORCID: https://orcid.org/0000-0003-1789-3004)
- Shadera Azzam (ORCID: https://orcid.org/0009-0005-9598-9257)
Institutions
- Center for Biologics Evaluation and Research (US)
- University of California, San Francisco (US)
- Food and Drug Administration (TH)
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