IMPORTANCE The recent parenteral opioid shortage (POS) has potential implications for cancer-related pain management in hospitalized patients. OBJECTIVE This study compared changes in opioid prescriptions and clinically improved pain (CIP) among patients treated by an inpatient palliative care (PC) team before and after our institution first reported the POS. DESIGN, SETTING, AND PARTICIPANTS A cohort study of 386 eligible patients with cancer treated at a comprehensive cancer center 1 month before and after the announcement of the POS. We reviewed data from electronic health records, including patient demographics, opioid type, route of administration, and dose. Board-certified palliative care specialists assessed CIP at follow-up day 1. EXPOSURES The announcement of the POS by the institution's pharmacy and therapeutics committee on February 8, 2018. MAIN OUTCOMES AND MEASURES The primary outcome was to measure the change in opioid prescription patterns of physicians, and the secondary outcome was to measure the proportion of patients who achieved CIP before and after announcement of the POS. RESULTS Of 386 eligible patients, 196 were men (51%), 270 were white (70%), and the median age was 58 years (interquartile range, 46-67 years). Parenteral opioids were prescribed less frequently by the referring oncology teams after the POS (56 of 314 [18%]) vs before the POS (109 of 311 [35%]) (P < .001). The PC team also prescribed fewer parenteral opioids after the POS (96 of 336 [29%]) vs before the POS (159 of 338 [47%]) (P < .001). After the POS (vs before the POS), significantly fewer patients achieved CIP on follow-up day 1 (119 [62%] vs 144 [75%] of 193; P = .01). Multivariate analysis showed that before the POS, patients had an 89% higher chance of achieving CIP on follow-up day 1 (odds ratio, 1.89; 95% CI, 1.22-2.94; P = .005). CONCLUSIONS AND RELEVANCE There was a significant change in opioid prescription patterns associated with the POS. Furthermore, after the POS, fewer patients achieved CIP. These factors have potential implications for patient satisfaction and hospital length of stay.