# ACDNet: Attention-guided Collaborative Decision Network for Effective
Medication Recommendation

Jiacong Mi  Yi Zu  Zhuoyuan Wang  Jieyue He<EMAIL_ADDRESS>
###### Abstract

Medication recommendation using Electronic Health Records (EHR) is challenging
due to complex medical data. Current approaches extract longitudinal
information from patient EHR to personalize recommendations. However, existing
models often lack sufficient patient representation and overlook the
importance of considering the similarity between a patient’s medication
records and specific medicines. Therefore, an Attention-guided Collaborative
Decision Network (ACDNet) for medication recommendation is proposed in this
paper. Specifically, ACDNet utilizes attention mechanism and Transformer to
effectively capture patient health conditions and medication records by
modeling their historical visits at both global and local levels. ACDNet also
employs a collaborative decision framework, utilizing the similarity between
medication records and medicine representation to facilitate the
recommendation process. The experimental results on two extensive medical
datasets, MIMIC-III and MIMIC-IV, clearly demonstrate that ACDNet outperforms
state-of-the-art models in terms of Jaccard, PR-AUC, and F1 score, reaffirming
its superiority. Moreover, the ablation experiments provide solid evidence of
the effectiveness of each module in ACDNet, validating their contribution to
the overall performance. Furthermore, a detailed case study reinforces the
effectiveness of ACDNet in medication recommendation based on EHR data,
showcasing its practical value in real-world healthcare scenarios.

###### keywords:

Medication recommendation , Data mining , Electronic Health Record , Attention
mechanism , Transformer

††journal: Journal of Biomedical Informatics

[label1]organization=School of Computer Science and Engineering, Key Lab of
Computer Network and Information Integration, MOE, Southeast University,
city=Nanjing, postcode=210018, state=Jiangsu, country=China

##  1 Introduction

Medication recommendation is an important part of healthcare, helping to find
the best treatment plans by comparing patient histories, medicine information,
and other data with medical knowledge. It uses technologies like machine
learning, natural language processing, and data mining to improve treatment,
reduce bad drug reactions, and boost patient well-being. Electronic health
records (EHR) [1] have led to large, complex data sets with patient details,
reports, and medication records. Medication records are key parts of EHR,
providing vital info for doctors. As a result, using EHR data for medication
recommendation is a main focus in recent medical studies.

In recent years, with the continuous development of machine learning and deep
learning, medication recommendation models based on deep learning have
attracted increasing attention [2]. These models can be divided into instance-
based [3, 4] and longitudinal-based [5, 6, 7, 8, 9, 10, 11, 12, 13]
categories. Instance-based medication recommendation models solely rely on
patients’ current health information, neglecting past health data and
medication records, which limits their effectiveness. In contrast,
longitudinal-based models provide a more comprehensive understanding of
patients’ conditions, thereby improving the effectiveness of medication
recommendation. However, longitudinal-based medication recommendation models
still face challenges and problems. Firstly, certain studies [7, 11, 12]
utilize GRU or RNN to encode patients’ EHR information, which makes it
challenging to capture the comprehensive health information of patients from a
global perspective. Secondly, some studies [9, 10, 6] disregard the importance
of patients’ medication records, overlooking the crucial combinations of
medications that significantly impact patients’ well-being.

To address these challenges, we propose the Attention-guided Collaborative
Decision Network (ACDNet) model for medication recommendation. ACDNet utilizes
attention mechanism and Transformer to effectively capture important
information from the patient’s historical visits and medication records at
both the local and global levels, thereby providing more comprehensive
medication recommendations. Firstly, ACDNet employs attention mechanism and
Transformer to encode patients’ visit information at both the local and global
levels, generating representations for their health conditions and medication
records. Secondly, it incorporates various domain-specific knowledge to
comprehensively model medications. Finally, ACDNet utilizes collaborative
decision network to recommend the most suitable medications for patients based
on their medical history and the similarity between their medication records
and available medicines.

In addition to the widely used MIMIC-III dataset [14], we conducted
experiments on the latest MIMIC-IV dataset [15]. Compared to MIMIC-III, MIMIC-
IV offers more abundant medical data. The experimental results indicate that
ACDNet model demonstrates significant improvements in accuracy and
effectiveness compared to existing models in medication recommendation. Our
main contributions are summarized as follows:

  * $\bullet$

We employ attention mechanism and Transformer to effectively capture the
health conditions and medication records of a patient by modeling his
historical visits at both local and global levels.

  * $\bullet$

We incorporate a collaborative decision mechanism to provide personalized
medication recommendation by leveraging various medical information from a
patient’s history of visits, as well as diverse medicine information.

  * $\bullet$

We conduct extensive experiments on both the MIMIC-III and MIMIC-IV datasets,
demonstrating the effectiveness of our proposed approach in comparison to
existing methods.

##  2 Related Works

In recent years, various medication recommendation methods [9, 11] have
incorporated molecular information as external knowledge to improve the
accuracy and effectiveness of medication recommendation. In this section, we
discuss two research directions: medication recommendation and molecular
representation.

###  2.1 Medication recommendation

Medication recommendation can be classified into instance-based and
longitudinal-based categories. The former recommends medicines based on
patients’ current visit information, while the latter utilizes patients’
historical visit information to predict future medication requirements. In
instance-based medication recommendation, LEAP [4] employs RNN and attention
mechanism to model current information, introducing reinforcement learning to
prevent adverse drug combinations. SMR [3] uses EHR data and medical knowledge
graphs to construct a heterogeneous graph, transforming the medication
recommendation problem into a link prediction problem. In longitudinal-based
medication recommendation, RETAIN [5] proposes a two-level neural attention
model effectively capturing relevant information in patients’ visits. GAMENet
[7] uses RNN to model visit information, incorporating drug interaction
information to represent medications. MICRON [10] employs residual networks to
predict changes in health conditions, focusing on analyzing the differences
between two consecutive visits. SafeDrug [11] is the first to model drug
molecules and proposes a new loss function to reduce drug interaction rates.
COGNet [16] employs Transformer to encode visit and medicine information,
comparing current visit information with previous visits to make comprehensive
judgments. DRMP [6] uses GRU and graph neural networks to capture
relationships between visits, introducing a DDI Gating Mechanism to decrease
drug interaction rates. FFBDNet [9] incorporates various external knowledge
sources and employs a binary decision network for medication recommendation.
Despite the progress achieved by existing medication recommendation methods,
challenges and shortcomings still persist in adequately representing patient
information and providing effective medication recommendations for patients.

###  2.2 Molecular Representation

Molecular representation transforms structures into numerical vectors for
predicting properties and functions. Presently, graph neural network
(GNN)-based methods [17, 18, 19] are considered effective means for learning
high-quality molecular representations. Both MPNN [20] and Chemprop [21] are
GNN methods based on message-passing mechanism. The former updates atomic
embedding vectors by exchanging information between atoms and bonds, while the
latter uses self-supervised learning to improve the quality of molecular
representations, learning atom-level representations by predicting partial
charges for each atom in the molecule and averaging or summing these
representations to form molecule-level representations. D-GCAN [22] is a deep
learning method based on graph convolutional attention networks, combining
graph convolution and attention mechanism to extract feature vectors for atoms
and bonds in molecular structures. D-GCAN uses graph convolution for molecular
representation and then employs graph attention to calculate the importance of
atoms and bonds within the molecule, ultimately forming the molecular
representation. Current molecular representation techniques may encounter
difficulties in capturing complex molecular features and interdependencies,
necessitating further research to enhance the accuracy of predicting molecular
properties and functions.

##  3 Problem Formulation

In medication recommendation, we utilize patient EHR data and external
medicine information to provide personalized medicine suggestions for
patients. Below are the definitions of EHR data, medicine information, and
medication recommendation.

###  3.1 Electronic health records (EHR)

In the EHR dataset, each patient is represented by sequential data
${X}^{(n)}=\left[{x}_{1}^{(n)},{x}_{2}^{(n)},\cdots,{x}_{T^{(n)}}^{(n)}\right]$.
Each record ${x}_{t}=\left[c_{t}^{d},c_{t}^{p},c_{t}^{m}\right](t<T)$ contains
diagnosis codes $c^{d}_{t}$, procedure codes $c^{p}_{t}$, and medication codes
$c^{m}_{t}$. The current medical record
${x}_{T}=\left[c_{T}^{d},c_{T}^{p}\right]$ consists of diagnosis codes
$c^{d}_{T}$ and procedure codes $c^{p}_{T}$ but excludes medication codes. For
simplicity, medical code $c_{t}^{*}\in\mathbb{N}^{l^{*}_{t}}$ is utilized to
represent the standardized definition of various medical code types where
$\mathbb{N}\in[0,|C^{*}|]$, $C^{*}$ is the medical code set and $l^{*}_{t}$ is
the number of medical codes in $c_{t}^{*}$.

###  3.2 EHR and DDI Graph

The EHR graph ${G}^{E}=\left\\{{V}^{{E}},{E}^{{E}}\right\\}$ and DDI graph
${G}^{D}=\left\\{{V}^{{D}},{E}^{{D}}\right\\}$ both have node sets
$V^{E}=C^{M}$ and $V^{D}=C^{M}$, representing all medicines. $E^{E}$
corresponds to known medication combinations in the EHR database, while
$E^{D}$ represents known drug-drug interactions from an external knowledge
base. The adjacency matrices $A^{E},A^{D}\in
R^{\left|C^{M}\right|\times\left|C^{M}\right|}$ help clarify the construction
of edge sets $E^{E}$ and $E^{D}$, respectively.

###  3.3 Molecular Graph

Molecular graph for medication $m_{i}\in C^{M}$ can be represented as
$G^{m_{i}}=\left\\{V^{m_{i}},E^{m_{i}}\right\\}$, where $V^{m_{i}}$ is the
node set consisting of all molecular units of medication $m_{i}$, and
$E^{m_{i}}$ is the edge set of known molecular structures of $m_{i}$. So the
adjacency matrix for each medicine molecule can be represented as $A^{m_{i}}$.

###  3.4 Medication Recommendation

Given the current time $T$, medical codes
${x}_{T}=\left[c_{T}^{d},c_{T}^{p}\right]$ that only include diagnoses and
procedures, as well as the medical records
${X}=\left[{x_{1}},{x_{2}},\cdots,{x}_{T-1}\right]$ from the previous $T-1$
times and graphs
$G^{E},G^{D},\left\\{G^{m_{i}},{i}\in\left[1,\ldots,\left|C^{M}\right|\right]\right\\}$,
the aim is to obtain a multi-class output
${\hat{o}}\in\\{0,1\\}^{\left|C^{m}\right|}$ of medicines while minimizing the
interactions between them.

##  4 Method

Our ACDNet model has three modules: a patient representation module, a
medicine representation module, and a medication recommendation module. In the
patient representation module, we utilize attention mechanism and Transformer
encoder to extract essential information from historical medical records,
creating the patient’s representations of their past visits and medication
history from both local and global perspectives. The medicine representation
module encodes the medicine molecular graph and uses the EHR and DDI graphs to
generate medicines’ vector representation. Finally, the medication
recommendation module employs a collaborative decision mechanism to determine
the medication to recommend for the patient. The ACDNet model’s architecture
is shown in Figure 1.

Figure 1: The architecture of ACDNet

###  4.1 Patient representation

By leveraging a patient’s past health information and medication records, we
can gather a significant amount of information related to their well-being.
During the ongoing medical consultation, we further determine the patient’s
latest health condition. By integrating the collected data, we can conduct a
thorough evaluation of the patient’s health and provide customized medication
recommendation. Specifically, we initially represent each visit as a vector
using the EHR Embedding module. Following this, with the application of
techniques such as attention mechanism and Transformer encoder, we obtain
encoded representations of visit sequences and medication records sequences.
Finally, by employing the self-attention mechanism, we generate a vector
representation of the patient’s historical health and medication records,
establishing a foundation for subsequent personalized recommendation.

####  4.1.1 Attention module

We employ the Self-Attention mechanism to effectively capture valuable
information from a sequence vector of length $L$. This mechanism allows us to
focus on the most relevant parts of the sequence, considering the
relationships and dependencies among different elements, ultimately enhancing
our ability to extract significant insights from the sequence data.

$\text{SelfAttention}(v)=\text{softmax}\left(tanh(v\cdot W_{\alpha
1})W_{\alpha 2}\right)^{T}\cdot v$ (1)

where $v\in R^{L\times dim}$ represents the new input sequence, $W_{\alpha
1}\in R^{dim\times dim}$, $W_{\alpha 2}\in R^{dim\times 1}$. The output
dimension of the sequence is $R^{dim}$.

####  4.1.2 Transformer encoder module

During the encoding process, the Transformer encoder [23] can capture
important information from the historical visit records and medication
records. The Transformer encoder consists of $L$ Transformer encoder Layers,
and for the $i^{th}$ layer, its output is:

$Z^{(i)}=\text{LayerNorm}\left(\text{MultiHeadAttention}\left({seq}^{(i)},{seq}^{(i)},{seq}^{(i)}\right)+{seq}^{(i)}\right)\\\
$ (2)
$F^{(i)}=\text{LayerNorm}\left(\text{FeedForward}\left(Z^{(i)}\right)+Z^{(i)}\right)$
(3)

Describing MultiHeadAttention, we have the following expressions:

$\text{MultiHeadAttention}(Q,K,V)=\text{Concat}(\text{head}_{1},\text{head}_{2},\ldots,\text{head}_{h})W^{O}$
(4)
$\text{Attention}(Q,K,V)=\text{softmax}\left(\frac{QK^{T}}{\sqrt{d_{k}}}\right)V$
(5)

Here, $\mathrm{head}_{i}=\mathrm{Attention}(Q_{i},K_{i},V_{i})$ denotes the
computation for each attention head, where $\sqrt{d_{k}}$ serves as the
scaling factor, and $W^{O}$ represents the output weight matrix utilized for
the linear transformation and aggregation of results from various attention
heads to yield the ultimate output.

The final output of the Transformer encoder is:

$\text{TransformerEncoder}({seq})=\text{LayerNorm}\left({seq}+\text{sum}\left(F^{(1)},\ldots,F^{(L)}\right)\right)$
(6)

where sum is the pooling operation that involves adding up the results.

####  4.1.3 Local representation Module

