
196 Ill. App.3d 832 (1990)
554 N.E.2d 472
MICHAEL REESE HOSPITAL AND MEDICAL CENTER, Plaintiff-Appellant,
v.
CHICAGO HMO, LTD., Defendant-Appellee.
No. 1-88-2580.
Illinois Appellate Court  First District (3rd Division).
Opinion filed April 4, 1990.
*833 Jeffrey Lennard, Jay Conison, Barney I. Cohen, and Stephen J. Weiser, all of Sonnenschein, Carlin, Nath & Rosenthal, of Chicago, for appellant.
Howard J. Swibel, Arthur L. Klein, Patrick F. Geary, and Richard C. Gering, all of Arnstein & Lehr, of Chicago, for appellee.
Rudolf G. Schade, of Cassiday, Schade & Gloor, of Chicago, and Mark D. Deaton, of Naperville, for amici curiae.
Reversed and remanded.
JUSTICE WHITE delivered the opinion of the court:
Plaintiff, Michael Reese Hospital and Medical Center (Reese), appeals from an order of the circuit court granting defendant's motion to dismiss Reese's complaint with prejudice, pursuant to section 2-615 of the Code of Civil Procedure (Ill. Rev. Stat. 1987, ch. 110, par. 2-615). Reese argues that the trial court erred in finding that the complaint failed to state a claim for restitution.
Reese filed suit in the circuit court against defendant, Chicago HMO, Ltd. (CHMO), seeking a declaration that CHMO was obligated to pay Reese for medical services rendered to CHMO members. In its complaint, Reese alleged that it was a not-for-profit corporation licensed to provide hospital services under the laws of Illinois; that under Illinois law, it was obligated to provide emergency medical services to any person who came to Reese in need of such services (Ill. Rev. Stat. 1987, ch. 111 1/2, pars. 86, 6151); that despite its obligation to provide emergency medical services, it was not required to provide its services for free; that it had the right to reimbursement for its services from the persons to whom the services were provided as well as from any person with a duty to provide or arrange for the provision of emergency services to such persons; that when it provided emergency services to a patient it did so with the intent to charge for the services rendered; and that, unless there was a contractual arrangement to the contrary, such patients were billed at Reese's usual and customary rate for the services rendered.
Reese alleged that the Illinois Department of Public Aid (IDPA) had a statutory responsibility to compensate providers of medical assistance to public aid recipients, and that in some instances IDPA contracted through the Illinois Competitive Access and Reimbursement Equity (ICARE) program to reimburse hospitals directly. In other instances IDPA entered into arrangements with health maintenance organizations *834 (HMOs), under which the HMOs assumed responsibility for providing or paying for medical services rendered to those public aid recipients who became members of the HMOs.
Reese further alleged that both it and CHMO had entered into contracts with the IDPA pursuant to IDPA's ICARE program. Under Reese's contract with IDPA, Reese agreed to provide emergency care to a specified number of public aid recipients and IDPA agreed to make direct payments to Reese in an amount lower than the usual and customary rate charged by Reese. The amount of these payments, called the "ICARE rate," was determined on the basis of projections by Reese of the number of public aid patients it would treat. Reese's contract with IDPA stated that the ICARE rate was to be kept confidential.
Under CHMO's contract with IDPA, IDPA provided payments to CHMO, in exchange for which CHMO agreed to provide or arrange to provide emergency medical care to public aid recipients who became CHMO members. The contract required CHMO to make payments to all hospitals that provided emergency medical services to CHMO members, whether or not CHMO had entered into contracts with those hospitals for the provision of such services.
In 1983, Reese began providing emergency medical services to public aid recipients who were members of CHMO. Reese alleged that initially it was unaware that the patients it treated were CHMO members and, therefore, it billed IDPA for the services rendered to those patients. After Reese was informed by IDPA that CHMO was responsible for reimbursing Reese, Reese submitted the bills for those patients to CHMO. However, CHMO refused to reimburse Reese on the ground that Reese had failed to notify CHMO of the treatment within 48 hours.
Reese alleged that if CHMO were permitted to avoid payment to Reese for services Reese rendered to CHMO patients because of lack of notification, CHMO would be able to retain the amounts paid to it by IDPA for the cost of such services while escaping its contractual obligation to reimburse Reese for such services. Alleging that this would result in unjust enrichment of CHMO, Reese sought a declaration that CHMO had no right to deny payment based on Reese's failure to notify CHMO within a period unilaterally fixed by CHMO.
Reese also alleged that in 1984 it began notifying CHMO of emergency treatment provided by Reese to CHMO members within 48 hours of such treatment; that Reese billed CHMO for the treatment at Reese's usual and customary rate; and that Reese expected payment in full for its services. Despite Reese's demands for payment in *835 full, CHMO regularly tendered payment for services rendered to its members, not at Reese's usual and customary rate, but at the lower ICARE rate established in the contract between Reese and IDPA.
Reese alleged that it was not required by its contracts with IDPA to accept payment from HMOs at the ICARE rate. In support of this allegation, Reese attached to its complaint a letter in which IDPA stated that "at no time has [IDPA] contemplated the application of the ICARE rates for the reimbursement of hospital services to HMO recipients."
Reese further alleged that under the contract between IDPA and CHMO, the payments made by IDPA to CHMO were based on CHMO paying an amount in excess of the ICARE rate to hospitals that provided care to CHMO members. Reese contended that if CHMO was permitted to pay Reese no more than the ICARE rate, CHMO would be unjustly benefitted at the expense of Reese.
CHMO filed a motion to dismiss Reese's complaint pursuant to section 2-615. In its motion, CHMO argued that because Reese had an independent duty to provide emergency medical treatment to public aid recipients, Reese had no right to restitution from CHMO. CHMO also argued that Reese had no reasonable expectation of payment from CHMO, in light of CHMO's continued refusal to pay for the services rendered at the rate demanded by Reese.
Following a hearing the trial court granted CHMO's motion and entered an order dismissing Reese's complaint with prejudice. The trial court found that under the principles of Griffith Wrecking Co. v. Greminger (1978), 65 Ill. App.3d 962, 382 N.E.2d 1387, Reese was barred from seeking restitution because of its statutory obligation to provide medical services.
In this appeal, Reese argues that the trial court erred in dismissing its complaint pursuant to section 2-615. We agree.
 1, 2 Under section 2-615, a party may move for dismissal of an action where the pleadings fail to state a cause of action. However, a cause of action should not be dismissed on the pleadings unless it clearly appears that no set of facts can be proved which will entitle the plaintiff to recover. (Edgar County Bank & Trust Co. v. Paris Hospital, Inc. (1974), 57 Ill.2d 298, 312 N.E.2d 259; Krautstrunk v. Chicago Housing Authority (1981), 95 Ill. App.3d 529, 420 N.E.2d 429.) In determining whether a motion to dismiss was properly allowed, pertinent facts alleged in the complaint and contained in appended exhibits are accepted as true. (Krautstrunk, 95 Ill. App.3d 529, 420 N.E.2d 429; Spencer v. Community Hospital (1980), 87 Ill. App.3d 214, 408 N.E.2d 981.) If, on the facts alleged and the inferences *836 reasonably drawn therefrom, there is any possibility of recovery, the order of dismissal must be vacated. First Security Bank v. Bachleda (1987), 165 Ill. App.3d 725, 520 N.E.2d 660.
 3 In the present case, Reese's complaint sought restitution for the value of services rendered to CHMO patients based upon a theory of unjust enrichment. To state a cause of action based on a theory of unjust enrichment, a complaint need only allege that there was an unjust retention of a benefit, by one party, to the detriment of another party against the fundamental principles of justice, equity, and good conscience. HPI Health Care Services, Inc. v. Mt. Vernon Hospital, Inc. (1989), 131 Ill.2d 145, 545 N.E.2d 672; Kenneke v. First National Bank (1978), 65 Ill. App.3d 10, 382 N.E.2d 309.
