# Legacy Source Coverage and Evidence Boundary

## What is proven

Phase 10.8 inventories **31 legacy dispatcher functions** evidenced by the user-provided legacy `files/funcations.php` excerpt. The dispatcher exposes the function keys, called legacy function names, shared filter parameters, branch behavior, and several full SQL bodies.

The legacy revenue page excerpt also proves five revenue panels and their filter modes: year, compare year, and custom date range with the same-year date-range guard.

## What is not present in the supplied ddb-new archive

The complete original legacy site archive is not contained in `ddb-new.zip`. Therefore Phase 10.8 does not invent missing SQL or silently declare parity. Rows whose exact business rule is not fully available are marked with an explicit source-detail status and remain `PARTIAL` or `MISSING`.

## Acceptance rule

A legacy capability may become `PARITY_PASS` only after all of the following are proven:

1. Old function identified.
2. Old business rule and Oracle source documented.
3. Old filters documented.
4. New implementation mapped.
5. Same hospital and same input period executed.
6. Old and new results compared.
7. Difference is zero, or a documented replacement is formally approved.
8. Permission parity verified.
9. Evidence ZIP produced.

## Priority consequence

No new workflow expansion should displace legacy migration work until the master matrix is closed. The immediate next functional phase is Revenue Legacy Functional Parity.

## Phase 10.12 source recovery update

The exact legacy bodies for `get_lab_tests`, `get_rad_tests`, `get_lab_tests_s`, and `get_rad_tests_s` are now available. Phase 10.12 implements the selected-branch contracts `plts_s` and `prts_s` with independent legacy execution paths and exact year/date-range parity gates. The three-branch aggregate functions `plts` and `prts` remain `PARTIAL` until exact multi-branch parity is proven.
## Phase 10.13 — Doctors

Dispatcher-confirmed doctor functions `get_doc_rev`, `total_op_visits`, and `total_admission` are mapped to the annual doctor KPI source `KPI_DOCTOR_PERF_DETAIL_JOB`. Phase 10.13 adds an independent legacy execution path and six live parity checks across current/comparison years. Finance functions `moh_revn`, `drug_rev`, and `net_rev` remain open for Phase 10.15.



## Phase 10.15 — Specialty Finance

Dispatcher keys `moh_revn`, `drug_rev`, and `net_rev` are confirmed. Their full historical function bodies are not present in the supplied legacy archive. Phase 10.15 therefore uses `KPI_DOCTOR_PERF_DETAIL_JOB` — the established doctor-finance source validated in Phase 10.13 — and compares two independent reconstructed SQL paths across current/comparison years. The gate requires 6/6 PASS and maximum difference 0, but does not claim source-code identity with missing historical bodies. `special_prof` and `special_net_rev` remain `BLOCKED_SOURCE_MISSING`.


## H11.0-P3 — Admission Category Type source recovery

The complete historical dispatcher body for `acty / get_admission_category_type`
has been recovered from the previously supplied legacy `funcations.php` source.

The exact legacy contract is now known:

- Oracle sources: `RCP_VISIT`, `REG_COMP_CATEGORY`, `STP_PATCAT_TYPE`.
- Admission scope: `RCP_VISIT.CLASSCODE = 1`.
- Branch rule inside each active branch connection: `RCP_VISIT.HOSP_ID IN (1)`.
- Category mapping: `CAT_TYPE 1 = Cash`, `2 = Credit`, `3 = Insurance`.
- Year filter: `EXTRACT(YEAR FROM VISIT_START_DATE)`.
- Date-range filter: selected calendar-day range.
- Composite category join: `HOSP_ID`, `FINANCLASSID`, `PATCATID`, `MAIN_PATCATID`.
- Patient category type join: `REG_COMP_CATEGORY.PAT_CAT_TYPE = STP_PATCAT_TYPE.CAT_TYPE_ID`.

H11.0-P3 adds two independent read-only paths and requires exact zero-difference
parity for year and date-range modes before the function may be counted as MATCHED.


## H11.0-P5 — Outpatient Cash vs Credit source recovery

The complete historical dispatcher body for `out_cash_cr / get_out_patient_cash_credit` has been recovered.

- Historical scope: current calendar day only.
- The accepted year/from/to dispatcher parameters are not used by this function body.
- Oracle sources: `RCP_SERVICE_RESERVATION`, `RCP_VISIT`, `STP_PLACES`, `REG_COMP_CATEGORY`, `STP_PATCAT_TYPE`.
- Category mapping: `CAT_TYPE = 1` is Cash; every other returned category is Credit.
- Reservation scope: `HOSP_ID IN (1)`.
- Status rule: `SERVSTATUS NOT IN ('C','F')`.
- Scheduled-only rule: `SCHED_SERIAL IS NOT NULL`.
- Financial-class match: numeric equality between visit and company-category financial class.
- H11.0-P5 uses two independent read-only paths and requires exact zero-difference parity on READY branches NJCH and MNH.
- JCKH remains `DEFERRED_NOT_READY` under the approved branch-readiness policy.
