# H11.0-P6 — Specialty Total Revenue Legacy Source Contract

## Legacy identity

- Dispatcher key: `special_prof`
- Historical function: `get_special_prof`
- Domain: Specialty Finance
- Source evidence boundary: `FULL_HISTORICAL_FUNCTION_BODY_RECOVERED`

## Exact historical SQL contract

The recovered legacy function uses:

- Table: `KPI_DOCTOR_PERF_DETAIL_JOB`
- Year filter: `YEARID = selected year`
- Metric: `SUM(DISTINCT TOT_REV)`
- Grouping:
  - `SPECIAL_SPEC_ID`
  - `SPECIAL_SPEC_EN_NAME`
- Inclusion threshold: metric `> 50000`
- Ordering: metric descending

The visible business wording is **Total Revenue by Specialty** because the
historical SQL source uses `TOT_REV`. The internal historical function name
`get_special_prof` is retained only for parity and traceability.

## Current implementation

`SpecialtyFinanceRepository::specialtyTotalRevenueRanking()`

The current path uses an equivalent CTE and bind parameters.

## Independent legacy implementation

`LegacySpecialtyFinanceRepository::specialtyTotalRevenueRanking()`

The legacy path preserves the recovered nested-query shape and does not call the
current repository.

## Live acceptance

- READY branches: NJCH and MNH
- Deferred branch: JCKH
- Years: selected test year + comparison year
- Dataset checks: 4
- Identity mismatches: 0
- Maximum difference: 0
- Oracle writes: NONE

A full PASS promotes `special_prof` from partial/source-blocked to MATCHED.
