Any person with mental illness or serious emotional disturbance in a public or private residential facility for persons with mental illness or serious emotional disturbance is entitled to file for a writ of habeas corpus upon petition by the person with mental illness or serious emotional disturbance or a friend to any court generally empowered to issue the writ of habeas corpus in the county in which the person with mental illness or serious emotional disturbance is detained.
T.C.A. § 33-3-801