If a defendant is found "guilty but mentally ill" or enters that plea and the plea is accepted by the court, the court shall impose any sentence which could be imposed upon a defendant pleading or found guilty of the same charge. If the defendant is sentenced to a state correctional facility, he shall undergo further examination and may be given the treatment that is psychiatrically indicated for his mental illness. If treatment is available, it may be provided through facilities under the jurisdiction of the Department of Social Services. The secretary of corrections may transfer the defendant from the state correctional facility to other facilities under the jurisdiction of the Department of Social Services, with the consent of the secretary of social services, and return the defendant to the state correctional facility after completion of treatment for the balance of the defendant's sentence.
SDCL 23A-27-38