If the director of a facility in which a person is hospitalized certifies that a person whose sentence is about to expire or who has been committed to the custody of the Human Services Center pursuant to § 23A-10A-4, or against whom all criminal charges have been dismissed solely for the reasons related to the mental condition of the person, is presently suffering from a mental disease or defect as a result of which his release would create a substantial risk of bodily injury to another person or serious damage to property of another, he shall transmit a certificate to that effect to the clerk of the court which had jurisdiction over the person. The clerk shall send a copy of the certificate to the person's counsel and to the prosecuting attorney. The court shall order a hearing to determine whether the person is presently suffering from a mental disease or defect as a result of which his release would create a substantial risk of bodily injury to another person or serious damage to property of another. A certificate filed under this section shall stay the release of the person pending completion of the procedures contained in §§ 23A-46-9 to 23A-46-13, inclusive.
SDCL 23A-46-8