Study cohort

Data used in this study was obtained from the EHR of six primary care clinics in Singapore. The study was approved by SingHealth Centralized Institutional Review Board (Reference Number: 2019/2604) prior to conduct of the study. Requirement of written consent was waived by the SingHealth Centralized Institutional Review Board as it was deemed impracticable while privacy risks were mitigated through the use of de-identified data. All methods were performed in accordance with relevant guidelines and regulations. The study cohort comprises multi-ethnic Asians adult patients, age 21 years or older having diabetes diagnosis under International Classification of Diseases (ICD), 9th or 10th Revision codes (250.90, 250.40, 250.80, E11.9, E11.21, E11.22, E14.31, E14.73 and E11.40) or have at least one diabetes medication in the 10-year period. These patients may also have hypertension (HTN) with ICD codes 401.1, 796.2, I10, or if they were on one or more anti-hypertensive medications. They may also have hyperlipidaemia (HLD) with ICD codes 272.0, E78.5, or if they were on one or more lipid-lowering medications. Patients’ demographic, disease history, laboratory test results and medications prescriptions were extracted over a 10-year period from 1 January 2010 to 31 December 2019. In total, the study cohort consisted of 54,933 patients.

Patient variables

Variables used for patient similarity learning included age, gender, blood pressure, cholesterol, triglycerides, HbA1c, disease duration of diabetes (DM), HLD and HTN, medications for DM, HLD and HTN. Medications were grouped by their classes and medication counts were derived by counting the number of medications in each class. In total, there were 18 DM medication types and six DM medication classes, nine HLD medication types and four HLD medication classes and 22 HTN medication types and eight HTN medication classes. All medication dosages except Insulin were expressed in prescribed daily dose (PDD) defined using three intensity level: low (L), moderate (M) and high (H) with reference to the maximum daily dosage (for example, L: ≤ 1/3 maximum daily dosage, M: ≤ 2/3 maximum daily dosage and H: > 2/3 maximum daily dosage). The list of medication types, classes and their dosage intensity can be found in Supplementary Table S1. To avoid complexity and the risk of overtreatment of insulin with oral DM medications23, insulin medications were regarded as binary variable (i.e. 1 if patient was prescribed an Insulin medication, 0 otherwise).

Recommendation algorithm

Given a target patient, the proposed DMRS uses patient’s latest clinical profiles and HbA1c trajectories to retrieve a set of similar patients and use their prescribed medications for the recommendation.

For the clinical profile similarity, we used the data-driven and domain knowledge (D3K) similarity measure proposed by Oei et al.24 to obtain an initial similarity score. The patient variables consisted of age, gender, systolic and diastolic blood pressure, cholesterol High-Density Lipoprotein (HDL), Low-Density Lipoprotein (LDL), triglyceride, HbA1c, HLD and HTN comorbidities, duration of disease(s) in years and count of medication types and classes. These variables were weighted by learning a generalized Mahalanobis measure that maximized the distance between patient pair, (\(P_{i}\), \(P_{k}\)) deemed to be clinically dissimilar while minimizing the distance between patients (\(P_{i}\), \(P_{j}\)) deemed as clinically similar. The personalized score of patient P for variable v, denoted as score (P, v), was determined based on the P’s value for v. Given two patients P1, P2, each with D variables, their D3K similarity score was given by

$$D3K\_sim\left( {P1,P2} \right) = \frac{{2\mathop \sum \nolimits_{v = 1}^{D} \min \left( {score{ }\,\left( {P1,{ }v} \right),{ }score{ }\left( {P2,{ }v,} \right)} \right)}}{{(\mathop \sum \nolimits_{v = 1}^{D} score\,\left( {P1,v} \right) + \mathop \sum \nolimits_{v = 1}^{D} score\left( {P2,v} \right))}}$$

For the management of chronic diseases such as diabetes, we observed that besides assessing whether the patient’s HbA1c value falls within the normal range, clinicians often up or down-titrate medication dosage with regards to the trend in HbA1c test results over the years. We modelled how clinicians typically analysed patient’s lab results by mapping patient’s HbA1c trajectory to a sequence of symbols. The symbols represent whether the results were normal (N), abnormal (A), increasing (U) or decreasing (D). Trajectory mapping were illustrated using the two cases as follows: First, we compared the HbA1c values v1 and v2 at every two consecutive months and used τ to denote a pre-determined threshold.

If v1 lies within the normal HbA1c range, we mapped this to the symbol “N”, otherwise it would be mapped to the symbol “A”.

