# Delivery roadmap

1. Foundation (included): auth, roles baseline, facilities, audit, patients and encounter lifecycle.
2. Core clinical: vitals, nursing workflows, diagnosis catalogue, medication orders, appointments and patient transfer/merge controls.
3. Specialist services: pharmacy, LIS, ANC/MCH, child health/immunisation, emergency, referrals.
4. Operations: inventory, finance, HR, medical records, surveillance and facility performance.
5. Intelligence: executive indicators, configurable clinician-approved alert rules, AI governance and only then validated models.
6. Interoperability/offline: FHIR profiles, terminology services, DHIS2 mapping, PWA threat model and sync conflict handling.
7. QA: automated feature/security tests, clinical validation, load testing, disaster recovery and deployment sign-off.

## Milestone 2 additions (source created; runtime verification pending)

- Structured encounter observations (vital-sign and measurement types; values and units retained as entered).
- Appointment scheduling, date/status filtering and status transitions.
- Inter-facility transfer request and destination review workflow.
- Append-only amendment request and approval records for signed encounters; original signed encounter remains unchanged.
- Added navigation and forms for appointment and transfer workflows.

These additions do not provide validated clinical thresholds, triage rules, automated patient-record reassignment, or clinical protocol recommendations.

## Milestone 3 additions (source created; runtime verification pending)

- Pharmacy medicine catalogue, batch receipt, prescription creation, dispensing and transactional stock deduction.
- Laboratory test catalogue, requests, result entry and separate verification by a different laboratory user.
- Maternal pregnancy registration and ANC visit recording.
- Child health registration and administered immunisation recording.
- Emergency triage assessments recorded with staff-assigned priority.
- Referral issue, receiving facility/destination, status tracking and feedback.

## Milestone 4 additions (source created; runtime verification pending)

- Medical consumables inventory catalogue, suppliers, batch receipt, stock issue and movement ledger.
- Staff directory, attendance recording and leave requests.
- Private document uploads and permission-checked downloads.
- Disease surveillance notifications and review status.
- Facility service-indicator reporting.
- Patient/service invoices, payment receipts and balanced manual journal posting with seeded chart of accounts.

## Milestone 5 additions (source created; runtime verification pending)

- LCDA command centre with date/facility filters and database-driven patient, encounter, alert, lab and dispensing counts.
- Configurable clinical alert rule registry; rules remain inactive until approved by authorised LCDA clinical leadership.
- Manual evaluation of submitted measurements against approved configured rules; alert acknowledgement and resolution.
- AI model and version registry with training-data provenance fields.
- Validation record capture for performance, subgroup/fairness and calibration metrics.
- AI incident reporting.
- Human review endpoint for prediction records; no prediction generation or model deployment is included.

## Milestone 6 additions (source created; runtime verification pending)

- Read-only FHIR R4 facade for CapabilityStatement, Patient read/search and Encounter read/search, protected by Sanctum authentication.
- ICD-10 and LOINC terminology mapping/search infrastructure; code-set content must be loaded from licensed/approved distributions.
- DHIS2 dataValueSet preview/export adapter with optional authenticated outbound submission when server credentials are configured.
- PWA manifest, service worker and static-shell caching; authenticated pages and clinical records are intentionally not cached.
- IndexedDB offline queue for inventory stocktake only (no patient identifiers or clinical notes stored offline).
- Idempotent sync operation IDs, payload hash checks, server-side stock snapshot conflict detection, conflict records and review endpoint.

## Milestone 6 verification summary

- 92 PHP files passed `php -l`.
- Both JavaScript files passed `node --check`.
- ZIP archive integrity check passed.
- Composer is not installed in the build environment, and no MySQL service is available; Laravel boot, migration execution, API integration, IndexedDB browser behaviour and DHIS2 endpoint tests remain pending.


Milestone 6 syntax verification: all 92 PHP files passed `php -l`; both JavaScript files passed `node --check`; ZIP archive integrity check passed. Composer and MySQL are unavailable in the generation environment, so dependency installation, Laravel boot, migrations and integration tests remain unexecuted.


## Security-hardening continuation after Phase 7

