# Flow: Lab & Radiology Order → Result

**Actors**: Doctor (orders and, in this manual-entry phase, also typically enters results)
**Phase**: 9

## Ordering

1. From an encounter, doctor selects one or more tests from `clinic_lab_test_catalog`
   (HbA1c, Fasting Glucose, Lipid Profile, TSH/T3/T4, Creatinine/eGFR, Microalbumin, etc.) →
   `LabOrderService::create($encounter, $tests)` creates one `LabOrder` row with `status = 'ordered'`.

## Entering results — manual, no device integration

2. When results are available (from an external lab, phoned in, or entered by clinic staff),
   doctor opens the order → `LabOrderService::recordResult($order, $test, $value)` creates a
   `LabResult` row per test, computing `flag` (`normal`/`high`/`low`) against the catalog's
   `reference_range_low`/`_high`, and copies `unit` from the catalog at that moment (snapshot,
   same reasoning as `Booking.price`).
3. Once every requested test on the order has a result, `LabOrderService` flips `LabOrder.status`
   to `'resulted'`.

## Feeds the trend views

4. The Phase 7 HbA1c/glucose trend view and any lipid-profile trend read `clinic_lab_results`
   directly, filtered by patient + test name, ordered by `resulted_at` — no additional
   aggregation table needed; a plain indexed query is sufficient at clinic scale.
5. A `flag = 'high'`/`'low'` result on a diabetic patient's HbA1c is what the Phase 13
   "diabetes control rate" report counts against.

## Printing

6. Phase 12 adds a print view for the order (what was requested) — a separate results print view
   is a natural follow-up but not required for Phase 12's minimum scope; decide at build time
   based on whether the center hands patients a printed order to take to an external lab.
