
94% of researchers rate our articles as excellent or good
Learn more about the work of our research integrity team to safeguard the quality of each article we publish.
Find out more
ORIGINAL RESEARCH article
Front. Pharmacol. , 14 March 2025
Sec. Drugs Outcomes Research and Policies
Volume 16 - 2025 | https://doi.org/10.3389/fphar.2025.1534552
This article is part of the Research Topic Clinical Pharmacist Service Promotes the Improvement of Medical Quality Volume II View all 51 articles
Background: Optimizing prescription practices for surgical patients is crucial due to the complexity and sensitivity of their medication regimens. To enhance medication safety and improve patient outcomes by introducing a machine learning (ML)-based warning model integrated into a pharmacist-led Surgical Medicines Prescription Optimization and Prediction (SMPOP) service
Method: A retrospective cohort design with a prospective implementation phase was used in a tertiary hospital. The study was divided into three phases: (1) Data analysis and ML model development (1 April 2019 to 31 March 2022), (2) Establishment of a pharmacist-led management model (1 April 2022 to 31 March 2023), and (3) Outcome evaluation (1 April 2023 to 31 March 2024). Key variables, including gender, age, number of comorbidities, type of surgery, surgery complexity, days from hospitalization to surgery, type of prescription, type of medication, route of administration, and prescriber’s seniority were collected. The data set was divided into training set and test set in the form of 8:2. The effectiveness of the SMPOP service was evaluated based on prescription appropriateness, adverse drug reactions (ADRs), length of hospital stay, total hospitalization costs, and medication expenses.
Results: In Phase 1, 6,983 prescriptions were identified as potential prescription errors (PPEs) for ML model development, with 43.9% of them accepted by prescribers. The Random Forest (RF) model performed the best (AUC = 0.893) and retained high accuracy with 12 features (AUC = 0.886). External validation showed an AUC of 0.786. In Phase 2, SMPOP services were implemented, which effectively promoted effective communication between pharmacists and physicians and ensured the successful implementation of intervention measures. The SMPOP service was fully implemented. In Phase 3, the acceptance rate of pharmacist recommendations rose to 71.3%, while the length of stay, total hospitalization costs, and medication costs significantly decreased (p < 0.05), indicating overall improvement compared to Phase 1.
Conclusion: SMPOP service enhances prescription appropriateness, reduces ADRs, shortens stays, and lowers costs, underscoring the need for continuous innovation in healthcare.
Optimizing prescription practices for surgical patients is critical due to the complexity and sensitivity of their medication regimens. Surgical patients often require multiple medications to manage their conditions before and after surgery, especially elderly patients, who typically need more prescriptions due to comorbidities (Cross et al., 2020). The frequent use of high-alert medications such as anticoagulants (Raccah et al., 2021), opioids (Heneka et al., 2018), anesthesia (Kothari et al., 2010), and sedatives, during surgery increases the risk of prescription errors (Abbasi et al., 2022). Studies report a 9.3% error rate among all prescription in 1,000 perioperative patients in the United States (Langlieb et al., 2023). These errors can lead to adverse drug events (ADEs), prolonged hospital stays, and higher healthcare costs (Durand et al., 2024), highlighting the need to optimize prescriptions to improve outcomes.
Given the high risk of errors, it is crucial to explore strategies to enhance prescription accuracy. Strengthening the clinical role of clinical pharmacists is one such effective strategy (Jia et al., 2021). Previous literature has confirmed that clinical pharmacists play a pivotal role in drug management and reducing ADRs (Johns et al., 2024; Mahomedradja et al., 2023; Delgado-Pérez et al., 2023). Studies have shown that clinical pharmacists have significantly reduced drug errors and adverse drug reactions through systematic drug review services. For instance, research has demonstrated that pharmacist-led prescription review services improve appropriateness, reduce errors, enhance patient outcomes, and minimize resource wastage (Dalton and Byrne, 2017; Jaam et al., 2021; Jošt et al., 2024). Yang, for example, found that a pharmacist-led, system-assisted review model reduced inpatient prescribing errors from 6.94% to 1.96% (Yang et al., 2021). Pharmacists are particularly important in the drug management of surgical patients, especially in complex treatment plans (Xie et al., 2023). Pharmacists can optimize drug selection and administration routes, reduce inappropriate drug use, and thus mitigate the occurrence of drug-related adverse reactions (Nguyen et al., 2023). Other studies have shown that pharmacist-involved drug optimization services significantly reduce the incidence of adverse drug reactions and shorten hospital stays (Gray et al., 2023).
However, while these interventions are beneficial, addressing potential prescription errors (PPEs) is even more critical. Numerous studies have shown that pharmacists can resolve possible conflicts in treatment plans between doctors and pharmacists through effective communication, further improving the safety of drug therapy (Kim et al., 2024; Waszyk-Nowaczyk et al., 2021). Yet over 50% of PPEs identified by pharmacists were not accepted by prescribers in prior studies (Alipour et al., 2018; Albassam et al., 2020). Few studies have developed management models to address unaccepted PPEs, leading to higher risks and potential harm.
Developing a management model for unaccepted PPEs has proven challenging due to factors such as patient conditions, disease complexities, and medication regimens Unresolved PPEs present significant risks to medication safety and efficacy. Prescribers may reject pharmacists’ recommendations due to differing focuses, with prescribers prioritizing outcomes and pharmacists emphasizing drug properties and interactions (Waszyk-Nowaczyk et al., 2021). Heavy workloads and existing management processes contribute to communication discrepancies (Rosen et al., 2018). A study found that 60% of pharmacist interventions were not implemented by prescribers, often due to differences in clinical focus (De Rijdt et al., 2008). The lack of a structured approach exacerbates these gaps in medication safety.
To bridge these challenges, recent advances in machine learning (ML) offer promising solutions. ML can handle large-scale datasets and identify factors influencing healthcare management outcomes. A study demonstrated that models such as Random Forest (RF) and Support Vector Machine (SVM) could enhance predictive accuracy and patient outcomes by identifying critical factors like age, BMI, and blood pressure in diabetic groups (Tan et al., 2023). In recent years, the application of ML in drug management has also gradually increased. Studies have shown that by introducing ML models, pharmacists can more accurately identify potential medication errors and inappropriate drug treatment plans, thereby improving the efficiency and accuracy of drug reviews (Chalasani et al., 2023). For example, by using an RF model, pharmacists can significantly enhance the accuracy and efficiency of drug reviews, consequently reducing drug-related adverse events (Vora et al., 2023; Li et al., 2024). Integrating machine learning models with pharmacists' clinical expertise can help mitigate disagreements between pharmacists and prescribing physicians (Al Meslamani, 2023), leading to greater acceptance of drug treatment plans (Babel et al., 2021) and ultimately reducing adverse drug reactions (Dsouza et al., 2025) and healthcare costs (Khanna et al., 2022).
This study presents an ML-based warning model t designed to identify key intervention points in the medication management process and optimize the pharmacist-led prescription review system. The aim is to evaluate the effectiveness of the model in improving prescription appropriateness for surgical patients, reducing adverse drug events (ADEs), and shortening hospital stays. By focusing on surgical patients, the study seeks to contribute to the standardization of clinical medication management, thereby enhancing patient safety and improving healthcare outcomes in perioperative care.
This study employed a retrospective cohort design combined with a prospective implementation phase to evaluate the effectiveness of a pharmacist-led prescription optimization intervention service for surgical patients. The study was structured into three phases: data analysis and ML model development, establishment of a pharmacist-led management model, and outcome evaluation (Figure 1). This study was approved by the Ethics Committee of our hospital (Ethics Number: 2021-K-K229).
Figure 1. Flowchart. ADRs: Adverse Drug Reactions; AUC: Area Under the ROC Curve; PPV: positive predictive value; NPV: negative predictive value; PPEs: potential prescription errors.
The study was conducted at a tertiary hospital, which was the first to implement an electronic system-assisted review service for all inpatient prescriptions (beginning on 1 April 2019). The participant cohort included surgical patients admitted between April 2019 and March 2024. Patients were selected based on the following criteria: (1) Patients underwent surgery during hospitalization; (2) Patients were aged 18 years or older; (3) Patients had multiple comorbidities (defined as having at least two chronic conditions) (Skou et al., 2022) and complex medication regimens (defined as the use of five or more medications during hospitalization) (Pazan and Wehling, 2021). Exclusion criteria included: (1) Patients with incomplete medical records; (2) Patients transferred from other hospitals.
Data was collected from the electronic prescription review (EPR) system. Key data points included: patient demographics (gender, age, number of comorbidities, length of stay, incidence of ADRs, total hospitalization costs, cost of medication); surgical-related information (type of surgery, days from hospitalization to surgery, and level of surgery complexity); prescription-related information (type of prescription, number of concurrent medications, type of medication, route of administration, grade of prescription, and type of PPEs); and intervention Information (prescribers’ seniority, prescribers’ gender, and pharmacist training).
To define Potential Prescription Errors (PPEs), we utilized a set of criteria embedded in the commercialization EPR system, which has been implemented in multiple leading hospitals across China. These criteria were developed based on authoritative literature, clinical guidelines, drug package inserts, and national drug use policies.
Before the implementation of EPR system, our hospital established a Prescription Review Rules Panel comprising multidisciplinary experts, including clinical pharmacists, prescribers, and other healthcare professionals. The panel developed the criteria using established resources such as the Beers Criteria (American Geriatrics Society, 2023), STOPP/START Criteria (O'Mahony et al., 2015), Centers for Disease Control and Prevention (CDC) opioid prescribing guidelines (Dowell et al., 2022), and other relevant guidelines.
After updating the criteria based on these resources, the panel finalized them through two rounds of the Delphi method. The updated rules were updated with monthly to address evolving clinical needs.
The included rules were embedded in the hospital’s EPR system, which contained approximately 90,000 rules. To facilitate the implementation, prescriptions were categorized into eight grades according to these rules: (1) Grades 0–4: Defined as appropriate prescriptions. Based on existing evidence, these prescriptions were likely to benefit the patient. (2) Grades 5–6: Defined as potential errors prescription. These prescriptions required further evaluation by a pharmacist, as the benefits and risks could not be conclusively determined from existing evidence. (3) Grade 7: Defined as error prescriptions. Based on existing evidence, these prescriptions had clear contraindications or risks for the patient.
According to the prescription review process, grades 5–6 prescriptions were forwarded to the pharmacist’s interface for further review. If the prescription was considered as appropriate by the pharmacist, it could proceed to dispensing; if considered a PPE, it was sent back to the prescriber’s interface for reconsideration. The prescriber then decided whether to continue with the prescription based on the pharmacist’s suggestion. Due to disagreements between pharmacists and prescribers in resolving PPEs identified as grades 5–6, the communication and acceptance process required considerable effort, making it challenging to efficiently manage risks for these prescriptions. Therefore, grades 5–6 prescriptions were included as the subject of investigation in this study. Additionally grades 5–6 PPEs were defined according to the following criteria: (1) Contraindicated drug; (2) Drug interactions; (3) Incorrect dilution; (4) Incompatibilities; (5) Incorrect infusion rate or order; (6) Non-compliance with hospital policies; (7) Incorrect duration of treatment; (8) Wrong utilization.
This study was conducted in three phases to optimize and evaluate the SMPOP service model. The phases include data analysis and ML model development, establishment of the SMPOP intervention model, and outcome evaluation. Figure 1 summarizes the key activities and timeline of each phase.
The data was divided into an accepted group and an unaccepted group based on the prescribers’ decisions which were informed by the pharmacist’s opinion. Independent variables included patient variables (gender, age, number of comorbidities); surgical variables (type of surgery, days from hospitalization to surgery, level of surgery complexity); prescription variables (type of prescription, number of concurrent medications, type of medication, route of administration, grade of prescription, and type of PPEs); and intervention variables (prescriber’s seniority, prescriber’s gender, pharmacist’s training).
The 6,983 prescriptions were split into a training set and an internal validation set in a ratio of 8:2. The 15 aforementioned features were used to develop the prediction models. 11 ML models were used to predict whether the prescriber accepts the pharmacist’s decision: Naive Bayes (NB), RF, extreme gradient boosting (XGBoost), artificial neural network (ANN), SVM, decision tree (DT), extra trees (ET), gradient boosting machine (GBM), light gradient boosting machine (LightGBM), logistic regression (LR), and adaptive boosting (AdaBoost).
The reliability of the models was assessed using common evaluation metrics (Mandrekar, 2010; McHugh, 2012), including the area under the receiver operating characteristic curve (AUC), accuracy, F1 score, sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), and kappa coefficient. The prediction models were validated using Five-fold and Ten-fold cross-validation.
SHapley Additive exPlanations (SHAP) was used to interpret the models and estimate the contribution of each variable (Hu et al., 2024). SHAP values were used to reduce the features from 15 to the top three based on feature importance ranking. The Delong nonparametric method and binomial exact test in MedCalc (version 22.030) (DeLong et al., 1988) were used to compare the differences in AUC for different features.
In this phase, version 1.0 of a pharmacist-led Surgical Medicines Prescription Optimization and Prediction (SMPOP) ® service model was developed. Activities included: (1) Technical Integration: The ML-based optimization and prediction model was embedded into the hospital’s EPR system. (2) System Debugging and Calibration: Continuous monitoring and adjustment of the system were performed made to ensure the system operated accurately and efficiently operation. (3) SMPOP Process Design: Based on significant findings from Phase 1, multiple management nodes were established, and the overall process clearly defined (Figure 2).
Figure 2. Establishment and Implementation of the Pharmacist-Led Surgical Medicines Prescription Optimization and Prediction (SMPOP)® Service Model. PPEs: potential prescription errors; SOP: standard operating procedures.
During this phase, the effectiveness of the SMPOP service was assessed. Data from the following periods were collected and analyzed to measure the impact of the SMPOP service on patient outcomes: (1) April 2019 to March 2020 (ML Development Period): This period was dedicated to developing ML models using data from the derivation cohort. (2) April 2020 to March 2021 (External Validation Period): During this period, the developed models were externally validated using a separate dataset to ensure robustness and generalizability. (3) April 2023 to March 2024 (Post-Implementation Evaluation Period): This period involved evaluating patient outcomes after the implementation and stabilization of the pharmacist-led prescription optimization intervention service model.
The following key outcome measures were evaluated: (1) Prescription appropriateness: Evaluated based on the prediction of PPEs and the acceptance rate of pharmacist recommendations by prescribers. (2) ADRs: Measured by the total incidence rate of ADRs across the three periods to determine the effectiveness of the intervention in reducing medication-related harm. (3) Length of Hospital Stay: A comparison of the average duration of hospital stays across the three periods was used to highlight any improvements in patient recovery times and hospital efficiency. (4) Total Hospitalization Costs: Analyzed by comparing the total costs incurred during hospital stays across the three periods, which includes all expenses related to patient care and treatment. (5) Cost of Medication: Evaluated by comparing the total expenditure on medications across the three periods, reflecting the cost-effectiveness of the optimized prescription practices.
Statistical analyses were performed using Python (Spyder-py3), IBM SPSS Statistics (version 25.0), and R (version 4.4.0). Decision curve analysis (DCA) was performed using R (version 4.4.0), while precision-recall curve analysis (P-R curve analysis) was performed using Python (Spyder-py3). In the comparative analysis between the two groups, categorical variables were expressed as frequencies (percentages) and compared using the chi-square test. For normally distributed continuous data, descriptive statistics were presented as mean ± standard deviation, and the independent sample t-test was used. For non-normally distributed continuous data, distribution characteristics were described using the interquartile range (IQR), and the Mann-Whitney U test was applied. A p-value <0.05 was considered statistically significant.
A total of 2,049,499 prescriptions were issued for both the pre- and post-implementation SMPOP service cohorts between 1 April 2019, and 31 March 2024. For pre-implementation cohorts, 793,395 prescriptions were classified as grades 5 and 6 by the system and were sent to the pharmacist interface for further review. Among these, 6,983 prescriptions were deemed to have PPEs and were included for ML model development during Phase 1. Prescriptions for external validation were included in Phase 1. In Phase 3, the number of prescriptions included was 3,307.
4,208 patients were associated with the 6,983 prescriptions deemed to have PPEs: 62.55% of patients had one prescription, 22.81% had two prescriptions, 7.87% had three prescriptions, and 6.86% of patients had more than three prescriptions (Supplementary Table S1).
For the analysis of the ML model development, of the 6,983 PPE prescriptions,43.90% were accepted by prescribers and defined as the ‘accepted group’, while 56.10% were not accepted and were categorized as the ‘unaccepted group’. Comparison between the two groups indicated that the type of surgery, days from hospitalization to surgery, level of surgery complexity, type of prescription, number of concurrent medications, type of medication, route of administration, grade of prescription, type of PPEs, prescriber’s gender, and pharmacist training were significantly different (p < 0.05). Specifically, regarding the grade of prescription, prescriptions of grade 5 accounted for 84.52% of all PPE prescriptions, and made up 83.33% of the ‘unaccepted’ group (p = 0.001). For all types of PPE, the most common error was inappropriate indication (67.76%), accounting for 68.30% of the ‘unaccepted’ group (p < 0.001). Others, such as gender, age, number of comorbidities, or prescriber’s seniority, showed no significant statistical differences (p > 0.05) (Supplementary Table S2). A comparison of demographics and variables between the training set, internal validation set, and external validation set was provided in Supplementary Table S3.
During Phase 1, 11 ML models were generated to predict whether the prescriber accepts the pharmacist’s recommendation. Among the 11 ML models, the RF model had the best predictive performance in terms of AUC (AUC = 0.893), followed by the LightGBM model (AUC = 0.797), DT model (AUC = 0.780), XGBoost model (AUC = 0.777), and GBM model (AUC = 0.773) (Figure 3A). For other performance metrics, these 5 ML models also performed better than the other six models (Supplementary Table S4), and were therefore selected as further analysis models.
Figure 3. Performance of ML Models in Predicting Whether the prescriber accepts the pharmacist’s decision. (A) ROC curves of the top five best-performing ML models; (B) AUC of the top five best-performing ML models with different numbers of features; (C) AUC, Sensitivity, Accuracy, Specificity, Kappa, and F1 Score of the RF model with different numbers of features. ROC: Receiver Operating Characteristic; AUC: Area Under the ROC Curve; AdaBoost: Adaptive Boosting; ANN: Artificial Neural Network; DT: Decision Tree; ET: Extra Trees; GBM: Gradient Boosting Machine; LightGBM: Light Gradient Boosting Machine; LR: Logistic Regression; ML: Machine Learning; RF: Random Forest; SVM: Support Vector Machine; XGBoost: Extreme Gradient Boosting.
In the SHAP summary plot for all features, the ‘type of prescription’ consistently ranked as the most important feature across the five optimal ML models (Supplementary Figure S1). During the feature reduction using feature engineering, changes in the AUC values indicated that the RF model demonstrated the best predictive capability (Figure 3B). Additionally, performance evaluations of the RF model with varying numbers of features further confirmed its strong predictive capability (Figure 3C; Supplementary Table S5).
The final model was selected through the feature reduction process of the RF model. The DeLong and binomial exact tests were used to compare the differences in AUC with different features in predicting whether the prescriber accepts the pharmacist’s decision. The results showed that the 15-feature model (AUC = 0.893, 95%CI = 0.876–0.909) was significantly better than the 9-feature model (AUC = 0.868, ΔAUC = 0.025, p < 0.001, 95% CI = 0.849–0.885), the 6-feature model (AUC = 0.802, ΔAUC = 0.092, p < 0.001, 95% CI = 0.780–0.822), and the 3-feature model (AUC = 0.678, ΔAUC = 0.216, p < 0.001, 95% CI = 0.653–0.702) but was not significantly better than the 12-feature model (AUC = 0.886, ΔAUC = 0.007, p = 0.092, 95%CI = 0.868–0.902). This implies that reducing the number of features did not significantly affect model performance (Supplementary Figure S2A; Supplementary Table S6).
The DCA curve was used to compare prediction models with varying numbers of features. Results showed that the 12-feature model provided a greater net benefit, demonstrating strong predictive performance across different thresholds (Supplementary Figure S2B). Additionally, the P-R curve revealed that the 12-feature model (PR-AUC = 0.867) performed slightly below the 15-feature model (PR-AUC = 0.874), indicating that both models offer similarly high clinical utility (Supplementary Figure S2C).
Finally, the 12-feature RF model (including gender, age, number of comorbidities, type of surgery, level of surgery complexity, days from hospitalization to surgery, type of prescription, number of concurrent medications, type of medication, route of administration, type of PPEs, prescriber’s seniority) was selected as the final model for further analysis. The final RF model for predicting prescriber opinion had an AUC of 0.886, a sensitivity of 0.836, a specificity of 0.773, PPV of 0.742, NPV of 0.857, accuracy of 0.800, F1 score of 0.786, and kappa of 0.600.
To validate the adequacy of the sample size and the robustness of the model, additional cross-validation was performed. The final RF model achieved a mean AUC of 0.891 ± 0.012 in five-fold cross-validation (Supplementary Figure S3A) and 0.898 ± 0.014 in ten-fold cross-validation (Supplementary Figure S3B). Additionally, the final model had a mean AUC of 0.912 ± 0.026 for 2019 (n = 2,734) and 0.885 ± 0.012 for 2020 (n = 4,249) according to ten-fold cross-validation (Supplementary Table S7).
Data from 2021 to 2022 were used as external validation data. The RF model performed well in both internal and external validation. Internal validation showed an AUC of 0.886, while external validation showed an AUC of 0.786, with a ΔAUC of 0.100, indicating the model’s consistency and generalizability across different datasets (Supplementary Figure S4). Despite a slight decrease in the AUC during external validation, other key performance metrics, such as accuracy, precision, PPV, NPV, and specificity, remained high on the external dataset, which demonstrated the model’s effectiveness and robustness for new data (Supplementary Table S8).
Using the SHAP method, both local and global interpretations of the model were provided. Local interpretation was used to understand the specific prediction process for individual samples in the RF model. Variables such as gender, age, number of comorbidities, type of surgery, level of surgery complexity, days from hospitalization to surgery, type of prescription, type of medication, route of administration, and prescriber’s seniority were found to have a positive impact on the SHAP values. In contrast, the number of concurrent medications and type of PPEs were found to have a negative impact on the SHAP values (Figure 4A).
Figure 4. SHAP Explanation of the RF Model. (A) SHAP Force Plot: Contribution of each feature value for a single sample; (B) SHAP Summary Plot: Summary of SHAP values for each variable; (C) SHAP Summary Bar Plot: Absolute mean of SHAP values for each variable.
Global interpretation was used to describe the overall functionality of the model. By calculating and plotting the SHAP values for each feature across all samples, the SHAP values for each sample were summarized and variables ranked in descending order. For example, the SHAP values for long-term prescriptions were found to be relatively low, indicating a significant negative impact on model predictions (Figure 4B). The importance of the features was evaluated based on the average absolute SHAP values, which were arranged in descending order. According to the RF model, the five most important features were identified as type of prescription, type of surgery, type of medication, number of comorbidities, and days from hospitalization to surgery (Figure 4C). SHAP dependence plots were used to understand how individual features influenced the model’s output. The relationships between the actual values and SHAP values for these 12 features are illustrated in Supplementary Figure S5.
The changes in prescribers' acceptance of pharmacists' recommendations, length of stay, total hospitalization costs, cost of medication, and number of ADRs were compared across three periods to evaluate the effectiveness of the SMPOP service. An increase in the acceptance rate of pharmacists' recommendations was observed among the three groups, along with decreases in the length of stay, total hospitalization costs, cost of medication, and ADRs (Table 1). Compared to the ML development period and external validation period, the acceptance rate of pharmacists’ recommendations in the post-implementation evaluation period increased from 40.63% to 71.30%, the length of stay was reduced from 13 days (IQR: 8, 22) (P < 0.001) to 7 days (IQR: 9, 15) (p < 0.001), total hospitalization costs decreased from 32,263.42 RMB (IQR: 16,880.46,68,921.29) (p < 0.001) to 20,842.89 RMB (IQR: 13,516.59, 32,055.51) (p < 0.001), cost of medication decreased from 7847.67 RMB (IQR: 3815.45,19,980.16) (p < 0.001) to 4,712.92 RMB (IQR: 2866.63, 7716.55) (p < 0.001), and the ADR rate was reduced from 0.4% to 0.18% (p = 0.095).
This study demonstrated the potential of an ML-based model integrated into a pharmacist-led SMPOP service to enhance prescription practices for surgical patients. Given the complexity of surgical medication regimens, optimizing prescriptions was essential to improving outcomes and reducing costs. Using a three-phase approach, namely, data analysis and model development, management model establishment, and outcome evaluation, the study showed how predictive analytics can enhance the identification and resolution of PPEs. The RF model proved most effective in predicting the acceptance of pharmacist recommendations, enhancing prescription appropriateness, reducing ADRs, shortening hospital stays, and saving costs. These findings highlight the benefits of integrating ML with clinical decision-making, providing a framework for better medication management and patient safety in surgical care.
A significant proportion of identified PPEs remained unaccepted by prescribers from 2019 to 2022. Similar to findings from prior research, a study from the United States found that around 30% of discovered medication errors reached patients (Sacks et al., 2009). However, that investigation did not focus on surgical settings, a factor which may have influenced how unaccepted PPEs were resolved. Even with pharmacy-based interventions, 53% of drug errors during the administration stage persisted (FitzHenry et al., 2007), highlighting the difficulty of comparing PPE rates across studies, as they can vary based on context, methodology, and definitions of prescription errors (Lisby et al., 2010; Saif et al., 2024; Alsabri et al., 2024). Consequently, these comparison data should be interpreted cautiously. Nonetheless, the high proportion of unresolved PPEs underscores the need to enhance efforts to address these issues.
The final ML prediction model included critical features: age, gender, number of comorbidities, type of surgery, level of surgical complexity, days from hospitalization to surgery, number of concurrent medications, type of medication, route of administration, type of PPEs, prescriber’s seniority, and type of prescription. Inclusion of these features could enhance the efficiency of resolving unaccepted PPEs and provide a nuanced understanding of effective strategies (Johns et al., 2024; Mahomedradja et al., 2023; Tansuwannarat et al., 2023). Our study identified that male patients with comorbidities undergoing complex surgeries were at higher risk for unresolved PPEs, aligning with prior research indicating that surgical complexity and comorbidities are significant predictors, often exacerbating communication challenges in resolving PPEs (Tonelli et al., 2018; Nanji et al., 2016).
While gender had not traditionally been viewed as a significant factor, our findings suggested that prescriptions for male patients required closer collaboration between prescribers and pharmacists. Medications administered via non-oral routes, such as intravenous, intramuscular, subcutaneous, and via inhalation, were flagged as high-risk categories, indicating that non-oral routes were associated with higher rates of PPEs due to their complexities (Alsabri et al., 2024). Additionally, our study found that junior pharmacists were more likely to reduce unresolved PPEs, contradicting the notion that experience necessarily enhances PPE resolution (Jaam et al., 2021; Dean et al., 2002). This may be due to junior pharmacists being more attuned to newer protocols and dedicating more time to PPE-related issues, supporting research advocating for fresh perspectives and up-to-date training in the healthcare workforce (Newby et al., 2019; Gillani et al., 2021).
In this study, the RF model was selected for its superior predictive performance in identifying PPEs and supporting pharmacist-led interventions. Among the tested ML models, RF achieved the highest AUC, making it optimal in this context. This finding aligns with prior studies highlighting the effectiveness of RF models in predicting clinical outcomes by managing complex, non-linear interactions among variables (Hu et al., 2024). Unlike LR and SVM commonly used in earlier prescription optimization studies (Chalasani et al., 2023; Couronné et al., 2018; Marchi et al., 2022), RF showed superior adaptability to patient, surgical, and prescription-related factors (Hassan et al., 2023). Furthermore, feature reduction confirmed the RF’s ability to maintain high predictive accuracy with fewer variables. The 12-feature model selected through SHAP analysis maintained strong performance comparable to the full 15-feature model, as confirmed by DCA, PR-AUC, and statistical tests. The RF model’s capacity to handle large feature sets and provide interpretable results through SHAP aligns with the complexities of clinical decision-making in surgical settings.
The SMPOP service integrated an ML-based warning system into the EPR process, improving the identification of high-risk prescriptions. Predictive analytics established key intervention nodes, facilitating collaboration between pharmacists and the healthcare team. This framework was implemented and calibrated through continuous feedback, ensuring alignment with clinical practices and enhancing its utility in optimizing surgical medication use. In this study, the RF within SMPOP demonstrated strong predictive accuracy and efficiency, even after feature reduction that integrated patient factors, surgical complexities, prescription details, and both pharmacist and prescriber characteristics. Traditional pharmacist-led interventions, though effective, often faced limitations in comprehensiveness and scalability (Jaam et al., 2021; Li et al., 2024; Moon et al., 2020; Mostafa et al., 2020) This integrated approach contrasts with earlier models that focused on fewer variables or lacked a holistic view of factors affecting prescription appropriateness (Bates et al., 2021; Alotaibi and Federico, 2017).
ML model have demonstrated significant advantages in detecting inappropriate prescriptions and identifying factors leading to prescription errors, as confirmed by studies conducted by Johns et al. (2024), Mahomedradja et al. (2023). After the introduction of ML model, this study shows that the acceptance rate of pharmacists' recommendations increased from 43.9% to 71.3%, indicating that the model enhanced the scientific rigor and credibility of pharmacists' advice. In terms of types of medication errors, this study found that “Wrong utilisation” accounted for 67.76%, being the most common type. Similarly, a 10-year retrospective analysis also indicates that dosage and drug selection errors are the most frequent types of errors (Tansuwannarat et al., 2023). In short, by combining ML models with pharmacist-led intervention services, this study further improves the effectiveness of prescription optimization.
This study demonstrates the effectiveness of an ML-based pharmacist-led prescription intervention in optimizing prescriptions, improving appropriateness, reducing ADEs, shortening hospital stays, and lowering healthcare costs. By integrating advanced technologies with medication management expertise, this approach offers a promising strategy for improving patient outcomes and underscores the importance of continuous pharmacist-led innovation in medication safety.
However, because this study was conducted in a single tertiary hospital, its findings may have limited generalizability to other healthcare settings. Future research should explore the intervention’s applicability across diverse hospital environments and patient populations, further refine the ML models to improve predictive accuracy, identify additional features, and evaluate the intervention’s long-term impacts on clinical outcomes.
The raw data supporting the conclusions of this article will be made available by the authors, upon reasonable request. Requests to access the datasets should be directed to c2hhbmduYW5AdmlwLjE2My5jb20=.
The studies involving humans were approved by This study was approved by the Ethics Committee of the First Hospital of Shanxi Medical University (Ethics Number: 2021-K-K229). The studies were conducted in accordance with the local legislation and institutional requirements. Written informed consent for participation was not required from the participants or the participantsandapos; legal guardians/next of kin in accordance with the national legislation and institutional requirements.
XL: Methodology, Writing–original draft, Formal Analysis. XY: Formal Analysis, Methodology, Writing–original draft, Investigation. LZ: Formal Analysis, Methodology, Writing–review & editing. XZ: Data curation, Funding acquisition, Supervision, Writing–review & editing. NS: Data curation, Funding acquisition, Supervision, Investigation, Methodology, Project administration, Writing–original draft, Writing–review & editing.
The author(s) declare that financial support was received for the research and/or publication of this article. This study was funded by Research Project Supported by Shanxi Scholarship Council of China (No. 2024-146) and Shanxi Province High-Quality Development Research Special Project on the Big Health Industry (No. DJKZXKT2023012).
The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
The authors declare that no Generative AI was used in the creation of this manuscript.
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
The Supplementary Material for this article can be found online at: https://www.frontiersin.org/articles/10.3389/fphar.2025.1534552/full#supplementary-material
Abbasi, S., Rashid, S., and Khan, F. A. (2022). A retrospective analysis of peri-operative medication errors from a low-middle income country. Sci. Rep. 12, 12404. doi:10.1038/s41598-022-16479-7
Albassam, A., Almohammed, H., Alhujaili, M., Koshy, S., and Awad, A. (2020). Perspectives of primary care physicians and pharmacists on interprofessional collaboration in Kuwait: A quantitative study. PLoS One 15, e0236114. doi:10.1371/journal.pone.0236114
Alipour, F., Peiravian, F., and Mehralian, G. (2018). Perceptions, experiences and expectations of physicians regarding the role of pharmacists in low-income and middle-income countries: the case of Tehran hospital settings. BMJ Open 8, e019237. doi:10.1136/bmjopen-2017-019237
Al Meslamani, A. Z. (2023). Applications of AI in pharmacy practice: a look at hospital and community settings. J. Med. Econ. 26, 1081–1084. doi:10.1080/13696998.2023.2249758
Alotaibi, Y. K., and Federico, F. (2017). The impact of health information technology on patient safety. Saudi Med. J. 38, 1173–1180. doi:10.15537/smj.2017.12.20631
Alsabri, M., Eapen, D., Sabesan, V., Tarek Hassan, Z., Amin, M., Elshanbary, A. A., et al. (2024). Medication errors in pediatric emergency Departments: a systematic review and recommendations for enhancing medication safety. Pediatr. Emerg. Care 40, 58–67. doi:10.1097/PEC.0000000000003108
American Geriatrics Society, (2023). American Geriatrics Society 2023 updated AGS Beers Criteria® for potentially inappropriate medication use in older adults. J. Am. Geriatr. Soc. 71, 2052–2081. doi:10.1111/jgs.18372
Babel, A., Taneja, R., Mondello Malvestiti, F., Monaco, A., and Donde, S. (2021). Artificial intelligence solutions to increase medication adherence in patients with non-communicable diseases. Front. Digit. Health 3, 669869. doi:10.3389/fdgth.2021.669869
Bates, D. W., Levine, D., Syrowatka, A., Kuznetsova, M., Craig, K. J. T., Rui, A., et al. (2021). The potential of artificial intelligence to improve patient safety: a scoping review. NPJ Digit. Med. 4, 54. doi:10.1038/s41746-021-00423-6
Chalasani, S. H., Syed, J., Ramesh, M., Patil, V., and Pramod Kumar, T. M. (2023). Artificial intelligence in the field of pharmacy practice: a literature review. Explor Res. Clin. Soc. Pharm. 12, 100346. doi:10.1016/j.rcsop.2023.100346
Couronné, R., Probst, P., and Boulesteix, A. L. (2018). Random forest versus logistic regression: a large-scale benchmark experiment. BMC Bioinforma. 19, 270. doi:10.1186/s12859-018-2264-5
Cross, A. J., Elliott, R. A., Petrie, K., Kuruvilla, L., and George, J. (2020). Interventions for improving medication-taking ability and adherence in older adults prescribed multiple medications. Cochrane Database Syst. Rev. 5, Cd012419. doi:10.1002/14651858.CD012419.pub2
Dalton, K., and Byrne, S. (2017). Role of the pharmacist in reducing healthcare costs: current insights. Integr. Pharm. Res. Pract. 6, 37–46. doi:10.2147/IPRP.S108047
Dean, B., Schachter, M., Vincent, C., and Barber, N. (2002). Causes of prescribing errors in hospital inpatients: a prospective study. Lancet 359, 1373–1378. doi:10.1016/S0140-6736(02)08350-2
Delgado-Pérez, G., Dávila-Espinoza, C., and Beltran-Noblega, C. (2023). Impact of the role of the clinical pharmacist on the underreporting of adverse drug reactions at a Peruvian hospital. Hosp. Pharm. 58, 295–303. doi:10.1177/00185787221138006
Delong, E. R., Delong, D. M., and Clarke-Pearson, D. L. (1988). Comparing the areas under two or more correlated receiver operating characteristic curves: a nonparametric approach. Biometrics 44, 837–845. doi:10.2307/2531595
De Rijdt, T., Willems, L., and Simoens, S. (2008). Economic effects of clinical pharmacy interventions: a literature review. Am. J. Health Syst. Pharm. 65, 1161–1172. doi:10.2146/ajhp070506
Dowell, D., Ragan, K. R., Jones, C. M., Baldwin, G. T., and Chou, R. (2022). CDC clinical practice guideline for prescribing opioids for pain - United States, 2022. MMWR Recomm. Rep. 71, 1–95. doi:10.15585/mmwr.rr7103a1
Dsouza, V. S., Leyens, L., Kurian, J. R., Brand, A., and Brand, H. (2025). Artificial intelligence (AI) in pharmacovigilance: a systematic review on predicting adverse drug reactions (ADR) in hospitalized patients. Res. Soc. Adm. Pharm. doi:10.1016/j.sapharm.2025.02.008
Durand, M., Castelli, C., Roux-Marson, C., Kinowski, J. M., and Leguelinel-Blache, G. (2024). Evaluating the costs of adverse drug events in hospitalized patients: a systematic review. Health Econ. Rev. 14, 11. doi:10.1186/s13561-024-00481-y
Fitzhenry, F., Peterson, J. F., Arrieta, M., Waitman, L. R., Schildcrout, J. S., and Miller, R. A. (2007). Medication administration discrepancies persist despite electronic ordering. J. Am. Med. Inf. Assoc. 14, 756–764. doi:10.1197/jamia.M2359
Gillani, S. W., Gulam, S. M., Thomas, D., Gebreighziabher, F. B., Al-Salloum, J., Assadi, R. A., et al. (2021). Role and services of a pharmacist in the prevention of medication errors: a systematic review. Curr. Drug Saf. 16, 322–328. doi:10.2174/1574886315666201002124713
Gray, S. L., Perera, S., Soverns, T., and Hanlon, J. T. (2023). Systematic review and meta-analysis of interventions to reduce adverse drug reactions in older adults: an update. Drugs Aging 40, 965–979. doi:10.1007/s40266-023-01064-y
Hassan, A. M., Biaggi-Ondina, A., Rajesh, A., Asaad, M., Nelson, J. A., Coert, J. H., et al. (2023). Predicting patient-reported outcomes following surgery using machine learning. Am. Surg. 89, 31–35. doi:10.1177/00031348221109478
Heneka, N., Shaw, T., Rowett, D., Lapkin, S., and Phillips, J. L. (2018). Exploring factors contributing to medication errors with opioids in Australian specialist palliative care inpatient services: a multi-incident analysis. J. Palliat. Med. 21, 825–835. doi:10.1089/jpm.2017.0578
Hu, J., Xu, J., Li, M., Jiang, Z., Mao, J., Feng, L., et al. (2024). Identification and validation of an explainable prediction model of acute kidney injury with prognostic implications in critically ill children: a prospective multicenter cohort study. EClinicalMedicine 68, 102409. doi:10.1016/j.eclinm.2023.102409
Jaam, M., Naseralallah, L. M., Hussain, T. A., and Pawluk, S. A. (2021). Pharmacist-led educational interventions provided to healthcare providers to reduce medication errors: a systematic review and meta-analysis. PLoS One 16, e0253588. doi:10.1371/journal.pone.0253588
Jia, X., Zhang, W., Du, S., Wen, L., Li, H., Yin, Z., et al. (2021). What is the role of pharmacists in treating COVID-19 patients? The experiences and expectations of front line medical staff. Front. Public Health 9, 778863. doi:10.3389/fpubh.2021.778863
Johns, E., Alkanj, A., Beck, M., Dal Mas, L., Gourieux, B., Sauleau, E. A., et al. (2024). Using machine learning or deep learning models in a hospital setting to detect inappropriate prescriptions: a systematic review. Eur. J. Hosp. Pharm. 31, 289–294. doi:10.1136/ejhpharm-2023-003857
Jošt, M., Kerec Kos, M., Kos, M., and Knez, L. (2024). Effectiveness of pharmacist-led medication reconciliation on medication errors at hospital discharge and healthcare utilization in the next 30 days: a pragmatic clinical trial. Front. Pharmacol. 15, 1377781. doi:10.3389/fphar.2024.1377781
Khanna, N. N., Maindarkar, M. A., Viswanathan, V., Fernandes, J. F. E., Paul, S., Bhagawati, M., et al. (2022). Economics of artificial intelligence in healthcare: diagnosis vs. Treatment. Healthc. (Basel) 10, 2493. doi:10.3390/healthcare10122493
Kim, E., Worley, M. M., Yum, S., and Law, A. V. (2024). Pharmacist roles in the medication use process: qualitative analysis of stakeholder perceptions. J. Am. Pharm. Assoc. 64, 102186. doi:10.1016/j.japh.2024.102186
Kothari, D., Gupta, S., Sharma, C., and Kothari, S. (2010). Medication error in anaesthesia and critical care: a cause for concern. Indian J. Anaesth. 54, 187–192. doi:10.4103/0019-5049.65351
Langlieb, M. E., Sharma, P., Hocevar, M., and Nanji, K. C. (2023). The additional cost of perioperative medication errors. J. Patient Saf. 19, 375–378. doi:10.1097/PTS.0000000000001136
Li, W., Shang, N., Zhang, Z., Li, Y., Li, X., and Zheng, X. (2024). Development and validation of a machine learning model to improve precision prediction for irrational prescriptions in orthopedic perioperative patients. Expert Opin. Drug Saf. 24, 99–109. doi:10.1080/14740338.2024.2348569
Lisby, M., Nielsen, L. P., Brock, B., and Mainz, J. (2010). How are medication errors defined? A systematic literature review of definitions and characteristics. Int. J. Qual. Health Care 22, 507–518. doi:10.1093/intqhc/mzq059
Mahomedradja, R. F., Schinkel, M., Sigaloff, K. C. E., Reumerman, M. O., Otten, R. H. J., Tichelaar, J., et al. (2023). Factors influencing in-hospital prescribing errors: a systematic review. Br. J. Clin. Pharmacol. 89, 1724–1735. doi:10.1111/bcp.15694
Mandrekar, J. N. (2010). Receiver operating characteristic curve in diagnostic test assessment. J. Thorac. Oncol. 5, 1315–1316. doi:10.1097/JTO.0b013e3181ec173d
Marchi, M., Galli, G., Fiore, G., Mackinnon, A., Mattei, G., Starace, F., et al. (2022). Machine-learning for prescription patterns: random forest in the prediction of dose and number of antipsychotics prescribed to people with schizophrenia. Clin. Psychopharmacol. Neurosci. 20, 450–461. doi:10.9758/cpn.2022.20.3.450
Mchugh, M. L. (2012). Interrater reliability: the kappa statistic. Biochem. Med. Zagreb. 22, 276–282. doi:10.11613/bm.2012.031
Moon, J. Y., Lee, Y., Han, J. M., Lee, M. H., Yee, J., Song, M. K., et al. (2020). Effects of pharmacist interventions on reducing prescribing errors of investigational drugs in oncology clinical trials. J. Oncol. Pharm. Pract. 26, 29–35. doi:10.1177/1078155219834723
Mostafa, L. S., Sabri, N. A., El-Anwar, A. M., and Shaheen, S. M. (2020). Evaluation of pharmacist-led educational interventions to reduce medication errors in emergency hospitals: a new insight into patient care. J. Public Health (Oxf) 42, 169–174. doi:10.1093/pubmed/fdy216
Nanji, K. C., Patel, A., Shaikh, S., Seger, D. L., and Bates, D. W. (2016). Evaluation of perioperative medication errors and adverse drug events. Anesthesiology 124, 25–34. doi:10.1097/ALN.0000000000000904
Newby, D. A., Stokes, B., and Smith, A. J. (2019). A pilot study of a pharmacist-led prescribing program for final-year medical students. BMC Med. Educ. 19, 54. doi:10.1186/s12909-019-1486-1
Nguyen, P. M., Nguyen, K. T., Pham, S. T., Thanh Le, V. T., Thi Le, T. C., Diep, H. G., et al. (2023). Pharmacist-led interventions to reduce drug-related problems in prescribing for pediatric outpatients in a developing country: a randomized controlled trial. J. Pediatr. Pharmacol. Ther. 28, 212–221. doi:10.5863/1551-6776-28.3.212
O'mahony, D., O'sullivan, D., Byrne, S., O'connor, M. N., Ryan, C., and Gallagher, P. (2015). STOPP/START criteria for potentially inappropriate prescribing in older people: version 2. Age Ageing 44, 213–218. doi:10.1093/ageing/afu145
Pazan, F., and Wehling, M. (2021). Polypharmacy in older adults: a narrative review of definitions, epidemiology and consequences. Eur. Geriatr. Med. 12, 443–452. doi:10.1007/s41999-021-00479-3
Raccah, B. H., Erlichman, Y., Pollak, A., Matok, I., and Muszkat, M. (2021). Prescribing errors with direct oral anticoagulants and their impact on the risk of bleeding in patients with atrial fibrillation. J. Cardiovasc Pharmacol. Ther. 26, 601–610. doi:10.1177/10742484211019657
Rosen, M. A., Diazgranados, D., Dietz, A. S., Benishek, L. E., Thompson, D., Pronovost, P. J., et al. (2018). Teamwork in healthcare: key discoveries enabling safer, high-quality care. Am. Psychol. 73, 433–450. doi:10.1037/amp0000298
Sacks, G. S., Rough, S., and Kudsk, K. A. (2009). Frequency and severity of harm of medication errors related to the parenteral nutrition process in a large university teaching hospital. Pharmacotherapy 29, 966–974. doi:10.1592/phco.29.8.966
Saif, S., Bui, T. T. T., Srivastava, G., and Quintana, Y. (2024). Evaluation of the design and structure of electronic medication labels to improve patient health knowledge and safety: a systematic review. Syst. Rev. 13, 12. doi:10.1186/s13643-023-02413-z
Skou, S. T., Mair, F. S., Fortin, M., Guthrie, B., Nunes, B. P., Miranda, J. J., et al. (2022). Multimorbidity. Nat. Rev. Dis. Prim. 8, 48. doi:10.1038/s41572-022-00376-4
Tan, K. R., Seng, J. J. B., Kwan, Y. H., Chen, Y. J., Zainudin, S. B., Loh, D. H. F., et al. (2023). Evaluation of machine learning methods developed for prediction of diabetes complications: a systematic review. J. Diabetes Sci. Technol. 17, 474–489. doi:10.1177/19322968211056917
Tansuwannarat, P., Vichiensanth, P., Sivarak, O., Tongpoo, A., Promrungsri, P., Sriapha, C., et al. (2023). A 10-year retrospective analysis of medication errors among adult patients: characteristics and outcomes. Pharm. (Basel) 11, 138. doi:10.3390/pharmacy11050138
Tonelli, M., Wiebe, N., Manns, B. J., Klarenbach, S. W., James, M. T., Ravani, P., et al. (2018). Comparison of the complexity of patients seen by different medical subspecialists in a universal health care system. JAMA Netw. Open 1, e184852. doi:10.1001/jamanetworkopen.2018.4852
Vora, L. K., Gholap, A. D., Jetha, K., Thakur, R. R. S., Solanki, H. K., and Chavda, V. P. (2023). Artificial intelligence in pharmaceutical technology and drug delivery design. Pharmaceutics 15, 1916. doi:10.3390/pharmaceutics15071916
Waszyk-Nowaczyk, M., Guzenda, W., Kamasa, K., Pawlak, K., Bałtruszewicz, N., Artyszuk, K., et al. (2021). Cooperation between pharmacists and physicians - whether it was before and is it still ongoing during the pandemic? J. Multidiscip. Healthc. 14, 2101–2110. doi:10.2147/JMDH.S318480
Xie, J., Huang, X., Gao, M., Wei, L., Wang, R., Chen, J., et al. (2023). Surgical pharmacy for optimizing medication therapy management services within enhanced recovery after surgery (ERAS(®)) programs. J. Clin. Med. 12, 631. doi:10.3390/jcm12020631
Keywords: medication errors, machine learning, pharmacists, patient safety, surgical procedures
Citation: Li X, Yue X, Zhang L, Zheng X and Shang N (2025) Pharmacist-led surgical medicines prescription optimization and prediction service improves patient outcomes - a machine learning based study. Front. Pharmacol. 16:1534552. doi: 10.3389/fphar.2025.1534552
Received: 26 November 2024; Accepted: 25 February 2025;
Published: 14 March 2025.
Edited by:
Hao Li, Shanghai Jiao Tong University, ChinaReviewed by:
Xingwei Wu, University of Electronic Science and Technology of China, ChinaCopyright © 2025 Li, Yue, Zhang, Zheng and Shang. This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) and the copyright owner(s) are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.
*Correspondence: Nan Shang, c2hhbmduYW5AdmlwLjE2My5jb20=
†ORCID: Nan Shang, orcid.org/0000-0003-0314-2859
Disclaimer: All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.
Research integrity at Frontiers
Learn more about the work of our research integrity team to safeguard the quality of each article we publish.