a judge of a court with jurisdiction to try felony cases in the county where the person is confined, after notice to the district attorney general, shall fix a time and place for a hearing and shall order the person having custody of the prisoner to produce the prisoner at the hearing.
a judge of the court in which the action is pending may issue a certificate certifying all the facts and that the attendance of the person as a witness in the court is required for a specific number of days. The certificate may be issued upon application of either the state or defendant demonstrating all the facts specified in this section.