# HMS Prototype — Implementation Plan

## Sprint 1: Foundation (first functional milestone)

1. Generate a compatible Laravel skeleton, verify Composer lockfile, establish PHPUnit/Pest tests and CI.
2. Build authentication, secure sessions and role/permission checks.
3. Implement platform tenant registry, tenant context resolver and tenant-aware persistence.
4. Create facility and department management.
5. Add a staff dashboard and navigation with a consistent UI.
6. Establish immutable audit events for important administrative changes.
7. Add automated cross-tenant access tests and synthetic demo seeders.
8. Add deployment verification for the target cPanel account.

**Exit criteria:** a demo platform administrator can provision two synthetic organizations, create facilities and scoped staff accounts, sign in, and demonstrate that cross-organization queries are rejected.

## Sprint 2: Patient Registry
- Register, search and update synthetic patient profiles, including emergency contact.
- Duplicate candidate detection scoped to tenant.
- Clinical history and visit identifiers scoped to tenant.
- No cross-tenant access through direct IDs or route manipulation.

## Sprint 3: Outpatient workflow
- Appointment scheduling and check-in.
- Triage and vital signs.
- Encounters, clinician notes, diagnoses and orders.
- Record changes auditable; emergency clinical work never gated by payment.

## Sprint 4: Laboratory, pharmacy, finance
- Laboratory worklist, verified results release.
- Prescriptions and dispensing.
- Stock ledger, batches and expiration.
- Billing, invoices, cashier receipts and basic reconciliation.

## Initial domain boundaries
- Platform: tenant registration and SaaS configuration.
- Identity: staff authentication, roles and facility assignments.
- Facilities: facility/department administration.
- Patients: tenant-local identity, demographics and history.
- Clinical: encounters, triage, consultations.
- Laboratory: orders, specimens, results.
- Pharmacy: prescriptions and dispense events.
- Billing: charges, invoices and payments.
- Inventory: products, batches, stock movements.

No module should directly change another module's authoritative records without its defined application API.

## Minimum security gates
- Only synthetic or properly de-identified data.
- Never commit credentials or `.env` files.
- CSRF protection, secure session cookies, authorization at every protected action.
- Tenant isolation testing, audit logging, private file uploads and safe error reporting.
- cPanel deployment is not equivalent to clinical production approval.
