# Flow: Surgery Scheduling & Documentation

**Actors**: Clinic Admin/Receptionist (scheduling), Surgeon (assessment, post-op note)
**Phase**: 10

**Scope reminder**: scheduling and documentation only — no bed/ward/admission step anywhere in
this flow, per the user's confirmed decision.

## Scheduling

1. A candidate is typically identified via a `BariatricAssessment.surgical_readiness = 'ready'`
   row from an earlier encounter (Phase 7), though the flow also supports general surgery cases
   not tied to a bariatric assessment.
2. Clinic Admin/Receptionist (or the surgeon) opens the "Surgery Schedule" admin screen — same
   list/date-picker interaction pattern as the existing Doctor Schedules screen
   (`resources/views/dashboard/admin/clinic/schedules/index.blade.php`) — and calls
   `SurgeryCaseService::schedule()`: patient, procedure type, surgeon, assistants, anesthesiologist,
   date/time, duration estimate → creates a `SurgeryCase` row with `status = 'scheduled'`.

## Pre-op assessment and consent

3. Surgeon (or the assigned clinical staff) completes the pre-op checklist on the case →
   `SurgeryCaseService::recordPreopAssessment()` creates/updates the `SurgeryPreopAssessment` row:
   fitness confirmed, labs reviewed (cross-referencing the patient's `LabOrder`/`LabResult` rows
   from Phase 9 manually — no automated check in this phase), fasting confirmed, consent
   signed-at + uploaded file.
4. Once all three checklist flags are true and `consent_signed_at` is set,
   `SurgeryCaseService` transitions `SurgeryCase.status` to `'pre_op_ready'`. A case cannot be
   marked `completed` while still `scheduled` (the transition is enforced in the service, not the
   database).

## Post-op documentation

5. After the procedure, the surgeon opens the case → "Record Post-Op Note" → this reuses the
   Phase 6 encounter screen directly: `EncounterService::start()` with
   `encounter_type = 'post_op'` and `surgery_case_id` set to this case — **no separate post-op
   screen is built**, per the decision in `07-database-schema-expansion.md`.
6. `SurgeryCaseService::complete($case)` flips `status` to `'completed'` once the post-op
   encounter is finalized.

## Feeds into billing

7. Completing a `SurgeryCase` (or, depending on the center's workflow, scheduling one) is a
   trigger point for drafting a `ClinicInvoice` line with `service_type = 'surgery'` — see
   `12-billing-and-posting-flow.md`.