- Administrative user account management with role and facility assignment.
- Facility administrators can assign operational staff roles only; super-administrator assignment is restricted to the super administrator.
- Facility-scoped user listing and editing.
- Mandatory first-login password change middleware for accounts marked `must_change_password`.
- Self-service password change with current-password verification and a 14-character minimum.
- Audit-log browsing with action/date filters.
- Added feature-test source for forced password change and privilege-escalation prevention.

These are source additions. The Laravel test suite has not been executed because Composer dependencies are unavailable in the build environment.


## Phase 8 — Access-control and facility-isolation hardening
Implemented additional active-account checks, API-aware forced-password-change responses, patient and encounter facility scoping, clinical-role guards, appointment/transfer authorisation, specialist module role gates and audit facility attribution. See `PHASE8_SECURITY_REVIEW.md`. Runtime tests remain pending until Composer dependencies and a database are available.


## Phase 9 — Deployment infrastructure and runtime readiness (source prepared)
- Added the missing Laravel public front controller.
- Added Dockerfile for PHP 8.3-FPM with required PHP extensions.
- Added Docker Compose services for PHP-FPM, MySQL 8.4 and Nginx.
- Added private application storage and persistent database volumes.
- Added an interactive first-super-administrator Artisan command.
- Added Docker backup/restore scripts and a container deployment runbook.
- Corrected Composer post-autoload-dump callback escaping.
- Docker build/run remains unverified because Docker and Composer are not installed in this environment.


## Phase 10 — Functional acceptance test suite (test source prepared)
Added acceptance-test source for encounter creation/signing, immutable signed encounters, appointment scheduling/check-in and pharmacy stock deduction/partial dispensing. Expanded static consistency checks for database table references, route names and controller actions. PHPUnit execution remains blocked by unavailable Composer dependencies and database drivers in this environment.


## Phase 11 — Runtime-readiness static review
Removed the duplicate custom Sanctum personal-access-token migration to avoid collision with the Sanctum v4 package migration. Added Eloquent SoftDeletes to Patient and Facility models to match their migration columns. Added a runtime-readiness report distinguishing corrections from outstanding execution blocked by missing Composer, Docker, MySQL and PDO drivers.


## Phase 12 — CI and reproducible dependency management
- Added GitHub Actions CI for locked dependency installation, Composer audit, Laravel route compilation, PHPUnit tests and source syntax checks.
- Added a manual lock-file generation workflow that uploads the resolved lock for human review.
- Added a local Composer lock generation script with backup, validation and dependency audit.
- Added staging preflight checks for lock file, environment, APP_KEY, APP_DEBUG, PDO MySQL, Composer and Laravel boot.
- `composer.lock` remains intentionally ungenerated because Composer is unavailable in this environment.


## Phase 13 — Release acceptance gates
- Added a non-destructive release-gate script requiring reviewed dependencies, production environment settings, secure cookies, Composer audit, Laravel boot, migration status and PHPUnit.
- Added public HTTP smoke test for `/up` and `/login`.
- Added release acceptance evidence checklist and explicit release-status report.
- The release gate is expected to block in the current environment because `composer.lock`, Composer, Docker, MySQL and PDO MySQL are unavailable.


## Phase 14 — Procurement, finance, workforce and privacy source workflows
- Added purchase orders, line items, maker-checker approval, supplier bills and supplier bill payments.
- Added facility-scoped payroll periods and entries with draft/approved/paid workflow and maker-checker approval.
- Added leave request approval/rejection workflow.
- Added bank account registration with encrypted account number storage, manual statement lines, receipt matching and supplier payment matching.
- Added patient consent events, privacy request workflow, retention policy register and retention review records.
- Added acceptance test source for procurement approval separation and payroll calculation/approval.
- All database and application runtime tests remain pending.


## Phase 15 — General ledger, budget control and procurement receiving
- Added reusable balanced/idempotent `LedgerPoster` and unique facility/source key.
- Automatic double-entry postings for patient invoices/receipts, inventory receipts/issues, GRNs, supplier bills/payments and payroll payments.
- Added budget allocations by facility, account and period, with maker-checker approval, PO commitments and bill expenditure.
- Added GRN workflow with approved-PO check, outstanding-quantity check, inventory batch/movement creation and inventory/GRNI posting.
- Supplier bills now require an approved PO and GRN and cannot exceed cumulative received value for that PO.
- Added period ledger summary, revenue/expense summary, budget monitoring and CSV ledger export.
- Added acceptance test source for ledger idempotency and GRN stock/ledger effects.


