import { DashboardLayout } from "@/components/layout/dashboard-layout"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { requirePatient } from "@/lib/auth-session/auth-server"; import { prisma } from "@/lib/types/prisma"; import type { Metadata } from "next"; import { FileText, Calendar, User } from "lucide-react"; export const metadata: Metadata = { title: "Health Records", }; // Force dynamic rendering since this page uses authentication (headers) export const dynamic = "force-dynamic"; export default async function HealthRecordsPage() { const { user } = await requirePatient(); const userDetails = await prisma.user.findUnique({ where: { id: user.id }, include: { appointmentsAsPatient: { where: { status: "completed", }, include: { service: true, dentist: true, }, orderBy: { date: "desc", }, }, }, }); return (

Health Records

Your medical history and treatment records

{/* Personal Information */} Personal Information

Full Name

{userDetails?.name}

Email

{userDetails?.email}

Phone

{userDetails?.phone || "Not provided"}

Date of Birth

{userDetails?.dateOfBirth ? new Date(userDetails.dateOfBirth).toLocaleDateString() : "Not provided"}

Address

{userDetails?.address || "Not provided"}

{/* Medical History */} Medical History Important medical information for your dentist {userDetails?.medicalHistory ? (

{userDetails.medicalHistory}

) : (

No medical history recorded

)}
{/* Treatment History */} Treatment History Completed dental procedures {!userDetails?.appointmentsAsPatient || userDetails.appointmentsAsPatient.length === 0 ? (

No treatment history

) : (
{userDetails.appointmentsAsPatient.map((appointment) => (

{appointment.service.name}

Dr. {appointment.dentist.name}

{new Date(appointment.date).toLocaleDateString()} at{" "} {appointment.timeSlot}

{appointment.notes && (

Notes:{" "} {appointment.notes}

)}
))}
)}
); }