
837 So.2d 316 (2002)
In the Matter of N.D.M.
2010381.
Court of Civil Appeals of Alabama.
June 7, 2002.
Bill Pryor, atty. gen.; and Courtney W. Tarver, deputy atty. gen. and general counsel, and Tamara R. Pharrams, asst. *317 atty. gen., Alabama Department of Mental Health & Mental Retardation.
Derek E. Yarbrough of Motley, Motley & Yarbrough, Dothan, for N.D.M.
PITTMAN, Judge.
The Department of Mental Health and Mental Retardation ("the Department") appeals an order directing it to pay the costs of housing N.D.M., a juvenile, in the Southeast Alabama Diversion Center, until space became available for N.D.M. at the Department's facilities at Bryce Hospital.
Following a series of violent acts by N.D.M., the guardian ad litem for N.D.M. petitioned the Houston County juvenile court to commit N.D.M. to the Department for treatment. After holding a probable-cause hearing on September 21, 2001, the court committed N.D.M. to the Department for further evaluation and treatment. Pursuant to § 12-15-90(d)(3), Ala.Code 1975, the Department cannot accept anyone "if the [Department's] facility does not have adequate facilities available or if acceptance would result in an overcrowded condition." The Department notified the court that its facility at Bryce Hospital was full at that time and that it would be six weeks before it could accept N.D.M. at that facility.
Subsequently, on October 12, 2001, the juvenile court held another hearing at which it heard additional arguments and testimony from all parties; it concluded that N.D.M. posed a real threat of harm to himself and the community. The juvenile court issued an order that day concluding that involuntary commitment to the Department for treatment of N.D.M.'s mental illness was the least restrictive alternative and that, until there was space available at Bryce Hospital, confinement in the Southeast Alabama Diversion Center was necessary to prevent the minor from causing substantial harm to himself or to others. The juvenile court's order reiterated its September finding that N.D.M. be involuntarily committed to the Department for treatment, while also acknowledging that there was a five-week waiting period for placement into Bryce Hospital.
On November 15, 2001, upon motion by the guardian ad litem, the juvenile court held a show-cause hearing to determine why N.D.M. had not yet been admitted to Bryce Hospital. In its response to the motion and at the show-cause hearing, the Department stated that the adolescent unit at Bryce Hospital was full; that N.D.M. had been moved to the third position on the waiting list; and that the Department was doing everything possible to move N.D.M. into the Bryce facility. At the conclusion of the hearing, the juvenile court ordered the Department to pay the costs of maintaining N.D.M. at the diversion center. On November 19, 2001, the circuit court dismissed the Department's appeal from the juvenile court's order assessing the costs of maintaining N.D.M. at the diversion center against the Department. The Department then filed this appeal.
The Department raises a single issue on appeal: whether the juvenile court erred by ordering the Department to pay the county for the cost of N.D.M.'s care in the diversion center pending his admission to the Department's adolescent unit at Bryce Hospital. We note initially that a writ of mandamus is the proper method by which to seek to vacate an order a trial court had no authority to enter. See Alabama Dep't of Mental Health & Mental Retardation v. State, 718 So.2d 74, 75 (Ala.Civ.App.1998); Ex parte Dep't of Human Res., 620 So.2d 619 (Ala. 1993). However, mandamus is an extraordinary writ that will not issue if there is an *318 adequate remedy at law. See In re D.M., 738 So.2d 898 (Ala.Civ.App.1999). In In re D.M., this court accepted a direct appeal from an order of the juvenile court, because an appeal was an adequate remedy at law for the alleged error. In re D.M., 738 So.2d at 902.
In the case before us, the Department appealed the juvenile court's order to the circuit court. After the circuit court dismissed the appeal, the Department appealed to this court. Thus, the issue has been properly preserved for appellate review.
Section 12-15-71(c)(4), Ala.Code 1975, authorizes a juvenile court to make any "order as the court in its discretion shall deem to be for the welfare and best interests of the child." Section 12-15-70, Ala. Code 1975, provides that a court may order a child to undergo a physical or mental examination, the results of which shall be certified to the court. If a court has reason to believe that a minor is mentally ill or mentally retarded, the court shall proceed with a petition for commitment as set out in § 12-15-90. Section 12-15-70 also provides that if a minor needs medical care or needs placement in a hospital or institution for treatment, "[t]he expense of such treatment shall be a valid charge against the county unless otherwise provided for."
"The phrase, `unless otherwise provided for' is clarified by § 12-15-10, Ala.Code 1975, which provides:
"`All expenses necessary or appropriate to the carrying out of the purposes and intent of this chapter and all expenses of maintenance and care of children that may be incurred by order of the court in carrying out the provisions and intent of this chapter, except costs paid by parents, guardians or trustees, [and] court costs as provided by law ... shall be valid charges and preferred claims against the county and shall be paid by the county treasurer when itemized and sworn to by the creditor or other persons knowing the facts in the case and approved by the court.'
"(Emphasis added.) See generally, In re McCain, 348 So.2d 780 (Ala.1977)." In re D.M., 738 So.2d at 901.
Thus, § 12-15-10, Ala.Code 1975, requires the county to pay for the care and treatment of indigent juveniles. Furthermore, our supreme court has held that the Department must accept minors alleged to be mentally ill and must provide treatment through its programs and facilities. Ex parte Dep't of Mental Health, 511 So.2d 181, 183 (Ala.1987). Neither § 12-15-71(c)(4) nor § 12-15-70 authorizes a juvenile court to require a state department, as opposed to a county, to pay for the care and treatment of an indigent minor. See Ex parte Dep't of Human Res., 620 So.2d at 620. Nor can a juvenile court order a state department to spend its funds to pay for a minor's placement in a private facility. See Ex parte Dep't of Mental Health, 511 So.2d at 183.
Although the Department attempts to distinguish the cases cited above by stating that they did not involve the involuntary commitment of a child found to be mentally ill, we find this distinction unpersuasive. In a recent decision based on similar facts, Judge Thompson wrote, in conclusion, "[t]he juvenile court had no authority to direct the expenditure of state funds to reimburse the county for the care and maintenance of a juvenile committed to the custody of the Department, during the period before the Department had facilities available to accept the juvenile for treatment." Alabama Dep't of Mental Health & Mental Retardation v. State, 718 So.2d at 76. In this case, N.D.M. was committed to the Department for evaluation and treatment and was detained in the diversion center until the Department could *319 provide the mental-health services ordered by the juvenile court. We can find no legal difference between this case and Alabama Dep't of Mental Health & Mental Retardation v. State.
Therefore, we reverse the juvenile court's order and remand this case for proceedings consistent with this opinion.
REVERSED AND REMANDED.
YATES, P.J., and CRAWLEY and THOMPSON, JJ., concur.
