Skip to main content
JACC: Advances logoLink to JACC: Advances
. 2026 Oct 3;5(11):103291. doi: 10.1016/j.jacadv.2026.103291

A Knowledge Graph Framework for Longitudinal Congenital Heart Disease Modeling

Methodology Corner

Hang Xu a,b,c, Lila Cunge a,b,c, Zhengyang Ming a,b,c, Siyan Chen a,b,c, Majid Husain d, Pierangelo Renella b,e, Gentian Lluri f, J Paul Finn b,g,h, William Hsu b,c, Kim-Lien Nguyen a,b,c,g,h,∗
PMCID: PMC13660652  PMID: 42828809

Abstract

Background:

Congenital heart disease (CHD) is characterized by evolving clinical trajectories; staged interventions; and complex relationships among diagnoses, procedures, and encounters. Conventional machine learning applied to electronic health record (EHR) data often rely on static feature representations that do not preserve the natural longitudinal disease progression or clinical context.

Objectives:

The purpose of this study was to develop a knowledge graph–based framework for trajectory-aware representation and analysis of longitudinal CHD EHR data.

Methods:

We constructed a longitudinal knowledge graph that integrates patients, encounters, diagnoses, and procedures while preserving temporal ordering across the care continuum. Term frequency–inverse document frequency and Word2Vec approaches were applied to encounter contexts extracted from the graph to generate longitudinal patient representations that supported phenotyping, patient similarity analysis, and retrospective classification.

Results:

Using accumulated longitudinal EHR from a cardiovascular magnetic resonance cohort, we demonstrate that the framework captured clinically meaningful patterns and supported retrospective identification of single ventricle physiology as a representative use case.

Conclusions:

This knowledge graph framework provides a scalable approach for preserving temporal and relational clinical context and enable trajectory-aware modeling of longitudinal cardiovascular EHR data in patients with CHD.

Key words: congenital heart disease, electronic health records, knowledge graph, patient similarity, TF-IDF, Word2Vec

Central Illustration

graphic file with name ga1.webp

Background

Congenital heart disease (CHD) affects approximately 1% of live births and represents one of the most complex and heterogeneous conditions in cardiovascular medicine.1, 2, 3 Advances in surgical and catheter-based therapies have substantially improved long-term survival, resulting in a growing population of patients who require lifelong, multidisciplinary care.4,5 Clinical management involves multiple interventions, evolving physiological states, and care continuum that is highly variable across patients and institutions. In single ventricle physiology (SVP), one of the most complex forms of CHD, disease progression is characterized by staged surgical palliation, persistent hemodynamic burden, and progressive multisystem complications that sometimes evolve over decades. The resulting medical history is highly heterogeneous, temporally dynamic, and distributed across multiple encounters, procedures, and diagnostic events, making identification of clinically meaningful longitudinal patterns a major challenge for precision cardiovascular medicine.

Electronic health record (EHR) data contain rich longitudinal information on disease evolution and clinical decision-making. However, many machine-learning approaches summarize these records as fixed patient-level feature sets derived from diagnoses, procedures, and laboratory values, thereby limiting representation of the temporal and relational context of care.6, 7, 8, 9 Representation-learning methods have enabled scalable phenotyping and patient stratification from structured EHR data.10, 11, 12 For complex CHD, both the order and co-occurrence of diagnoses and procedures may carry important clinical information. Although sequence-based models can represent event ordering, they commonly encode records as ordered event sequences and may not explicitly capture relationships among patients, encounters, diagnoses, and procedures within the care pathway. Knowledge graphs provide a complementary framework by representing these entities and their connections as an interconnected relational network.13, 14, 15 Such graphs can be coupled with term frequency–inverse document frequency (TF-IDF) and Word2Vec representations to derive complementary longitudinal features from coded clinical data. However, graph neural network (GNN) approaches can be computationally demanding and may be susceptible to overfitting in small, heterogeneous clinical cohorts.16 Few existing EHR frameworks jointly represent encounter-level clinical relationships and longitudinal care patterns in complex cardiovascular disease populations.

We propose a knowledge graph–based framework for longitudinal CHD modeling that addresses this gap. Patients, clinical encounters, diagnoses (International Classification of Diseases [ICD]-9/10), and procedures (Current Procedural Terminology [CPT]) are represented as interconnected graph entities, with temporal ordering preserved across the longitudinal care trajectory. Encounter-level relationships extracted from the graph are then modeled using both sparse TF-IDF feature representations and dense skip-gram Word2Vec embeddings, enabling characterization of longitudinal co-occurrence patterns among diagnoses, procedures, and clinical encounters.17, 18, 19 Using a cohort of patients undergoing ferumoxytol-enhanced cardiovascular magnetic resonance imaging at a tertiary academic center, we demonstrate how this framework supports scalable phenotyping, patient similarity analysis, and disease classification, with SVP serving as a representative high-complexity use case.

Methods

Ethics statement and study cohorts

