Files
temetro/frontend/lib/dispenses.ts
T
Khalid Abdi 307cc3cc64 frontend: clinical UI fixes + chat/composer polish
- 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>
2026-06-16 20:45:30 +03:00

47 lines
1.2 KiB
TypeScript

import { apiFetch } from "@/lib/api-client";
// A dispensing event — the record of a medication handed to a patient at the
// pharmacy. Mirrors the backend `src/types/dispense.ts`. Scoped to the active
// clinic; patient + dispenser fields are denormalized for display.
export type Dispense = {
id: string;
fileNumber: string;
name: string;
initials: string;
medication: string;
dose: string;
quantity: number;
unit: string;
prescriptionId: string | null;
dispensedBy: string | null;
dispensedByName: string;
dispensedAt: string; // ISO timestamp
notes: string | null;
createdAt: string;
};
// The fields the dispense action collects; the backend fills the dispenser
// identity (from the signed-in user) and the timestamp.
export type DispenseInput = {
fileNumber: string;
name: string;
initials?: string;
medication: string;
dose?: string;
quantity?: number;
unit?: string;
prescriptionId?: string | null;
notes?: string | null;
};
export function listDispenses(): Promise<Dispense[]> {
return apiFetch<Dispense[]>("/api/dispenses");
}
export function createDispense(input: DispenseInput): Promise<Dispense> {
return apiFetch<Dispense>("/api/dispenses", {
method: "POST",
body: JSON.stringify(input),
});
}