Any person involuntarily committed by a board of mental illness and any person confined or in any manner detained or restrained is entitled to the benefit of the writ of habeas corpus. If the court finds that the criteria in § 27A-10-9.1 are met, the court may authorize continued involuntary commitment. Such authorization is not a bar to the issuing of the writ the second time if it is alleged that the criteria in § 27A-10-9.1 are no longer met.
SDCL 27A-12-32.2