If v1 < v2, we mapped this to the symbol “U” to represent an uptrend trajectory. Otherwise, we mapped to the symbol “D” to represent a downtrend trajectory.

If patients’ the HbA1c value were missing for that month, linear interpolation was used to estimate the missing value. In the instance where patients’ have multiple HbA1c values in a month, the average HbA1c value will be considered. For example, consider a patient having normal HbA1c values for three consecutive months, followed by increasing HbA1c values in the next two months and remains in the abnormal range in the last two months. The patient’s HbA1c trajectory will be illustrated by the sequence, ‘NNNUUAA’. Using the HbA1c trajectory mapping, we counted the occurrences of each n-grams in the sequence. We used n = 6 since most patients have their HbA1c tested every three to six months. There were two 6-grams in the above mapped sequence (i.e. ‘NNNUUA’ and ‘NNUUAA’) and both had a count of one.

We let d denote the total number of 6-grams in the mapped sequence of all the patients’ HbA1c trajectories. A d-dimensional vector was used to represent a patient’s trajectory with each dimension corresponds to a 6-gram. The ith entry represents the count of the occurrences of the ith 6-gram. The similarity between two patients P1, P2 with trajectory vectors u and v were computed as follows:

$$traj\_sim\left( {{\text{P}}1,{\text{ P}}2} \right) = \frac{1}{{1 + \left| {\left| {u – v} \right|} \right|_{2} }}$$

The overall similarity, trajectory-D3K (T-D3K) of patients P1, P2 was determined as follows:

$$sim\left( {{\text{P}}1,{\text{P}}2} \right) = {\text{ max}}\,\left( {D3K_{{sim\left( {{\text{P}}1,{\text{P}}2} \right)}} , traj_{{sim\left( {{\text{P}}1,{\text{P}}2} \right)}} } \right)$$

The proposed DMRS used the T-D3K method to generate the candidate set of medications for the target patient by retrieving prescription records of the similar patients (sorted by their overall similarity scores). For patients with the same similarity score, their medication lists were prioritized according to the degree of overlap with the target patient’s list of medications and dosages. In the instance of a tie, we ranked the medication lists based on the number of therapies (monotherapy was preferred over higher number of therapy), and dosage (lower dosage was preferred over higher dosage).


The proposed DMRS was evaluated on four groups of patients with different comorbidities profile (DM only, DM with HLD, DM with HTN, and DM with HLD and HTN (DHL)). For each group, 100 test patients were randomly selected among those with suboptimal HbA1c (i.e. HbA1c ≥ 8) and have at least one DM medication adjustment. For each test patient, the top K candidate medications were retrieved and ranked as described in the “Method” section.

We used the prescribed DM medication type and dose in the EHR records as our ground truth and evaluated the accuracy of our recommendations using three metrics: hit ratio, recall@K, and precision@K. Hit ratio refers to the percentage of patients where at least one of the recommended sets of medication matched the ground truth in both type and dosage.

As described in the previous section, the sets of medications to be recommended for a target patient were obtained from the prescription records of the similar patients. Each target patient can receive up to K unique sets of recommended medication.

We let S denote one set of recommended medication and G denote the ground truth medication. The percentage of matches between the recommended medication in S and that in the ground truth G were measured by recall (S,G) and precision (S,G) as follows:

$$recall\left( {S, G} \right) = \frac{{\left| {G \cap S} \right|}}{\left| G \right|}$$

$$precision\left( {S,G} \right) = \frac{{\left| {G \cap S} \right|}}{{\left| { S} \right|}}$$

For each target patient, we computed recall@K as the maximum recall (S,G) and precision@K as the maximum precision (S,G) among the K sets of recommended medication. In addition, to evaluate the quality of the recommendations, we used Mean Reciprocal Rank (MRR)25. MRR takes into account the position of the matched recommendation in the list. A high MRR indicates that the matched recommendation was positioned near the top of the recommendation list.

We compared our T-D3K approach of medication recommender systems with the following methods:

  • Euclidean distance on normalized data.

  • D3K. This approach retrieves similar patients and their prescribed medications using multiple clinical measurements and medication counts at a single time point.

  • Trajectory. This approach retrieves similar patients and their prescribed medications based on HbA1c (%) trajectory over multiple time points.

Ethics approval

Ethics approval was obtained from SingHealth Centralized Institution Review Board (CIRB) in 2019 (SingHealth CIRB Reference: 2019/2604). Patient consent was not obtained as the analysis was conducted on de-identified data.


By admin

Leave a Reply

Your email address will not be published. Required fields are marked *