This retrospective study was approved by the Institutional Review Board of the University of California, Los Angeles (IRB #17-0032 and IRB #25-2049), conducted in accordance with the Declaration of Helsinki, and compliant with the U.S. Health Insurance Portability and Accountability Act. Informed consent was waived for the retrospective use of existing EHR data. The derivation cohort (cohort 1) included 1,020 patients (age range 121 days to 104 years) who underwent ferumoxytol-enhanced cardiovascular magnetic resonance imaging at a tertiary academic medical center between January 1, 2014, and December 31, 2022. Patients were identified using relevant CPT codes (70010-76499) and imaging-related keywords. Extracted data included demographics, encounters, diagnoses (ICD-9/-10), and procedures (CPT). The data set comprised 126,446 encounters, 10,219 unique ICD codes, and 6,857 unique CPT codes. Cohort characteristics and expert physician adjudication have been previously described.20 The CHD validation cohort (cohort 2) initially comprised 2,500 patients identified using ICD-9 and ICD-10 diagnostic codes between March 1, 2013, and May 10, 2023. The general-population cohort (cohort 3) initially comprised 58,774 patients with at least two clinical encounters between January 1, 2023, and December 31, 2023, and at least 1 available echocardiography, cardiovascular magnetic resonance, or computed tomography report. Cohorts 2 and 3 were used to evaluate external validity and generalizability, respectively.

Because the cohorts were assembled independently from the same institutional EHR using different eligibility criteria and calendar periods, patient overlap was possible and steps were taken to avoid overlap. First, patient-level linkage identified 38 patients shared by cohorts 1 and 2, 127 shared by cohorts 1 and 3, and 317 shared by cohorts 2 and 3; no patient appeared in all three cohorts. Before model development and validation, cohort membership was reconciled using unique patient identifiers according to a prespecified hierarchical assignment procedure. Cohort 1 retained priority as the derivation cohort, and its members were excluded from cohorts 2 and 3. Among the remaining patients, cohort 2 retained priority as the CHD validation cohort, and its members were excluded from cohort 3. The resulting mutually exclusive analytic cohorts comprised 1,020 patients in cohort 1, 2,462 patients in cohort 2, and 58,330 patients in cohort 3. Their demographic characteristics are summarized in Supplemental Table 1.

SVP reference labeling and general-population screening audit

SVP reference labels for the derivation cohort (cohort 1; N = 1,020) and independent CHD validation cohort (cohort 2; N = 2,500) were established using a previously validated phenotyping framework that incorporated operative reports, imaging findings, catheterization data, and longitudinal clinical documentation. In the initial general-population screening cohort (cohort 3; N = 58,774), rule-based and ICD-based screening identified 347 candidate cases (0.59%) for independent cardiologist review. To audit potential false negatives, 200 patients were randomly sampled from the 58,427 patients classified as screen-negative and underwent independent physician review. No SVP cases were identified in this sample (0/200; observed missed-case proportion, 0%; one-sided exact 95% upper confidence limit, 1.49%). This audit was performed as a negative-case quality-assurance assessment and did not constitute complete adjudication of the screen-negative population. To ensure patient-level independence, cohort membership was reconciled using a prespecified hierarchical assignment procedure. Patients in cohort 1 were retained in the derivation cohort and excluded from cohorts 2 and 3. Among the remaining patients, those assigned to cohort 2 were retained in the CHD validation cohort and excluded from cohort 3. The resulting mutually exclusive analytic cohorts included 95 patients with SVP among 1,020 patients in cohort 1, 88 among 2,462 patients in cohort 2, and 48 among 58,330 patients in cohort 3.

Framework overview

The overall pipeline (Figure 1) consists of: 1) data standardization and harmonization; 2) longitudinal knowledge graph construction; and 3) downstream longitudinal modeling using TF-IDF feature representations and Word2Vec-based co-occurrence analysis derived from encounter contexts extracted from the graph. The knowledge graph served as the organizational framework for preserving longitudinal temporal ordering and relational clinical structure across encounters, diagnoses, and procedures, whereas TF-IDF and Word2Vec approaches generated patient-level longitudinal representations for phenotyping, patient similarity analysis, and retrospective classification applications. Sequential aggregation refers to the longitudinal combination of encounter-level representations across temporally ordered clinical visits to generate patient-level representations summarizing evolving diagnostic and procedural patterns over time.

Figure 1.

Figure 1

Knowledge Graph Framework for Longitudinal Cardiovascular Disease Modeling

Structured electronic health record data, including demographics, encounters, diagnoses (ICD-9/10), and procedures (CPT), were harmonized through an ETL pipeline with temporal alignment and code normalization. The patient-centered knowledge graph organized longitudinal clinical relationships among patients, encounters, diagnoses, and procedures. Term frequency–inverse document frequency and Word2Vec approaches were applied to encounter contexts extracted from the graph to generate longitudinal patient representations to support phenotyping, patient similarity analysis, trajectory characterization, and retrospective single ventricle physiology classification. CPT = Current Procedural Terminology; DILV = double inlet left ventricle; ENC = encounter; ETL = Extract, Transform, and Load; HLHS = hypoplastic left heart syndrome; ICD = International Classification of Diseases.

EHR data standardization and harmonization

Clinical encounters were represented as sets of co-occurring ICD diagnosis codes and CPT procedure codes. ICD-9 codes were mapped to ICD-10 equivalents using the Centers for Medicare and Medicaid Services General Equivalence Mappings to establish a unified diagnostic coding system.21 CPT codes were normalized to canonical identifiers to remove formatting inconsistencies.

Knowledge graph construction

A patient-centered knowledge graph was constructed in which patients, encounters, diagnoses, and procedures were represented as nodes connected through typed relational edges, including has_encounter, has_diagnosis, and has_procedure, capturing the multirelational structure of clinical care. Temporal ordering of encounters was preserved across the graph, enabling reconstruction of individual patient trajectories as longitudinally ordered encounter networks. Unlike static feature aggregation approaches that collapse longitudinal records into a single vector, this structure jointly encodes relational context within encounters and temporal progression across visits.

