Cal. Penal Code § 4029
(e) Whenever within any county adult detention facility or part of any county detention facility used for the confinement of adults, not including any city jail, an inpatient psychiatric facility designated by the county mental health director to treat patients under Division 5 (commencing with Section 5000) and Division 6 (commencing with Section 6000) of the Welfare and Institutions Code, is provided for prisoners of one sex who may not depart from the detention facility for treatment elsewhere, and where the proportion of prisoners of the opposite sex requiring the same type of treatment is so small that the cost of providing a separate program of equal quality would not be justified in relation to the reduction in the level of another program, service, or privilege that would result from the diversion of funds for such purpose, the above designated mental health treatment program may treat prisoners of both sexes if each of the following conditions is met: