# H11.0-P5 — Outpatient Cash vs Credit Legacy Source Contract

## Legacy identity

- Dispatcher key: `out_cash_cr`
- Historical function: `get_out_patient_cash_credit`
- Domain: Patient Finance / Visits
- Source evidence boundary: `FULL_HISTORICAL_FUNCTION_BODY_RECOVERED`

## Exact business rule

The historical function does not use its year or custom date-range inputs. It always evaluates scheduled outpatient reservations for the current calendar day.

### Oracle sources

- `RCP_SERVICE_RESERVATION`
- `RCP_VISIT`
- `STP_PLACES`
- `REG_COMP_CATEGORY`
- `STP_PATCAT_TYPE`

### Filters and joins

- `RCP_SERVICE_RESERVATION.HOSP_ID IN (1)`
- Current calendar day only
- `SERVSTATUS NOT IN ('C','F')`
- `SCHED_SERIAL IS NOT NULL`
- Visit/reservation join by `VISIT_ID` and `PATIENTID`
- Reservation place join to `STP_PLACES.PLACE_ID1`
- Visit/category joins by `HOSP_ID`, `PATCATID`, `MAIN_PATCATID`
- Numeric financial-class equality through `TO_NUMBER`
- Patient category type uses the historical Oracle outer join

### Mapping

- `CAT_TYPE = 1` → Cash
- Every other returned category → Credit

## Current implementation

`VisitsRepository::outpatientCashCreditToday()` uses equivalent ANSI joins and an inclusive/exclusive `TRUNC(SYSDATE)` calendar-day window.

## Independent legacy implementation

`LegacyPatientActivityRepository::outpatientCashCreditToday()` preserves the recovered old-style Oracle query shape and does not call the current repository.

## Live acceptance

- READY branches: NJCH and MNH
- Deferred branch: JCKH
- Categories per branch: Cash + Credit
- Exact comparisons: 4/4
- Required maximum difference: 0
- Oracle writes: NONE

A PASS promotes `out_cash_cr` from `MISSING` to `MATCHED` under the approved branch-readiness policy.