Model development and comparative evaluation

SVP classification models were developed in the physician-adjudicated derivation cohort (cohort 1; N = 1,020). Longitudinal ICD and CPT codes from all available encounters were cleaned, harmonized, and aggregated into patient-level clinical-code documents. Physician-adjudicated SVP status served as the reference standard. Three complementary representation strategies were evaluated: sparse TF-IDF vectors, dense Word2Vec embeddings, and a GNN. TF-IDF represented the relative importance of individual codes, whereas skip-gram Word2Vec generated patient vectors by averaging the embeddings of all tokens in each patient’s record. Both representations were evaluated using logistic regression and XGBoost.22 The GNN was implemented using GraphSAGE architecture.23 Patients were represented as nodes with L2-normalized Word2Vec vectors designated as node features. An undirected 15-nearest-neighbor patient-similarity graph was constructed using cosine distance. The two-layer GraphSAGE model used mean neighborhood aggregation, a 64-dimensional hidden layer, rectified linear-unit activation, and dropout of 0.30, followed by a single patient-level classification logit. This architecture assessed whether incorporating information from clinically similar neighboring patients improved classification beyond individual patient representations.

The TF-IDF– and Word2Vec–based logistic regression and XGBoost pipelines and the GraphSAGE model were internally evaluated using identical patient-level stratified 5-fold cross-validation partitions. All encounters belonging to the same patient were retained within a single fold. In each outer iteration, approximately 80% of patients comprised the training partition, whereas the remaining 20% were held out exclusively for evaluation. All data-dependent preprocessing, including TF-IDF fitting, Word2Vec training, class-weight estimation, classifier fitting, and threshold selection, was restricted to the outer training partition. For GraphSAGE, the patient-similarity graph used for model training was constructed using only outer-training patients; held-out patients and their incident edges were excluded. GraphSAGE was optimized using AdamW and class-weighted binary cross-entropy, with early stopping based on area under the precision-recall curve (AUPRC) in an inner validation subset drawn exclusively from the outer training partition. The fitted transformations and models were then applied to the outer held-out fold. For GraphSAGE, held-out predictions were generated using the frozen training-derived Word2Vec representation and prespecified 15-nearest-neighbor graph-construction procedure. Predictions from the five held-out folds were pooled, yielding 1 out-of-fold prediction per patient. The outer held-out fold was not used for preprocessing, model fitting, early stopping, threshold selection, or hyperparameter optimization.

After development, all preprocessing objects, model parameters, and classification thresholds were locked. The models were applied without further training, tuning, recalibration, or threshold optimization to the independent CHD cohort (cohort 2) and general-population cohort (cohort 3). TF-IDF and Word2Vec features were generated using parameters learned from the derivation cohort. For GraphSAGE, a separate 15-nearest-neighbor graph was constructed within each external cohort using fixed Word2Vec representations and cosine distance; external outcome labels were not used in graph construction or model fitting. Performance was assessed using area under the receiver-operating characteristic curve (AUROC), AUPRC, accuracy, precision, recall, F1 score, and Brier score, with 95% CIs.

Temporal scope and intended use

For each patient, diagnosis and procedure features were aggregated across all available encounters within the applicable cohort-specific data-extraction period. The analysis did not define an index decision time or a future prediction horizon. The resulting models were developed for SVP phenotype classification and cohort identification using retrospectively accumulated longitudinal EHR information.

Downstream clinical applications

The learned patient representations were further evaluated for phenotypic organization, patient similarity analysis, and longitudinal trajectory characterization. Embedding structure was visualized using Uniform Manifold Approximation and Projection, with cluster separation assessed using silhouette score and cluster purity metrics. Pairwise cosine similarity between patient embeddings was calculated to compare similarity distributions among SVP-SVP, SVP–non-SVP, and non-SVP–non-SVP patient pairs. Similarity matrices were additionally used to construct k-nearest-neighbor networks to identify patients with shared longitudinal clinical trajectories. Model interpretability and contributing clinical features were evaluated using SHapley Additive exPlanations (SHAP).

Statistical and computational analysis

Analyses were performed in Python 3.11.11 using custom pipelines, gensim 4.4.0 for Word2Vec, XGBoost 2.0.0 and scikit-learn 1.6.1 for classification, and SHAP 0.50.0 for model interpretation. Internal performance was calculated from patient-level pooled out-of-fold predictions. Ninety-five percent percentile confidence intervals for AUROC, AUPRC, accuracy, precision, recall, specificity, F1 score, and Brier score were estimated using 2,000 stratified patient-level bootstrap resamples. Identical resamples were used for paired model comparisons. The same procedure was applied to the independent CHD validation cohort; general-population results were summarized as a screen-assisted application.

Data availability

The data sets analyzed contain protected health information and are not publicly available due to Institutional Review Board and Health Insurance Portability and Accountability Act restrictions. Data were accessed and analyzed within an approved secure environment. Requests for access to de-identified data may be considered subject to institutional and Institutional Review Board approval and execution of an appropriate data-use agreement.

Results

Cohort characteristics and data processing

