Files
stack/src/ipps/rules.py
kert 8d03927754
Some checks failed
CI / lint (push) Failing after 2m19s
CI / notebooks-smoke (push) Successful in 1m53s
Deploy / changes (push) Successful in 16s
CI / test (push) Successful in 5m26s
Infra CI / notebooks (push) Successful in 57s
Infra CI / zotero (push) Successful in 25s
Infra CI / docs (push) Successful in 27s
Infra CI / api (push) Successful in 1m19s
Infra CI / bcda (push) Successful in 1m51s
Infra CI / mc (push) Successful in 19s
Infra CI / llm (push) Successful in 58s
Lean Pay / pay (push) Successful in 17s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Package Supply Chain / pkg-supply-chain (push) Successful in 2m14s
Deploy / api (push) Successful in 1m53s
Deploy / llm (push) Successful in 1m29s
Deploy / mc (push) Has been skipped
Deploy / bcda (push) Successful in 1m52s
Deploy / report (push) Successful in 14s
feat(ipps): price the operating federal rate
The operating rate is the MS-DRG weight times the full-update labor
and nonlabor standardized amounts, adjusted by the pre-reclassification
wage index. Table 1A applies when the wage index is above 1 and Table
1B otherwise. Capital is the weight times the Table 1D national rate.
IME, DSH, outliers, and the Lean ceiling stay absent.
2026-11-18 11:19:05 -05:00

70 lines
2.4 KiB
Python

"""Which published IPPS dollars the operating rate uses.
Table 1A is the labor and nonlabor split for a wage index above 1.
Table 1B is the split for a wage index of 1 or below. CMS sets the two
splits so they add to the same national standardized amount. The
full-update hospital submitted quality data and is a meaningful EHR
user. FY2014 names that row ``full_update``. From FY2015 the same row
is ``quality_ehr``.
Table 1D ``national_rate`` is the capital standard federal rate. It is
not split by wage index. Table 1E is the LTCH PPS rate and is not an
operating amount. Puerto Rico rows are not the national rate.
"""
from __future__ import annotations
# Lower rank wins when a year somehow carries both names.
LABOR_COMPONENTS: tuple[tuple[str, int], ...] = (
("quality_ehr_labor", 0),
("full_update_labor", 1),
)
NONLABOR_COMPONENTS: tuple[tuple[str, int], ...] = (
("quality_ehr_nonlabor", 0),
("full_update_nonlabor", 1),
)
CAPITAL_TABLE = "1D"
CAPITAL_COMPONENT = "national_rate"
WAGE_INDEX_GT1_TABLE = "1A"
WAGE_INDEX_LE1_TABLE = "1B"
COMPONENT_ROLE: dict[str, tuple[str, int]] = {
name: ("labor", rank) for name, rank in LABOR_COMPONENTS
} | {name: ("nonlabor", rank) for name, rank in NONLABOR_COMPONENTS}
def wage_index_table(wage_index: float) -> str:
"""Table code for this wage index. Above 1 uses 1A; 1 and below use 1B."""
if wage_index > 1:
return WAGE_INDEX_GT1_TABLE
return WAGE_INDEX_LE1_TABLE
def _coalesce(table: str, components: tuple[tuple[str, int], ...]) -> str:
ordered = [name for name, _rank in sorted(components, key=lambda item: item[1])]
cases = [
"MAX(CASE WHEN table_code = '"
+ table
+ "' AND component = '"
+ name
+ "' THEN amount END)"
for name in ordered
]
return "COALESCE(" + ", ".join(cases) + ")"
def schedule_sql() -> str:
"""One row per fiscal year: both wage-index splits of the full update."""
return (
"SELECT fiscal_year, "
+ _coalesce(WAGE_INDEX_GT1_TABLE, LABOR_COMPONENTS)
+ " AS labor_gt1, "
+ _coalesce(WAGE_INDEX_GT1_TABLE, NONLABOR_COMPONENTS)
+ " AS nonlabor_gt1, "
+ _coalesce(WAGE_INDEX_LE1_TABLE, LABOR_COMPONENTS)
+ " AS labor_le1, "
+ _coalesce(WAGE_INDEX_LE1_TABLE, NONLABOR_COMPONENTS)
+ " AS nonlabor_le1 "
+ "FROM ipps.standardized_amount GROUP BY fiscal_year"
)