Skip to main content

Manual Edits and Hardcoded Logic

This page catalogs every manual override, hardcoded constant, and special-case rule in the SSP pricing pipeline. Use this as a reference when debugging unexpected prices or when a new SSP requires custom handling.


1. Revenue Code Overrides

What it does: Forces specific HCPCS codes to map to a different revenue code than what claims data or the RC-HCPCS crosswalk would assign.

Where: pricing/line_codes/institutional_line_codes.py -- rc_overrides CTE

HCPCS CodeOverridden RCRC Family Description
443900750Gastrointestinal Services
218200450Emergency Room

Why: Claims data sometimes maps these codes to incorrect or inconsistent revenue code families. The overrides ensure the correct RC family is used for charge allocation.

How to modify: Add or remove rows in the rc_overrides CTE VALUES list. Each row is (line_code, revenue_code).


2. NS_ SSP Revenue Code Override

What it does: For SSPs whose name contains ns_ (non-surgical), any anchor code that would be mapped to Operating Room (0360-0369) is overridden to Emergency Room (0450-0459).

Where: pricing/line_codes/institutional_line_codes.py -- CASE WHEN g.ssp_grouper LIKE '%ns_%' block in the final SELECT

Why: Non-surgical SSPs should not allocate institutional charges to Operating Room revenue code families. These procedures are typically performed in the ER or a procedure suite, so ER is a more appropriate RC family for the anchor code.

How to modify: Edit the CASE WHEN expression in the final SELECT of the institutional_line_codes query. The condition checks g.ssp_grouper LIKE '%ns_%' and g.label = 'Anchor Code' and the resolved revenue code family equals '0360-0369'.


3. Carve-Out Rules

What it does: Determines which revenue code families are priced as additive carve-outs (separate from the base allocation) and which participate in the proportional base allocation.

Where: pricing/line_codes/institutional_line_codes.py -- carveout_families CTE and rc_allocation CTE in the second query (institutional_rc_family_allocation)

Pharmacy (0630-0639)

  • Only qualifies as a carve-out if avg_line_charge exceeds $2,000.
  • If below the threshold, Pharmacy participates in the base allocation like any other RC family.
  • Carve-out lines are labeled Carved Out: Drug.

Med/Surg Supplies (0270-0279)

  • Completely excluded from the base allocation.
  • Only appears if the SSP has line codes with the Carved Out: Implant label (determined by the implant_codes CTE in the first query).
  • Re-added to rc_families_all only when the SSP+RC family pair exists in carveout_families.

Carve-Out Pricing

All carve-out families are priced at:

allocated_price = avg_line_charge * 50%

Base (non-carve-out) families are priced at:

allocated_price = fee_schedule_price * charge_allocation

where charge_allocation is the family's proportional share of total avg_line_charge across all base families (sums to 1.0 within each SSP).

Drug and Implant Classification

Carved-out line codes are classified using two reference tables:

LabelSource
Carved Out: Drugasp_reference_pricing (ASP drugs) with avg_line_charge greater than $1,000 on drug/supply revenue codes
Carved Out: Implantref_aapc_cpthierarchy (C-codes for devices, Q-codes for skin substitutes, L-codes for prosthetics)

How to modify:

  • Change the $2,000 pharmacy threshold in the carveout_families CTE (ilc.rc_family_avg_line_charge > 2000).
  • Change the $1,000 drug candidate threshold in carved_out_candidates (avg_line_charge > 1000).
  • Change the 50% carve-out pricing factor in the final CASE WHEN ra.is_carveout expressions.
  • Add or remove implant device categories in the implant_codes CTE.

4. NCCI Manual Overrides

What it does: Adds manually defined mutually exclusive code pairs to the NCCI PTP edit graph. These pairs are unioned into the me_set used by the Union-Find algorithm that clusters line codes into NCCI groups.

Where: pricing/line_codes/professional_ncci_groups.py -- MANUAL_ME_PAIRS list

Code ACode BDescription
0081100812Lower GI anesthesia vs screening colonoscopy anesthesia

