(1) If the attendance of any person confined in any correctional facility is required for the purpose of his or her taking on his or her trial, or attending a hearing into a criminal charge against him or her, the court may, by order in writing, direct a correctional officer to bring up the body of the person, as often as may be required, for the purpose of the trial or hearing, and the correctional officer shall obey such order.