
370 N.E.2d 819 (1977)
54 Ill. App.3d 931
12 Ill.Dec. 908
The PEOPLE of the State of Illinois, Plaintiff-Appellee,
v.
Lamartine PATTERSON, Defendant,
In re Illinois DEPARTMENT OF MENTAL HEALTH AND DEVELOPMENT DISABILITIES, Petitioner-Appellant.
No. 76-946.
Appellate Court of Illinois, First District, Third Division.
September 28, 1977.
As Modified On Denial of Rehearing December 14, 1977.
*820 William J. Scott, Atty. Gen., Chicago, for petitioner-appellant; Barbara A. Weiner, Staff Atty., and William J. Fitzpatrick, Sp. Asst. Atty. Gen., of counsel.
Bernard Carey, State's Atty., Chicago, for plaintiff-appellee; Laurence J. Bolon, Lee T. Hettinger, James S. Veldman, Asst. State's Attys., of counsel.
McNAMARA, Justice.
The Department of Mental Health, represented by the Attorney General, brings this appeal from the trial court's refusal to vacate, amend, or alter its order of June 8, 1976 as it affected Lamartine Patterson. The Department's position is opposed by the State's Attorney of Cook County who requests that we dismiss the appeal.
Patterson was charged with two incidents of armed robbery. On January 24, 1975 he was found unfit to stand trial for these offenses and committed to the Department by Judge Strayhorn. On March 19, 1975, after conducting a hearing, Judge Collins sitting in the county division of the circuit court of Cook County found Patterson to be in need of mental treatment and ordered him committed for hospitalization. On May 11, 1976 the Superintendent of Manteno Mental Health Center discharged Patterson as no longer in need of hospitalization and returned him to the Sheriff of Cook County. On May 20, 1976, the Department petitioned Judge Strayhorn for defendant's release on bail or recognizance. On June 8, 1976, Judge Strayhorn denied the Department's petition and entered an order containing six paragraphs which are challenged by the Department in this appeal. On June 22, 1976 the judge refused to vacate, amend, or alter his order of June 8.
The six paragraphs complained of are as follows:
"5. That such treatment shall continue until such time as the petitioner-defendant shall have recovered from his mental illness to the extent that he is fit to stand trial, and the Department of Mental Health shall so certify.
6. That no finding of not in need of mental treatment pursuant to a Civil hearing specified in the Mental Health Code (Chapter 91½, Section 1-1, et seq.) will relieve the Department of Mental Health from its obligation to treat the petitioner-defendant for his mental illness and such treatment shall continue until Medical personnel assigned to the Department of Mental Health are prepared to state that defendant-petitioner is now fit to stand trial.
7. That such treatment by the Department of Mental Health shall continue until such time as petitioner-defendant is relieved of his mental disability and is fit for trial on the pending criminal indictment.
8. Prior to the holding of any Civil hearing pursuant to statute touching upon the question of further need for hospitalization or mental treatment the Department shall notify the committing criminal court as to the date of such Civil hearing and shall no later than 72 hours prior to such hearing transport the petitioner to the Psychiatric Institute of Cook County for examination by the state of such institute.
9. Notice of such Civil hearing shall be served on the Psychiatric Institute of the Circuit Court of Cook County at the same time as petitioner is brought to their offices as aforesaid.