The training cohort comprised 1,020 patients with 126,446 clinical encounters, encompassing 10,219 unique ICD diagnostic codes and 6,857 unique CPT procedural codes. The Extract, Transform, and Load pipeline successfully harmonized multimodal EHR inputs, demographics, encounters, diagnoses, and procedures, through temporal alignment, ICD-9 to ICD-10 mapping, and CPT normalization (Figure 2A). Among the 1,020 patients, 516 carried a CHD diagnosis spanning ICD-10 subtypes Q20–Q28, with heterogeneous distribution across CHD categories (Figure 2B). Diagnostic and procedural code utilization demonstrated substantial variability in health care utilization and clinical complexity across this tertiary referral population. A CHD ontology framework mapped ICD-10 diagnostic categories Q20–Q28 to corresponding ICD-9 code ranges, enabling unified longitudinal code representation within the knowledge graph framework (Figure 2C). Model generalizability was subsequently evaluated in an independent CHD validation cohort (N = 2, 462) and a large general population cohort (N = 58,330), enabling assessment across broader clinical populations and varying SVP prevalence.

Figure 2.

Figure 2

Data Processing Pipeline, Cohort Characterization, and Congenital Heart Disease Ontology

(A) Extract, transform, and load pipeline processing raw EHR data through sequential stages of extraction, harmonization (temporal alignment, code normalization, ICD-9 to ICD-10 mapping), knowledge graph construction, and cohort evaluation. (B) Cohort characterization shows CHD subtype distribution across ICD-10 categories Q20 through Q28, age distribution across CHD and non-CHD patients, top 15 ICD diagnostic chapters and CPT procedural categories by encounter frequency, and distributions of unique and total ICD and CPT codes per patient. (C) CHD ontology framework mapping ICD-10 diagnostic categories Q20 through Q28 to corresponding ICD-9 code ranges, supporting unified code representation within the knowledge graph. CHD = congenital heart disease; CM = clinical modification; EHR = electronic health record; other abbreviations as in Figure 1.

Knowledge graph construction and ontology

A domain-specific clinical ontology for SVP captured the full spectrum of diagnostic evaluations, staged surgical palliation, and long-term complications characteristic of single ventricle care (Figure 3A). The knowledge graph entities included patients, encounters, diagnoses, and procedures. Linked relationships included has_encounter, has_diagnosis, and has_procedure (Figure 3B). The schema organized clinical data into a hierarchical structure that connected patient-level records to encounter-level events and their associated ICD and CPT codes (Figure 3C). Two patient trajectories were reconstructed as temporally ordered encounter networks, capturing the sequential evolution of diagnoses, procedures, and follow-up events over time (Figure 3D).

Figure 3.

Figure 3

Knowledge Graph Ontology and Patient Trajectory Representation

(A) SVP clinical ontology to capture diagnostic evaluation, staged surgical palliation (Norwood, Glenn, and Fontan), postoperative outcomes, and long-term complications including arrhythmias, Fontan-associated liver disease, and protein-losing enteropathy. (B) Knowledge graph construction includes clinical entities (patient, encounter, diagnosis, procedure) and typed relational edges. (C) Knowledge graph schema illustrates hierarchical linkage from patient nodes through encounter nodes to diagnosis and procedure codes. (D) Example longitudinal trajectories for two SVP patients showing temporally ordered encounters connected through sequential relational edges with associated diagnoses and procedures. BT = Blalock-Taussig (shunt); CT = computed tomography; KG = knowledge graph; MRI = magnetic resonance imaging; SVP = single ventricle physiology; other abbreviations as in Figure 1.

Encounter-level embeddings capture clinically coherent structure

Uniform Manifold Approximation and Projection visualization of encounter embeddings derived from ICD diagnosis codes demonstrated clustering of major clinical diagnostic categories across 126,446 encounters (Figure 4A). The ontology for harmonizing ICD chapters used for the encounter embedding is shown in Supplemental Figure 1. Embeddings derived from CPT procedure codes similarly grouped encounters according to prominent procedural categories, including evaluation and management, surgery, radiology, and laboratory services, across 143,516 encounters (Figure 4B). The difference in encounter counts between diagnosis-based (126,446 encounters) and procedure-based (143,516 encounters) analyses reflect the fact that ICD diagnosis codes and CPT procedure codes are captured independently within the EHR. Consequently, not all encounters contained both code types, resulting in different numbers of encounters available for each embedding analysis. All CPT codes of procedural categories are provided in Supplemental Table 2, and CHD-related CPT codes in Supplemental Table 3. These results indicate that the skip-gram approach captured meaningful co-occurrence structure within clinical encounters without requiring manual feature engineering.

Figure 4.

Figure 4

Embedding-Based Representation of Encounters and Patient Trajectories

(A) UMAP visualization of encounter embeddings derived from ICD diagnosis codes across 126,446 encounters showing clustering by diagnostic category. (B) UMAP visualization of CPT procedure code embeddings across 143,516 encounters showing clustering by procedural category including CHD-specific subgroups. (C) Patient-level embedding space showing distribution of SVP and non-SVP patients. (D) Pairwise cosine similarity distributions among SVP-SVP, SVP-non-SVP, and non-SVP-non-SVP pairs. (E) Longitudinal trajectory of a representative SVP patient across six encounters from 2016 to 2022, spanning staged palliation from Blalock-Taussig shunt to Fontan completion, with corresponding 128-dimensional encounter embeddings and UMAP trajectory visualization. EP = electrophysiology; UMAP = Uniform Manifold Approximation and Projection; other abbreviations as in Figure 1, Figure 2, Figure 3.

Patient-level embeddings preserve trajectory-specific signatures

