(a) The court shall set and may change the conditions under which the examination is to be conducted.

(b) On consideration of the nature of the petition, the court may require the examination to be conducted on an outpatient basis if the child was previously detained under § 3-8A-15 of this subtitle and shall require the examination to be conducted on an outpatient basis if the child was not previously detained under § 3-8A-15 of this subtitle.

(c) (1) If a child was previously detained under § 3-8A-15 of this subtitle, the court may order the child to continue to be detained beyond any period specified in § 3-8A-15 of this subtitle until the examination is completed.

(2) If the court finds it appropriate for the health or safety of the child, or for the safety of others, the court may order confinement of the juvenile, pending the examination, in a medical facility that the Maryland Department of Health designates as appropriate.