
    THE LLOYD NOLAND FOUNDATION, INC. v. HealthSOUTH CORPORATION.
    1041121.
    Supreme Court of Alabama.
    Aug. 24, 2007.
    
      Sydney F. Frazier, Jr., and Roy J. Crawford of Cabaniss, Johnston, Gardner, Dumas & O’Neal, LLP, Birmingham; Daniel J. Reynolds, Jr., Bessemer; J. Timothy Francis, Birmingham; and W. Ryan deGraffenried, Jr., of Watson, deGraffen-ried, Hardin & Tyra, Tuscaloosa, for appellant.
    Bruce F. Rogers and Charles K. Hamilton of Bainbridge, Mims, Rogers & Smith, LLP, Birmingham; and Jon B. Terry of Bains & Terry, Bessemer, for appellee.
   BOLIN, Justice.

The Lloyd Noland Foundation, Inc. (“the Foundation”), appeals from the Jefferson Circuit Court’s order granting a motion filed by HealthSouth Corporation to dismiss the Foundation’s complaint on the grounds of res judicata and collateral estoppel. We reverse and remand.

Facts and Procedural History

In 1996, the Foundation and Tenet Health System Medical, Inc., a subsidiary of Tenet Healthcare Corporation (“Tenet”), entered into a stock-purchase agreement pursuant to which Tenet acquired the stock and assets of the Lloyd Noland Hospital. The Foundation alleges that a number of contractual provisions were connected with this sale, including commitments from Tenet to provide health benefits to retired employees of the hospital, a long-term lease on the Foundation’s management offices at the hospital, an option to repurchase 120 licensed beds at the hospital (“the option beds”) for one dollar ($1.00), a duty to cooperate in obtaining the necessary certificates of need (“CONs”) and in licensing the option beds in the name of the Foundation, and a separate lease agreement providing space in the hospital for 55 of the option beds in a long-term acute-care unit. The Foundation also required Tenet to bind any successor owner to these same obligations.

Tenet operated the hospital for approximately three years then sold it to the City of Fairfield Healthcare Authority (“Fair-field”) in 1999. The sale to Fairfield involved four contracts: (1) an asset sale agreement executed on October 21, 1999; (2) a security agreement executed on November 15, 1999; (3) a six-month promissory note executed by Fairfield on November 15, 1999, in favor of Tenet; and (4) a guaranty agreement executed on November 15, 1999. The promissory note was extended by an “Agreement Regarding Amendment of Secured Promissory Note,” dated May 15, 2000. HealthSouth managed the hospital on behalf of Fairfield from 1999 to 2003 because Fairfield had no employees or assets; at that time, according to HealthSouth, HealthSouth “repossessed” the hospital. (HealthSouth’s brief at p. 4.) The hospital was subsequently closed.

On February 11, 2000, Fairfield brought a declaratory-judgment action in the Montgomery Circuit Court, seeking a judgment declaring that the Foundation was not entitled to CONs to reclassify 100 existing “acute-care” beds at the hospital to “long-term acute-care” hospital beds pursuant to § 22-21-265, Ala.Code 1975, and Ala. Admin. Code (SHPDA) r. 410-1-2-.19. The Foundation filed a counterclaim against Fairfield, alleging that Fairfield had expressly assumed the obligations of the contracts between Tenet and the Foundation, including the obligations of the lease agreement relating to 55 of the option beds and the duty to cooperate in obtaining the necessary CONs. The Montgomery Circuit Court entered a summary judgment in favor of Fairfield, and the Foundation appealed. This Court reversed the summary judgment and concluded that Fairfield was “contractually bound to, among other things, ‘cooperate with [the Foundation] in having the Option Beds relicensed, recertified or relocated for long term acute care purposes at the Hospital or at other sites,’ so that the Foundation could, following the issuance of the CONs, purchase up to 120 beds from Fairfield.” Lloyd Noland Found., Inc. v. City of Fairfield Healthcare Auth., 837 So.2d 253, 266 (Ala.2002).

On February 16, 2001, the Foundation sued Tenet in the United States District Court for the Northern District of Alabama, on the basis of diversity jurisdiction. The Foundation alleged that Tenet failed to ensure that certain obligations arising out of Tenet’s purchase of the hospital from the Foundation were met and sought damages under a guaranty agreement executed by Tenet and the Foundation in 1996. Specifically, the Foundation alleged that the obligations assumed by Tenet in its purchase of the hospital and guaranteed in the guaranty agreement were:

