Temporal graph transformer for next visit diagnosis prediction on electronic health records

Next-visit diagnosis prediction with electronic health records (EHR) is critical for proactive medicine, but mainstream methods fail to simultaneously capture cross-visit temporal dependencies, inter-medical-event structural associations and the patient-visit-code hierarchical semantic relationships in EHR, and lack clinical interpretability. This study proposes EHRFormer, a temporal graph transformer model for EHR-based next-visit diagnosis prediction. We first construct a patient-specific temporal heterogeneous graph with timestamped visit nodes and heterogeneous medical event nodes to decouple medical event semantics and visit temporal states, and model intra-visit structural and cross-visit temporal relationships via two types of heterogeneous edges. A temporal-aware heterogeneous message passing mechanism integrated with Time2Vec-based time encoding is designed to fuse temporal and structural information, and meta-path-based global positional and local structural encoding are introduced to capture high-order medical event interactions. Additionally, a patient graph explainer module is developed to identify prediction-critical subgraphs and medical events for clinical interpretability. Extensive experiments on three real-world EHR datasets (MIMIC-III, MIMIC-IV, MarketScan CCAE) with core metrics of visit-level precision@k and code-level accuracy@k demonstrate that EHRFormer achieves state-of-the-art performance, strong noise robustness, and high inference efficiency with linear time complexity. The graph explainer can accurately identify clinically meaningful medical events consistent with clinical guidelines. EHRFormer realizes collaborative learning of EHR’s three-level hierarchical representations, unifying high prediction accuracy, reliable clinical interpretability and efficient inference, and provides a novel paradigm for EHR-based medical predictive modeling with notable clinical application value.

Authors

Institutions

Publication Details

Journal
Scientific Reports
Published
2026-08-14
DOI
https://doi.org/10.1038/s41598-026-66714-8
Primary Topic
Machine Learning in Healthcare
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Temporal graph transformer for next visit diagnosis prediction on electronic health records

Shuhong Zhang, Yuxing Shi, Shumin Zhang, Hua Zhang et al.
Scientific Reports
Machine Learning in Healthcare
article

Temporal graph transformer for next visit diagnosis prediction on electronic health records

Shuhong Zhang, Yuxing Shi, Shumin Zhang, Hua Zhang, Minsi Liang, Zhongheng Jian, Qiang Li, Junchao Liang
article en

Abstract

Next-visit diagnosis prediction with electronic health records (EHR) is critical for proactive medicine, but mainstream methods fail to simultaneously capture cross-visit temporal dependencies, inter-medical-event structural associations and the patient-visit-code hierarchical semantic relationships in EHR, and lack clinical interpretability. This study proposes EHRFormer, a temporal graph transformer model for EHR-based next-visit diagnosis prediction. We first construct a patient-specific temporal heterogeneous graph with timestamped visit nodes and heterogeneous medical event nodes to decouple medical event semantics and visit temporal states, and model intra-visit structural and cross-visit temporal relationships via two types of heterogeneous edges. A temporal-aware heterogeneous message passing mechanism integrated with Time2Vec-based time encoding is designed to fuse temporal and structural information, and meta-path-based global positional and local structural encoding are introduced to capture high-order medical event interactions. Additionally, a patient graph explainer module is developed to identify prediction-critical subgraphs and medical events for clinical interpretability. Extensive experiments on three real-world EHR datasets (MIMIC-III, MIMIC-IV, MarketScan CCAE) with core metrics of visit-level precision@k and code-level accuracy@k demonstrate that EHRFormer achieves state-of-the-art performance, strong noise robustness, and high inference efficiency with linear time complexity. The graph explainer can accurately identify clinically meaningful medical events consistent with clinical guidelines. EHRFormer realizes collaborative learning of EHR’s three-level hierarchical representations, unifying high prediction accuracy, reliable clinical interpretability and efficient inference, and provides a novel paradigm for EHR-based medical predictive modeling with notable clinical application value.

Scientific Reports
Nanyang Technological University (SG), Chengdu Medical College (CN), Sichuan University (CN), Third People's Hospital of Chengdu (CN), Zigong First People's Hospital (CN), Inner Mongolia University of Technology (CN)
Natural Science Foundation of Inner Mongolia
Openalex Percentile: Top 8%
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.