Add patient: intake form in the input that creates + opens a new chart

- chat-input: new "Add patient" pill (UserPlus) opens an intake dialog;
  remounts it via a key each open for a fresh file # / cleared form. On
  create it runs /patient <new#> so the record's cards open in the chat.
- add-patient-dialog: controlled Dialog + form — generated file # (with
  regenerate), identity (name/age/sex/status/PCP), current vitals, and
  repeatable allergies & medications. Save builds a Patient and adds it
  to the store. Save disabled until a name is entered.
- lib/patients: generateFileNumber() (unique) + addPatient() (session
  store; swap point for a real create API).
- patient-cards: graceful empty states (no labs / meds / problems /
  visits / trend) so a brand-new sparse chart renders cleanly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalid Abdi
2026-06-01 21:00:12 +03:00
parent eeae642751
commit bb7478433c
4 changed files with 523 additions and 51 deletions
+15
View File
@@ -266,3 +266,18 @@ export async function getPatient(fileNumber: string): Promise<Patient | null> {
await new Promise((resolve) => setTimeout(resolve, 700));
return PATIENTS[fileNumber.trim()] ?? null;
}
// Generate a unique 5-digit file number not already in the store.
export function generateFileNumber(): string {
let candidate: string;
do {
candidate = String(10000 + Math.floor(Math.random() * 89999));
} while (candidate in PATIENTS);
return candidate;
}
// Add (or replace) a patient in the in-memory store. Session-only — no backend
// yet, so this resets on reload. Swap point for a real "create patient" API.
export function addPatient(patient: Patient): void {
PATIENTS[patient.fileNumber] = patient;
}