“(a) The obligation to resell to the Foundation for One Dollar ($1.00) 120 of the licensed acute-care hospital beds conveyed to [Tenet] by the Foundation pursuant to the Stock Purchase Agreement, such resale to take place when the Foundation became legally authorized to operate the beds for long-term acute-care services.
“(b) The obligation to cooperate with the Foundation in having the beds reli-censed, recertified or relocated for long-term acute-care services at the Lloyd Noland Hospital or at other locations.
“(c) The obligation to lease to the Foundation 19,000 square feet in the Lloyd Noland Hospital for the purposes of operating the long-term acute-care beds.
“(d) The obligation to provide certain medical benefits to retired employees of the Foundation.
“(e) The obligation to bind any successors or assigns of [Tenet] by the same duties and obligations to the Foundation which were required of [Tenet] under the Stock Purchase Agreement.
“(f) The obligation to obtain the prior written consent of the Foundation before any of the assets, rights and duties under the Stock Purchase Agreement were delegated or assigned by [Tenet] to a third party.”

The Foundation alleged that Tenet breached the following obligations:

“(a) [Tenet] breached its obligation to obtain written consent from the Foundation prior to the assignment of the assets, rights and duties under the Stock Purchase Agreement.
“(b) [Tenet] breached its obligation to ensure that the aforesaid terms and provisions of the Stock Purchase Agreement were binding and enforceable on [Fairfield] as the successor and assign of [Tenet], in that [Fairfield] has failed and refused to honor the aforesaid duties and obligations to the Foundation, contending instead that it has assumed none of those obligations. Instead [Fairfield] has intentionally, willfully, deliberately and maliciously set about to delay and destroy the Foundation’s contractual rights under the Stock Purchase Agreement by the following acts and conduct:
“(1) [Fairfield] has denied, rejected and repudiated each and all of the foregoing obligations of [Tenet] to the Foundation.
“(2) [Fairfield] has instituted litigation and administrative proceedings for the purpose of nullifying, delaying, preventing and otherwise interfering with and damaging the Foundation’s contractual rights under the Stock Purchase Agreement with [Tenet].
“(3) [Fairfield] has entered into contracts and agreements for the operation of the Lloyd Noland Hospital with a competitor of the Foundation as part of a plan, intent and design to interfere with and damage the Foundation’s contractual rights under the Stock Purchase Agreement with [Tenet].
“(4) [Fairfield] has failed and refused to honor the obligations of the medical benefit program for retirees of the Foundation.”

Subsequently, Tenet filed a third-party complaint against both Fairfield and HealthSouth, seeking indemnity based on a contractual provision in the agreement amending the six-month promissory note, which was executed on May 15, 2000. The provision stated as follows:

“Indemnification obligation: [Fair-field] and Guarantor [HealthSouth] shall jointly and severally indemnify Payee [Tenet] for any loss, damage, expenses, or costs (including attorney’s fees) incurred by Payee that are attributable to any claim by the Lloyd Noland Foundation, an Alabama nonprofit corporation (‘LNF’), based on acts or failure to act by [Fairfield] and/or Guarantor after the Closing Date (as such term is defined in the Asset Sale Agreement) with respect to ‘LNF beds’ as such term is used in Schedule 1.7(f) to the Asset Sale Agreement and/or the Lloyd Noland Retiree Medical Discount Program, referenced in Schedule 1.7(f).”

The promissory note was paid by HealthSouth on November 15, 2000. Both Fairfield and HealthSouth moved for a summary judgment in the federal litigation, arguing that the agreement amending the promissory note, which included the indemnity provision, expired when Health-South paid the promissory note in full. Additionally, Fairfield argued that it had not authorized HealthSouth to execute an indemnity agreement on its behalf. Tenet filed a motion for a partial summary judgment, arguing that the agreement to indemnify did not end when HealthSouth paid the promissory note.

