(1)(a) At any time after exhausting all administrative remedies, a person held in a secure facility under this part may file a petition for habeas corpus in the circuit court for the county in which the facility is located alleging that:
1. The person’s conditions of confinement violate a statutory right under state law or a constitutional right under the State Constitution or the United States Constitution; or
2. The facility in which the person is confined is not an appropriate secure facility, as that term is used in s. 394.915.
(b) Upon filing a legally sufficient petition stating a prima facie case under paragraph (a), the court may direct the Department of Children and Family Services to file a response. If necessary, the court may conduct an evidentiary proceeding and issue an order to correct a violation of state or federal rights found to exist by the court. A final order entered under this section may be appealed to the district court of appeal. A nonfinal order may be appealed to the extent provided by the Florida Rules of Appellate Procedure. An appeal by the department shall stay the trial court’s order until disposition of the appeal.
(2) Any claim referred to in subsection (1) may be asserted only as provided in this section. No claim referred to in subsection (1) shall be considered in commitment proceedings brought under this part. A person does not have a right to appointed counsel in any proceeding initiated under this section.
(3) Relief granted on a petition filed under this section must be narrowly drawn and may not exceed that which is minimally necessary to correct, in the least intrusive manner possible, the violation of the state or federal rights of a particular petitioner. A court considering a petition under this section must give substantial weight to whether the granting of relief would adversely impact the operation of the detention and treatment facility or would adversely impact public safety.
(4) The court may not enter an order releasing a person from secure detention unless the court expressly finds that no relief short of release will remedy the violation of state or federal rights which is found to have occurred.