(a)
(1) The sheriff has the authority, when the jail of the county is insufficient for the safekeeping of a prisoner, to convey the prisoner to the nearest sufficient jail in the state or, if the prisoner is a juvenile, to the nearest sufficient juvenile detention facility in the state.
(2) In all cases where it is shown to the committing court that the jail of the county in which the commitment should be made is insufficient for the safekeeping of the prisoner, the court may order commitment of the prisoner to the nearest sufficient county jail or, if the prisoner is a juvenile, to the nearest sufficient juvenile detention facility.
(3) In all cases where the jail in which a prisoner is confined becomes insufficient for any cause, any circuit, criminal, or general sessions judge, upon the application of the sheriff and proof of the fact, may order the prisoner to be removed to the nearest sufficient jail or, if the prisoner is a juvenile, to the nearest sufficient juvenile detention facility.
(b)
(1) An order issued under this section shall be reviewed by the issuing court at least once every thirty (30) days. In conducting the review, the court shall determine whether the order needs to remain in place, be terminated, or be modified to place conditions on the order. In evaluating whether the order needs to remain in place, the court shall consider the jail or juvenile detention facilities' obligations relative to the use of restrictive housing. If the order is terminated, the prisoner shall be returned to the county jail or juvenile detention facility, as appropriate.
(2) Nothing in this section authorizes a non-adjudicated juvenile, or a non-adjudicated juvenile who has been transferred to criminal court in accordance with title 37, chapter 1, to be committed or removed to the state penitentiary or a branch prison for safekeeping.