Aggregation of encounter-level embeddings yielded patient-level representations summarizing longitudinal diagnostic and procedural trajectories (Figure 4C). Descriptively, SVP-SVP pairs exhibited higher cosine similarity than either SVP–non-SVP or non-SVP–non-SVP pairs. The median TF-IDF cosine similarity was 0.126 for SVP-SVP pairs, compared with 0.033 for SVP–non-SVP pairs and 0.033 for non-SVP–non-SVP pairs. Because each patient contributed to multiple pairwise observations, these distributions were not statistically independent and were therefore summarized descriptively without conventional pairwise inference (Figure 4D). In a representative patient with SVP, six sequential encounters from March 2016 to February 2022 delineated the clinical course from stage I palliation with a Blalock-Taussig shunt through stage II bidirectional Glenn palliation, interstage follow-up, longitudinal surveillance, pre-Fontan evaluation, and stage III Fontan completion. At each encounter, co-occurring diagnoses and procedures were encoded as a 128-dimensional Word2Vec representation and projected into a 2-dimensional embedding space. Temporal changes in embedding position corresponded to evolving clinical contexts across staged palliation and follow-up, providing a qualitative illustration of longitudinal trajectory representation (Figure 4E).

Embedding-based patient similarity and SVP classification

Similarity networks derived from ICD and CPT code representations in the 1,020-patient derivation cohort (cohort 1) demonstrated preferential clustering of expert-adjudicated SVP patients within distinct regions of the patient representation space, despite SVP not being directly encoded by individual ICD diagnosis codes (Figure 5A). Using TF-IDF representations and XGBoost modeling in the cohort 1, SVP classification demonstrated strong discrimination between SVP and non-SVP patients. The confusion matrix generated from held-out testing folds during 5-fold cross-validation demonstrated high agreement between model classifications and expert-adjudicated ground-truth labels (Figure 5B). Threshold-dependent analysis further demonstrated consistently favorable sensitivity and specificity across classification thresholds in the testing cohort (Figure 5C). Cross-validated testing performance achieved an AUROC of 0.984 ± 0.017 and an AUPRC of 0.910 ± 0.055 (Figure 5D and 5E), supporting robust discrimination despite class imbalance. SHAP analysis of the TF-IDF–XGBoost model performed on the full cohort 1 identified congenital cardiac diagnoses, staged surgical management procedures, cardiovascular imaging utilization, and longitudinal procedural patterns among the most influential contributors to SVP classifications (Figure 5F). Comparative modeling across TF-IDF, Word2Vec, logistic regression, XGBoost, and a GraphSAGE-based GNN approaches demonstrated that TF-IDF combined with XGBoost achieved the strongest overall performance across accuracy, precision, recall, and F1-score metrics within the derivation cohort (cohort 1; N = 1,020) (Figure 5G). In the independent CHD validation cohort (cohort 2; N = 2,462), TF-IDF combined with logistic regression demonstrated stable performance. The locked pipeline was additionally deployed in the general-population cohort (cohort 3; N = 58,330) as a large-scale screening application. Because outcome status was only partially verified in this cohort, its results were not interpreted as independent estimates of diagnostic accuracy (Figure 5H).

Figure 5.

Figure 5

Patient Similarity Networks and Embedding-Based Single Ventricle Physiology Classification

(A) Patient similarity network derived from ICD and CPT code embeddings, demonstrating preferential clustering of expert-adjudicated SVP patients (red circles) within the embedding space. (B) Confusion matrix from internal validation of the TF-IDF and XGBoost classifier in the 1,020-patient derivation cohort. (C) Threshold-dependent sensitivity and specificity analysis. (D) Receiver-operating characteristic curve and (E) precision–recall for SVP classification. (F) SHAP-based feature importance analysis identifying influential ICD and CPT code features contributing to retrospective SVP classification. (G) Comparison of TF-IDF, Word2Vec, logistic regression, XGBoost, and GNN models across AUROC, AUPRC, accuracy, precision, recall, and F1-score metrics. (H) External validation performance in the independent CHD cohort (Cohort 2; N = 2,462) and descriptive results from large-scale screening application in the general-population cohort (Cohort 3; N = 58,330). AUPRC = area under the precision-recall curve; AUROC = area under the receiver-operating characteristic curve; GNN = graph neural network; N/A = not applicable; RVOT = right ventricular outflow tract; SHAP = SHapley Additive exPlanations; SVT = supraventricular tachycardia; TF-IDF = term frequency–inverse document frequency; other abbreviations as in Figures 1, 2, and 4.

Discussion

This study presents a knowledge graph–based framework for longitudinal modeling of CHD care that preserves both relationships within clinical encounters and temporal progression across visits. Applied to a cohort of patients undergoing ferumoxytol-enhanced cardiovascular magnetic resonance imaging at a tertiary academic center and validated against larger and more generalizable patient cohorts, the framework generated patient representations that captured clinically coherent diagnostic and procedural organization, identified SVP-enriched longitudinal trajectory patterns, and supported patient similarity analysis and retrospective SVP phenotype classification. Comparative analyses across TF-IDF, Word2Vec, logistic regression, XGBoost, and GraphSAGE-based GNN approaches further demonstrated the feasibility of scalable longitudinal phenotyping using structured EHR data. Across all cohorts, the expert-informed rule-based phenotyping algorithm consistently achieved the highest overall performance, highlighting the continued value of clinically curated phenotyping frameworks.20 Importantly, the rule-based phenotyping approach incorporated multimodal clinical information, including echocardiography, cardiovascular magnetic resonance imaging, computed tomography reports, and consultation notes, whereas the computational classification approaches evaluated in the current study relied primarily on structured ICD and CPT code representations alone. These approaches may facilitate scalable, automated longitudinal phenotyping and prioritization of patients for subsequent clinical review.