Reese alleged in its complaint that under the contract between IDPA and CHMO, IDPA provided payments to CHMO in exchange for which CHMO was to (1) provide medical services to CHMO members and (2) pay for all emergency services rendered by hospitals to its members, whether or not it had entered into a contract with those hospitals. Reese also alleged that a number of CHMO members had received treatment at Reese; that CHMO refused to reimburse Reese for the care provided to such patients at Reese's usual and customary rate and instead paid only the ICARE rate; that IDPA did not intend the ICARE amount to be applied in reimbursing hospitals; that the payments CHMO received from IDPA on behalf of its members exceeded the ICARE amount; and that if CHMO were allowed to reimburse Reese at the ICARE rate, and in some instances escape reimbursement entirely, it would be unjustly enriched.
 4 We find that these allegations sufficiently allege that CHMO has received a benefit, and that the retention of the benefit would be unjust and to the detriment of Reese. (HPI Health Care Services, Inc., 131 Ill.2d at 160.) We conclude, therefore, that the trial court erred in dismissing Reese's complaint for failure to state a cause of action.
CHMO argues, and the trial court found, that Reese's statutory duty to provide emergency care precludes it from recovering for its services. CHMO bases its argument on section 106 of the Restatement of Restitution (Restatement of Restitution § 106 (1936)) and on the decision in Griffith Wrecking Co. v. Greminger.
Section 106 states:
"A person who, incidentally to the performance of his own duty or to the protection or the improvement of his own things, has conferred a benefit upon another, is not thereby entitled to contribution." (Restatement of Restitution § 106 (1936).)
*837 In Griffith, the appellate court relied on this section in finding that the City of Springfield was not entitled to reimbursement under theories of unjust enrichment and implied contract.
There, plaintiff filed suit against defendant to recover for the demolition of a fire-damaged building on defendant's property. Defendant filed a third-party complaint against the City of Springfield alleging that the work was done at the city's request, at a time when the city was conducting a search for the bodies of two unaccounted-for inhabitants of the building. In response, the city alleged that defendant was under a statutory duty and municipal ordinance obligation to demolish the building for reasons of public safety; that the city was entitled to recover the cost of demolition from defendant under an implied contract theory; and that defendant would be unjustly enriched if he were not required to reimburse the city for discharging his duty. The trial court found that defendant was not liable to the city and the appellate court affirmed.
In reaching its decision, the appellate court took note of testimony from plaintiff's president that the Springfield fire department requested that plaintiff demolish the building so that a search for bodies could be conducted. The appellate court held that this evidence was sufficient to support a finding that the principal purpose of the work was the search for bodies. Relying on section 106, the court further held that such a finding would preclude the city from recovery for the incidental benefit defendant received by being relieved of his duty to demolish the building. Griffith Wrecking Co. v. Greminger (1978), 65 Ill. App.3d at 963.
 5 Reese argues that neither Griffith nor section 106 is applicable to the present case. We agree and we find that there is nothing in the Griffith decision or in the language of section 106 that would preclude Reese from recovering for its services.
