When the court, on its own motion or upon the application of the director of the department of public health and human services, the prosecution, or the defendant or the defendant's legal representative, determines, after a hearing if a hearing is requested, that the defendant has regained fitness to proceed, the proceeding must be resumed. If, however, the court is of the view that so much time has elapsed since the commitment of the defendant that it would be unjust to resume the criminal proceedings, the court may dismiss the charge and may order the defendant to be discharged or, subject to the law governing the civil commitment of persons suffering from serious mental illness, order the defendant committed to an appropriate facility of the department of public health and human services.
§ 46-14-222, MCA