Key Points Question Was the implementation of mandatory consultation with a prescription drug monitoring program (PDMP) that integrates electronic health record (EHR) alerts associated with changes in the postoperative quantity of opioid medications prescribed at discharge after general, obstetric and gynecologic, and orthopedic surgery? Findings In this cross-sectional study of 93 760 adult patients within a large health care system who received a postoperative prescription for an opioid medication, implementation of mandatory PDMP consultation with EHR-based alerts was associated with significant decreases in postoperative opioid prescription quantities during the quarter in which the mandate was implemented after accounting for preimplementation prescribing patterns. Meaning This study found that implementation of legislation mandating PDMP consultation and the use of EHR alerts may be associated with changes in postoperative opioid prescribing behavior and decreases in the excess number of opioid tablets in circulation., Importance Legislation mandating consultation with a prescription drug monitoring program (PDMP) was implemented in California on October 2, 2018. This mandate requires PDMP consultation before prescribing a controlled substance and integrates electronic health record (EHR)–based alerts; prescribers are exempt from the mandate if they prescribe no more than a 5-day postoperative opioid supply. Although previous studies have examined the consequences of mandated PDMP consultation, few have specifically analyzed changes in postoperative opioid prescribing after mandate implementation. Objective To examine whether the implementation of mandatory PDMP consultation with concurrent EHR-based alerts was associated with changes in postoperative opioid quantities prescribed at discharge. Design, Setting, and Participants This cross-sectional study performed an interrupted time series analysis of opioid prescribing patterns within a large health care system (Sutter Health) in northern California between January 1, 2015, and February 1, 2020. A total of 93 760 adult patients who received an opioid prescription at discharge after undergoing general, obstetric and gynecologic (obstetric/gynecologic), or orthopedic surgery were included. Exposures Mandatory PDMP consultation before opioid prescribing, with concurrent integration of an EHR alert. Prescribers are exempt from this mandate if prescribing no more than a 5-day opioid supply postoperatively. Main Outcomes and Measures The primary outcome was the total quantity of opioid medications (morphine milligram equivalents [MMEs] and number of opioid tablets) prescribed at discharge before and after implementation of the PDMP mandate, with separate analyses by surgical specialty (general, obstetric/gynecologic, and orthopedic) and most common surgical procedure within each specialty (laparoscopic cholecystectomy, cesarean delivery, and knee arthroscopy). The secondary outcome was the proportion of prescriptions with a duration of longer than 5 days. Results Of 93 760 patients (mean [SD] age, 46.7 [17.6] years; 67.9% female) who received an opioid prescription at discharge, 65 911 received prescriptions before PDMP mandate implementation, and 27 849 received prescriptions after implementation. Most patients received general or obstetric/gynecologic surgery (48.6% and 30.1%, respectively), did not have diabetes (90.3%), and had never smoked (66.0%). Before the PDMP mandate was implemented, a decreasing pattern in opioid prescribing quantities was already occurring. During the quarter of implementation, total MMEs prescribed at discharge further decreased for all 3 surgical specialties (eg, medians for general surgery: β = −10.00 [95% CI, −19.52 to −0.48]; obstetric/gynecologic surgery: β = −18.65 [95% CI, −22.00 to −15.30]; and orthopedic surgery: β = −30.59 [95% CI, −40.19 to −21.00]) after adjusting for the preimplementation prescribing pattern. The total number of tablets prescribed also decreased across specialties (eg, medians for general surgery: β = −3.02 [95% CI, −3.47 to −2.57]; obstetric/gynecologic surgery: β = −4.86 [95% CI, −5.38 to −4.34]; and orthopedic surgery: β = −4.06 [95% CI, −5.07 to −3.04]) compared with the quarters before implementation. These reductions were not consistent across the most common surgical procedures. For cesarean delivery, the median number of tablets prescribed decreased during the quarter of implementation (β = −10.00; 95% CI, −10.10 to −9.90), but median MMEs did not (β = 0; 95% CI, −9.97 to 9.97), whereas decreases were observed in both median MMEs and number of tablets prescribed (MMEs: β = −33.33 [95% CI, −38.48 to −28.19]; tablets: β = −10.00 [95% CI, −11.17 to −8.82]) for laparoscopic cholecystectomy. For knee arthroscopy, no decreases were found in either median MMEs or number of tablets prescribed (MMEs: β = 10.00 [95% CI, −22.33 to 42.33; tablets: β = 0.83; 95% CI, −3.39 to 5.05). The proportion of prescriptions written for longer than 5 days also decreased significantly during the quarter of implementation across all 3 surgical specialties. Conclusions and Relevance In this cross-sectional study, the implementation of mandatory PDMP consultation with a concurrent EHR-based alert was associated with an immediate decrease in opioid prescribing across the 3 surgical specialties. These findings might be explained by prescribers’ attempts to meet the mandate exemption and bypass PDMP consultation rather than the PDMP consultation itself. Although policies coupled with EHR alerts may be associated with changes in postoperative opioid prescribing behavior, they need to be well designed to optimize evidence-based opioid prescribing., This cross-sectional study examines whether the implementation of mandated consultation with a prescription drug monitoring program was associated with changes in the quantity of postoperative opioid medications prescribed at discharge among adult patients in a health care system in California.