Cal. Bus. & Prof. Code § 4068
(a) Notwithstanding any provision of this chapter, except as provided in subdivision (b), a prescriber may dispense a dangerous drug, including a controlled substance, to an emergency room patient if all of the following apply:
(b) Notwithstanding any provision of this chapter, including subdivision (a), a prescriber may dispense an unused portion of a dangerous drug acquired by the hospital pharmacy to an emergency room patient upon discharge under all of the following conditions: