On a petition of the director of the department of behavioral healthcare, developmental disabilities and hospitals, or on the petition of the director of the department of corrections, setting forth that any person awaiting trial or convicted of a crime and imprisoned for the crime in the adult correctional institutions is mentally ill and requires specialized mental health care and psychiatric in-patient services that cannot be provided in a correctional facility, a judge of the district court or justice of the superior court may order the examination of the person as in his or her discretion he or she shall deem appropriate.
R.I. Gen. Laws § 40.1-5.3-6