# Shifa One — Demo Stories & Cases

Human-medical demo edition. Log in as **`shifa / 123456`** at
**https://localhost/shifa-one/public**. Rebuild any time with
`php artisan shifa:install --fresh`. See [Shifa-One-Logins.md](Shifa-One-Logins.md)
and [Shifa-One-Modules.md](Shifa-One-Modules.md).

## What's in the box (seeded)
- **1 business** "Shifa One", **3 locations** (Hospital — New Cairo, Clinic — Maadi, Central Pharmacy Store).
- **7 users** (owner + 6 staff), **3 bank/cash accounts** with opening balances.
- **55 products** across every type: managed-stock **pharmacy** & **human vaccines** & **medical supplies**, **controlled drugs**, a **cafeteria combo** (F&B), **clinical services**, **diagnostic imaging**, **laboratory tests**.
- **15 contacts**: 3 medical suppliers + 12 patients.
- **12 patients** across **12 specialties**, each with its specialty profile.
- **10 appointments** (completed / confirmed / pending / no-show / cancelled), **3 e-prescriptions**, **7 vaccinations** (incl. overdue + an upcoming booster), **3 medical reports**.
- **2 lab result sets** (CBC + Chemistry, abnormal flags) + **1 pending lab order**, all linked to patients.
- **2 care plans** + **4 active subscriptions** (membership contracts).
- **5 POS sells** (paid / partial / due) + **1 received purchase**.

---

## Story 1 — Patient journey: registration → specialist consult → e-prescription
1. **Reception** registers a patient (a `clc_patients` row 1:1 with an `App\Contact`),
   choosing a **Default Specialty** (e.g. Cardiology). The matching specialty profile
   card (`cardiology_patient_profiles`) appears on the patient record.
2. **Dr. Yasmin** opens the patient's appointment, records **vitals** (BP/pulse/temp/SpO₂/
   glucose/BMI) and a **SOAP** note (Subjective/Objective/Assessment/Plan).
3. She issues an **e-prescription** (`clc_prescriptions` + items) from the medicine catalogue.
4. **Pharmacist** dispenses; the visit is billed at the **POS**.
   → Try patient **Ahmed Saleh** (`/clinic/patients`).

## Story 2 — Multi-specialty views (one engine, many shapes)
Open these patients to see the **same core engine** render different specialty cards:
- **Dental** patient → interactive **tooth chart** (`dental_tooth_findings`: tooth 26 caries, 46 filled).
- **OB/Gyn** patient → pregnancy card with **GPAL** + computed **EDD** (from LMP).
- **Ophthalmology** patient → R/L visual acuity, refraction, **IOP** (left eye flagged high).
- **Endocrinology** patient → HbA1c / fasting glucose / TSH.

## Story 3 — Lab loop (ClinicLab → analyzer → ClinicWhatsApp)
1. A clinician **orders a lab test** for a patient → pending `lab_worklist` row (`/clinic-lab`).
2. The analyzer returns results → `lab_test_sessions` (linked by `clc_patient_id`) +
   `lab_test_results` with **abnormal flags** (seeded: WBC high; glucose/HbA1c/cholesterol high).
3. Results-ready WhatsApp goes to the patient:
   ```bash
   php artisan clinicwa:notify-lab-results --dry   # → notifies 2 patients (CBC-2001, CHEM-2002)
   ```

## Story 4 — Recalls (appointments + vaccination boosters)
```bash
php artisan clinicwa:send-recalls --dry
# [appt] next-day appointment reminder
# [vax]  upcoming booster (e.g. Tetanus Toxoid) due within 7 days
```
Overdue vaccinations are also visible on the patient records for follow-up.

## Story 5 — Controlled-drug governance
Medicines **Morphine / Pethidine / Diazepam / Tramadol / Phenobarbital** are flagged
`controlled_schedule` on `clc_medicines` (and stocked as products). Dispensing is gated
by the ClinicCore controlled-drug capability / register.

## Story 6 — Advanced 3-stage stock transfer
**Central Pharmacy Store → Hospital → Clinic** using **Advanced Transfer**
(`/tps-product/receive-stock`): **prepare → ship (with shipping cost) → receive**.

## Story 7 — Procurement: Purchase Requisition → PO (+ landed cost)
Raise a **Purchase Requisition**, compare supplier quotes, convert to a **PO**, and
allocate **landed cost**. One received purchase (`SHIFA-PO-0001`) is pre-seeded.

## Story 8 — AI assistant (medical vertical)
**AiCore** is set to the **`medical_clinic`** vertical, so the in-app assistant uses a
healthcare persona/guardrails (no diagnosis/dosing; refer clinical questions to a doctor).

## Story 9 — External integration (TPConnector OAuth)
```bash
curl -k -X POST https://localhost/shifa-one/public/api/tp-connector/login \
  -H "Content-Type: application/json" \
  -d '{"username":"shifa","password":"123456"}'
# → { "token_type": "Bearer", "access_token": "..." }
```

## Story 10 — Front-desk billing & cashflow
The **POS** shows 5 invoices with mixed payment status (paid / partial / due) plus the
received supplier purchase — exercising accounts, payments, and the **paid/partial/due**
reporting across the seeded transactions.
