Examination Before Imposition of Sentence. Whenever a person who has been criminally charged is to be sentenced, the court may defer sentence and order him to be examined for mental illness to aid it in the determination of disposition. This action may be taken on the court's initiative or on the application of the attorney for the Commonwealth, the person charged, his counsel, or any other person acting in his interest. If at the time of sentencing the person is not in detention, examination shall be on an outpatient basis unless inpatient examination for this purpose is ordered pursuant to the civil commitment provisions of Article III.
50 P.S. § 7405