On August 27, 2004, while the federal action was pending, the Foundation filed a complaint in the Birmingham Division of the Jefferson Circuit Court against HealthSouth based on alleged conduct related to the 1999 sale of the hospital by Tenet to Fairfield and the subsequent management of the hospital. The Foundation alleged that HealthSouth had misrepresented “that [Fairfield] was the purchaser of the Hospital” when, the Foundation alleged, Fairfield had no finances, no credit, no employees, and was not a duly organized entity. The Foundation also alleged fraudulent misrepresentation based on statements made when HealthSouth acquired the hospital from Fairfield in 2003. The Foundation alleged that HealthSouth had intentionally interfered with its contractual relations with Tenet when Health-South arranged the purchase of the hospital by Fairfield. The Foundation sought $15,000,000 in actual damages and $100,000,000 in punitive damages. In the alternative, the Foundation sought injunc-tive relief and a judgment declaring (1) that Fairfield was a mere instrumentality of HealthSouth; (2) that all the obligations that were assumed by Fairfield when it purchased the hospital in 1999 were binding on HealthSouth; (3) that this Court’s decision in Lloyd Noland Foundation, Inc. v. City of Fairfield Healthcare Authority, supra, upholding the Foundation’s rights under the stock-purchase agreement was binding on HealthSouth; (4) that Health-South was liable for damages resulting from the closure of the hospital; and (5) that HealthSouth was barred by the doctrine of equitable estoppel from failing to recognize the medical-benefit program of the Foundation’s retirees. The Foundation also sought to enjoin HealthSouth from assigning or selling the option beds provided to the Foundation under the stock-purchase agreement.

On October 4, 2004, HealthSouth filed a motion for a change of venue, seeking to transfer the case to the Bessemer Division of the Jefferson Circuit Court. Health-South attached an affidavit of an employee in support of the motion.

On November 4, 2004, the federal district court entered a summary judgment, granting in part and denying in part Fair-field’s motion for a summary judgment, granting HealthSouth’s motion for a summary judgment, and denying Tenet’s motion for a partial summary judgment. Lloyd Noland Found., Inc. v. Tenet Healthcare Corp., (No. 01-cv-0437-BE-S and 01-cv-1904-BE-S, November 9, 2004) (N.D.Ala.2004). Specifically, the district court concluded that the indemnity provision in the agreement amending the promissory note, dated May 15, 2000, expired upon payment of the promissory note. The court also held that the issue whether Fairfield had authorized HealthSouth to execute an indemnity agreement on its behalf was moot.

On November 22, 2004, HealthSouth filed its answer to the complaint filed in the Jefferson Circuit Court. On November 25, 2004, the case was transferred to the Bessemer Division. On January 28, 2005, HealthSouth filed a motion to dismiss the Foundation’s complaint pursuant to Rule 12(b)(6), Ala. R. Civ. P. On February 3, 2005, the trial court entered an order setting the motion to dismiss for a hearing on March 7, 2005. HealthSouth’s brief in support of its motion to dismiss, filed on February 28, 2005, asserted the following grounds for dismissal: that the Foundation’s fraud claim must fail because the Foundation did not allege direct injury as a result of its own reliance on Health-South’s alleged misrepresentations; that the Foundation’s intentional-interference claim must fail because HealthSouth was not a stranger to the business relationship at issue; that the Foundation’s request for declaratory relief does not state a justicia-ble controversy but merely seeks an advisory opinion; and that the Foundation is not entitled to injunctive relief. Health-South attached to its brief a copy of the Foundation’s complaint filed against Tenet in the federal litigation. HealthSouth also attached a copy of a purported amendment to the complaint filed in the federal action, but the amendment is not signed or dated, and it does not bear the federal court’s stamp showing that the amendment was filed.

On March 3, 2005, HealthSouth filed an amended answer raising the defenses of res judicata, collateral estoppel, equitable estoppel, and lack of privity between it and the Foundation. HealthSouth asserted that “the estoppel theories” were based on the federal litigation. On March 28, 2005, the Foundation filed a memorandum in opposition to HealthSouth’s motion to dismiss. On March 29, 2005, HealthSouth filed a supplemental brief in support of its motion to dismiss, arguing that the Foundation’s complaint should be dismissed on the grounds of res judicata and collateral estoppel based on the federal litigation. Attached to its supplemental brief was a copy of the federal court’s memorandum opinion entered on November 4, 2004.

On April 11, 2005, the Jefferson Circuit Court granted HealthSouth’s motion to dismiss. The entry on the case-action summary states: “HealthSouth Corporation’s motion to dismiss based on collateral estoppel and res judicata is granted. These same issues could have been raised in Federal Court Cases but were not.”

Standard of Review

