The escape hatch

Patterns in the SQL

1,189 calculations are raw T-SQL, spread across 828 of 1,612 fee logics — but only 268 distinct bodies. All 268 have been read. The shapes that recur tell you more about the migration than the totals do.

Count bodies, not uses

Effort scales with distinct SQL to port; volume scales with uses. The two give opposite answers, because two snippets account for 36% of all SQL usage while172 of 268 bodies are used exactly once. A uses-weighted read makes the corpus look consolidatable. It is not — it is a long, thin, customer-specific tail.

Where the dependencies point

DependencyBodies% bodiesUses% uses
none8632.136831
mixed752813911.7
legacy-etl4918.31008.4
payer-crosswalk3111.6756.3
medicare-reference176.349341.5
customer-schedule103.7141.2

155 of 268 bodies (58%) need data the replacement cannot reach — legacy per-customer ETL output and payer crosswalk tables — but only 26% of uses.

The heaviest bodies

UsesCustsDependencyDifficultyWhat it computes
2368medicare-referencemediumAllocates a global-surgery-period allowed amount to its post-operative portion: pulls a procedure's POST_OP percentage and GLOB_DAYS (global period length) from Medicare RVU reference data and returns Allowed / GlobalDays * PostOpRate — i.e. a per-day post-op share of the total global allowed amount.
1902medicare-referencelowSame global-surgery post-op allocation as hash c5fd5754fcf4a52d (Allowed/GlobalDays*PostOpRate), but hardened: falls back to returning {Allowed} unchanged when GLOB_DAYS or POST_OP is missing/non-numeric/zero instead of dividing by zero.
1191nonelowA cosmetic/no-charge carve-out override: for charges whose extracted code fields flag them as 'no charge' (CS='NC'), cosmetic (CT like COS/S9999MN), or specific vision codes (V2786F/V2787F/V27878F), it returns the billed charge as-is (or zero when the billed charge is itself zero) instead of running normal fee-schedule pricing.
471medicare-referencemediumCaps a charge's allowed amount when its billed units exceed a per-procedure maximum-allowed-units limit (a therapy/multiple-unit cap): if the code has a configured max-units value and billed Units exceed it, the allowed amount is scaled down proportionally (Allowed * maxUnits/units); otherwise Allowed passes through unchanged.
382nonemediumFor charges flagged with a custom 'ML' (manual-limit) code = 'Yes', applies a flat 15% reduction (Allowed*0.85) unless the charge carries modifier TC/AS or its code falls in one of several excluded ranges/patterns (alpha-prefixed codes, 95xxx, lab 80047-89398, radiology 70010-79999, immunization 90281-90470/90475-90749, cardio 93000-93278).
331mixedhighAnesthesia fee-schedule lookup with a CRNA doubling rule: looks up a base fee from the customer's fee schedule by code/insurance/facility-type/modifier/date, then doubles it (x{Units}x2 instead of x{Units}) when the facility is flagged as a CRNA site and the matched schedule entry is itself flagged as an anesthesia line.
151nonelowZeroes the allowed amount for two specific drug HCPCS codes (J1097, J1096) — an unconditional 'no separate payment' exclusion for those two codes.
111payer-crosswalkhighHumana commercial 'carveout' fee lookup: resolves the billing provider's Humana specialty and the facility's Humana region, then looks up a flat carveout dollar amount keyed by specialty+region+procedure code+modifier+date range.
111legacy-etlmediumAnesthesia fee-schedule lookup restricted to anesthesia CPT codes (00100-01999) for Anthem VA/NV, selecting between two Anthem carveout schedules ('GAVA-Anthem-NV-Anes-Carveouts' vs '...Tidewater-Anes-Carveouts') based on a geo-locale code embedded in {Codes}.
111payer-crosswalkhighBCBS RVU-style fee lookup: resolves the billing provider's specialty and 'Exhibit B' provider flag via a BCBS-specific crosswalk, resolves the facility's type, then looks up a per-unit fee keyed by charge type+modifier(26/TC only)+specialty+ExhibitB flag+facility type+date, multiplied by Units.
91legacy-etlhighAPG (Ambulatory Payment Group) rate computation: maps a procedure code to an APG/EAPG code, looks up that APG's relative weight for the service date, looks up a base rate by practice+rate-code+facility-zip+date, and multiplies BaseRate * Weight.
81nonelowOptometry fee-schedule lookup that selects between a 'Optometry-Hospital' vs 'Optometry-Clinic' schedule based on the charge's place-of-service (via a secondary POS-Code-Indicators schedule), then returns the matching fee * Units.

One rule is a third of the estate

Two bodies, both named “Modifier 55 Adj”, account for 426 uses — 35.8% of all SQL. Every one is gated by a single filter: modifier 55 present. It is Medicare's split-surgical-care rule. Porting it correctly retires more than a third of the SQL estate — but its gate is a Filter, the mechanism the replacement does not implement, one customer runs both variants, and both select their reference row withTOP 1 keyed on procedure code alone while the CMS file is keyed on code and modifier.