mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 20:08:14 +00:00
307cc3cc64
- chat composer: attach works with text (sr-only file input); lighter bordered input box - messages: defer "+" menu actions past close so file/appointment pickers fire - tasks: top-level New task button - chat: condensed appointment card with "View in calendar" deep-link; appointments page auto-opens the month calendar from ?calendar=&date= - lab: work-queue rows expand to show task detail + complete - inventory: clickable item detail dialog - pharmacy: Dispense action records a dispense + "Recently dispensed" feed; expiring badge uses endDate and only flags <=2 days left - prescriptions: keyboard nav in patient search, inventory-backed medication combobox (free-text fallback), optional start/end dates; thread dates through - sidebar: whole nav scrolls as one - i18n keys for all new strings Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
81 lines
2.2 KiB
TypeScript
81 lines
2.2 KiB
TypeScript
import { apiFetch } from "@/lib/api-client";
|
|
|
|
// A prescription. Mirrors the backend `src/types/prescription.ts`. Scoped to the
|
|
// active clinic. `prescribedAt` is an ISO YYYY-MM-DD date.
|
|
export type RxStatus = "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
|
|
startDate: string | null; // YYYY-MM-DD, optional course start
|
|
endDate: string | null; // YYYY-MM-DD, optional course end (drives expiry)
|
|
status: RxStatus;
|
|
duration: string | null;
|
|
notes: string | null;
|
|
source: "manual" | "ai"; // "ai" = drafted by the chat agent, flag for review
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
// The fields the "New prescription" dialog collects; the backend fills the
|
|
// prescriber (from the signed-in user), prescribedAt (today) and status.
|
|
export type PrescriptionInput = {
|
|
fileNumber: string;
|
|
name: string;
|
|
initials: string;
|
|
medication: string;
|
|
dose: string;
|
|
frequency: string;
|
|
duration?: string | null;
|
|
notes?: string | null;
|
|
prescriber?: string;
|
|
prescribedAt?: string;
|
|
startDate?: string | null;
|
|
endDate?: string | null;
|
|
status?: RxStatus;
|
|
source?: "manual" | "ai";
|
|
};
|
|
|
|
// "2026-06-05" -> "Jun 5, 2026" (matches the previous mock display format).
|
|
export function formatPrescribedAt(iso: string): string {
|
|
return new Date(`${iso}T00:00:00`).toLocaleDateString("en-US", {
|
|
month: "short",
|
|
day: "numeric",
|
|
year: "numeric",
|
|
});
|
|
}
|
|
|
|
export function listPrescriptions(): Promise<Prescription[]> {
|
|
return apiFetch<Prescription[]>("/api/prescriptions");
|
|
}
|
|
|
|
export function createPrescription(
|
|
input: PrescriptionInput,
|
|
): Promise<Prescription> {
|
|
return apiFetch<Prescription>("/api/prescriptions", {
|
|
method: "POST",
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function updatePrescription(
|
|
id: string,
|
|
input: PrescriptionInput,
|
|
): Promise<Prescription> {
|
|
return apiFetch<Prescription>(`/api/prescriptions/${id}`, {
|
|
method: "PUT",
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function deletePrescription(id: string): Promise<void> {
|
|
return apiFetch<void>(`/api/prescriptions/${id}`, { method: "DELETE" });
|
|
}
|