Any person who has been committed is entitled to a writ of habeas corpus, upon a proper application made by the State Department of State Hospitals or the State Department of Developmental Services, by that person, or by a relative or friend in his or her behalf to the judge of the superior court of the county in which the hospital is located, or if the person has been found incompetent to stand trial and has been committed pursuant to Chapter 6 (commencing with Section 1367) of Title 10 of Part 2 of the Penal Code, judicial review shall be in the superior court for the county that determined the question of the mental competence of the person. All documents requested by the court in the county of confinement shall be forwarded from the county of commitment to the court. Upon the return of the writ, the truth of the allegations under which he or she was committed shall be inquired into and determined. The medical history of the person as it appears in the clinical records shall be given in evidence, and the superintendent in charge of the state hospital wherein the person is held in custody and any other person who has knowledge of the facts shall be sworn and shall testify relative to the mental condition of the person.
Ca. Welf. and Inst. Code § 7250