At any hearing ordered pursuant to § 23A-27A-22.1, the defendant shall be represented by counsel and, if financially unable to obtain adequate representation, counsel shall be appointed for the defendant. The defendant shall be afforded an opportunity to testify, to present evidence, to subpoena witnesses on the defendant's behalf, and to confront and cross-examine witnesses who appear at the hearing.
SDCL 23A-27A-22.5