Background: Diabetes mellitus (DM) is a major public health problem worldwide. It involves dysfunction of blood sugar regulation resulting from insulin resistance, inadequate insulin secretion, or excessive glucagon secretion.Methods: This study collated 971,401 drug usage records of 51,009 DM patients. These data included patient identification code, age, gender, outpatient visit dates, visit codes, medication features (including items, doses, and frequencies of drugs), HbA1c results, and time of testing. We applied a random forest (RF) model for feature selection and implemented a regression model with a bidirectional long short-term memory (Bi-LSTM) deep learning architecture. Finally, we used the root mean square error (RMSE) as the evaluation index for the prediction model.Results: After data cleaning, the data included 8,729 male and 9,115 female cases. Metformin was suggested to be the most important feature by the RF model, followed by glimepiride, acarbose, pioglitazone, glibenclamide, gliclazide, repaglinide, nateglinide, sitagliptin, and vildagliptin. The model performed better when using the past two seasons in the training data than with additional seasons. Further, the Bi-LSTM model performed better than the support vector machine (SVM) model.Conclusion: This study found that the Bi-LSTM model is a well processing architecture in a clinical decision support system (CDSS), which assists physicians in decision-making, and increasing the number of seasons had a negative impact on the model performance. In addition, this study showed that the most important drug was metformin, which is recommended as the first-line oral hypoglycemic agent (OHA) in DM patients.