Conventional machine learning approaches applied to EHR data typically compress longitudinal patient histories into static cross-sectional feature vectors, limiting preservation of temporal relationships and co-occurring clinical context within encounters that are central to CHD care.8 Sequence-based models partially address temporal ordering but often fail to represent the true complexity of the clinical history and patient visits.24 Our framework addresses these limitations by using a patient-centered knowledge graph in which encounters, diagnoses, and procedures are represented as interconnected entities linked through typed relationships, whereas temporal ordering is preserved across the longitudinal care trajectory. Word2Vec-based encounter embeddings were primarily used to evaluate longitudinal co-occurrence structure, patient similarity, and trajectory organization within the embedding space. For SVP classification, we used TF-IDF representations of longitudinal diagnostic and procedural code patterns as input features for machine learning models, as this approach demonstrated stronger and more stable classification performance across internal validation cohorts.25 Together, these approaches enabled identification of clinically coherent longitudinal patterns from heterogeneous real-world EHR data without extensive manual feature engineering.

Although temporal sequence models and transformer-based approaches may capture ordering and timing of clinical events,11,26,27 our study focused on retrospective SVP phenotyping using accumulated longitudinal diagnosis and procedure histories. Compared with transformer-based approaches, we used co-occurrence–based skip-gram Word2Vec embeddings and TF-IDF feature representations derived from encounter contexts extracted from the graph. This strategy prioritized computational efficiency, scalability, and robustness for relatively small heterogeneous clinical cohorts while leveraging longitudinal co-occurrence patterns among diagnoses and procedures. Unlike free-text approaches, the framework operated directly on structured ICD and CPT codes aggregated across longitudinal encounters. The resulting encounter representations captured clinically meaningful diagnostic and procedural relationships across 126,446 encounters, and longitudinal aggregation generated patient-level representations that preserved evolving clinical trajectory patterns. Consistent with the updated comparative analyses, TF-IDF combined with logistic regression demonstrated stronger and more stable classification performance than XGBoost and GNN approaches across internal validation cohorts, supporting the utility of this computationally efficient framework for longitudinal cardiovascular phenotyping. Across all cohorts, the expert-informed rule-based phenotyping algorithm consistently achieved the strongest overall performance, likely reflecting incorporation of multimodal clinical information including echocardiography, cardiovascular magnetic resonance imaging, computed tomography reports, and consultation notes, which were not directly incorporated into the artificial intelligence-based models in the current study.

A key design principle of this framework is generalizability. By representing clinical relationships through standardized diagnostic and procedural ontologies rather than institution-specific features, the knowledge graph framework is potentially adaptable across multi-institutional EHR data sets and broader cardiovascular modeling applications.18,21 Notably, SVP-enriched embedding neighborhoods emerged without explicit SVP phenotype encoding, as SVP is not directly represented by individual ICD diagnostic codes, suggesting that the framework captured latent clinical structure from longitudinal co-occurrence patterns among diagnoses and procedures. The observed overlap between SVP and non-SVP patients within the embedding space likely reflects the shared comorbidities, procedural pathways, and longitudinal care patterns characteristic of real-world CHD populations rather than inadequate model separation. This partial overlap may therefore represent clinically meaningful structure and may contribute to improved robustness and generalizability across external cohorts with heterogeneous disease presentations.

Trajectory-aware modeling of longitudinal EHR data may have important clinical relevance for the care of patients with CHD and other cardiovascular diseases. Identifying patients with similar longitudinal clinical patterns, even in the absence of explicit diagnostic labels, may help support individualized risk assessment, longitudinal follow-up planning, and earlier recognition of patients at risk for clinical deterioration or late complications. The patient similarity networks generated by this framework also provide an interpretable view of shared clinical trajectories that may be useful during important transitions of care, including transfer from pediatric to adult CHD programs. More broadly, as cardiovascular care increasingly incorporates longitudinal real-world data, approaches that preserve both temporal progression and relationships among clinical events may help support future clinical decision support and longitudinal phenotyping applications.

Study Limitations

Several limitations warrant consideration. First, the derivation and validation cohorts were obtained from a single tertiary referral center, and variations in clinical practice patterns, referral pathways, and coding practices across institutions may influence model transportability, highlighting the need for future multicenter external validation. Second, the current framework relies primarily on structured diagnostic and procedural codes and does not incorporate additional modalities such as imaging-derived phenotypes or unstructured clinical notes, which may further improve longitudinal patient representations and classification performance. Third, although the study compared TF-IDF, Word2Vec, and GNN approaches, more advanced transformer-based longitudinal sequence models were not evaluated and warrant future investigation. Fourth, SVP adjudication relied on expert physician review, which provided high-quality reference labels but may limit scalability. Fourth, the general-population cohort was designed as a screening application rather than a fully adjudicated validation cohort. Among 58,427 screen-negative patients, 200 were randomly reviewed, with no missed SVP cases identified. This limited audit cannot exclude false negatives in the full cohort or within the CHD-coded subgroup; therefore, general-population findings should not be interpreted as fully verified estimates of sensitivity or negative predictive value. Fifth, sequential aggregation summarizes longitudinal encounter-level representations into patient-level embeddings and may not fully capture complex temporal dependencies or evolving disease states. Finally, because features were aggregated across the available longitudinal record without a predefined index decision time, information documented later in the clinical course could contribute to SVP classification. This design is appropriate for phenotype identification, cohort discovery, and chart-review triage based on retrospectively collected data but does not establish prospective, early-detection, or real-time predictive performance. Such applications require a separate temporal design in which features are restricted to information available before a predefined decision time and evaluated against a specified future outcome horizon. Future work will therefore focus on integrating multimodal longitudinal data, evaluating transformer-based architectures, expanding multicenter validation, and prospectively evaluating temporally anchored models before their use for cardiovascular risk stratification or longitudinal clinical decision support.