Based on the previous context, the vector
$x_{t}=[c_{t}^{d},c_{t}^{p},c_{t}^{m}]$ represents the representation of a
visit. To refine the processing of these vectors, we have devised three
embedding operations, $E_{d}:{\mathbb{N}^{l^{d}_{t}}}\rightarrow
R^{{l^{d}_{t}}\times dim}$,
$E_{p}:\mathbb{N}^{l^{p}_{t}}\rightarrow{R}^{l^{p}_{t}\times dim}$, and
$E_{m}:\mathbb{N}^{l^{m}_{t}}\rightarrow{R}^{l^{m}_{t}\times dim}$,
facilitating their mapping into the embedding space. Explicitly, upon querying
each vector within the embedding operations, we obtain the respective embedded
vectors, culminating in the subsequent result:

$\displaystyle e_{t}^{d}$ $\displaystyle=E_{d}(c_{t}^{d})$ (7) $\displaystyle
e_{t}^{p}$ $\displaystyle=E_{p}(c_{t}^{p})$ $\displaystyle e_{t}^{m}$
$\displaystyle=E_{m}(c_{t}^{m})$

To obtain the sequential representation of the visit $x_{t}$, we concatenate
the following three vectors:

$e_{t}=\left[e_{t}^{d}\,\|\,e_{t}^{p}\,\|\,e_{t}^{m}\right]$ (8)

where $e_{t}\in R^{l\times dim}$, $l$ is the sum of ${l^{d}_{t}},{l^{p}_{t}}$
and ${l^{m}_{t}}$. Consequently, by executing an averaging operation on this
vector, we ascertain the current visit’s average representation:

$e_{t}^{ave}={average}\left(e_{t}\right)$ (9)

where $e_{t}^{ave}\in R^{dim}$ and $average$ denotes the vector’s averaging
operation.

Our goal is to enhance the performance of the model by capturing the
interaction information between medical codes. To achieve this, we employ
self-attention mechanism to calculate the interdependencies among the medical
code features within the current input sequence, in order to capture the
important information from each patient visit. Thus, by applying the self-
attention mechanism, we can model the informatiovn of a patient’s visit at
time $t$ and obtain a local representation of the patient’s visit history:

$v_{t}^{att}=\text{SelfAttention}\left(e_{t}\right)$ (10)

where $v_{t}^{att}\in R^{dim}$. Subsequently, we concatenate vectors to
acquire the attention representation sequence for the patient’s $T$ visits:

${seq}_{e}^{att}=\left[v_{1}^{att}||v_{2}^{att}||\ldots||v_{T}^{att}\right]$
(11)

where ${seq}_{e}^{att}\in R^{T\times dim}$.

####  4.1.4 Global representation module

In COGNet [16], the model employs the Transformer to encode medical records
for individual visits, with a specific focus on capturing the relationships
between various medical codes within each visit. In contrast, ACDNet treats
each visit as a vector, arranging all visits into a sequence processed through
a Transformer encoder to emphasize the relationships between distinct visits.

We handle the complete set of patient visit and medication records separately,
enabling the capture of essential information at a global level throughout the
patient’s entire visit history. The patient’s health status and medication
records after $T$ visits can be represented as:

$seq_{e}^{ave}=\left[e_{1}^{ave}||e_{2}^{ave}||\ldots||e_{T}^{ave}\right]$
(12) ${seq}_{m}=\left[e_{1}^{m}||e_{2}^{m}||\ldots||e_{T-1}^{m}\right]$ (13)

where ${seq}_{e}^{ave}\in R^{T\times dim}$ and ${seq}_{m}\in R^{(T-1)\times
dim}$. Then, we input them into the Transformer encoder separately to obtain
the encoded vectors:

${seq}_{e}^{tr}=\text{TransformerEncoder}\left({seq}_{e}^{ave}\right)$ (14)
${seq}_{m}^{tr}=\text{TransformerEncoder}\left({seq}_{m}\right)$ (15)

where ${seq}_{e}^{tr}\in R^{T\times dim}$ and ${seq}_{m}^{tr}\in
R^{(T-1)\times dim}$.

####  4.1.5 Represent module

After processing with the attention mechanism and the Transformer encoder, we
can obtain the representations of the patient’s health status and medication
records after $T$ medical visits. For the patient’s health information
representation, we concatenate the two patient health status sequences and
perform a self-attention operation:

$r_{p}=\text{SelfAttention}\left({seq}_{e}^{att}||seq_{e}^{tr}\right)$ (16)

where $r_{p}\in R^{dim}$. Similarly, we perform a self-attention operation on
the medication records sequence:

$r_{m}=\text{SelfAttention}\left({seq}_{m}^{tr}\right)$ (17)

where $r_{m}\in R^{dim}$.

###  4.2 Medicine Representation

To improve the effectiveness of medication recommendation and better express
medicine information, we employ various methods to model medicines, including
EHR graph, DDI graph, and molecular graphs. First, we use a basic embedding
table to represent all medicines. Then, we introduce graph neural networks to
encode the graph information. Finally, we aggregate all representation
information to obtain the final medicine representation. As shown in Equation
(7), we use the learned Embedding table $E_{m}$ as the base representation for
all medicines:

$M_{base}=E_{m}(C^{M})$ (18)

where $M_{base}\in R^{|C^{m}|\times dim}$.

As mentioned earlier, we obtained the EHR Graph and DDI Graph with their
adjacency matrices represented as $A^{E}$ and $A^{D}$, respectively. Inspired
by the use of GCN [24] to encode graph information in GAMENet [7], we apply
GCN separately to the EHR graph and DDI graph, given the graph adjacency
matrix $A^{*}$:

$\tilde{A}^{*}=\widetilde{D}^{-\frac{1}{2}}\left(A^{*}+I\right)\widetilde{D}^{-\frac{1}{2}}$
(19)

where $\widetilde{D}$ is a diagonal matrix of $A^{*}$ and $I$ are identity
matrices. Then, we can obtain the graph representation:

$M^{*}=\tilde{A}^{*}\sigma\left(\tilde{A}^{*}W_{g1}^{*}\right)W_{g2}^{*}$ (20)

where $\sigma$ is a nonlinear activation function, $W_{g1}^{*}\in
R^{|V^{*}|\times dim}$, $W_{g2}^{*}\in R^{dim\times dim}$ are learnable
parameters. Based on the above formula, we obtain the EHR Graph representation
$M_{e}\in R^{|C^{m}|\times dim}$ and DDI Graph representation $M_{d}\in
R^{|C^{m}|\times dim}$.

Medicine molecules can be represented in the form of molecular graphs, where
nodes represent atoms and edges represent chemical bonds between atoms.
Inspired by D-GCAN [22], we adopt GCN [24] and GAT [25] to represent
molecules. For each molecule $G^{m^{i}}$ with adjacency matrix $A^{m^{i}}$, we
first obtain $M_{g}^{m^{i}}\in R^{|V^{m^{i}}|\times dim}$ through equations
(19) and (20). Then, using GAT and Readout fuction, we get:

$M^{m^{i}}=\operatorname{READOUT}\left(GAT\left(M_{g}^{m^{i}}\right)\right)$
(21)

where $M^{m^{i}}\in R^{dim}$ is the vector representation of the $i^{th}$
medicine molecule. Finally, we obtain the representations of all molecules:

