Criminal Code of Canada
PART XVI- COMPELLING APPEARANCE OF ACCUSED BEFORE JUSTICE AND INTERIM RELEASE
PROCEDURE TO PROCURE ATTENDANCE OF A PRISONER
527 (1) A judge of a superior court of criminal jurisdiction may order in writing that a person who is confined in a prison be brought before the court, judge, justice or provincial court judge before whom the prisoner is required to attend, from day to day as may be necessary, if
(a) the applicant for the order sets out the facts of the case in an affidavit and produces the warrant, if any; and
(b) the judge is satisfied that the ends of justice require that an order be made.
(2) A provincial court judge has the same powers for the purposes of subsection (1) or (7) as a judge has under that subsection where the person whose attendance is required is within the province in which the provincial court judge has jurisdiction.
(3) An order that is made under subsection (1) or (2) shall be addressed to the person who has custody of the prisoner, and on receipt thereof that person shall
(a) deliver the prisoner to any person who is named in the order to receive him; or
(b) bring the prisoner before the court, judge, justice or provincial court judge, as the case may be, on payment of his reasonable charges in respect thereof.
(4) Where a prisoner is required as a witness, the judge or provincial court judge shall direct, in the order, the manner in which the prisoner shall be kept in custody and returned to the prison from which he is brought.
(5) Where the appearance of a prisoner is required for the purposes of paragraph (1)(a) or (b), the judge or provincial court judge shall give appropriate directions in the order with respect to the manner in which the prisoner is
(a) to be kept in custody, if he is ordered to stand trial; or
(b) to be returned, if he is discharged on a preliminary inquiry or if he is acquitted of the charge against him.
(6) Sections 718.3 and 743.1 apply where a prisoner to whom this section applies is con-victed and sentenced to imprisonment by the court, judge, justice or provincial court judge.
(7) On application by the prosecutor, a judge of a superior court of criminal jurisdiction may, if a prisoner or a person in the custody of a peace officer consents in writing, order the transfer of the prisoner or other person to the custody of a peace officer named in the order for a period specified in the order, where the judge is satisfied that the transfer is required for the purpose of assisting a peace officer acting in the execution of his or her duties.
(8) An order under subsection (7) shall be addressed to the person who has custody of the prisoner and on receipt thereof that person shall deliver the prisoner to the peace officer who is named in the order to receive him.
(9) When the purposes of any order made under this section have been carried out, the prisoner shall be returned to the place where he was confined at the time the order was made.
EDIT.