*821 10. When said Petitioner recovers from said unfitness, that the Department of Mental Health communicate with the Sheriff of Cook County and arrange with said Sheriff to transfer custody of said Petitioner to said Sheriff, who shall thereupon keep said Petitioner in custody upon the instant indictment until said indictment is disposed of or until said Petitioner is discharged by operation of law."
The Unified Code of Corrections, Ill.Rev. Stat.1975, ch. 38, par. 1005-2-2(a) and (b), provides as follows:
"(a) If the defendant is found unfit to stand trial or be sentenced, the court shall remand the defendant to a hospital, as defined by Mental Health Code of 1967, and shall order that a hearing be conducted in accordance with the procedures, and within the time periods, specified in such Act. The disposition of defendant pursuant to such hearing, and the admission, detention, care, treatment and discharge of any such defendant found to be in need of mental treatment, shall be determined in accordance with such Act. If the defendant is not ordered hospitalized in such hearing, the Department of Mental Health and Developmental Disabilities shall petition the trial court to release the defendant on bail or recognizance, under such conditions as the court finds appropriate, which may include, but need not be limited to requiring the defendant to submit to or to secure treatment for mental condition. (b) A defendant hospitalized under this Section shall be returned to the court not more than 90 days after the court's original finding of unfitness, and each 12 months thereafter. At such re-examination the court may proceed, find, and order as in the first instance under paragraph (a) of this Section. If the court finds that defendant continues to be unfit to stand trial or be sentenced but that he no longer requires hospitalization, the defendant shall be released under paragraph (a) of this Section on bail or recognizance. Either the State or the defendant may at any time petition the court for review of the defendant's fitness."
Section 10-4 of the Mental Health Code, Ill.Rev.Stat.1975, ch. 91½, par. 10-4, under which the Superintendent of the Manteno Hospital discharged Patterson, provides as follows:
"When any person has been admitted or hospitalized under this Act or any prior Act, upon court order or otherwise, the superintendent of the hospital in which such person is hospitalized may at any time grant an absolute discharge * * and shall do so if the patient is no longer in need of hospitalization under such rules and regulations as may be adopted by the Department. * * *"
We believe that the trial court erred in entering paragraphs five through ten of its order of June 8, 1976, and that it erred in refusing to grant the Department's motion to vacate, alter or amend that order. Those portions of the order in effect would mandate the Department to keep Patterson in custody until he was fit to stand trial. Unless he became fit to stand trial, Patterson's commitment would exist for an indefinite period, a constitutionally impermissible consequence. (See Jackson v. Indiana (1972), 406 U.S. 715, 92 S.Ct. 1845, 32 L.Ed.2d 435; People v. Byrnes (1972), 7 Ill.App.3d 735, 288 N.E.2d 690.) We therefore vacate the trial court's order of June 8, 1976.
We next must consider the Department's request that the trial court be ordered forthwith to conduct a hearing on the Department's petition to release Patterson on bail or recognizance.
Recently this court in a companion case, faced with an order containing identical language to that in the present order, directed the trial court to conduct such a hearing forthwith. (People v. Theim (1977), 52 Ill. App.3d 160, 9 Ill.Dec. 933, 367 N.E.2d 367). In so ruling, we relied on two cases. (People ex rel. Martin v. Strayhorn (1976), 62 Ill.2d 296, 342 N.E.2d 5; People v. Ealy (1977), 49 Ill.App.3d 922, 7 Ill.Dec. 864, 365 N.E.2d 149.) However there is one significant difference in the present case. In the foregoing cases, judges in subsequent civil commitment proceedings had found the defendants *822 not to be in need of hospitalization. Here, there was no such judicial determination following Judge Collins' earlier finding that Patterson was in need of mental treatment. Rather, the hospital superintendent under Section 10-4 of the Mental Health Code ordered Patterson discharged from hospitalization. The only interpretation of paragraph 1005-2-2(b) of the Unified Code of Corrections which leaves it with any meaning or significance is that because in a judicial proceeding Patterson has been found in need of mental treatment, the trial court is required to make a further determination that Patterson no longer requires hospitalization before conducting a hearing on bail or recognizance. That paragraph states specifically: "If the court finds that defendant continues to be unfit to stand trial or be sentenced but that he no longer requires hospitalization, the defendant shall be released under paragraph (a) of this Section." It would appear that the legislature inserted this language to serve as a guideline for the somewhat exceptional circumstances of the instant case. Statutes which relate to the same subject matter must be compared and construed with reference to each other so that effect may be given to all provisions of each if such can be done by a reasonable and fair construction. (People v. Gardner (1973), 15 Ill.App.3d 255, 304 N.E.2d 125.) It is undisputed that Patterson is unfit to stand trial for the criminal charges. Thus compliance with the above paragraph, in our view, requires the court to conduct a civil commitment hearing for the sole purpose of determining whether Patterson requires mental treatment or hospitalization. (See People v. Davis (1975), 25 Ill.App.3d 1007, 324 N.E.2d 58.) The outcome of a civil commitment hearing, of course, does not necessarily indicate whether an individual possesses the mental capacity to stand trial on criminal charges. (People v. Chambers (1976), 36 Ill.App.3d 838, 345 N.E.2d 119.) Accordingly, we direct the trial court to conduct a civil commitment hearing to determine whether Patterson requires hospitalization. If it is established that he does not require hospitalization, the court is ordered to conduct a hearing on bail or recognizance.
The State's Attorney has requested that we dismiss the appeal because the Department is not a proper party appellant and because the order is not final and appealable. In People v. Theim, supra, we held that the Department was a proper party and that an identical order was final and appealable. We adhere to that conclusion, and we deny the State's Attorney's motion to dismiss the appeal. See also People v. Ealy, supra.
For the reasons stated, the order of the circuit court of Cook County of June 8, 1976 is vacated, and the cause is remanded for further proceedings in accordance with the holding of this opinion.
Reversed and remanded with directions.
SIMON, P. J., and McGILLICUDDY, J., concur.