$M_{mol}=\left[M^{m^{1}}||M^{m^{2}}||\ldots||M^{\left|C^{M}\right|}\right]$
(22)

where $M_{mol}\in R^{|C^{M}|\times dim}$ represents the molecular graph
information of all drugs. Ultimately, we obtain the final medicine
representation:

$M=\text{NN}_{\text{med }}\left(M_{\text{base
}}||M_{e}||M_{d}||M_{\text{mol}}\right)$ (23)

where $\text{NN}_{\text{med }}(\cdot):R^{4dim}\rightarrow R^{dim}$ is a fully
connected feedforward neural network, and $M\in R^{|C^{M}|\times dim}$
incorporates various medicine information, which is beneficial for similarity
calculations with the patient’s medication information.

###  4.3 Medication Recommendation

Drawing inspiration from FFBDNet[9], our medication recommendation system
incorporates two modules that work collaboratively to provide medication
suggestions for patients. The direct module primarily focuses on the patient’s
representation to recommend suitable medicines. On the other hand, in contrast
to FFBDNet, the indirect module takes into account the similarity between the
patient’s medication records and medicine representation. By integrating the
patient’s medication history, which contains valuable information about
relevant medicines, we aim to simulate the decision-making process of a
prescribing doctor. This integration enables us to generate comprehensive
personalized medication recommendation based on the patient’s specific
medication history.

In the direct recommendation module, we use the patient representation and a
feedforward neural network to recommend suitable medicines directly:

$o_{1}=\text{NN}_{o_{1}}\left(r_{p}\right)$ (24)

where $o_{1}\in R^{|C^{m}|}$ is the result of the direct recommendation, and
$NN_{o_{1}}(\cdot):R^{dim}\rightarrow R^{\left|C^{m}\right|}$ is a learnable
feedforward neural network.

The indirect recommendation module integrates the patient’s medication records
in EHR with the representations of medicines and calculates the similarity
between them. This similarity calculation mimics the prescribing behavior of
healthcare professionals, selecting the most important combination of
medications from all the patient’s medication records.

$s_{m}=\text{ Cosine Similarity }(r_{m},M)=\frac{r_{m}\cdot
M^{T}}{\|r_{m}\|\cdot\|M\|}$ (25)

where $s_{m}\in R^{|C^{m}|}$ is the similarity between medication records and
medicines.

Then, we concatenate the direct recommendation $o_{1}$ and similarity results
and input them into a neural network to obtain the indirect recommendation
result:

$o_{2}=\text{NN}_{o_{2}}\left(\alpha o_{1}||\beta s_{m}\right)$ (26)

where $o_{2}\in R^{|C^{m}|}$ is the output result of indirect recommendation
based on similarity,
$\text{NN}_{o_{2}}(\cdot):R^{2\times\left|C^{m}\right|}\rightarrow
R^{\left|C^{m}\right|}$ is a fully connected feedforward neural network, and
$\alpha$, $\beta\in R^{1}$ are trainable parameters.

Finally, we adjust the two modules to obtain the ultimate recommendation
result:

$\hat{o}=\sigma\left(w_{1}\odot o_{1}+w_{2}\odot o_{2}\right)$ (27)

where $\sigma$ is a nonlinear activation function, $w_{1},w_{2}\in
R^{|C^{m}|}$ are learnable parameters to adjust the two recommendation
modules, and $\hat{o}\in R^{|C^{m}|}$ is the output medication recommendation
result.

###  4.4 Training and Inference

To suggest medicine combinations, we treat this task as a multi-label
prediction problem. During training, we use two common multi-label loss
functions: binary cross-entropy loss ($L_{bce}$) and multi-label margin loss
($L_{multi}$). Binary cross-entropy loss handles multi-label binary
classification problems by calculating binary cross-entropy loss for each
label and summing them up. Multi-label margin loss accounts for label
correlations, producing smoother predictions.

$L_{bce}=-{\textstyle\sum_{i}^{\left|C^{m}\right|}}y_{i}\log\left(\hat{o}_{i}\right)+\left(1-y_{i}\right)\log\left(1-\hat{o}_{i}\right)$
(28) $L_{\text{multi
}}=\sum_{i,j:y_{i}=1,y_{j}=0}\frac{\max\left(0,1-\left(\hat{o}_{\mathrm{i}}-\hat{o}_{\mathrm{j}}\right)\right)}{|y|}$
(29)

where $\mathbf{y}\in\\{0,1\\}^{\left|C^{m}\right|}$ is the true label set of
recommended medicines. Therefore, the final Loss is represented as:

${L}=\lambda L_{bce}+(1-\lambda)L_{\text{multi}}$ (30)

where $\lambda\in R$ is a predefined parameter.

In ACDNet training, we combine these loss functions for better prediction
performance, as detailed in Algorithm 1.

Input: Training set
$X^{(n)}=\left[x_{1}^{(n)},x_{2}^{(n)},\cdots,x_{T^{(n)}}^{(n)}\right]$, EHR
graph $A^{E}$, DDI graph $A^{D}$, molecular graph
$\left\\{A^{m_{i}},i\in\left[1,\ldots,\left|C^{m}\right|\right]\right\\}$

1 Generate the medicine representation $M$ according to Equations (18)-(23);

2 for  _patient $i=1$ to $N$_ do

3 Read the patient $i$’s history $x_{1}$, $x_{2}$, … , $x_{T}$;

4 for  _history visit $t=1$ to $T$_ do

5 Read the historical diagnoses, procedures, medicines of the patient at the
$t^{th}$ visit $\left[c_{1}^{d},c_{2}^{d},\ldots
c_{t}^{d}\right],\left[c_{1}^{p},c_{2}^{p},\ldots
c_{t}^{p}\right],\left[c_{1}^{m},c_{2}^{m},\ldots c_{t-1}^{m}\right]$;

6 Generate embeddings $e_{t}$ and $e_{t}^{ave}$ by Equations (7)-(9);

7 Generate visit $v_{t}^{att}$ using self-attention by Equation (10);

8 Generate sequences $seq_{e}^{att},seq_{e}^{tr},seq_{m}^{tr}$ by Equations
(11)-(15);

9 Generate patient representation $r_{p}$ and medication records
representation $r_{m}$ by Equations (16)-(17);

10 Generate similarity $s_{m}$ by Equations (25);

11 Generate output $\hat{o}$ by Equations (24), (26)-(27);

12

13 Generate and accumulate $L_{bce}$, $L_{multi}$ in Equations (28)-(29);

14

Optimize the combined loss $L$ in Equation (30)

Algorithm 1 One training epoch of ACDNet

##  5 Experiment

To validate the effectiveness of ACDNet, we conducted experiments on two
publicly available datasets, which can be divided into the following three
sections:

  * $\bullet$

In comparative experiments, we assessed the performance of ACDNet and
baselines on both datasets.

  * $\bullet$

In the parameter experiments, we explore different parameter combinations in
the parameter experiments to find the optimal model configuration for ACDNet.

  * $\bullet$

In ablation experiments, we separately verified the effectiveness of each
module in ACDNet.

  * $\bullet$

Additionally, we performed case validation, demonstrating the practical
application of ACDNet in real-world scenarios.

###  5.1 Dateset

