BackgroundsPredicting medications is a crucial task in intelligent healthcare systems, aiding doctors in making informed decisions based on electronic medical records (EMR). However, medication prediction faces challenges due to complex relations within heterogeneous medical data. Existing studies primarily focus on the supervised mining of hierarchical relations between homogeneous codes in medical ontology graphs, such as diagnosis codes. Few studies consider the valuable relations, including synergistic relations between medications, concurrent relations between diseases, and therapeutic relations between medications and diseases from historical EMR. This limitation restricts prediction performance and application scenarios.MethodsTo address these limitations, we propose KAMPNet, a multi-sourced medical knowledge augmented medication prediction network. KAMPNet captures diverse relations between medical codes using a multi-level graph contrastive learning framework. Firstly, unsupervised graph contrastive learning with a graph attention network encoder captures implicit relations within homogeneous medical codes from the medical ontology graph, generating knowledge augmented medical code embedding vectors. Then, unsupervised graph contrastive learning with a weighted graph convolutional network encoder captures correlative relations between homogeneous or heterogeneous medical codes from the constructed medical codes relation graph, producing relation augmented medical code embedding vectors. Finally, the augmented medical code embedding vectors, along with supervised medical code embedding vectors, are fed into a sequential learning network to capture temporal relations of medical codes and predict medications for patients.ResultsExperimental results on the public MIMIC-III dataset demonstrate the superior performance of our KAMPNet model over several baseline models, as measured by Jaccard, F1 score, and PR-AUC for medication prediction.ConclusionsOur KAMPNet model can effectively capture the valuable relations between medical codes inherent in multi-sourced medical knowledge using the proposed multi-level graph contrastive learning framework. Moreover, The multi-channel sequence learning network facilitates capturing temporal relations between medical codes, enabling comprehensive patient representations for downstream tasks such as medication prediction.