We have set forth the standard of review that must be applied in reviewing a dismissal pursuant to Rule 12(b)(6), Ala. R. Civ. P.:

“On appeal, a dismissal is not entitled to a presumption of correctness. The appropriate standard of review under Rule 12(b)(6) is whether, when the allegations of the complaint are viewed most strongly in the pleader’s favor, it appears that the pleader could prove any set of circumstances that would entitle her to relief. In making this determination, this Court does not consider whether the plaintiff will ultimately prevail, but only whether she may possibly prevail. We note that a Rule 12(b)(6) dismissal is proper only when it appears beyond doubt that the plaintiff can prove no set of facts in support of the claim that would entitle the plaintiff to relief.”

Nance v. Matthews, 622 So.2d 297, 299 (Ala.1993) (citations omitted).

The trial court based its final order on the affirmative defenses of res judicata and collateral estoppel. Rule 8(c), Ala. R. Civ. P., provides that affirmative defenses shall be set forth in a responsive pleading. “Res judicata” and “estoppel” are two of the affirmative defenses listed in Rule 8(c). An affirmative defense is “[a] defendant’s assertion of facts and arguments that, if true, will defeat the plaintiffs or prosecution’s claim, even if all the allegations in the complaint are true.” Black’s Law Dictionary 451 (8th ed.2004). The party asserting the affirmative defense bears the burden of proving it. Stewart v. Brinley, 902 So.2d 1 (Ala.2004).

Generally, an affirmative defense is pleaded in a responsive pleading, such as an answer to a complaint. The reason affirmative defenses must be pleaded in a responsive pleading is to give the opposing party notice of the defense and a chance to develop evidence and offer arguments to controvert the defense. Blonder-Tongue Labs., Inc. v. University of Illinois, 402 U.S. 313, 350, 91 S.Ct. 1434, 28 L.Ed.2d 788 (1971). “Since the facts necessary to establish an affirmative defense generally must be shown by matters outside the complaint, the defense technically cannot be adjudicated on a motion under Rule 12[, Fed.R.Civ.P.].” 5 Charles Alan Wright and Arthur C. Miller, Federal Practice and Procedure § 1277 (3d ed.2004). However, a party can obtain a dismissal under Rule 12(b)(6), Ala. R. Civ. P., on the basis of an affirmative defense when “ ‘the affirmative defense appears clearly on the face of the pleading.’ ” Jones v. Alfa Mut. Ins. Co., 875 So.2d 1189, 1193 (Ala.2003)(quoting Braggs v. Jim Skinner Ford, Inc., 396 So.2d 1055, 1058 (Ala.1981)). In Jones v. Alfa, swpra, the face of the plaintiffs’ complaint did not indicate that the statutory limitations period applicable to their bad-faith refusal-to-pay-insurance-benefits claim had expired before they sued; therefore, the insurer was not entitled to a dismissal pursuant to Rule 12(b)(6), Ala. R. Civ. P., on the affirmative defense of the statute of limitations.

In Wilger v. State Department of Pensions & Security, 390 So.2d 656 (Ala.Civ.App.1980), the father filed a custody petition for six of his children who were under the care and custody of the Department of Pensions and Security. The Department did not file a responsive pleading or motion but argued at trial that to allow the father to retry the custody issue would be contrary to the doctrine of res judicata. The trial court dismissed the father’s petition. The Court of Civil Appeals reversed the judgment of the trial court because the record did not contain the necessary pleadings and proof to support the judgment of dismissal. The court noted that res judi-cata was an affirmative defense that should be pleaded under Rule 8, Ala. R. Civ. P., and that the Department had the burden of proving from the evidence the sufficiency of the defense. “In some instances, res judicata may be properly raised by means of a motion to dismiss or, more commonly, through a motion for a summary judgment.” 390 So.2d at 657.

In the present case, the Foundation’s complaint does not mention the federal litigation. In response to the Foundation’s complaint, HealthSouth, in compliance with Rule 8(c), Ala. R. Civ. P., pleaded res judicata and collateral es-toppel in its amended answer. Health-South filed a “motion to dismiss,” and, in a supplemental brief in support of its motion to dismiss, it addressed the doctrines res judicata and collateral estoppel. Additionally, HealthSouth attached filings from the federal court proceeding. Although HealthSouth’s motion addressing its defenses of res judicata and collateral estoppel was actually framed as a “motion to dismiss,” the motion should have been treated as one seeking a summary judgment because the face of the eom-plaint did not reference the prior litigation and HealthSouth properly pleaded res judicata and collateral estoppel in its answer. The substance of a motion, not what a party calls it, determines the nature of the motion. Ex parte Lewter, 726 So.2d 603 (Ala.1998). Furthermore, the trial court clearly considered matters outside the pleadings in making its determination, thus converting the Rule 12(b)(6) motion to dismiss into a Rule 56, Ala. R. Civ. P., summary-judgment motion. Although neither party has raised the issue of the appropriateness of converting the motion from a motion to dismiss to a motion for a summary judgment, we address this matter because it implicates our standard of review. We find persuasive the following text addressing affirmative defenses under the Federal Rules of Civil Procedure:

“Obviously, as many cases make clear, on a motion for summary judgment district courts may consider evidence beyond the pleadings bearing on a defendant’s challenge to a claim for relief that falls within the scope of the Rule 8(c) affirmative defenses. In addition, both Rule 12(b) and Rule 12(c) provide that when affidavits or other matter outside the pleadings is presented to the district court on a motion to dismiss or for judgment on the pleadings and this matter is not excluded by the court, the motion ‘shall be treated’ as one for summary judgment. Thus, in practice, courts that allow the adjudication of affirmative defenses on a motion to dismiss or for judgment on the pleadings after permitting the parties to include extra-pleading materials are converting these motions into summary judgment motions; this requires the court to give all parties notice and the opportunity provided by Rule 56 to present pertinent evidentiary material to the district judge. This procedure obviates the danger that the assertion of an affirmative defense by a motion to dismiss under Rule 12 might deprive the plaintiff of an adequate opportunity to present arguments rebutting the defense. However, it must be remembered that disputes over material issues of fact cannot be resolved on a motion to dismiss or for summary judgment but must be reserved for resolution at trial by the appropriate trier.”

5 Wright and Miller, supra, § 1277 (footnotes omitted).

Our standard of review for a summary judgment is as follows:

“We review the trial court’s grant or denial of a summary-judgment motion de novo, and we use the same standard used by the trial court to determine whether the evidence presented to the trial court presents a genuine issue of material fact. Bookman v. WCH, L.L.C., 943 So.2d 789 (Ala.2006). Once the summary-judgment movant shows there is no genuine issue of material fact, the nonmovant must then present substantial evidence creating a genuine issue of material fact. Id. We review the evidence in a light most favorable to the nonmovant.’ 943 So.2d at 795. We review questions of law de novo. Davis v. Hanson Aggregates Southeast, Inc., 952 So.2d 330 (Ala.2006).”

Smith v. State Farm Mut. Auto. Ins. Co., 952 So.2d 342, 346 (Ala.2006).

Analysis

The trial court concluded that the Foundation’s complaint was barred by the doctrines of res judicata and collateral estop-pel based on the federal litigation.

Res Judicata

The elements of res judicata are: “(1) a prior judgment on the merits, (2) rendered by a court of competent jurisdiction, (3) with substantial identity of parties, and (4) with the same cause of action presented in both actions.” Equity Res. Mgmt., Inc. v. Vinson, 723 So.2d 634, 636 (Ala.1998). “If those four elements are present, then any claim that was, or that could have been, adjudicated in the prior action is barred from further litigation.” 723 So.2d at 636. “Res judicata, therefore, bars a party from asserting in a subsequent action a claim that it has already had an opportunity to litigate in a previous action.” Lee L. Saad Constr. Co. v. DPF Architects, P.C., 851 So.2d 507, 517 (Ala.2002).

The federal litigation involved claims by the Foundation against Tenet, in which the Foundation alleged that Tenet had failed to ensure that certain obligations arising out of Tenet’s purchase of the hospital from the Foundation were met, including providing health benefits to the retired employees of the hospital, the option to repurchase 120 licensed beds, a duty to cooperate in having the beds relicensed for long-term acute care, and an obligation to lease space from the Foundation to operate the long-term acute-care beds. Pursuant to Rule 14, Fed.R.Civ.P., Tenet filed a third-party complaint against Fairfield and HealthSouth in the federal litigation seeking indemnity. HealthSouth moved for a summary judgment, which the federal district court granted because it found that the indemnity provision in the agreement amending the promissory note, dated May 15, 2000, expired upon payment of the promissory note and that HealthSouth thus was under no duty to indemnify Tenet in the federal litigation. HealthSouth now argues that the summary-judgment order in the federal litigation precludes the Foundation’s present claims against it because “[t]his case involves the same alleged primary rights and duties, as well as the same damages and requests for relief.” (HealthSouth’s brief at 30.)

