"use client"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { Skeleton } from "@/components/ui/skeleton"; import type { AllergySeverity, LabFlag, Patient } from "@/lib/patients"; type BadgeVariant = "default" | "secondary" | "destructive" | "outline"; type PatientResultProps = { status: "loading" | "ready" | "not-found"; fileNumber: string; patient?: Patient; }; const severityVariant: Record = { mild: "outline", moderate: "secondary", severe: "destructive", }; const labFlagVariant: Record = { normal: "outline", low: "secondary", high: "secondary", critical: "destructive", }; const statusVariant: Record = { active: "secondary", inpatient: "destructive", discharged: "outline", }; const sexLabel: Record = { F: "Female", M: "Male" }; function SectionLabel({ children }: { children: string }) { return (

{children}

); } function SummaryCard({ patient }: { patient: Patient }) { return (
{patient.initials}
{patient.name} {patient.age} · {sexLabel[patient.sex]} · MRN {patient.fileNumber}
{patient.status}
Primary care: {patient.pcp}
); } function AllergiesCard({ patient }: { patient: Patient }) { return ( Allergies & alerts {patient.alerts.length > 0 && (
{patient.alerts.map((alert) => ( {alert} ))}
)}
Allergies {patient.allergies.length === 0 ? (

No known allergies.

) : ( patient.allergies.map((allergy) => (
{allergy.substance} {" "} — {allergy.reaction} {allergy.severity}
)) )}
); } function MedicationsCard({ patient }: { patient: Patient }) { return ( Medications & problems
Active medications {patient.medications.map((med) => (
{med.name} {med.dose} · {med.frequency}
))}
Problem list {patient.problems.map((problem) => (
{problem.label} since {problem.since}
))}
); } function VitalsCard({ patient }: { patient: Patient }) { const { vitals } = patient; const vitalItems = [ { label: "BP", value: vitals.bp }, { label: "HR", value: vitals.hr }, { label: "Temp", value: vitals.temp }, { label: "SpO₂", value: vitals.spo2 }, ]; return ( Vitals, labs & visits Vitals taken {vitals.takenAt}
{vitalItems.map((item) => (
{item.label} {item.value}
))}
Recent labs {patient.labs.map((lab) => (
{lab.name}
{lab.value} {lab.flag}
))}
Recent visits {patient.encounters.map((encounter) => (
{encounter.type} {encounter.date}
{encounter.summary} {encounter.provider}
))}
); } function LoadingCards() { return ( <>
{[0, 1, 2].map((card) => ( {[0, 1, 2].map((row) => ( ))} ))} ); } export function PatientResult({ status, fileNumber, patient }: PatientResultProps) { if (status === "not-found") { return (

No patient found for file #{fileNumber}.

); } return (
{status === "loading" || !patient ? ( ) : ( <> )}
); }