The purpose of this randomized controlled trial is to determine whether the quantity of opioid pills prescribed at discharge is associated with the number of opioid pills consumed or unused by patients after primary hip and knee arthroplasty within 30 days after discharge.