The trial court’s order dismissing the present action indicates that Health-South’s motion to dismiss on the basis of the doctrine of res judicata was granted because those same claims could have been raised in the federal litigation but were not. The Foundation argues that the claims it now asserts against HealthSouth are not barred by its failure to assert them in the federal litigation because not all the elements of res judicata are met. The Foundation further argues that its present action should not be barred in that it was prevented from bringing the present claims in the federal litigation because the federal district court did not have supplemental jurisdiction over the claims it now asserts against HealthSouth. We do not decide whether the same parties or their privies were involved in the federal litigation, nor do we decide whether the present action arises from the same cause of action as did the federal litigation. We proceed instead to consider whether the Foundation was required to raise these issues in the federal litigation based on supplemental jurisdiction.

The grant of diversity jurisdiction is codified at 28 U.S.C. § 1332. The purpose of diversity “is to provide a federal forum for important disputes where state courts might favor, or be perceived as favoring, home-state litigants.” Exxon Mobil Corp. v. Allapattah Servs., Inc., 545 U.S. 546, 553-54, 125 S.Ct. 2611, 162 L.Ed.2d 502 (2005). The federal courts developed the common-law doctrines of pendant jurisdiction (allowing state-law claims linked to federal claims in federal court) and ancillary jurisdiction (allowing nondiverse parties linked to diverse parties in federal court) to avoid piecemeal litigation. In 1990, Congress codified the doctrines of pendant and ancillary jurisdiction at 28 U.S.C. § 1367, as “supplemental jurisdiction.” Section 1367(a) establishes that supplemental jurisdiction is generally applicable in diversity cases. However, subsection (b) makes an important exception:

“(b) In any civil action of which the district courts have original jurisdiction founded solely on section 1332 of this title, the district courts shall not have supplemental jurisdiction under subsection (a) over claims by plaintiffs against persons made parties under Rule 14, 19, 20, or 24 of the Federal Rules of Civil Procedure, or over claims by persons proposed to be joined as plaintiffs under Rule 19 of such rules, or seeking to intervene as plaintiffs under Rule 24 of such rules, when exercising supplemental jurisdiction over such claims would be inconsistent with the jurisdictional requirements of section 1332.”

“Although ancillary and pendent jurisdiction now are both codified in a new statutory jurisdiction, termed supplemental jurisdiction, that form of jurisdiction is not available in actions premised on diversity of citizenship over ‘claims by plaintiffs against persons made parties under Rule 14, 19, 20, or 24.’ ” 6 Charles Alan Wright et al., Federal Practice and Procedure § 1444 (2d ed.1990). To allow otherwise would let the “plaintiff ... defeat the statutory requirement of complete diversity by the simple expedient of suing only those defendants who were of diverse citizenship and waiting for them to implead nondi-verse defendants.” Owen Equip. & Erection Co. v. Kroger, 437 U.S. 365, 374, 98 S.Ct. 2396, 57 L.Ed.2d 274 (1978) (footnote omitted).

For purposes of diversity, a corporation is deemed a citizen of any state where it is incorporated and where it has its principal place of business. 28 U.S.C. § 1382(c). The Foundation’s complaint against Tenet in the federal litigation was based solely on diversity of citizenship. Tenet impleaded HealthSouth as a third-party defendant in the federal litigation. Both the Foundation and HealthSouth have their principal places of business in Alabama. In the federal litigation, the mandate of complete diversity would have applied to the Foundation’s claims against third-party defendant HealthSouth. Because § 1367(b) barred the exercise of supplemental jurisdiction over the Foundation’s state-law claims against HealthSouth, the Foundation is correct in its assertion that it was prohibited from asserting its state-law claims against HealthSouth in the federal litigation.

HealthSouth does not dispute that it and the Foundation were both citizens of the same state. Instead, Health-South argues that the Foundation could have chosen to bring its claims against Tenet in state court rather than in federal court. This Court has stated that for purposes of res judicata, the prior judgment must be rendered by a court of competent jurisdiction. A court of competent jurisdiction is a court with jurisdiction over the subject matter. If a court lacks jurisdiction over a claim, then that claim would not qualify as one that “might have been tried” by that court.