## Phase 16 — Government finance, procurement governance and data quality
- Added financial periods, non-overlap validation, opening balance entry, year-end close journal and closed-period posting guard.
- Added government financial activity reporting, facility consolidation and service-indicator scorecard.
- Added tender register, publication approval, sealed-bid staff registry, post-closing bid evaluation, weighted scoring and highest-score award.
- Added procurement approval threshold matrix and supplier performance evaluation.
- Added data quality scan for missing demographics, old unsigned encounters, expired stock and below-reorder stock, with review/resolution tracking.
- Added audit CSV export.
- Added acceptance test source for financial period closing and data quality scanning.


## Phase 17 — Public health surveillance and clinical intelligence
- Added public-health command dashboard with facility/date-filtered case, maternal, ANC, child health, immunisation dose and clinical alert counts.
- Added configurable outbreak count thresholds, rolling-window scan, duplicate open-signal suppression and epidemiological review statuses.
- Added surveillance follow-up records for investigation, contact tracing, referral and community response.
- Added clinical alert escalation queue with role-targeted acknowledgement workflow.
- Added responsible-AI monitoring view for manually recorded model metrics, prediction review counts and AI incidents.
- Added acceptance test source for outbreak threshold scanning and clinical alert escalation.


## Phase 18 — Interoperability and continuity of care
- Changed DHIS2 initial submission to an idempotent outbox queue with manual HTTPS dispatch, five-attempt cap, retry backoff and integration logs.
- Extended limited read-only FHIR R4 facade with Observation, Immunization and ServiceRequest referral search endpoints.
- Added configurable immunisation schedule rules and due/overdue child follow-up list (no schedule defaults).
- Added moderate/high-risk maternal follow-up task register.
- Added patient SMS reminder opt-in/opt-out, evidence reference and appointment reminder outbox; no SMS delivery provider is configured.
- Added acceptance test source for DHIS2 idempotency and consent-gated reminder queue.


## Phase 19 — Production infrastructure and integration automation
- Docker image now installs from a reviewed Composer lock file and no longer resolves dependencies during build.
- Added dedicated database queue worker and scheduler services; moved container queue connection to database.
- Added queue tables migration and failed-job pruning schedule.
- Added API rate limiters for general and sensitive/FHIR endpoints.
- Added staging deployment script that intentionally leaves migrations to an explicit operator action.
- Added encrypted database and uploaded-storage backup plus guarded restore scripts.
- Added Docker ignore rules and container log rotation.
- Added Phase 19 production infrastructure runbook.


## Phase 21 — Release candidate preparation and defect remediation
- Added SQLite database connection for the in-memory PHPUnit test environment.
- Made HTTPS secure-cookie configuration explicit in `.env.example`.
- Configured trusted proxy handling for the private reverse-proxy deployment topology.
- Regenerated the authenticated session after password changes.
- Hardened encounter signing ID comparison across PDO scalar types.
- Restricted FHIR Encounter reads/search to signed encounters only.
- Added FHIR draft isolation and password-change acceptance test source.
- Added fail-closed `scripts/phase21-release-candidate.sh` and release-candidate runbook.
- Static verification passes; runtime release gate remains blocked by unavailable Composer, Docker, PDO drivers and staging environment.

\n## Phase 22 — Staging deployment and runtime test execution
- Added a dedicated Docker test image profile with PHPUnit development dependencies and in-memory SQLite.
- Production image continues to install production-only Composer dependencies.
- Added fail-closed staging deployment runner with Docker build/start, MySQL health wait, Laravel boot/route compilation, migration status, explicit migration approval, PHPUnit and HTTPS smoke tests.
- Executed the available checks in the authoring environment; runtime deployment is blocked by absent Composer, lock file, Docker, PDO drivers, vendor dependencies, `.env` and staging URL.


Phase 22 execution evidence: staging deployment runner was executed and stopped at missing Docker; `php artisan about` failed because Composer vendor dependencies are absent. Corrected Docker test image to retain autoload-dev mappings for PHPUnit while production image excludes dev dependencies. No runtime deployment or PHPUnit run is claimed.
