diff --git a/app/[locale]/(app)/checkups/[id]/page.tsx b/app/[locale]/(app)/checkups/[id]/page.tsx index 37ae17a..d6b2eda 100644 --- a/app/[locale]/(app)/checkups/[id]/page.tsx +++ b/app/[locale]/(app)/checkups/[id]/page.tsx @@ -35,15 +35,31 @@ export default async function CheckupPage({ if (!c) notFound(); - const [{ data: customer }, { data: templates }] = await Promise.all([ + const [{ data: customer }, { data: templates }, { data: recentDiagnoses }] = await Promise.all([ supabase.from("customers").select("last_name, first_name, dob, gender, phone").eq("id", c.customer_id).maybeSingle(), supabase .from("checkup_templates") .select("id, name, gender, fields") .eq("deleted", false) .order("name", { ascending: true }), + supabase + .from("checkups") + .select("diagnosis") + .not("diagnosis", "is", null) + .eq("deleted", false) + .order("checkup_date", { ascending: false }) + .limit(200), ]); + // De-dupe + trim recent diagnoses for the quick-pick, capped at 50 entries. + const diagnosisSuggestions = [ + ...new Set( + (recentDiagnoses ?? []) + .map((r) => r.diagnosis?.trim()) + .filter((d): d is string => !!d), + ), + ].slice(0, 50); + const patientName = customer ? `${customer.last_name} ${customer.first_name}` : "—"; // Prefer templates matching the patient's gender (or applicable to "any"); @@ -113,6 +129,7 @@ export default async function CheckupPage({ templates={templateOptions} initialTemplateId={c.template_id} initialTemplateValues={templateValues} + diagnosisSuggestions={diagnosisSuggestions} />
{t("title")}
diff --git a/app/[locale]/(app)/checkups/[id]/prescription/prescription-composer.tsx b/app/[locale]/(app)/checkups/[id]/prescription/prescription-composer.tsx index b396122..5477e03 100644 --- a/app/[locale]/(app)/checkups/[id]/prescription/prescription-composer.tsx +++ b/app/[locale]/(app)/checkups/[id]/prescription/prescription-composer.tsx @@ -17,6 +17,7 @@ import { useTranslations } from "next-intl"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { dosePresets } from "@/lib/billing/dose-presets"; import { paymentMethods, type MarkPaidState, @@ -24,6 +25,8 @@ import { } from "@/lib/billing/prescription-schema"; import { markPaidAction, savePrescriptionAction } from "./actions"; +const DOSE_PRESETS_LIST_ID = "dose-presets"; + const vnd = (n: number) => `${new Intl.NumberFormat("vi-VN").format(n)} ₫`; const SELECT = @@ -120,6 +123,12 @@ export function PrescriptionComposer({ return (