Conclusions

A knowledge graph–based framework that preserves relational structure and temporal ordering within EHR data may provide a scalable approach for longitudinal cardiovascular modeling. Applied to a complex CHD cohort with emphasis on SVP, the framework supported longitudinal phenotyping, patient similarity analysis, and retrospective SVP classification using structured clinical data without extensive manual feature engineering. These findings suggest that longitudinal modeling approaches incorporating relational clinical structure may provide a useful framework for future phenotyping and clinical decision-support applications in congenital and potentially acquired cardiovascular disease.

Perspectives.

COMPETENCY IN MEDICAL KNOWLEDGE: A patient-centered knowledge graph can organize longitudinal diagnoses, procedures, and encounters while preserving relational context and temporal ordering. Structured-code representations enabled scalable retrospective identification of single ventricle physiology; whereas, the superior performance of expert-informed multimodal phenotyping underscored the continuing value of clinically curated imaging and textual information.

TRANSLATIONAL OUTLOOK: Prospective clinical use will require evaluation at predefined decision points using only information available at those times, with prespecified prediction horizons when applicable. Further work should include independent multicenter validation with strict patient-level separation, representative expert adjudication of both positive and negative cases, and integration of imaging data and clinical text.

Funding support and author disclosures

This work was supported in part by NIH grant R01HL127153 and NIH/NCATS UL1TR001881. The authors have reported that they have no relationships relevant to the contents of this paper to disclose.

Acknowledgments

The authors thank the patients for whose longitudinal clinical data made this research possible. The authors acknowledge UCLA Clinical and Translational Science Institute and the UCLA Unified Learning Environment for Analytics and Data (ULEAD) team for their support with data access and research infrastructure. The authors thank UCLA Health for providing access to the EHR data used in this study, and the clinical collaborators who contributed to case adjudication and expert physician review of SVP. The authors thank Ms. Xinran Gao for her assistance with the Central Illustration. The authors thank Prof Myung-Shin Sim for additional review of statistical analyses.

Central Illustration.

Central Illustration

Knowledge Graphs for Longitudinal Modeling of Congenital Heart Disease

Longitudinal EHR diagnoses, procedures, and encounters were represented using TF-IDF, Word2Vec, and GraphSAGE for retrospective SVP phenotyping and patient-similarity analysis. Models were developed in the derivation cohort (N = 1,020), evaluated in the independent same-center CHD cohort (N = 2,462), and applied to the general-population screening cohort (N = 58,330). Displayed model combinations had the numerically highest point estimates; superiority was not inferred without paired confidence intervals. CHD = congenital heart disease; EHR = electronic health record; GNN = graph neural network; SVP = single ventricle physiology; TF-IDF = term frequency–inverse document frequency.

Footnotes

The authors attest they are in compliance with human studies committees and animal welfare regulations of the authors’ institutions and Food and Drug Administration guidelines, including patient consent where appropriate. For more information, visit the Author Center.

Appendix

For supplemental tables and figures, please see the online version of this paper.

Supplementary material

Supplementary material
mmc1.docx (5MB, docx)

