Automated Hierarchical Graph Construction for Multi-source Electronic Health Records

Yinjie Wang, Doudou Zhou, Yue Liu, Junwei Lu, Tianxi CaiarXiv 2025 · DOI

Abstract

Electronic Health Records (EHR) are a cornerstone of modern medical research, yet their utility is often hampered by the lack of standardization across different healthcare systems. This paper introduces MASH (Multi-source Automated Structured Hierarchy), a novel framework designed to automatically harmonize medical codes and construct interpretable hierarchical graphs. By leveraging neural optimal transport for cross-institutional alignment and hyperbolic geometry for structural representation, MASH effectively bridges the gap between local hospital codes and global standards. Experimental results using large-scale data from the U.S. Department of Veterans Affairs and Mass General Brigham demonstrate that MASH outperforms existing methods in both data alignment and clinical interpretability, providing a scalable solution for unified health record analysis.

Introduction

The integration of Electronic Health Records (EHR) from multiple sources is critical for large-scale clinical studies, particularly those focusing on rare diseases or drug efficacy. However, researchers frequently encounter the "local code" problem: while some institutions use standardized systems like LOINC for laboratory tests, others rely on internal, undocumented identifiers. This fragmentation necessitates manual, error-prone mapping processes that limit the scalability of multi-center research.

To address this, we propose MASH, a three-stage framework that automates the harmonization of medical concepts and the construction of human-readable hierarchies. MASH moves beyond simple linear mappings, employing advanced geometric and probabilistic techniques to create a "universal translator" for medical data.

The MASH Framework

MASH operates through a sophisticated pipeline designed to capture both the semantic meaning and the structural relationships of medical codes.

  1. Neural Optimal Transport (OT): The first stage involves aligning embedding spaces from different institutions. Unlike traditional Procrustes analysis, which assumes a rigid rotation, MASH uses Neural OT to find a flexible, principled mapping. This process integrates co-occurrence data—reflecting how codes appear together in patient records—with semantic information derived from biomedical language models like CODER.
  2. Hyperbolic Learning: Hierarchical structures are inherently "curved," expanding exponentially from root to leaves. Standard Euclidean space is poorly suited for representing such structures without significant distortion. MASH maps aligned embeddings into hyperbolic space (specifically using the Lorentzian model), which naturally accommodates tree-like hierarchies. By employing an "additivity loss," the model ensures that distances along the tree paths remain logically consistent.
  3. Recursive Grouping and LLM Annotation: The final stage constructs the actual graph using recursive k-means clustering. To ensure the resulting "latent nodes" (the branches of the tree) are useful to clinicians, MASH utilizes GPT-4o to generate concise, clinically accurate labels for each cluster based on its descendant codes. This transforms abstract mathematical clusters into an interpretable clinical tool.

Data and Evaluation

The framework was validated using datasets from two of the largest health systems in the United States: the U.S. Department of Veterans Affairs (VA), encompassing 12.6 million patients, and Mass General Brigham (MGB), with 2.5 million patients. The study focused on three primary categories: Diagnoses (PheCodes), Medications (RxNorm), and Laboratory Tests (LOINC and local codes).

Distribution of medical codes across MGB and VA datasets.

As shown in Figure 1, a significant challenge lies in the laboratory tests category, where the VA system contains 1,853 local codes that do not overlap with MGB or standard LOINC mappings. MASH's ability to harmonize these "messy" codes is a key contribution of this work.

Results and Clinical Utility

MASH demonstrated superior performance across several benchmarks:

  • Semantic Relatedness: The model achieved an AUC of 0.889 in distinguishing related medical pairs, significantly outperforming the CODER language model (0.709).
  • Feature Selection: In identifying relevant features for specific diseases, MASH embeddings showed a correlation of 0.593 with expert-level rankings, compared to 0.390 for the MIKGI baseline.
  • Structural Fidelity: GPT-4 evaluations of the generated hierarchies yielded near-perfect scores (0.97–0.99) for logical consistency and semantic distinction.

Notably, MASH generated the first automated hierarchies for unstructured local laboratory codes in the VA system, establishing a foundational reference for future multi-institutional research.

Conclusion

MASH represents a significant advancement in EHR data harmonization. By combining neural optimal transport with hyperbolic geometry and LLM-driven interpretability, it provides a robust framework for navigating the complexities of multi-source medical data. Future work will explore the integration of procedure codes (CPT) and the application of MASH in federated learning environments, further enhancing its utility in privacy-sensitive clinical research.

Summary updated

BibTeX
@misc{wang2025automated,
  author = {Yinjie Wang and Doudou Zhou and Yue Liu and Junwei Lu and Tianxi Cai},
  title = {{Automated Hierarchical Graph Construction for Multi-source Electronic Health Records}},
  year = {2025},
  eprint = {2509.06576},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.06576},
}
Figure