We employed MIMIC-III [14] and MIMIC-IV [15] as sources for our experimental
data. For the MIMIC-IV dataset, diagnoses and procedures are based on ICD-9
and ICD-10 codes. To process this information, we initially converted ICD-10
coded data to ICD-9 coded data [26]. In accordance with the data processing
methods utilized in GAMENet [7] and SafeDrug [11], we processed the datasets,
resulting in the data presented in Table 1.

Table 1: Statistics of the datasets | MIMIC-III | MIMIC-IV
---|---|---
# patients | 6350 | 64462
# clinical events | 15032 | 171295
# diagnoses | 1958 | 2000
# procedures | 1430 | 1500
# medicines | 131 | 131
Avg/max # of visits | 2.37/29 | 2.66/66
Avg/max # of diagnoses | 10.51/128 | 8.54/228
Avg/max # of procedures | 3.84/50 | 2.22/72
Avg/max # of medicines | 11.44/65 | 6.54/72
total # of DDI pairs | 448 | 448

###  5.2 Baselines and Metrics

We compare our model with the baselines below.

  * $\bullet$

LR is a instance-based classifier with L2 regularization.

  * $\bullet$

ECC [27] is an ensemble model for multi-label classification with correlated
labels.

  * $\bullet$

RETAIN [5] is an interpretable healthcare model using reverse time attention.

  * $\bullet$

LEAP [4] captures label dependencies and prevents adverse drug interactions
with reinforcement learning.

  * $\bullet$

GAMENet [7] recommends safe medication combinations using graph-augmented
memory networks.

  * $\bullet$

SafeDrug [11] is a DDI-controllable drug recommendation model utilizing
molecular structures.

  * $\bullet$

MICRON [10] predicts medication changes based on patient health using
recurrent residual networks.

  * $\bullet$

COGNet [16] generates medicine sets for patients based on diagnoses with a
copy-or-predict mechanism.

  * $\bullet$

DRMP [6] is a drug recommendation model using message propagation and DDI
gating mechanism.

  * $\bullet$

FFBDNet [9] is a feature fusion and bipartite decision network for medication
combination recommendation.

We evaluate the prediction performance using several metrics, including DDI
rate, Jaccard similarity score (Jaccard) [28], Average F1 score (F1), PR-AUC
[29], precision@k and nDCG@k, to assess the safety, accuracy, and
effectiveness of our model.

###  5.3 Implementation details

In line with previous research efforts [7, 11], we divided the dataset into
training, validation, and test sets at a 4:1:1 ratio. Our model is implemented
using Python 3.9.15 and PyTorch 1.12.1 [30], with training and testing
conducted on Intel Xeon CPU and NVIDIA 3080Ti GPU. After conducting parameter
experiments, optimal hyperparameters were selected within the model, with the
embedding dimension size set at 64 and $\lambda$ set at 0.97. For the
Transformer encoder, we selected a configuration with 8 attention heads and 6
layers. Due to varying dataset sizes, a learning rate of 0.0015 was
established for the MIMIC-III dataset, and 0.0002 for the MIMIC-IV dataset. We
utilized the Adam optimizer to refine the model. For all baseline models, we
used the optimization parameters mentioned in the literature for training and
testing on the MIMIC-III dataset. Similarly, for the MIMIC-IV dataset, we re-
optimized the parameters for all baseline models to ensure their optimal
performance. According to SafeDrug [11], in the evaluation process, instead of
conducting cross-validation, we apply bootstrapping sampling. Specifically, we
randomly sample 80% of the data points from the test set for one round of
evaluation. We perform 10 rounds of sampling and evaluation, and report the
mean and standard deviation values.

###  5.4 Performance Comparison

Table 2 presents the performance of various models on the MIMIC-III dataset.
ACDNet outperforms the baseline models in terms of Jaccard, PR-AUC, and F1
metrics, demonstrating its effectiveness in capturing both local and global
patient information and facilitating collaborative decision-making. The
results suggest that longitudinal-based models are more accurate than
instance-based approaches, as they can better capture patients’ historical
health information, leading to improved patient representations. In terms of
reducing the drug-drug interaction (DDI) rate, SafeDrug performs well due to
its utilization of DDI loss to minimize the DDI rate. However, it is important
to note that the actual DDI rate is 0.08379, and ACDNet’s results closely
resemble the real dataset, indicating its reliability and alignment with the
genuine data.

Table 2: Performance comparison on MIMIC-III Models | Jaccard | PR-AUC | F1 | DDI | Avg_Med
---|---|---|---|---|---
LR | 0.4865 ± 0.0021 | 0.7509 ± 0.0018 | 0.6434 ± 0.0019 | 0.0829 ± 0.0009 | 16.1773 ± 0.0942
ECC | 0.4996 ± 0.0049 | 0.6844 ± 0.0038 | 0.6569 ± 0.0044 | 0.0846 ± 0.0018 | 18.0722 ± 0.1914
RETAIN | 0.4887 ± 0.0028 | 0.7556 ± 0.0033 | 0.6481 ± 0.0027 | 0.0835 ± 0.0020 | 20.4051 ± 0.2832
LEAP | 0.4521 ± 0.0024 | 0.6549 ± 0.0033 | 0.6138 ± 0.0026 | 0.0731 ± 0.0008 | 18.7138 ± 0.0666
GAMENet | 0.5067 ± 0.0025 | 0.7631 ± 0.0030 | 0.6626 ± 0.0025 | 0.0864 ± 0.0006 | 27.2145 ± 0.1141
SafeDrug | 0.5213 ± 0.0030 | 0.7647 ± 0.0025 | 0.6768 ± 0.0027 | 0.0589 ± 0.0005 | 19.9178 ± 0.1604
MICRON | 0.5100 ± 0.0033 | 0.7687 ± 0.0026 | 0.6654 ± 0.0031 | 0.0641 ± 0.0007 | 17.9267 ± 0.2172
COGNet | 0.5336 ± 0.0011 | 0.7739 ± 0.0009 | 0.6869 ± 0.0010 | 0.0852 ± 0.0005 | 28.0900 ± 0.0950
DRMP | 0.5312 ± 0.0015 | 0.7757 ± 0.0016 | 0.6854 ± 0.0011 | 0.0865 ± 0.0006 | 22.7300 ± 0.2300
FFBDNet | 0.5292 ± 0.0020 | 0.7777 ± 0.0010 | 0.6833 ± 0.0017 | 0.0717 ± 0.0016 | 19.6900 ± 0.3000
ACDNet | 0.5433 ± 0.0027 | 0.7904 ± 0.0021 | 0.6957 ± 0.0021 | 0.0859 ± 0.0010 | 20.4900 ± 0.1197

Table 3 presents the performance of various models on the MIMIC-IV dataset.
Similar to the MIMIC-III dataset, longitudinal-based models prove more
accurate than instance-based approaches on the MIMIC-IV dataset. Although the
LEAP model performs well in DDI, its accuracy is inferior to other models. To
enhance SafeDrug’s accuracy, we set its DDI threshold to 0.1. The results
reveal that despite SafeDrug’s lower DDI value, its accuracy remains subpar
compared to other models. The MICRON model primarily focuses on differences
between adjacent visits and performs poorly on the more complex MIMIC-IV
dataset. COGNet, DRMP, and FFBDNet exhibit satisfactory performance on the
MIMIC-IV dataset, yet still fall short of ACDNet. ACDNet excels in Jaccard,
PR-AUC, and F1 metrics, signifying its superior capability in obtaining
patient health information and medication representations compared to other
models.

