If the most serious charge against the defendant is a Class A, B, or C felony, the order shall be for a term of years the court determines is reasonable or until the charges have been dismissed by the prosecution. The order may not exceed the maximum penalty allowable for the most serious charge facing the defendant. Upon expiration of the order of detention, the criminal charges against the defendant shall be dismissed. If the prosecutor believes there is probable cause to believe that the defendant is a danger to self or to others at the time of dismissal, the prosecutor may file a petition in accordance with chapter 27A-10 or 27A-11A or title 27B, for further restoration to competency.
Every twelve months thereafter, the director of the approved facility shall notify the court if the defendant is still in a restoration to competency program under the direction of an approved facility or in the approved facility pursuant to this chapter, and the circuit court shall hold a hearing to review any order of detention to determine if the defendant has become competent to proceed.
SDCL 23A-10A-15