
891 So.2d 587 (2004)
PACIFIC INSURANCE COMPANY, LTD., etc., Appellant,
v.
George BOTELHO, D.O., Center For Orthopedic Surgery and Rheumatic Disease, a/k/a Center for Orthopaedic Surgery, P.A., Lawrence Goldschlager, M.D., Emcare of Florida, Inc., and Marathon HMA, d/b/a Fishermen's Hospital, Inc., Appellees.
No. 3D04-810.
District Court of Appeal of Florida, Third District.
December 22, 2004.
Rehearing Denied February 9, 2005.
*588 Nicklaus & Associates, Coral Gables, and Alexander J. Perkins, for appellant.
Wicker, Smith, O'Hara, McCoy, Graham & Ford and Shelley H. Leinicke (Fort Lauderdale) for appellees George M. Botelho, D.O., and Center for Orthopedic Surgery and Rheumatic Disease, a/k/a Center for Orthopaedic Surgery, P.A.
McGrane, Nosich & Ganz and Ruben V. Chavez, Coral Gables, for appellee Emcare of Florida, Inc.
Marlow, Connell, Valerius, Abrams, Adler, Newman & Lewis, Coral Gables, and Beverly Eisenstadt, Miami, for appellee Marathon HMA, d/b/a Fishermen's Hospital, Inc.
Before COPE and GODERICH, JJ., and NESBITT, JOSEPH, Senior Judge.
GODERICH, Judge.
The plaintiff, Pacific Insurance Company, Ltd., as subrogee of Hawk's Cay Investors, Ltd., a Florida limited partnership, d/b/a Hawk's Cay Resort & Marina [Pacific], appeals from a final order dismissing with prejudice its complaint for equitable subrogation against defendants, George Botelho, D.O.; Center for Orthopedic Surgery and Rheumatic Disease, a/k/a Center for Orthopaedic Surgery, *589 P.A.; Lawrence Goldschlager, M.D.;[1] Emcare of Florida, Inc.; and Marathon HMA, d/b/a Fishermen's Hospital, Inc. [collectively referred to as medical providers].
Martha Ziesenheim tripped and fell on the premises of Hawk's Cay Resort & Marina [Hawk's Cay]. She then received treatment from the medical providers for injuries she sustained.
Mr. and Mrs. Ziesenheim filed suit against Hawk's Cay. At the time of the accident, Hawk's Cay was insured by Pacific. The Ziesenheims filed a proposal for settlement in the amount of $500,000 listing only Hawk's Cay. Hawk's Cay accepted the proposal. The Ziesenheims objected to the release and settlement agreement prepared on behalf of Hawk's Cay because it included the assignment of the medical malpractice claim. Because the parties could not agree as to whether the medical malpractice claims were included in the proposal for settlement, this issue was submitted to the trial court for determination. The trial court found that the medical malpractice claims were not included in the proposal for settlement, and thereafter, the Ziesenheims executed a Release and Settlement Agreement [Release] that included only the claim against Hawk's Cay.
Pacific then filed its complaint for equitable subrogation against the medical providers asserting that their negligence was a direct or proximate cause of the injuries sustained by Mrs. Ziesenheim and that "the amount paid by PACIFIC was far greater than would have fairly and reasonably been paid in the settlement of Martha Ziesenheim's claim because the negligence of [the medical providers] caused additional injuries, conditions, and infections which otherwise required unnecessary treatment, surgeries, hospitalization, medical bills, and increased permanent injury to Martha M. Ziesenheim."
The medical providers filed motions to dismiss the complaint [collectively referred to as Motion to Dismiss]. Moreover, Fishermen's Hospital also filed a Motion to Strike the Complaint as Sham [Motion to Strike] attaching a copy of the Release executed by the Ziesenheims. Fishermen's Hospital subsequently submitted the affidavit of an attorney for the Ziesenheims who averred that the Ziesenheims' lawsuit was for a slip and fall against Hawk's Cay, not medical malpractice against the medical providers, and that the malpractice claims had been retained by the Ziesenheims. Fishermen's Hospital's Motion to Strike was later adopted by the other medical providers. The trial court heard the Motion to Strike and the Motion to Dismiss at a single hearing. At the hearing, Pacific argued that it was inappropriate for the trial court to consider the Release in ruling on the Motion to Dismiss. Further, over Pacific's objection, the trial court allowed one of the Ziesenheims' attorneys to testify. The attorney testified that the proposal for settlement was limited to a claim against Hawk's Cay, and that a trial judge had determined that the proposal did not include any claims except for those against Hawk's Cay. The trial court reserved ruling on the motions.
Prior to the trial court ruling on the motions, Pacific filed an amended complaint adding Paragraph 26 to the common allegations, which provided in part that "the Ziesenheims and/or their attorneys would not agree to the release language expressly releasing the subsequent negligent medical providers."
The trial court entered a single order which denied the Motion to Strike, but granted the Motion to Dismiss with prejudice. In granting the Motion to Dismiss, *590 the trial court relied on the Release itself and also on Paragraph 26 of the amended complaint. This appeal follows.
Pacific contends that the trial court erred by relying on the Release when ruling on the Motion to Dismiss. We agree.
The purpose of a motion to dismiss is to test the legal sufficiency of the complaint. Barbado v. Green & Murphy, P.A., 758 So.2d 1173, 1174 (Fla. 4th DCA 2000). Unlike a motion for summary judgment, when ruling on a motion to dismiss, "[a] court may not go beyond the four corners of the complaint in considering the legal sufficiency of the allegations." Barbado, 758 So.2d at 1174; see also Patriotcom, Inc. v. Vega, 821 So.2d 1261 (Fla. 4th DCA 2002). Further, a motion to dismiss cannot be granted based on an affirmative defense unless the defense appears upon the face of a pleading. Ramos v. Mast, 789 So.2d 1226 (Fla. 4th DCA 2001); Beach Roundhouse Town Corp. v. Skinner, 356 So.2d 881 (Fla. 3d DCA 1978).
In the instant case, the Release signed by the Ziesenheims was not attached to either the complaint or amended complaint. As such, the trial court erred by relying on the copy of the Release when ruling on the Motion to Dismiss. In most instances, reversal would be warranted where the trial court went beyond the four corners of the complaint when ruling upon a motion to dismiss. However, in this case, the trial court gave two reasons for granting the motion to dismiss, the Release itself, which is beyond the four corners of the complaint, and Paragraph 26 of the amended complaint, which is within the four corners of the complaint. Based on our finding that the trial court erred by relying on the Release itself in granting the Motion to Dismiss, we must now consider whether dismissal of the action was warranted based solely on the averment contained in Paragraph 26 of the amended complaint.
The medical providers contend that even if the trial court erroneously relied on the copy of the Release, reversal is not warranted, and this Court must nonetheless affirm, because Paragraph 26 of the amended complaint demonstrates that Pacific did not, and cannot, plead a cause of action for equitable subrogation. We agree.
To state a cause of action for equitable subrogation, the allegations of the complaint must demonstrate that: "(1) the subrogee made the payment to protect his or her own interest, (2) the subrogee did not act as a volunteer, (3) the subrogee was not primarily liable for the debt, (4) the subrogee paid off the entire debt, and (5) subrogation would not work any injustice to the rights of a third party." Dade County School Bd. v. Radio Station WQBA, 731 So.2d 638, 646 (Fla.1999). The medical providers argue, and we agree, that based on Paragraph 26 of the amended complaint, which we must accept as true, Pacific cannot establish that it paid off the entire debt because "the Ziesenheims and/or their attorneys would not agree to the release language expressly releasing the subsequent negligent medical providers (Defendants) in the underlying release." Therefore, because the medical providers were not released and the Ziesenheims retained their cause of action against the medical providers, Pacific cannot state a cause of action for equitable subrogation. As such, we affirm the order dismissing the action with prejudice.
In light of our holding, it is not necessary for us to address the remaining arguments raised by the parties.
Affirmed.
NESBITT, Senior Judge, concurs.
COPE, J. (dissenting).
Since it appears reasonably clear that the dismissal order was based on consideration *591 of matters outside the four corners of the complaint, I would reverse without prejudice to the appellees to file a motion for summary judgment.
As an aside, the majority opinion accurately quotes a portion of paragraph twenty-six of the complaint which states in part that "the Ziesensheims and/or their attorneys would not agree to the release language expressly releasing the subsequent negligent medical providers. . . ." Clearly there is an error in the complaint. As explained earlier in the majority opinion, the proposed release included an assignment of the Ziesensheims' medical malpractice claim to Hawk's Cay. Majority at 3. There was no intention on the part of any of the settling parties to release the medical providers.
In light of the evidentiary record developed at the motion to strike as sham, it seems unlikely that anything will change on remand. Nevertheless, the procedural objection relating to the motion to dismiss is well taken, and I would reverse without prejudice to the appellees to file a motion for summary judgment.
NOTES
[1]  Dr. Goldschlager is an employee of Emcare, but he was never personally served.