Why: Some code pairs are clinically mutually exclusive (a provider would never bill both on the same encounter) but are not flagged in the CMS NCCI PTP edits table. Without this override, both codes would appear in separate NCCI groups, allowing them to be selected together in pricing.

How to modify: Add tuples to the MANUAL_ME_PAIRS list. Each tuple is (code_a, code_b). Both directions are added to the lookup set automatically.


5. Combo SSP Definitions

What it does: Creates combination SSPs that represent two procedures performed together, using multiple-procedure pricing logic (100% of the higher-priced SSP + 50% of the lower-priced SSP).

Where: pricing/build/combo_ssps.py -- top-level constants and SQL

SSP Definition

ConstantValue
COMBO_SSPGA.2.colonoscopy_and_egd
SSP_AGA.0.colonoscopy
SSP_BGA.0.egd
POSOP

The combo SSP has a single subcategory (sub_category = '0') and no subcategory tiers.

Multiple-Procedure Logic

For each provider_id, the pipeline compares inst_price + prof_price between SSP_A and SSP_B. The higher-total SSP gets factor 1.0 (primary) and the lower-total gets factor 0.5 (secondary). All price columns are computed as factor_A * price_A + factor_B * price_B.

Hardcoded Institutional Line Codes

Where: pricing/legacy_ssp/manual_institutional_line_codes.py -- combo SSP VALUES block at the end of the query

Base CodeLine Codes
43250 + 4538445384, 0750, 43250, 0310, 88305, 43239, J2704, 0636, J7120
43251 + 453850750, 43251, 45385, 0312, 88305, 0636, J2704, 43239, 45380, J7120

Hardcoded Professional Line Codes

Where: pricing/legacy_ssp/manual_professional_line_codes.py -- combo SSP VALUES block at the end of the query

Base CodeLine Codes
43250 + 4538443250, 45384, 43239, 00813, 88305
43251 + 4538545385, 43251, 43239, 00813, 88305, 45380

Why: Combo SSPs cannot be derived from claims data because the two procedures share encounters. The line codes are manually curated as the union of line codes from the two source SSPs, with combo base codes (e.g., 43250 + 45384) used as identifiers.

How to modify:

  • To add a new combo SSP, duplicate the pattern in combo_ssps.py with new COMBO_SSP, SSP_A, SSP_B constants, add corresponding manual line code rows in both manual_institutional_line_codes.py and manual_professional_line_codes.py, and register the combo SSP in ssp_groupings.
  • To change line codes for an existing combo, edit the VALUES blocks in the two manual line code files.

6. Excluded Line Codes

What it does: Globally excludes specific codes from appearing as line codes in both institutional and professional line code discovery.

Where: pricing/legacy_ssp/manual_institutional_line_codes.py and pricing/legacy_ssp/manual_professional_line_codes.py -- excluded_line_codes table creation

CodeDescription
36415Venipuncture, routine
36416Venipuncture, capillary
36410Venipuncture, age 3+

Why: Venipuncture codes appear on nearly every encounter but are trivial, low-cost services that would inflate line code counts without adding meaningful pricing signal.

How to modify: Add or remove rows in the excluded_line_codes VALUES list. The table is created in both manual_institutional_line_codes.py and manual_professional_line_codes.py (the latter creation overwrites the former, so keep them in sync).


7. Configurable Pricing Factors

What it does: Defines global constants used across the pricing pipeline for rate calculations and thresholds.

Where: ssp/version.py

ConstantValueUsage
BASE_RATE500Denominator for relative weight calculation (weight = price / BASE_RATE)
ASSISTANT_SURGEON_FACTOR0.16Assistant surgeon price = 16% of primary surgeon fee
ASSISTANT_NONSURGEON_FACTOR0.136Assistant non-surgeon price = 13.6% of primary surgeon fee
CRNA_SUPERVISED_FACTOR0.50Supervised CRNA price = 50% of anesthesiologist fee
ENCOUNTER_THRESHOLD0.3Minimum encounter association rate for claims-based line code discovery (greater than 30%)