The doctrine of res judicata does not necessarily apply when “[t]he plaintiff was unable to rely on a certain theory ... or to seek a certain remedy or form of relief in the first action because of the limitations on the subject matter jurisdiction of the courts or restrictions on their authority to entertain multiple theories or demands for multiple remedies or forms of relief in a single action .... ” Restatement (Second) of Judgments § 26 (1982). In other words, “[i]f the court rendering judgment lacked subject-matter jurisdiction over a claim or if the procedural rules of the court made it impossible to raise a claim, then it is not precluded.” Browning v. Navarro, 887 F.2d 553, 558 (5th Cir.1989). The Foundation was not able to assert its claims against Health-South in the federal litigation. As a result, the trial court erred in concluding that the affirmative defense of res judicata prevented the Foundation from bringing its claims against HealthSouth in state court.

Collateral Estoppel

The trial court also based its judgment on the doctrine of collateral estoppel. Collateral estoppel applies when (1) the issue in a prior case was identical to the issue being litigated in the present action, (2) the issue was actually litigated in the prior action by a court of competent jurisdiction, (3) resolution of that issue was necessary to the prior judgment, and (4) the same parties are involved in the two actions. Smith v. Union Bank & Trust, 653 So.2d 933 (Ala.1995); Reed v. Brookwood Med. Ctr., 641 So.2d 1245 (Ala.1994).

