Application of machine learning to identify risk factors for outpatient opioid prescriptions following spine surgery Authors: Alexander Bouterse, Andrew Cabrera, Adam Jameel, David Chung, Olumide Danisa Published: 2024 ABSTRACT IntroductionSpine surgery is a common source of narcotic prescriptions and carries potential for long-term opioid dependence. As prescription opioids play a role in nearly 25 % of all opioid overdose deaths in the United States, mitigating risk for prolonged postoperative opioid utilization is crucial for spine surgeons.PurposeThe aim of this study was to employ six ML algorithms to identify clinical variables predictive of increased opioid utilization across spinal surgeries, including anterior cervical discectomy and fusion (ACDF), posterior thoracolumbar fusion (PTLF), and lumbar laminectomy.MethodsA query of the author’s institutional database identified adult patients undergoing ACDF, PTLF, or lumbar laminectomy between 2013 and 2022. Six supervised ML algorithms, including Random Forest, Extreme Gradient Boosting, and LightGBM, were tasked with predicting additional opioid prescriptions at a patient’s first postoperative visit based on set variables. Predictive variables were evaluated for missing data and optimized. Model performance was assessed with common analytical metrics, and variable importance was quantified using permutation feature importance. Statistical analysis utilized Pearson’s Chi-square tests for categorical and independent sample t-tests for numerical differences.ResultsThe author’s query identified 3202 patients matching selection criteria, with 841, 1,409, and 952 receiving ACDF, PTLF, and lumbar laminectomy, respectively. The ML algorithms produced an aggregate AUC of 0.743, performing most effectively for lumbar laminectomy. Random Forest and LightGBM classifiers were selected for generation of permutation feature importance (PFI) values. Hospital length of stay was the only highly featured variable carrying statistical significance across all procedures.ConclusionNotable risk factors for increased postoperative opioid use were identified, including shorter hospital stays, younger age, and prolonged operative time. These findings can help identify patients at increased risk and guide strategies to mitigate opioid dependence. 1. Introduction Spine surgery is a notable source of narcotic prescriptions and, in some cases, long-term opioid dependence. Specifically, estimates regarding the prevalence of chronic opioid use following spine surgery have ranged from 30 to 60 %, indicating a troubling correlation between postoperative pain management and the severity of the ongoing opioid epidemic [1]. As prescription opioids play a causative role in nearly 25 % of all opioid overdose deaths in the United States, mitigating risk for prolonged postoperative opioid use must be a principal focus for spine surgeons [2]. Prior investigations into the risk factors for chronic postoperative opioid use have identified a number of predictive variables that serve to guide pain management in this cohort of patients. Notably, clinical characteristics including female sex, preoperative opiate use, age, and the presence of psychiatric comorbidities have been found to contribute significantly to increased quantity and duration of opioid prescriptions in the postoperative period [3]. However the degree of invasive dissection and surgical instrumentation varies widely across the diverse catalog of spinal procedures, thus presenting a challenge to providers seeking to quantify the likelihood of this outcome postoperatively. Thus, investigation of risk factors across a number of spinal surgeries may serve to further delineate the characteristics that drive sustained postoperative opioid dependence. The widespread application of artificial intelligence into medical research invites a deeper exploration of this complex clinical dilemma. Of significance, the use of machine learning (ML) modalities has recently been utilized to effectively isolate and quantify the risk factors associated with an increased duration of post-procedural opioid use [4–7]. Given the insight provided by these studies, further application of ML modalities may be warranted to predict procedural risk factors for increased postoperative opioid prescriptions. As such, the aim of this study was to employ six ML algorithms to identify clinical variables predictive of increased opioid utilization across common spinal surgeries, including anterior cervical discectomy and fusion (ACDF), posterior thoracolumbar fusion (PTLF), and lumbar laminectomy. 2. Methods After receiving a notice of exemption from our institution’s review board (IRB #5240055), Tableau Desktop (Version 2022.4.7, Tableau Software, 2023) was used to query the author’s institutional database in order to identify adult patients undergoing ACDF, PTLF, or lumbar laminectomy between 2013 and 2022. These procedures were selected based upon their relatively high prevalence within our dataset as well as the differences in procedural complexity, instrumentation, and invasive dissection inherent to each. Within this population, International Classification of Disease (ICD) diagnostic codes were utilized to identify comorbid medical conditions and substance use disorders such as a history of opiate abuse. Our primary outcome, postoperative outpatient opioid prescriptions, was defined as any documented opioid prescription occurring at an outpatient visit within two weeks of the patient’s index surgery. Six supervised ML classification algorithms were constructed in the python programming language using the SciKit-Learn library and the XGboost, LightGBM, and CatBoost packages [8–12]. These algorithms included Random Forest Classifier (RF), Extreme Gradient Boosting Classifier (XGB), Light Gradient-Boosting Machine (LightGBM), Categorical Boosting (CatBoost), Multilayer Perceptron Classifier (MLP), and a logistic regression model (LogReg). These algorithms were tasked with predicting additional opioid prescriptions at a patients first postoperative visit based on a given set of patient variables, including demographics, comorbidities, and preoperative lab values (Tables 1–3). Prior to ML analysis, the predictive variables were systematically evaluated for missing data. To address missing data within each variable, the missForest package in the R statistical programming language was applied for imputation of the missing data [13,14]. Following data imputation, predictive variables underwent preprocessing using SciKit-Learn’s Robust and Min–Max scalers for continuous variables (eg, age, BMI, lab values) and SciKit-Learn’s OneHotEncoder for categorical variables (eg, race, insurance status) [9]. Our target variable, additional opioid prescriptions at a patient’s first postoperative visit, was encoded as a binary variable. An 80:20 train test split using Scikit-Learn’s train_test_split method was performed in which 80 % of our population data was randomly divided into our training dataset and the remaining 20 % set aside for the final testing of ML model performance on unseen data [9,15]. Training of each algorithm involved utilization of the Tree-Structured Parzen Estimator algorithm for Bayesian optimization from the Opunta library along with a stratified 5-fold cross validation to determine optimal hyperparameters on the training data and ensure model generalizability [16]. Once the appropriate hyperparameters were determined, the final models were subsequently evaluated using the set aside testing data from the train test split to determine the model’s performance. The performance of the five ML models were then evaluated by a series of commonly used metrics, including classification accuracy, sensitivity, specificity, Positive Predictive Value (PPV), Negative Predictive Value (NPV), F1 score, Area Under Receiver Operating Characteristics Curve (AUROC), and Area Under Precision-Recall Curve (AUPRC) [17–19]. The Matplotlib library in python was used for Graphical visualization of the ROCs and PRCs produced by the six models [20]. Importance of each variable was quantified using permutation feature importance (PFI) through utilization of SciKit-Learn’s permutation importance feature method [14,21]. Generation of PFI values is performed by measurement of model performance when a single variable is removed, disrupting the relationship between the variable and the predicted outcome. Thus, variables attributed with greater PFI values are deemed more important as predictive performance of that model decreases when that variable is removed [21,22]. As our study utilized multiple ML algorithms, the PFIs from the top performing model from each procedure were chosen for further statistical analysis. Statistical analysis was performed using SPSS version 28 (IBM Corporation, 2021, Armonk, NY, USA) with statistical significance defined as of p < 0.05. Differences between categorical variables were assessed using the Person’s Chi-square test, while numerical differences were assessed using independent sample t-test. Categorical variables are presented as frequencies in percentages and continuous variables are presented as means and standard deviations (SD). 3. Results Query of the author’s institutional database identified 3.202 patients matching inclusion criteria that underwent spinal surgery between 2013 and 2022. Among this cohort 841, 1,409, and 952 patients received ACDF, PTLF, and lumbar laminectomy, respectively. In total, 59.0 % of patients within this population were prescribed additional postoperative opioids at their first outpatient appointment, with the highest rate of prescriptions observed among patients undergoing ACDF (71.1 %), followed by PTLF (55.8 %), and lumbar laminectomy (53.2 %). An average of 997.41 MME’s were prescribed in the outpatient setting, with patients undergoing PTLF requiring a comparatively higher quantity of opioids to manage postoperative pain. A full description of the clinical characteristics and outcomes observed by each cohort of patients is provided in Tables 1–3. In predicting postoperative opioid prescriptions, the ML classification algorithms produced an aggregate AUC value of 0.743, performing most effectively when applied to the cohort of patients undergoing lumbar laminectomy. For the generation of variable PFI values, Random Forest and Light GBM algorithms were selected based on their comparatively high level of performance in predicting postoperative opioid prescriptions. Further characterization of the performance of each algorithm employed in our analysis is provided in Tables 4–6 and Figs. 1–6. Application of the RF classifier to patients undergoing ACDF identified hospital length of stay (PFI = 0.2174; p < 0.001), preoperative white blood cell count (PFI = 0.0151; p = 0.006), age (PFI = 0.0118; p = 0.022), operative time (PFI = 0.0084; p = 0.010) preoperative hemoglobin (PFI = 0.0057; p = 0.009), smoking history (PFI = 0.0045; p = 0.029), and preoperative creatinine (PFI = 0.0022; p < 0.001) as statistically significant predictors of additional opioid prescriptions postoperatively. Additional predictive variables identified within this cohort are described in Table 7. Through utilization of the Light GBM classifier to predict opioid prescriptions in patients receiving lumbar laminectomy, length of stay (PFI = 0.1217; p < 0.001), preoperative platelet levels (PFI = 0.0343; p = 0.043), chronic kidney disease (PFI = 0.0058; p < 0.001), and private insurance coverage (PFI = 0.0056; p = 0.019) were identified as statistically significant predictive variables. Additional predictive variables identified in this group are listed in Table 8. Finally, in utilizing the RF classifier to predict postoperative opioid prescriptions following PTLF identified the following variables as carrying both statistical significance and notable predictive importance: length of stay (PFI = 0.1178; p < 0.001), age (PFI = 0.0300; p < 0.001), operative time (PFI = 0.0128; p < 0.001), preoperative glucose (PFI = 0.0069; p = 0.048), preoperative creatinine (PFI = 0.0044; p = 0.026), APR Risk of Mortality Classification ≥3 (PFI = 0.0012; p < 0.001), and marital status (PFI = 0.0005; p = 0.019). Further description of the predictive variables identified in this group is provided in Table 9. 4. Discussion As the prevalence of opioid use disorders continues to rise throughout the United States, orthopedic providers must become increasingly aware of clinical risk factors that drive prolonged use of prescription opioids among surgical populations [23]. This study applies ML-based predictive analysis in order to isolate procedure-specific variables associated with additional opioid prescriptions at initial postoperative visits for patients undergoing spine surgery. In identifying and quantifying the contributions of relevant risk factors, providers may better anticipate the likelihood of prolonged opioid requirements and implement strategies to mitigate these factors among high-risk patient populations. This study serves to highlight several patterns of opioid prescriptions among our selected surgical populations. Most notably, across all procedural groups, a shorter duration of hospitalization was associated with a statistically significant increase in outpatient opioid prescriptions. While the constellation of clinical factors contributing to this phenomenon is not clearly defined, it is possible that this finding reflects a pattern of deferring postoperative pain management regimens to the outpatient setting following routine spine procedures. For example, as the safety of performing minor spine surgeries such as ACDF within an ambulatory setting has become increasingly recognized, many providers have transitioned to same-day discharges, thus eliminating the previously requisite period of inpatient postoperative pain assessment and shifting this requirement to the first postoperative visit [24,25]. While this approach has proven beneficial from both a clinical and financial perspective, this study illustrates that, in some scenarios, it may come at the cost of increasing outpatient opioid requirements. While reports on this phenomenon are inconsistent, it is certainly not without risks as outpatient opioid prescriptions have been associated with increased healthcare expenditures, larger prescription quantities, and a heightened risk for future substance use disorders and opioid overdose [26–28]. Furthermore, as persistent postoperative opioid use is a common and often unrecognized issue, deferring this requirement to the outpatient setting may exacerbate this phenomenon amongst same-day surgery candidates [28–30]. As such, it is important for providers to recognize the trend toward shorter lengths of stay as a potential nidus for increased opioid prescriptions as sameday surgery continues to become popular for low-risk spine surgeries. Similarly, among several surgical groups examined in our analysis, younger patients and those with prolonged operative times were more frequently the recipients of additional opioids at their first postoperative visit. Such factors have been well-documented within the current literature as notable risk factors, with authors positing that an increased prevalence of substance use disorders among younger patients may drive increasing opioid requirements, while the increased procedural complexity and extent of anatomic dissection associated with longer procedures may worsen postoperative pain [30–32]. This study serves to reinforce these variables as relevant risk factors following spine surgery and emphasizes the importance of recognizing the risk of increased or prolonged opioid use among patients with these characteristics. With regard to procedure-specific considerations, marriage and private insurance coverage were among those identified as risk factors for PTLF and laminectomy, respectively. Though each carried relatively low feature importance within our study and ultimately may lack clinical significance, it is worth noting that these variables have been previously documented as risk factors for increased or prolonged opioid prescriptions. Specifically, in a review of opioid prescribing patterns following traumatic injuries among military members, Chaudhary et al. found marriage to carry a consistent association with an increased likelihood of opioid prescriptions upon hospital discharge [32]. Similarly, upon review of prescription patterns amongst privately insured and Medicare-eligible patients, Mikosz et al. noted both a longer duration and increased quantity of opioid prescriptions in privately insured patients following lumbar decompression and spinal fusion procedures [33]. Though the identification of these same factors within our study may serve to add credence to their clinical relevance, the consistency of these findings across the literature is not well-supported and may simply be a byproduct of the specific populations examined by these studies. As such, further research is required to better determine the clinical importance of these variables and what causal relationship they may share with the patterns of opioid prescription observed in our study. In line with other studies that have examined the topic of postoperative opioid prescriptions following spine surgery, our study effectively applied ML algorithms in order to identify risk factors for outpatient prescriptions following a subset of minor procedures. In an examination of prescription patterns following ACDF, Karhade et al. applied a set of ML classifiers to predict sustained postoperative opioid use, achieving AUC values ranging from 0.63 to 0.80 [4]. Similarly, Chen et al. sought to apply this same methodology to a cohort of patients undergoing surgery for lumbar disc herniations in Taiwan and subsequently yielded AUC values between 0.66 and 0.76 [7]. Our study generated comparable predictive efficacy, producing an average AUC value of 0.743 across all utilized algorithms. As such, our examination of this topic provides an equivalent degree of algorithmic performance and serves to elucidate a broadened profile of risk factors for postoperative opioid use. The results of our analysis must be viewed in light of several key limitations. In particular, through our use of a deidentified institutional database, our results are limited in their scope, comprising only the outcomes of a single patient population. Furthermore, the use of this data source limits our access to variables that may be relevant to a patient’s perioperative course, as the database may be unable to capture these items or may feature a high volume of missing data points. For example, the number of vertebral segments spanned by each procedure, although potentially influential to postoperative opioid requirements, was not readily available within our selected database. Similarly, our insight into outpatient opioid prescriptions was limited to those occurring within two weeks of a patient’s index procedure as this outcome was inconsistently supplied by our data source outside this time range. Additionally, as with all large clinical datasets, the data utilized for our analysis may be confounded by errors that occur during the process of encoding clinical encounters. Finally, it should be qualified that, although a widely utilized method within ML analyses, PFI provides an indirect measure of the relative importance of the perioperative variables contained within our dataset [22,34]. Utilization of this method may predispose our analysis to bias as the permutation of highly correlated variables may inadvertently alter the predictive power of correlated features, thus leading to inaccurate assignment of variable importance [34,35]. As such, though our analysis may serve to highlight proposed risk factors, its findings should be used to supplement clinical expertise rather than to guide perioperative decision-making. 5. Conclusions This study presents the employment of six ML algorithms to predict postoperative opioid prescriptions within the outpatient setting following three common spine surgeries, ACDF, PTLF, and lumbar laminectomy. Through the use of this methodology, notable risk factors for an increase in postoperative opioid requirements were identified, including a shorter duration of hospitalization, younger age, and prolonged operative time. These findings may serve to identify patients at increased risk for persistent opioid use, and, in turn, allow providers to implement strategies to mitigate this risk within the perioperative period.