(a) At a competency hearing, if the court determines that the child is incompetent to proceed, but that there is a substantial probability that the child may be able to attain competency in the foreseeable future and that services are necessary to attain competency, the court may order the Maryland Department of Health to provide competency attainment services for the child for an initial period of not more than 90 days.
(b) Any competency attainment services shall be provided in the least restrictive environment.
(c) Subject to subsection (d) of this section, the court may order a child to be placed in a facility for children if:
(1) The child is detained under § 3–8A–15 of this subtitle at the time of the competency hearing; and
(2) The court finds after a hearing on the issue that:
(i) Placement in a facility is necessary to protect the child or others, or the child is likely to leave the jurisdiction of the court; and
(ii) No less restrictive alternative placement is available that will protect the child or the community or prevent the child from leaving the jurisdiction of the court.
(d) A child may not be:
(1) Unless the child’s individualized treatment plan developed under § 10–706 of the Health – General Article otherwise indicates, provided services in any group with persons who are at least 18 years old;
(2) Placed in a detention facility; or
(3) Placed in a psychiatric hospital, except in accordance with Title 10, Subtitle 6 of the Health – General Article.