In any proceeding for involuntary commitment, review, or detention, or in any proceeding challenging commitment or detention, the state's attorney for the county in which the proceeding is held shall represent the petitioner and shall defend all challenges to commitment or detention. The county ultimately shown to be the county of residence shall reimburse the county in which the proceeding is held for any reasonable cost of such representation. No lien may be placed against the person for the costs incurred in any proceeding for involuntary commitment, review, or detention.
SDCL 27A-11A-4