(a) Subject to the limitations in this section, a petition for the release of an individual who is held under this title from the facility or a Veterans’ Administration hospital may be filed, at any time by:
(1) The individual; or
(2) Any person who has a legitimate interest in the welfare of the individual.
(b) The petition shall be filed in an equity court in the county where the individual resides or resided at the time of the admission or where the facility is located.
(c) (1) If the individual is in a public facility, the Administration shall be the respondent.
(2) If the individual is in a private facility or a Veterans’ Administration hospital, it shall be the respondent.
(d) The petition shall be in the form and contain the information the Maryland Rules require.
(e) If the petitioner requests trial by jury, the trial shall be held with a jury as in a civil action at law.
(f) The trier of fact shall determine:
(1) Whether the individual has a mental disorder; and
(2) If so, whether the individual needs inpatient medical care or treatment for the protection of the individual or another.
(g) (1) If the trier of fact finds that the individual has a mental disorder and needs inpatient medical care or treatment, the court shall remand the individual to the custody of the facility or Veterans’ Administration hospital.
(2) If the trier of fact finds that the individual does not have a mental disorder or has a mental disorder, but does not need inpatient medical care or treatment, the individual shall be released from the facility or Veterans’ Administration hospital.
(h) Any party may appeal from a decision on the petition as in any other civil case.
(i) Appropriate records of the proceeding under this section shall be made a permanent part of the individual’s record.
(j) (1) After a determination on the merits of a petition filed under this section, a court may not hear a later petition for the individual within 1 year after that determination, unless the petition is accompanied by a valid affidavit that the court, after review of the petition and affidavit, determines to show an improvement in the mental condition of the individual after the determination.
(2) An affidavit is not valid if executed by an individual under care or treatment in a facility or Veterans’ Administration hospital.
(3) If the matter is reopened, the petition shall be heard as provided in this section.
(4) If the affidavit does not show improvement in the individual’s mental condition, the petition shall be dismissed.