(a) Any individual who has been admitted to a facility or Veterans’ Administration hospital or any person on behalf of the individual may apply at any time to a court of competent jurisdiction for a writ of habeas corpus to determine the cause and the legality of the detention.
(b) The Director, in the name of the Administration, may make an application for a writ of habeas corpus to determine whether a facility properly admitted or properly holds an individual. The State’s Attorney for the county where the facility is located or the individual is a resident, on behalf of the Administration, shall file the application.