"use client"; import { CircleCheck, Clock, Pill, Plus } from "lucide-react"; import { type ReactNode, useState } from "react"; import { AddPrescriptionDialog, type NewPrescription, } from "@/components/prescriptions/add-prescription-dialog"; import { PrescriptionDetailSheet } from "@/components/prescriptions/prescription-detail-sheet"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; // All figures here are mock/placeholder data — there is no prescriptions backend. // They illustrate the Prescriptions layout. export type RxStatus = "active" | "completed" | "expired"; export type Prescription = { fileNumber: string; name: string; initials: string; medication: string; dose: string; frequency: string; prescriber: string; date: string; status: RxStatus; duration?: string; notes?: string; }; const statusVariant: Record< RxStatus, "default" | "secondary" | "destructive" | "outline" > = { active: "default", completed: "outline", expired: "destructive", }; const statusLabel: Record = { active: "Active", completed: "Completed", expired: "Expired", }; const kpis = [ { label: "Active", value: "8", icon: Pill }, { label: "Due refill", value: "3", icon: Clock }, { label: "Completed", value: "27", icon: CircleCheck }, ]; const initial: Prescription[] = [ { fileNumber: "10293", name: "Amina Yusuf", initials: "AY", medication: "Lisinopril", dose: "10 mg", frequency: "Once daily", prescriber: "Dr. Okafor", date: "Jun 5, 2026", status: "active", }, { fileNumber: "10311", name: "Daniel Mensah", initials: "DM", medication: "Metformin", dose: "500 mg", frequency: "Twice daily", prescriber: "Dr. Okafor", date: "Jun 4, 2026", status: "active", }, { fileNumber: "10342", name: "Leila Haddad", initials: "LH", medication: "Amoxicillin", dose: "500 mg", frequency: "Three times daily", prescriber: "Dr. Stein", date: "May 28, 2026", status: "completed", }, { fileNumber: "10358", name: "Carlos Rivera", initials: "CR", medication: "Atorvastatin", dose: "20 mg", frequency: "Once daily", prescriber: "Dr. Okafor", date: "May 12, 2026", status: "expired", }, { fileNumber: "10377", name: "Priya Nair", initials: "PN", medication: "Salbutamol inhaler", dose: "100 mcg", frequency: "As needed", prescriber: "Dr. Stein", date: "Jun 1, 2026", status: "active", }, ]; function Kpi({ label, value, icon: Icon, }: { label: string; value: string; icon: typeof Pill; }) { return (
{label} {value}
); } function RxRow({ rx, onOpen }: { rx: Prescription; onOpen: () => void }) { return (
{ if (event.key === "Enter" || event.key === " ") { event.preventDefault(); onOpen(); } }} role="button" tabIndex={0} > {rx.initials}
{rx.medication} {rx.dose && ( · {rx.dose} )} {rx.name} · #{rx.fileNumber} · {rx.frequency}
{rx.prescriber} {rx.date}
{statusLabel[rx.status]}
); } function Section({ title, description, children, }: { title: string; description?: string; children: ReactNode; }) { return (

{title}

{description && (

{description}

)}
{children}
); } export function PrescriptionsView() { const [addOpen, setAddOpen] = useState(false); const [list, setList] = useState(initial); const [selected, setSelected] = useState(null); const [sheetOpen, setSheetOpen] = useState(false); const openRx = (rx: Prescription) => { setSelected(rx); setSheetOpen(true); }; // Insert a new (mock) prescription at the top of the list, marked active. const addPrescription = (rx: NewPrescription) => { setList((prev) => [ { fileNumber: rx.fileNumber, name: rx.name, initials: rx.initials, medication: rx.medication, dose: rx.dose, frequency: rx.frequency, duration: rx.duration || undefined, notes: rx.notes || undefined, prescriber: "Dr. Okafor", date: new Date().toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", }), status: "active" as const, }, ...prev, ]); }; return (

Prescriptions

Medications prescribed across the clinic. Sample data.

{kpis.map((k) => ( ))}
{list.map((rx) => ( openRx(rx)} rx={rx} /> ))}
); }