Table 3: Performance comparison on MIMIC-IV Models | Jaccard | PR-AUC | F1 | DDI | Avg_Med
---|---|---|---|---|---
LR | 0.4510 ± 0.0013 | 0.7290 ± 0.0014 | 0.6007 ± 0.0013 | 0.0762 ± 0.0004 | 8.9866 ± 0.0374
ECC | 0.4233 ± 0.0010 | 0.7284 ± 0.0012 | 0.5680 ± 0.0019 | 0.0771 ± 0.0003 | 8.1070 ± 0.0235
RETAIN | 0.4239 ± 0.0017 | 0.6798 ± 0.0018 | 0.5791 ± 0.0017 | 0.0939 ± 0.0015 | 10.8602 ± 0.0736
LEAP | 0.4287 ± 0.0012 | 0.5506 ± 0.0015 | 0.5820 ± 0.0012 | 0.0592 ± 0.0004 | 11.5198 ± 0.0459
GAMENet | 0.4507 ± 0.0013 | 0.7174 ± 0.0012 | 0.6043 ± 0.0014 | 0.0890 ± 0.0003 | 18.4426 ± 0.0474
SafeDrug | 0.4651 ± 0.0016 | 0.7118 ± 0.0016 | 0.6117 ± 0.0014 | 0.0740 ± 0.0004 | 14.4705 ± 0.0575
MICRON | 0.4554 ± 0.0026 | 0.6842 ± 0.0025 | 0.6088 ± 0.0032 | 0.0637 ± 0.0016 | 15.6963 ± 0.2875
COGNet | 0.4884 ± 0.0009 | 0.7087 ± 0.0008 | 0.6367 ± 0.0009 | 0.0894 ± 0.0003 | 19.7235 ± 0.0242
DRMP | 0.4913 ± 0.0015 | 0.7338 ± 0.0021 | 0.6435 ± 0.0018 | 0.0872 ± 0.0013 | 15.0512 ± 0.0365
FFBDNet | 0.4970 ± 0.0010 | 0.7435 ± 0.0012 | 0.6454 ± 0.0009 | 0.0838 ± 0.0004 | 11.2906 ± 0.0658
ACDNet | 0.5077 ± 0.0015 | 0.7501 ± 0.0017 | 0.6564 ± 0.0013 | 0.0849 ± 0.0005 | 12.7024 ± 0.0005

Table 4 and Table 5 display the precision and nDCG results on the MIMIC-III
and MIMIC-IV datasets. From the results, it is evident that ADCNet performs
the best in most cases, confirming its effectiveness in recommendations. LEAP
does not perform well, possibly because its reinforcement learning process for
sequential decisions may not effectively meet the requirements of
recommendations. Similarly, the information capture between adjacent visits in
MICRON does not yield strong results. In contrast, DRMP, which uses GNN and
GRU to model patient information, has shown promising results.

Table 4: Recommendation performance comparison on MIMIC-III Model | precision@5 | precision@10 | nDCG@5 | nDCG@10
---|---|---|---|---
LR | 0.8852 ± 0.0043 | 0.8075 ± 0.0035 | 0.8982 ± 0.0045 | 0.8404 ± 0.0038
ECC | 0.8851 ± 0.0033 | 0.8111 ± 0.0024 | 0.8993 ± 0.0038 | 0.8433 ± 0.0026
RETAIN | 0.8913 ± 0.0046 | 0.8126 ± 0.0033 | 0.9016 ± 0.0040 | 0.8436 ± 0.0030
LEAP | 0.7211 ± 0.0042 | 0.6772 ± 0.0040 | 0.7411 ± 0.0041 | 0.7033 ± 0.0039
GAMENet | 0.8953 ± 0.0054 | 0.8224 ± 0.0051 | 0.9079 ± 0.0049 | 0.8534 ± 0.0046
SafeDrug | 0.8964 ± 0.0040 | 0.8200 ± 0.0023 | 0.9088 ± 0.0037 | 0.8518 ± 0.0022
MICRON | 0.8655 ± 0.0061 | 0.8131 ± 0.0040 | 0.8740 ± 0.0054 | 0.8354 ± 0.0039
COGNet | 0.8913 ± 0.0037 | 0.8114 ± 0.0030 | 0.9045 ± 0.0027 | 0.8450 ± 0.0024
DRMP | 0.9003 ± 0.0032 | 0.8290 ± 0.0028 | 0.9097 ± 0.0024 | 0.8575 ± 0.0021
FFBDNet | 0.9029 ± 0.0042 | 0.8349 ± 0.0041 | 0.9136 ± 0.0043 | 0.8633 ± 0.0040
ACDNet | 0.9061 ± 0.0034 | 0.8400 ± 0.0026 | 0.9137 ± 0.0026 | 0.8660 ± 0.0021
Table 5: Recommendation performance comparison on MIMIC-IV Model | precision@5 | precision@10 | nDCG@5 | nDCG@10
---|---|---|---|---
LR | 0.7910 ± 0.0019 | 0.6581 ± 0.0016 | 0.8156 ± 0.0019 | 0.7154 ± 0.0016
ECC | 0.7858 ± 0.0017 | 0.6571 ± 0.0013 | 0.8105 ± 0.0014 | 0.7132 ± 0.0012
RETAIN | 0.7374 ± 0.0036 | 0.6109 ± 0.0029 | 0.7594 ± 0.0035 | 0.6645 ± 0.0029
LEAP | 0.5571 ± 0.0023 | 0.5139 ± 0.0023 | 0.5567 ± 0.0027 | 0.5275 ± 0.0024
GAMENet | 0.7722 ± 0.0014 | 0.6398 ± 0.0011 | 0.7944 ± 0.0016 | 0.6954 ± 0.0011
SafeDrug | 0.7740 ± 0.0018 | 0.6379 ± 0.0019 | 0.7974 ± 0.0019 | 0.6955 ± 0.0019
MICRON | 0.7583 ± 0.0022 | 0.6236 ± 0.0021 | 0.7801 ± 0.0023 | 0.6796 ± 0.0022
COGNet | 0.7609 ± 0.0012 | 0.6359 ± 0.0014 | 0.7870 ± 0.0011 | 0.6918 ± 0.0011
DRMP | 0.7938 ± 0.0016 | 0.6692 ± 0.0013 | 0.8150 ± 0.0017 | 0.7218 ± 0.0014
FFBDNet | 0.7931 ± 0.0011 | 0.6546 ± 0.0017 | 0.8157 ± 0.0010 | 0.7125 ± 0.0014
ACDNet | 0.8005 ± 0.0020 | 0.6647 ± 0.0020 | 0.8235 ± 0.0019 | 0.7221 ± 0.0019

###  5.5 Parameter influence

In this section, we will evaluate the performance of ACDNet on the MIMIC-III
dataset using various parameter settings. Specifically, we will explore
different combinations of $\lambda$ values and embedding dimensions to
identify the optimal configuration that yields the best results.

