
679 So.2d 836 (1996)
Lori Ann BOLZ, Appellant,
v.
STATE FARM MUTUAL AUTOMOBILE INSURANCE COMPANY, an Illinois corporation, Appellee.
No. 96-00070.
District Court of Appeal of Florida, Second District.
September 6, 1996.
Peter W. Martin of Peter W. Martin, Chartered, Sarasota, and Gerald C. Surfus of Surfus & Surfus, Sarasota, for Appellant.
*837 Richard R. Garland of Dickinson & Gibbons, P.A., Sarasota, for Appellee.
SCHOONOVER, Judge.
The appellant, Lori Ann Bolz, challenges a final judgment dismissing her action against the appellee, State Farm Mutual Automobile Insurance Company, on the basis of res judicata. We reverse.
Ms. Bolz filed this action against State Farm seeking to recover damages for injuries she sustained as a result of an automobile accident. She claimed that State Farm was responsible for the damages pursuant to the uninsured/underinsured motorist provisions of her insurance policy with State Farm.
State Farm filed a motion to dismiss Ms. Bolz's complaint on the grounds that her action was barred by the doctrine of res judicata. Copies of motions for summary judgment and a final summary judgment in another action in which the parties were involved were attached to the motion.
After considering the motion and the argument of counsel, the trial court, based upon section 627.7403, Florida Statutes (1995), and upon the holding of Florida Patient's Compensation Fund v. St. Paul Fire & Marine Ins. Co., 535 So.2d 335 (Fla. 4th DCA 1988), approved, 559 So.2d 195 (Fla.1990), held that Ms. Bolz's cause of action was barred by the doctrine of res judicata and dismissed it with prejudice. This timely appeal followed.
Because the trial court erred in dismissing Ms. Bolz's complaint based upon a procedurally incorrect motion, we are not required to decide if the law relied upon by the trial court was properly applied in this matter or if Ms. Bolz was improperly denied her right to show "good cause" under section 627.7403, and because of the inadequate record furnished to us, we decline to do so.
State Farm sought to have Ms. Bolz's claim dismissed on the ground that it was barred by the doctrine of res judicata. A motion to dismiss is designed to test the legal sufficiency of a complaint, not to determine issues of fact. Lowery v. Lowery, 654 So.2d 1218 (Fla. 2d DCA 1995). In considering a motion to dismiss, the trial court is required to confine itself to the allegations contained within the four corners of the complaint. City of Clearwater v. United States Steel Corp., 469 So.2d 915 (Fla. 2d DCA 1985); see Livingston v. Spires, 481 So.2d 87 (Fla. 1st DCA 1986). Res judicata is an affirmative defense, and although affirmative defenses can be raised in a motion to dismiss if the allegations of the complaint demonstrate their existence, City of Clearwater, 469 So.2d at 916, the complaint in this case does not refer to the prior action. Since the court could not consider the pleadings attached to State Farm's motion, the court erred in dismissing the action on the basis of res judicata. Lowery, 654 So.2d at 1219; Lucas v. Davidson, 624 So.2d 865 (Fla. 2d DCA 1993); Livingston, 481 So.2d at 88.
We, therefore, reverse and remand to permit the action to proceed. In answering the complaint, State Farm may, of course, allege res judicata as an affirmative defense if it desires.
Reversed and remanded with instructions.
THREADGILL, C.J., and FULMER, J., concur.