The doctrine of collateral es-toppel is not applicable in the present case. The order in the federal litigation granting HealthSouth’s summary-judgment motion addressed only the indemnity clause in Tenet and HealthSouth’s agreement amending the promissory note, dated May 15, 2000. The Foundation’s complaint in the present action involves HealthSouth’s alleged conduct related to the 1999 sale and the subsequent management of the hospital. The issue addressed by the holding in the federal litigation — whether HealthSouth had to indemnify Tenet — is not identical to any of the issues to be addressed in the present litigation. Furthermore, collateral estoppel is not applicable where the plaintiff was unable to seek a certain remedy or form of relief in the first action because of the limitations on the subject-matter jurisdiction of the courts. See Restatement (Second) of Judgments § 26 (1982). Collateral estop-pel does not apply where it is “asserted in an action over which the court rendering the prior judgment would not have had subject matter jurisdiction.” Restatement (Second) of Judgments § 28(3) cmt. d (1982). “[Ajffcer a court has incidentally determined an issue that it lacks jurisdiction to determine directly, the determination should not be binding when a second action is brought in a court having such jurisdiction.” Restatement (Second) of Judgments § 28(3) cmt. d. As discussed above, the federal court lacked supplemental jurisdiction over the Foundation’s state-law claims against HealthSouth. Therefore, the trial court erred in concluding that the Foundation’s claims were barred by the doctrine of collateral estop-pel.

Other Grounds

HealthSouth argues that this Court could affirm the trial court’s judgment on the other grounds raised in its original “motion to dismiss.” An appellate court may affirm the judgment of the trial court when the trial court has reached the right result for the wrong reason. Bay Lines, Inc. v. Stoughton Trailers, Inc., 838 So.2d 1013, 1017 (Ala.2002). However, this rule should not apply where the “wrong reason” prevented a party from properly presenting his case or prejudiced his rights. In the present case, based on the record before us, it appears that the trial court entered its judgment solely on the grounds of res judicata and collateral es-toppel. On January 28, 2005, HealthSouth filed a motion to dismiss. On February 3, 2005, the trial court entered an order setting the motion to dismiss for a hearing on March 7, 2005. On February 28, 2005, HealthSouth filed a brief in support of that motion, alleging: that the Foundation’s fraud claim must fail because it did not allege direct injury as a result of its own reliance on HealthSouth’s alleged misrepresentations; that the Foundation’s intentional-interference claim must fail because HealthSouth was not a stranger to the business relationship at issue; that the Foundation’s request for declaratory relief does not state a justiciable controversy but merely seeks an advisory opinion; and that the Foundation is not entitled to in-junctive relief. On March 3, 2005, Health-South filed an amended answer, alleging the affirmative defenses of res judicata and collateral estoppel. Apparently, the hearing was held on March 7, 2005, as scheduled. On March 29, 2005, Health-South filed a supplemental brief, addressing solely the issues of res judicata and collateral estoppel and putting forward evidence in support of those two affirmative defenses. On April 11, 2005, the trial court entered its order stating: “Health-South Corporation’s motion to dismiss based on collateral estoppel and res judica-ta is granted. These same issues could have been raised in Federal Court Cases but were not.”

This Court has held that when a Rule 12(b)(6), Ala. R. Civ. P., motion is converted by the trial court through consideration of matters outside the pleadings into a Rule 56, Ala. R. Civ. P., motion for a summary judgment, the nonmoving party must be given notice of the trial court’s intentions. Hales v. First Nat’l Bank, 380 So.2d 797 (Ala.1980). A Rule 12(b)(6) motion addresses the claim itself. The mov-ant is asserting that the particular pleading to which the motion is directed does not sufficiently state a claim on which relief can be granted. It does not challenge the actual existence of a meritorious claim. In contrast, a summary judgment is based on the pleadings and any affidavits, depositions, and other forms of evidence relative to the merits of the challenged claim or defense. In its original motion to dismiss, HealthSouth tested the sufficiency of the Foundation’s complaint, not the merits. In its answer and supplemental brief, Health-South challenged the Foundation’s complaint on the grounds of res judicata and collateral estoppel pursuant to a Rule 56 summary-judgment motion. To now review the trial court’s judgment pursuant to the summary-judgment standard on the additional grounds raised in HealthSouth’s original motion to dismiss would be unfair because neither party has had the opportunity to present affidavits and other evidence to support the grounds raised in the original motion to dismiss. Accordingly, we pretermit discussion of the other grounds raised by HealthSouth.

Conclusion

The judgment of the trial court is reversed and the cause is remanded for further proceedings.

REVERSED AND REMANDED.

COBB, C.J., and SEE, STUART, SMITH, and MURDOCK, JJ., concur.

LYONS and WOODALL, JJ., concur in part and concur in the result.

PARKER, J., recuses himself.

LYONS, Justice

(concurring in part and concurring in the result).

I concur in all aspects of the main opinion except for the rationale for not reaching the additional grounds relied upon by HealthSouth in its motion to dismiss. As to that issue, I concur in the result because the trial court has not yet ruled on those grounds.

WOODALL, J., concurs. 
      
      . Rule 15(a), Ala. R. Civ. P., provides:
      "Unless a court has ordered otherwise, a party may amend a pleading without leave of court, but subject to disallowance on the court’s own motion or a motion to strike of an adverse party, at any time more than forty-two (42) days before the first setting of the case for trial, and such amendment shall be freely allowed when justice so requires. Thereafter, a party may amend a pleading only by leave of court, and leave shall be given only upon a showing of good cause."
     
      
      . In Lee L. Saad Constr., 851 So.2d at 520 n. 6, this Court cited the Restatement (Second) of Judgments § 26 (1982), Reporter's Note to comment c(l), which provides:
      "When the plaintiff, after having lost a state action, seeks relief with respect to the same transaction under a federal statute enforceable only in federal court, it may be argued that he should be held barred especially if he could have instituted his original suit in federal court where both federal and state grounds could have been considered .... It appears sounder, however, not to preclude the federal action by the doctrine of bar, but rather to allow a carry-over decided issue from the state to the federal action by way of issue preclusion
      (Emphasis omitted; emphasis added.) HealthSouth presents the flip side of this argument (barring a plaintiff from going to federal court when he could have resolved everything in state court). The comment above rejects the application of res judicata; however, collateral estoppel may be applicable. That is, although res judicata does not bar claims over which the first court lacked jurisdiction, the first court's decisions on issues common to those before the second court may have preclusive effect under the doctrine of collateral estoppel.
     
      
      . The Foundation's original brief to this Court addresses only the issues of res judicata and collateral estoppel. HealthSouth’s brief addresses those issues, as well as the four grounds asserted in its motion to dismiss. In its reply brief, the Foundation addresses the additional grounds argued by HealthSouth. This comports with this Court's interpretation of the rules of appellate review. See Pavilion Dev., LLC v. JBJ P’ship, 979 So.2d 24 (Ala.2007)(where the trial court specifies a basis for its ruling, the appellant does not waive additional arguments not addressed in its principal brief).
     