Firstly, with a fixed embedding dimension of 64, we explored different
$\lambda$ values. As shown in Figure 2, the Jaccard, PR-AUC, and F1 scores
reach their peak when $\lambda$ is set to 0.97.

Figure 2: Impact of $\lambda$ values on MIMIC-III Dataset

Subsequently, with a fixed learning $\lambda$ value of 0.97, we examined the
impact of different embedding dimensions. The results, depicted in Figure 3,
indicate that an embedding dimension of 64 yields the highest Jaccard, PR-AUC,
and F1 scores.

Figure 3: Impact of Embedding Dimensions on MIMIC-III Dataset

###  5.6 Ablation study

In the section, we removed some components of the ACDNet model to observe
their impact on model performance.

  * $\bullet$

ACDNet ${w/o\ M_{e},M_{d}}$: We remove the EHR graph and DDI graph from input.

  * $\bullet$

ACDNet ${w/o\ M_{mol}}$: We remove the medicine molecular from input.

  * $\bullet$

ACDNet ${w/o\ att}$: We change the all self-attention to mean operation.

  * $\bullet$

ACDNet ${w/o\ seq^{att}_{e}}$ We remove the patient representations that have
undergone self-attention.

  * $\bullet$

ACDNet ${w/o\ seq^{tr}_{e}}$ We remove the patient representations that have
undergone Transformer Enconder.

  * $\bullet$

ACDNet ${w\ GRU}$: We replace the Transformer encoder with GRU.

  * $\bullet$

ACDNet ${w\ RNN}$: We replace the Transformer encoder with RNN.

  * $\bullet$

ACDNet ${w\ o_{1}}$: We remove vectors related to the medication record, such
as $seq_{m}^{tr}$, $r_{m}$, $M$, $s_{m}$, and $o_{2}$, retaining only the
patient EHR representation for recommendation.

Table 6: Ablation Study on MIMIC-III Models | Jaccard | PR-AUC | F1 | DDI | AVG_Med
---|---|---|---|---|---
ACDNet ${w/o\ M_{e},M_{d}}$ | 0.5423 ± 0.0015 | 0.7888 ± 0.0022 | 0.6947 ± 0.0022 | 0.0861 ± 0.0009 | 20.4650 ± 0.1077
ACDNet ${w/o\ M_{mol}}$ | 0.5398 ± 0.0022 | 0.7861 ± 0.0024 | 0.6927 ± 0.0021 | 0.0817 ± 0.0008 | 20.8585 ± 0.1200
ACDNet ${w/o\ att}$ | 0.5350 ± 0.0016 | 0.7845 ± 0.0020 | 0.6887 ± 0.0016 | 0.0815 ± 0.0009 | 20.7952 ± 0.1420
ACDNet ${w/o\ seq^{att}_{e}}$ | 0.5001 ± 0.0029 | 0.7430 ± 0.0029 | 0.6568 ± 0.0026 | 0.0914 ± 0.0007 | 22.0030 ± 0.1511
ACDNet ${w/o\ seq^{tr}_{e}}$ | 0.5357 ± 0.0020 | 0.7834 ± 0.0014 | 0.6893 ± 0.0019 | 0.0814 ± 0.0007 | 21.2701 ± 0.1517
ACDNet ${w\ GRU}$ | 0.5355 ± 0.0022 | 0.7814 ± 0.0023 | 0.6888 ± 0.0020 | 0.0861 ± 0.0009 | 21.1938 ± 0.1440
ACDNet ${w\ RNN}$ | 0.5323 ± 0.0024 | 0.7762 ± 0.0025 | 0.6860 ± 0.0022 | 0.0844 ± 0.0010 | 21.2428 ± 0.1564
ACDNet ${w\ o_{1}}$ | 0.5297 ± 0.0025 | 0.7789 ± 0.0024 | 0.6840 ± 0.0023 | 0.0889 ± 0.0008 | 20.0775 ± 0.0993
ACDNet | 0.5433 ± 0.0027 | 0.7904 ± 0.0021 | 0.6957 ± 0.0021 | 0.0859 ± 0.0010 | 20.4900 ± 0.1197

The results from Table 6 indicate that the removal of the EHR graph and DDI
graph has an observable impact on ACDNet’s performance, suggesting the
important role these two graphs may play in medication representation.
Furthermore, the inclusion of medication molecular structure information also
contributes to the effectiveness of medication representation. When the self-
attention mechanism is eliminated from the ACDNet model, a noticeable decline
in performance is observed, underscoring the critical role of the attention
mechanism in the model. After removing patient representations processed by
self-attention, the model’s performance significantly deteriorated. This
indicates the vital role of self-attention in capturing each visit in a
patient’s history. The results obtained by removing the Transformer or
replacing it with RNN or GRU in ACDNet emphasize the superiority of the
Transformer encoder in comprehensively capturing essential information from
patients’ visit records and medication records. Moreover, when the
collaborative decision-making component is removed, leaving only the direct
recommendation part, a significant reduction in performance is evident. This
emphasizes the significance of similarity-based collaborative decision-making
in the model’s overall effectiveness.

Overall, these findings demonstrate the importance of incorporating EHR and
DDI graphs, attention mechanism, Transformer encoder, and collaborative
decision-making in ACDNet to achieve superior performance in medication
recommendation tasks.

###  5.7 Case study

To investigate the effectiveness of ACDNet under different numbers of visits,
we selected two patients, one with 2 visit records and the other with 5 visit
records. We employed four models, namely SafeDrug, COGNet, FFBDNet, and
ACDNet, for medication recommendations. Figures 4 and 5 display the
recommendation results, where ”Correct” refers to medications that were
accurately recommended. ”Unseen” denotes medications predicted by the model
but not found in the actual data, while ”Missed” indicates medications present
in the actual data that the model failed to predict.

For patient A, who had only two visit records, ACDNet displayed remarkable
precision in medication recommendations, and the occurrence of unseen
medications was notably minimal. This underscores the robust effectiveness of
ACDNet in medication recommendations, as it consistently minimizes the
occurrence of erroneous medication suggestions.

Figure 4: Recommended Medications of Patient A

In the scenario of patient B, who had a more extensive medical history with
five visit records, ACDNet maintained its exceptional performance. It
delivered a considerably higher number of accurate medication recommendations
when compared to other models. This emphasizes the model’s consistent
excellence in catering to patients with a richer medical journey, establishing
ACDNet as a reliable choice for medication recommendation across diverse
patient profiles.

Figure 5: Recommended Medications of Patient B

##  6 Conclusion

Medication recommendation constitutes a crucial application of data mining
within the biomedical domain. However, existing models grapple with
inadequacies concerning patient information and medicine representation. To
address these issues, this study introduces the ACDNet model for modeling and
predicting patients’ health and medicine information. The model employs
attention mechanism and Transformer to encode patients’ EHR data and
incorporates various external knowledge sources to represent medicine
information. By combining the collaborative decision mechanism based on
medication record similarity, we have successfully achieved personalized
medication recommendation. We experimented with MIMIC-III and MIMIC-IV
datasets, comparing ACDNet to other models. Results show ACDNet outperforms in
Jaccard, PR-AUC, and F1 metrics, proving its efficacy in acquiring patient
health data and medication representations. In future work, we will strive to
reduce the interaction rate between drugs to avert potential adverse reactions
and side effects.

## CRediT authorship contribution statement

