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
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.
218 lines
8.0 KiB
Python
218 lines
8.0 KiB
Python
"""The IPPS operating federal rate uses the published standardized amounts."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import duckdb
|
|
import polars as pl
|
|
import pytest
|
|
|
|
from ipps.calcs.payment import capital_dollars, operating_dollars, operating_payment
|
|
from ipps.rules import wage_index_table
|
|
from ipps.table import OperatingPayment
|
|
|
|
# FY2026 CMS-1833-F full update (quality data and a meaningful EHR user),
|
|
# as loaded from Tables 1A, 1B, and 1D. MS-DRG 470 weight is Table 5.
|
|
_FY2026_GT1 = (4456.72, 2295.89)
|
|
_FY2026_LE1 = (4186.62, 2565.99)
|
|
_FY2026_CAPITAL = 524.15
|
|
_DRG_470 = 1.9289
|
|
|
|
# FY2014 names the same full-update hospital full_update rather than quality_ehr.
|
|
_FY2014_GT1 = (3737.71, 1632.57)
|
|
_FY2014_LE1 = (3329.57, 2040.71)
|
|
|
|
_REPLICA = Path(__file__).resolve().parents[2] / "data" / "replica" / "aco.ro.duckdb"
|
|
|
|
|
|
def _drg() -> pl.DataFrame:
|
|
return pl.DataFrame(
|
|
{
|
|
"ms_drg": ["470", "470"],
|
|
"relative_weight": [_DRG_470, _DRG_470],
|
|
"fiscal_year": [2026, 2014],
|
|
}
|
|
)
|
|
|
|
|
|
def _wage() -> pl.DataFrame:
|
|
return pl.DataFrame(
|
|
{
|
|
"cbsa": ["11111", "22222", "33333", "11111"],
|
|
"state": ["AL", "WY", "AK", "AL"],
|
|
"wage_index": [1.2, 0.9, None, 1.2],
|
|
"year": [2026, 2026, 2026, 2014],
|
|
}
|
|
)
|
|
|
|
|
|
def _amounts() -> pl.DataFrame:
|
|
rows = [
|
|
(2026, "1A", "quality_ehr_labor", _FY2026_GT1[0]),
|
|
(2026, "1A", "quality_ehr_nonlabor", _FY2026_GT1[1]),
|
|
(2026, "1B", "quality_ehr_labor", _FY2026_LE1[0]),
|
|
(2026, "1B", "quality_ehr_nonlabor", _FY2026_LE1[1]),
|
|
(2026, "1A", "no_quality_no_ehr_labor", 4313.38),
|
|
(2026, "1D", "national_rate", _FY2026_CAPITAL),
|
|
(2026, "1E", "standard_federal_rate_full_update", 50824.51),
|
|
(2014, "1A", "full_update_labor", _FY2014_GT1[0]),
|
|
(2014, "1A", "full_update_nonlabor", _FY2014_GT1[1]),
|
|
(2014, "1B", "full_update_labor", _FY2014_LE1[0]),
|
|
(2014, "1B", "full_update_nonlabor", _FY2014_LE1[1]),
|
|
(2014, "1D", "national_rate", 429.31),
|
|
(2014, "1D", "puerto_rico_rate", 209.82),
|
|
]
|
|
return pl.DataFrame(
|
|
{
|
|
"fiscal_year": [row[0] for row in rows],
|
|
"table_code": [row[1] for row in rows],
|
|
"component": [row[2] for row in rows],
|
|
"amount": [row[3] for row in rows],
|
|
}
|
|
)
|
|
|
|
|
|
def _priced() -> pl.DataFrame:
|
|
return operating_payment(_drg(), _wage(), _amounts())
|
|
|
|
|
|
class TestOperatingDollars:
|
|
def test_wage_index_above_one_uses_table_1a(self) -> None:
|
|
assert wage_index_table(1.2) == "1A"
|
|
assert operating_dollars(_DRG_470, *_FY2026_GT1, 1.2) == 14744.42
|
|
|
|
def test_wage_index_at_or_below_one_uses_table_1b(self) -> None:
|
|
assert wage_index_table(1.0) == "1B"
|
|
assert wage_index_table(0.9) == "1B"
|
|
assert operating_dollars(_DRG_470, *_FY2026_LE1, 0.9) == 12217.55
|
|
# At wage index 1 the two splits add to the same national amount.
|
|
assert operating_dollars(_DRG_470, *_FY2026_GT1, 1.0) == 13025.11
|
|
assert operating_dollars(_DRG_470, *_FY2026_LE1, 1.0) == 13025.11
|
|
|
|
def test_capital_is_the_national_rate_times_the_weight(self) -> None:
|
|
assert capital_dollars(_DRG_470, _FY2026_CAPITAL) == 1011.03
|
|
|
|
|
|
class TestOperatingPayment:
|
|
def test_output_matches_the_table_contract(self) -> None:
|
|
assert set(_priced().columns) == set(OperatingPayment.column_names())
|
|
|
|
def test_high_wage_index_uses_the_table_1a_dollars(self) -> None:
|
|
row = _priced().filter(
|
|
(pl.col("fiscal_year") == 2026) & (pl.col("cbsa") == "11111")
|
|
)
|
|
assert row["labor"][0] == _FY2026_GT1[0]
|
|
assert row["nonlabor"][0] == _FY2026_GT1[1]
|
|
assert row["operating_payment"][0] == 14744.42
|
|
assert row["capital_payment"][0] == 1011.03
|
|
|
|
def test_low_wage_index_uses_the_table_1b_dollars(self) -> None:
|
|
row = _priced().filter(pl.col("cbsa") == "22222")
|
|
assert row["labor"][0] == _FY2026_LE1[0]
|
|
assert row["nonlabor"][0] == _FY2026_LE1[1]
|
|
assert row["operating_payment"][0] == 12217.55
|
|
|
|
def test_a_blank_wage_index_is_filled_with_one(self) -> None:
|
|
row = _priced().filter(pl.col("cbsa") == "33333")
|
|
assert row["wage_index"][0] == 1.0
|
|
assert row["labor"][0] == _FY2026_LE1[0]
|
|
assert row["operating_payment"][0] == 13025.11
|
|
|
|
def test_fy2014_full_update_name_is_the_full_update(self) -> None:
|
|
row = _priced().filter(pl.col("fiscal_year") == 2014)
|
|
assert row["labor"][0] == _FY2014_GT1[0]
|
|
assert row["operating_payment"][0] == operating_dollars(
|
|
_DRG_470, *_FY2014_GT1, 1.2
|
|
)
|
|
# Puerto Rico's capital rate is not the national rate.
|
|
assert row["capital_rate"][0] == 429.31
|
|
|
|
def test_quality_ehr_wins_when_a_year_also_has_the_old_name(self) -> None:
|
|
amounts = pl.concat(
|
|
[
|
|
_amounts(),
|
|
pl.DataFrame(
|
|
{
|
|
"fiscal_year": [2026, 2026],
|
|
"table_code": ["1A", "1A"],
|
|
"component": ["full_update_labor", "full_update_nonlabor"],
|
|
"amount": [1.0, 1.0],
|
|
}
|
|
),
|
|
]
|
|
)
|
|
priced = operating_payment(_drg(), _wage(), amounts)
|
|
row = priced.filter(
|
|
(pl.col("fiscal_year") == 2026) & (pl.col("cbsa") == "11111")
|
|
)
|
|
assert row["labor"][0] == _FY2026_GT1[0]
|
|
|
|
|
|
class TestPipe:
|
|
def test_step_writes_the_operating_payment_table(self) -> None:
|
|
from ipps.pipe import STEPS
|
|
|
|
assert STEPS[0][2] is OperatingPayment
|
|
|
|
def test_registry_runs_one_expression(self) -> None:
|
|
from aco.pipe import registry
|
|
|
|
assert len(registry["ipps"]) == 1
|
|
assert registry["ipps"].names() == ["ipps.operating_payment"]
|
|
|
|
|
|
@pytest.mark.skipif(not _REPLICA.is_file(), reason="aco replica is not present")
|
|
class TestLoadedTables:
|
|
def test_every_loaded_year_reconciles_at_wage_index_one(self) -> None:
|
|
from rec.engine import reconcile
|
|
from rec.pricers.ipps import IppsPricer
|
|
|
|
con = duckdb.connect(str(_REPLICA), read_only=True)
|
|
try:
|
|
pricer = IppsPricer()
|
|
years = pricer.years_available(con)
|
|
assert years == list(range(2014, 2028))
|
|
for year in years:
|
|
result = reconcile(pricer, con, year)
|
|
assert result.matched_rows > 700, year
|
|
assert result.exact_matches == result.matched_rows, year
|
|
assert result.ground_truth_only == 0
|
|
assert result.calculated_only == 0
|
|
finally:
|
|
con.close()
|
|
|
|
def test_fy2026_drg_470_on_a_real_cbsa(self) -> None:
|
|
con = duckdb.connect(str(_REPLICA), read_only=True)
|
|
try:
|
|
drg = con.execute(
|
|
"""
|
|
SELECT ms_drg, relative_weight, fiscal_year
|
|
FROM ipps.drg_weight
|
|
WHERE fiscal_year = 2026 AND ms_drg = '470'
|
|
"""
|
|
).pl()
|
|
wage = con.execute(
|
|
"""
|
|
SELECT cbsa, state, wage_index, year
|
|
FROM opps.wage_index
|
|
WHERE year = 2026 AND cbsa = '10180' AND wage_index IS NOT NULL
|
|
"""
|
|
).pl()
|
|
amounts = con.execute(
|
|
"""
|
|
SELECT fiscal_year, table_code, component, amount
|
|
FROM ipps.standardized_amount
|
|
WHERE fiscal_year = 2026
|
|
"""
|
|
).pl()
|
|
finally:
|
|
con.close()
|
|
assert wage.height >= 1
|
|
priced = operating_payment(drg, wage, amounts)
|
|
index = float(wage["wage_index"][0])
|
|
band = _FY2026_GT1 if index > 1 else _FY2026_LE1
|
|
row = priced.filter(pl.col("state") == wage["state"][0])
|
|
assert row["operating_payment"][0] == operating_dollars(_DRG_470, *band, index)
|
|
assert row["capital_payment"][0] == capital_dollars(_DRG_470, _FY2026_CAPITAL)
|