Introduction
Medication recommendation for patients with multimorbidity—the presence of two or more chronic conditions—is a critical yet complex task in modern healthcare. Clinicians must balance therapeutic efficacy with the risk of adverse drug-drug interactions (DDIs). While deep learning models have shown promise in automating these recommendations using Electronic Health Records (EHR), existing longitudinal models face two primary challenges. First, they often overlook the nuanced intra-visit relationships between medical codes (diagnoses and procedures) occurring simultaneously. Second, they struggle with the "cold-start" problem, where patients with short medical histories provide insufficient context for accurate prediction.
To address these gaps, this paper introduces SHAPE (Sample-adaptive Hierarchical medicAtion Prediction nEtwork). SHAPE employs a hierarchical architecture to capture both immediate and longitudinal patient context, coupled with a novel adaptive training strategy to improve performance on information-sparse records.
Methodology
SHAPE is structured as a hierarchical deep learning framework consisting of three core components designed to model the complexity of patient journeys.
1. Intra-visit Set Encoder
Traditional models often treat medical codes within a single visit as a flat "multi-hot" vector, losing the relational context between specific diagnoses. SHAPE utilizes Induced Set Attention Blocks (ISAB), inspired by Set Transformers, to encode these codes. By treating a hospital visit as a set of events rather than a sequence, the model learns to identify which combinations of medical events are most relevant to the resulting medication needs, producing a compact and informative visit-level representation.
2. Inter-visit Longitudinal Encoder
To capture the temporal evolution of a patient's health, SHAPE employs a Recurrent Attention Block (RAB). This module integrates the sequential memory of Recurrent Neural Networks (RNNs) with the powerful attention mechanisms found in Transformers. Specifically, it uses GPT-style masking to ensure the model only attends to past visits, preventing information leakage from the future while effectively modeling long-term dependencies in the patient's history.
3. Adaptive Curriculum Learning (ACL)
The most distinctive feature of SHAPE is its training strategy. Recognizing that patients with fewer visits are "harder" to predict, the authors implement an Adaptive Curriculum Learning module. Unlike traditional curriculum learning that starts with easy samples, this module treats visit length as a proxy for difficulty. It dynamically adjusts the learning rate during training: shorter, more difficult records are assigned a lower learning rate. This guides the model to develop more robust parameter patterns for these cases, rather than relying solely on the easier-to-predict trends found in long-term historical data.
Optimization and Safety
The model is optimized using a multi-objective loss function. It balances Binary Cross Entropy (BCE) for prediction accuracy with a DDI penalty based on a drug-drug interaction graph derived from the TWOSIDES dataset. This ensures that the recommendations are not only accurate but also clinically safe.
Experimental Evaluation
Datasets
The researchers evaluated SHAPE using the MIMIC-III dataset, a benchmark EHR database containing de-identified data from over 46,000 patients. Medical codes were mapped to ATC Third Level codes to maintain consistency with the DDI knowledge graph.
Performance Metrics
SHAPE was compared against several state-of-the-art baselines, including COGNet, SafeDrug, and GAMENet. The evaluation focused on accuracy (Jaccard score, F1 score) and safety (DDI rate).
Results and Discussion
SHAPE demonstrated superior performance across all evaluated metrics:
- Accuracy: The model achieved a Jaccard score of 0.5513 and an F1 score of 0.7017. This represents approximately a 2% improvement over the previous state-of-the-art model, COGNet.
- Safety: SHAPE maintained a DDI rate of 0.0677, which is significantly lower than the average DDI rate of 0.0875 found in the raw MIMIC-III dataset. This suggests the model can recommend safer drug combinations than those historically recorded in human practice.
- Robustness to Short Records: Analysis confirmed that SHAPE maintains higher accuracy for patients with only 1 to 3 visits compared to other longitudinal models, effectively mitigating the cold-start problem through its adaptive curriculum learning strategy.
Conclusion
SHAPE advances the field of automated medication recommendation by treating patient data as a hierarchical set of relationships and adapting its learning process to the difficulty of the sample. By effectively modeling both intra-visit context and short-term patient histories, SHAPE provides a more accurate and safer tool for clinical decision support. Future work may involve incorporating multimodal data, such as clinical notes and laboratory results, to further refine patient representations and improve generalizability across diverse hospital systems.
Summary updated