Jiacong Mi: Methodology, Software, Validation, Writing - original draft. Yi
Zu: Data curation, Writing - review & editing. Zhuoyuan Wang: Data curation,
Writing - review & editing. Jieyue He: Supervision, Writing - review &
editing.

## Declaration of Competing Interest

The authors declare that they have no known competing financial interests or
personal relationships that could have appeared to influence the work reported
in this paper.

## Acknowledgments

This work was supported by National Key R&D Program of China (2019YFC1711000)
and Collaborative Innovation Center of Novel Software Technology and
Industrialization.

## References

  * [1] N. Menachemi, T. H. Collum, Benefits and drawbacks of electronic health record systems, Risk management and healthcare policy (2011) 47–55.
  * [2] Z. Ali, Y. Huang, I. Ullah, J. Feng, C. Deng, N. Thierry, A. Khan, A. U. Jan, X. Shen, W. Rui, et al., Deep learning for medication recommendation: A systematic survey, Data Intelligence (2023) 1–37.
  * [3] F. Gong, M. Wang, H. Wang, S. Wang, M. Liu, Smr: medical knowledge graph embedding for safe medicine recommendation, Big Data Research 23 (2021) 100174\.
  * [4] Y. Zhang, R. Chen, J. Tang, W. F. Stewart, J. Sun, Leap: learning to prescribe effective and safe treatment combinations for multimorbidity, in: proceedings of the 23rd ACM SIGKDD international conference on knowledge Discovery and data Mining, 2017, pp. 1315–1324.
  * [5] E. Choi, M. T. Bahadori, J. Sun, J. Kulas, A. Schuetz, W. Stewart, Retain: An interpretable predictive model for healthcare using reverse time attention mechanism, Advances in neural information processing systems 29 (2016).
  * [6] Y. Ren, Y. Shi, K. Zhang, X. Wang, Z. Chen, H. Li, A drug recommendation model based on message propagation and ddi gating mechanism, IEEE Journal of Biomedical and Health Informatics 26 (7) (2022) 3478–3485.
  * [7] J. Shang, C. Xiao, T. Ma, H. Li, J. Sun, Gamenet: Graph augmented memory networks for recommending medication combination, in: proceedings of the AAAI Conference on Artificial Intelligence, Vol. 33, 2019, pp. 1126–1133.
  * [8] Y. Tan, C. Kong, L. Yu, P. Li, C. Chen, X. Zheng, V. S. Hertzberg, C. Yang, 4sdrug: Symptom-based set-to-set small and safe drug recommendation, in: Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, 2022, pp. 3970–3980.
  * [9] Z. Wang, Y. Liang, Z. Liu, Ffbdnet: Feature fusion and bipartite decision networks for recommending medication combination, in: Proceedings of the European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML PKDD), 2022.
  * [10] C. Yang, C. Xiao, L. Glass, J. Sun, Change matters: Medication change prediction with recurrent residual networks, in: Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, 2021.
  * [11] C. Yang, C. Xiao, F. Ma, L. Glass, J. Sun, Safedrug: Dual molecular graph encoders for safe drug recommendations, in: Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, 2021.
  * [12] J. Wu, B. Qian, Y. Li, Z. Gao, M. Ju, Y. Yang, Y. Zheng, T. Gong, C. Li, X. Zhang, Leveraging multiple types of domain knowledge for safe and effective drug recommendation, in: Proceedings of the 31st ACM international conference on information & knowledge management, 2022, pp. 2169–2178.
  * [13] X. Li, Y. Zhang, X. Li, H. Wei, M. Lu, Dgcl: Distance-wise and graph contrastive learning for medication recommendation, Journal of Biomedical Informatics 139 (2023) 104301.
  * [14] A. E. Johnson, T. J. Pollard, L. Shen, L.-w. H. Lehman, M. Feng, M. Ghassemi, B. Moody, P. Szolovits, L. Anthony Celi, R. G. Mark, Mimic-iii, a freely accessible critical care database, Scientific data 3 (1) (2016) 1–9.
  * [15] A. Johnson, L. Bulgarelli, T. Pollard, S. Horng, L. A. Celi, R. Mark, Mimic-iv (version 2.0), PhysioNet (2022).
  * [16] R. Wu, Z. Qiu, J. Jiang, G. Qi, X. Wu, Conditional generation net for medication recommendation, in: Proceedings of the ACM Web Conference 2022, 2022, pp. 935–945.
  * [17] Y. Wang, J. Wang, Z. Cao, A. Barati Farimani, Molecular contrastive learning of representations via graph neural networks, Nature Machine Intelligence 4 (3) (2022) 279–287.
  * [18] O. Wieder, S. Kohlbacher, M. Kuenemann, A. Garon, P. Ducrot, T. Seidel, T. Langer, A compact review of molecular property prediction with graph neural networks, Drug Discovery Today: Technologies 37 (2020) 1–12.
  * [19] J. Zhou, G. Cui, S. Hu, Z. Zhang, C. Yang, Z. Liu, L. Wang, C. Li, M. Sun, Graph neural networks: A review of methods and applications, AI open 1 (2020) 57–81.
  * [20] J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, G. E. Dahl, Neural message passing for quantum chemistry, in: International conference on machine learning, PMLR, 2017, pp. 1263–1272.
  * [21] K. Yang, K. Swanson, W. Jin, C. Coley, P. Eiden, H. Gao, A. Guzman-Perez, T. Hopper, B. Kelley, M. Mathea, et al., Analyzing learned molecular representations for property prediction, Journal of chemical information and modeling 59 (8) (2019) 3370–3388.
  * [22] J. Sun, M. Wen, H. Wang, Y. Ruan, Q. Yang, X. Kang, H. Zhang, Z. Zhang, H. Lu, Prediction of drug-likeness using graph convolutional attention network, Bioinformatics 38 (23) (2022) 5262–5269.
  * [23] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, I. Polosukhin, Attention is all you need, Advances in neural information processing systems 30 (2017).
  * [24] T. N. Kipf, M. Welling, Semi-supervised classification with graph convolutional networks, arXiv preprint arXiv:1609.02907 (2016).
  * [25] P. Veličković, G. Cucurull, A. Casanova, A. Romero, P. Lio, Y. Bengio, Graph attention networks, arXiv preprint arXiv:1710.10903 (2017).
  * [26] N. B. of Economic Research, Icd-9-cm to and from icd-10-cm and icd-10-pcs crosswalk or general equivalence mappings (2016).
  * [27] J. Read, B. Pfahringer, G. Holmes, E. Frank, Classifier chains for multi-label classification, Machine learning 85 (2011) 333–359.
  * [28] S. Niwattanakul, J. Singthongchai, E. Naenudorn, S. Wanapu, Using of jaccard coefficient for keywords similarity, in: Proceedings of the international multiconference of engineers and computer scientists, Vol. 1, 2013, pp. 380–384.
  * [29] J. Davis, M. Goadrich, The relationship between precision-recall and roc curves, in: Proceedings of the 23rd international conference on Machine learning, 2006, pp. 233–240.
  * [30] A. Paszke, S. Gross, S. Chintala, G. Chanan, E. Yang, Z. DeVito, Z. Lin, A. Desmaison, L. Antiga, A. Lerer, Automatic differentiation in pytorch (2017).