Temporal EHR Models Detect Rare Disease Years Before Diagnosis

Read the full article See related articles

Listed in

This article is not in any list yet, why not save it to one of your lists.
Log in to save this article

Abstract

Background

Rare diseases collectively affect an estimated 300 million people worldwide, yet patients wait an average of 4–8 years for a correct diagnosis after visiting multiple physicians, accumulating unexplained findings, and suffering preventable disease progression before a unifying diagnosis is reached. Electronic health records (EHRs) capture this pre-diagnostic trajectory in rich detail, but conventional methods typically collapse years of longitudinal phenotypic signals into a single static snapshot; our approach instead models this temporal structure directly.

Methods

We conducted a retrospective cohort study using longitudinal EHR data from approximately 3 million patients at Mayo Clinic Platform_Accelerate. Cases were patients with confirmed diagnoses of 10 rare diseases; controls (∼5,200 per disease) had no record of any rare disease. HPO phenotype terms were extracted from clinical notes and laboratory results using a medspaCy NLP pipeline; ICD codes were grouped at three-character level. We developed and trained two temporal models, GRU-Attn and Conformer, that encode patient histories as quarterly time-binned sequences spanning up to 30 years, and compared these against three static baselines (CatBoost, XGBoost, logistic regression). Models were evaluated systematically at prediction horizons h = 1–10 years before diagnosis.

Results

In the full held-out cohort benchmark, temporal models outperformed static baselines across the large majority of diseases and prediction horizons, with the advantage widening substantially as the horizon lengthened. At 1–2 years prior to diagnosis, mean AUROC was 0.928 (GRU-Attn) versus 0.871 (CatBoost); at 6–10 years prior to diagnosis, 0.726 versus 0.693, with static models degrading to near-chance for some diseases. Combining HPO and ICD features yielded the strongest performance, with a mean gain of +0.063 AUROC over the best single source at 1–2 years prior to diagnosis. Separately, in a manually curated cohort of 143 confirmed-undiagnosed cases with extended EHR histories, GRU-Attn identified 138 cases before first disease mention and all 143 cases before formal diagnosis at the prespecified 99th-percentile specificity threshold, with median lead times of 1.1–8.3 years and 1.9–21.7 years, respectively.

Conclusions

By learning from the temporal trajectory of phenotypic signals rather than their static aggregate, temporal EHR models improved retrospective early detection performance across several rare diseases, most powerfully for conditions where pre-diagnostic findings accrue gradually and heterogeneously over years. These results show that longitudinal EHR trajectories carry rare-disease signal beyond static phenotypic burden and support prospective evaluation of temporal EHR modeling for rare-disease risk stratification.

Article activity feed