References

  • 1.Opotowsky A.R., Allen K.Y., Bucholz E.M., et al. Pediatric and congenital cardiovascular disease research challenges and opportunities: JACC review topic of the week. J Am Coll Cardiol. 2022;80:2239–2250. doi: 10.1016/j.jacc.2022.09.032. [DOI] [PubMed] [Google Scholar]
  • 2.Gilboa S.M., Devine O.J., Kucik J.E., et al. Congenital heart defects in the United States: estimating the magnitude of the affected population in 2010. Circulation. 2016;134:101–109. doi: 10.1161/CIRCULATIONAHA.115.019307. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Brem O., Pravda N.S., Xu H., Nguyen K.L., Husain M. A systematic review on deep learning in ventricular septal defect screening, diagnosis, and management. Ann Pediatr Cardiol. 2026;19(1):53–61. doi: 10.4103/apc.apc_163_25. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Zheng G., Wu J., Chen P., et al. Characteristics of in-hospital mortality of congenital heart disease after surgical treatment in children from 2005 to 2017: a single-center experience. BMC Pediatr. 2021;21:521. doi: 10.1186/s12887-021-02935-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Faraoni D., Zurakowski D., Vo D., et al. Post-operative outcomes in children with and without congenital heart disease undergoing noncardiac surgery. J Am Coll Cardiol. 2016;67:793–801. doi: 10.1016/j.jacc.2015.11.057. [DOI] [PubMed] [Google Scholar]
  • 6.Tang A.S., Woldemariam S.R., Miramontes S., et al. Harnessing EHR data for health research. Nat Med. 2024;30:1847–1855. doi: 10.1038/s41591-024-03074-8. [DOI] [PubMed] [Google Scholar]
  • 7.Heumos L., Ehmele P., Treis T., et al. An open-source framework for end-to-end analysis of electronic health record data. Nat Med. 2024;30:3369–3380. doi: 10.1038/s41591-024-03214-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.Makhni S., Cerrato P., Rico J., et al. Meeting the challenges of electronic health record (EHR) optimization. NPJ Digit Med. 2026;9:8. doi: 10.1038/s41746-025-02178-w. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Rotmensch M., Halpern Y., Tlimat A., et al. Learning a health knowledge graph from electronic medical records. Sci Rep. 2017;7:5994. doi: 10.1038/s41598-017-05778-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Miotto R., Li L., Kidd B.A., et al. Deep patient: an unsupervised representation to predict the future of patients from the electronic health records. Sci Rep. 2016;6 doi: 10.1038/srep26094. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Rajkomar A., Oren E., Chen K., et al. Scalable and accurate deep learning with electronic health records. NPJ Digit Med. 2018;1:18. doi: 10.1038/s41746-018-0029-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Rasmy L., Xiang Y., Xie Z., et al. Med-BERT: pretrained contextualized embeddings on large-scale structured electronic health records for disease prediction. NPJ Digit Med. 2021;4:86. doi: 10.1038/s41746-021-00455-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Rjoob K., McGurk K.A., Zheng S.L., et al. A multimodal vision knowledge graph of cardiovascular disease. Nat Cardiovasc Res. 2026;5:18–33. doi: 10.1038/s44161-025-00757-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Zhang Y., Sui X., Pan F., et al. A comprehensive large-scale biomedical knowledge graph for AI-powered data-driven biomedical research. Nat Mach Intell. 2025;7:602–614. [Google Scholar]
  • 15.Chandak P., Huang K., Zitnik M. Building a knowledge graph to enable precision medicine. Sci Data. 2023;10:67. doi: 10.1038/s41597-023-01960-3. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Corso G., Stark H., Jegelka S., Jaakkola T., Barzilay R. Graph neural networks. Nat Rev Methods Primers. 2024;4:17. [Google Scholar]
  • 17.Tshitoyan V., Dagdelen J., Weston L., et al. Unsupervised word embeddings capture latent knowledge from materials science literature. Nature. 2019;571:95–98. doi: 10.1038/s41586-019-1335-8. [DOI] [PubMed] [Google Scholar]
  • 18.Zhou D., Tong H., Wang L., et al. Representation learning to advance multi-institutional studies with electronic health record data from US and France. Nat Commun. 2026;17:4800. doi: 10.1038/s41467-026-71152-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19.Li M.M., Huang K., Zitnik M. Graph representation learning in biomedicine and healthcare. Nat Biomed Eng. 2022;6:1353–1369. doi: 10.1038/s41551-022-00942-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Xu H., Renella P., Badiyan R., et al. A phenotyping algorithm for classification of single ventricle physiology using electronic health records. JAMIA Open. 2025;8 doi: 10.1093/jamiaopen/ooaf035. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Columbo J.A., Kang R., Trooboff S.W., et al. Validating publicly available crosswalks for translating ICD-9 to ICD-10 diagnosis codes for cardiovascular outcomes research. Circ Cardiovasc Qual Outcomes. 2018;11 doi: 10.1161/CIRCOUTCOMES.118.004782. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Wali R., Xu H., Cheruiyot C., et al. Integrated machine learning and multimodal data fusion for patho-phenotypic feature recognition in iPSC models of dilated cardiomyopathy. Biol Chem. 2024;405:427–439. doi: 10.1515/hsz-2024-0023. [DOI] [PubMed] [Google Scholar]
  • 23.Hamilton W.L., Ying R., Leskovec J. Inductive representation learning on large graphs. Advances in Neural Information Processing Systems. 2017;30:1024–1034. [Google Scholar]
  • 24.Beaney T., Jha S., Alaa A., et al. Comparing natural language processing representations of coded disease sequences for prediction in electronic health records. J Am Med Inform Assoc. 2024;31:1451–1462. doi: 10.1093/jamia/ocae091. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Xu H., Zhang H., Sisniega C., et al. An electronic health record multimodal data integration platform for comprehensive analysis of single ventricle physiology. Circulation. 2025;152(Suppl 3):A4353854. [Google Scholar]
  • 26.Nguyen P., Tran T., Wickramasinghe N., et al. Deepr: a convolutional net for medical records. IEEE J Biomed Health Inform. 2017;21:22–30. doi: 10.1109/JBHI.2016.2633963. [DOI] [PubMed] [Google Scholar]
  • 27.Li Y., Rao S., Solares J.R.A., et al. BEHRT: transformer for electronic health records. Sci Rep. 2020;10:7155. doi: 10.1038/s41598-020-62922-y. [DOI] [PMC free article] [PubMed] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary material
mmc1.docx (5MB, docx)

Data Availability Statement

The data sets analyzed contain protected health information and are not publicly available due to Institutional Review Board and Health Insurance Portability and Accountability Act restrictions. Data were accessed and analyzed within an approved secure environment. Requests for access to de-identified data may be considered subject to institutional and Institutional Review Board approval and execution of an appropriate data-use agreement.


Articles from JACC: Advances are provided here courtesy of Elsevier

RESOURCES