feat: org-scoped prescriptions backend, wire prescriptions page

Add the prescriptions table, validation, service and CRUD routes
(/api/prescriptions, RBAC-gated; prescriber defaults to the signed-in
clinician, prescribedAt to today) and the frontend data module. The page
now loads/persists real data and computes its status KPIs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalid Abdi
2026-06-07 19:37:46 +03:00
parent dec04ec506
commit 7ef9da59bd
14 changed files with 2195 additions and 111 deletions
+21
View File
@@ -0,0 +1,21 @@
// The canonical Prescription shape returned by the API. Mirrors the frontend
// `lib/prescriptions.ts` Prescription type. Scoped to the active clinic; patient
// fields are denormalized for display and `fileNumber` links to a patient.
export type PrescriptionStatus = "active" | "completed" | "expired";
export type Prescription = {
id: string;
fileNumber: string;
name: string;
initials: string;
medication: string;
dose: string;
frequency: string;
prescriber: string;
prescribedAt: string; // YYYY-MM-DD
status: PrescriptionStatus;
duration: string | null;
notes: string | null;
createdAt: string;
updatedAt: string;
};