Why: These factors are sourced from CMS payment policy:

  • ASSISTANT_SURGEON_FACTOR (16%) and ASSISTANT_NONSURGEON_FACTOR (13.6%) align with Medicare assistant-at-surgery payment rules.
  • CRNA_SUPERVISED_FACTOR (50%) reflects the medical direction split when a CRNA works under an anesthesiologist.
  • ENCOUNTER_THRESHOLD (30%) filters out infrequent line codes that would add noise.
  • BASE_RATE ($500) is an arbitrary normalizing constant for weight computation.

How to modify: Edit the constants directly in ssp/version.py. Changes propagate to all downstream pipeline steps on the next run.


8. Anchor Code Units Cap

What it does: When a line code is also an anchor code within the same SSP, its units are capped at 1 regardless of the average_units value from sub_package_contents.

Where: pricing/line_codes/professional_line_codes.py -- ssp_groupings CTE, units column

CASE
WHEN spc.line_code IN (
SELECT code FROM {SCHEMA}.ssp_groupings_{DATE}
WHERE ssp_grouper = g.ssp_grouper
) THEN 1
...
END AS units

Why: Prevents double-counting. When the anchor code appears as its own line code (which it always does), using average_units greater than 1 would inflate the price. The anchor represents a single procedure occurrence, so units = 1 is correct. Other line codes (e.g., anesthesia codes with time-based units) retain their average_units values.

How to modify: Edit the first WHEN branch in the units CASE expression within the ssp_groupings CTE. To remove the cap entirely, delete the branch.


9. Encounter-Level Services

What it does: Controls how avg_line_charge is computed per revenue code family. For encounter-level services, the average is computed per encounter that has the RC family (dividing by encounter_count). For all other families, the sum is divided by total_encounters across the SSP.

Where: pricing/legacy_ssp/revenue_code_family_proportions.py -- final SELECT, avg_line_charge CASE expression

RC Family DescriptionAveraging Method
Gastrointestinal ServicesPer-encounter (divide by encounter_count)
Operating Room ServicesPer-encounter (divide by encounter_count)
Emergency RoomPer-encounter (divide by encounter_count)
ClinicPer-encounter (divide by encounter_count)
All othersPer-total-encounter (divide by total_encounters)

Why: Some services are billed once per encounter (e.g., a single OR fee, a single ER visit fee). Dividing their total charges by total_encounters would dilute the average because not every encounter has that RC family. Other services (e.g., lab tests, pharmacy) may appear on a subset of encounters but are billed in varying quantities, so dividing by total encounters produces a more stable per-case average.

How to modify: Add or remove family_description values from the WHEN clause of the CASE expression. Descriptions must match the family_description column from the revenue_codes reference table exactly.


10. LABPATH_RADIOLOGY_CODES

What it does: Provides a hardcoded list of 37 HCPCS codes that should be classified as Lab/Path or Radiology for ancillary provider type assignment, but are not captured by the Clinical Laboratory Fee Schedule (CLFS) or the spines Radiology category.

Where: ssp/version.py -- LABPATH_RADIOLOGY_CODES constant

Codes (37 total):

70481, 70487, 70491, 71047, 72083, 72132, 72148, 72158, 72193,
72197, 73502, 73522, 73701, 73722, 74177, 75572, 76801, 76818,
76827, 77002, 77062, 77066, 77076, 78071, 78433, 78815, 92133,
93307, 93351, 93923, 10011, 19085, 36247, 37243, 77372, 77386

Used by:

  • pricing/line_codes/ancillary_provider_types.py -- classifies line codes into ancillary provider types (Lab/Path vs Radiology vs Professional)
  • pricing/legacy_ssp/manual_professional_line_codes.py -- mirrors institutional ancillary line codes to the professional side when they match this list

Why: Some imaging and diagnostic codes (e.g., ultrasounds, nuclear medicine, certain interventional radiology codes) fall outside the standard CLFS and spines Radiology lookup. Without this list, they would be classified as generic Professional codes and priced using the wrong fee schedule.

How to modify: Add or remove quoted HCPCS codes in the LABPATH_RADIOLOGY_CODES string in ssp/version.py. The format is a comma-separated string of single-quoted codes (used directly in SQL IN clauses).