Unlike Griffith, in the case before us, Reese alleges that its statutory duty and CHMO's contractual duty were identical: both were obligated to provide emergency medical services to indigent patients.
Reese's complaint alleges that Reese had a statutory duty to provide emergency services to indigent patients and that CHMO had a contractual duty to either provide such services to its members or to reimburse Reese and other hospitals that did so. Reese also alleges that payments CHMO received from IDPA, with which it was to reimburse hospitals that provided medical care to CHMO members, were in excess of the ICARE rate which CHMO paid to Reese, and that, therefore, CHMO would be unjustly enriched at Reese's expense if it was allowed to retain the payments without reimbursing Reese for *838 the full value of its services.
As stated above, these allegations are sufficient to state a cause of action for unjust enrichment (see HPI Health Care Services, Inc., 131 Ill.2d at 160), and we find that they present a set of circumstances sufficiently distinguishable from those in Griffith. A further distinction from Griffith is that in the present case, Reese's complaint alleges that CHMO has made payment to Reese for services rendered to CHMO patients, indicating that CHMO has recognized that some right of restitution exists. No such allegations were made in Griffith, and we, therefore, hold that the court's decision in that case cannot be considered controlling.
In conclusion, we find that the trial court erred in dismissing Reese's complaint for failure to state a cause of action, and we reverse the court's decision and remand this cause for further proceedings.
The judgment of the circuit court of Cook County is reversed and remanded.
Reversed and remanded.
RIZZI and FREEMAN, JJ., concur.
