feat(ipps): price the claim from the published factors
Some checks failed
CI / lint (push) Failing after 44s
CI / notebooks-smoke (push) Successful in 1m48s
Deploy / changes (push) Successful in 18s
Infra CI / notebooks (push) Successful in 55s
Infra CI / zotero (push) Successful in 23s
CI / test (push) Successful in 4m23s
Infra CI / docs (push) Successful in 22s
Infra CI / api (push) Successful in 1m10s
Infra CI / bcda (push) Successful in 1m46s
Infra CI / llm (push) Successful in 52s
Infra CI / mc (push) Successful in 20s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Successful in 2m0s
Lean Pay / pay (push) Successful in 3m26s
Deploy / bcda (push) Successful in 1m59s
Deploy / mc (push) Has been skipped
Deploy / llm (push) Successful in 1m19s
Deploy / report (push) Successful in 15s
Comment Pull / comment-pull (push) Failing after 29s
Notebooks Integration / notebooks-integration (push) Failing after 12m24s
Renovate / renovate (push) Successful in 2m31s
LLM Golden / llm-golden (push) Successful in 29m52s
Zotero Sync / zotero-sync (push) Successful in 3m3s
Package Supply Chain / pkg-supply-chain (push) Successful in 1m35s

Operating payment is the federal rate with COLA on the nonlabor portion,
times (1 + operating IME + operating DSH), plus the uncompensated-care
add-on. The impact-file operating DSH is already the empirically justified
factor and is not multiplied by 0.25. Capital payment is the Table 1D
national rate times the hospital GAF, times (1 + capital IME + capital DSH).
The impact file is the final-rule model, not the quarterly Provider Specific
File.

An outlier is the 42 CFR 412.84 marginal factor on the excess of charge-based
cost over that claim payment and the wage- or GAF-adjusted fixed-loss share.
No charges, or no published fixed-loss threshold, produces no outlier. The
national wage-index-1 federal-rate identity is unchanged.
This commit is contained in:
kert
2026-11-18 12:51:45 -05:00
parent 0d99be1b06
commit 37c732dfd0
16 changed files with 1076 additions and 57 deletions

View File

@@ -12,8 +12,8 @@ Table 5 is the MS-DRG weight. When CMS publishes both a weight and a
Table 1A-1E is the national standardized amounts. Each published dollar
is one point.
There is still no claim-level IPPS pricer. IME, DSH, and outliers are
not computed here.
This loader stores the published tables. It does not price a claim.
Claim payment is ``ipps.calcs.claim_payment``.
"""
from __future__ import annotations

View File

@@ -43,6 +43,38 @@ theorem mppr_second : mpprPe 4 2 (1 / 2) = 2 := by
theorem pfs_is_formula : ceiling .pfs = .formula := by decide
theorem ipps_is_absent : ceiling .ipps = .absent := by decide
theorem ipps_operating_cola_one
(weight labor nonlabor wageIndex : Rat) :
ippsOperatingClaim weight labor nonlabor wageIndex 1 0 0 0
= ippsOperating weight labor nonlabor wageIndex 1 := by
unfold ippsOperatingClaim ippsOperating
ring
theorem ipps_capital_gaf_one (weight rate : Rat) :
ippsCapitalClaim weight rate 1 0 0 = ippsCapital weight rate 1 := by
unfold ippsCapitalClaim ippsCapital
ring
theorem ipps_operating_example :
ippsOperatingClaim 2 10 5 1 1 (1 / 8) (1 / 8) 1 = 77 / 2 := by
unfold ippsOperatingClaim ippsOperating
norm_num
theorem ipps_capital_example :
ippsCapitalClaim 2 10 1 (1 / 4) 0 = 25 := by
unfold ippsCapitalClaim ippsCapital
norm_num
theorem ipps_outlier_example :
ippsOutlier 1000 (1 / 4) (1 / 4) 30 20 100 (1 / 2) (1 / 2) 1 1 1
outlierMarginal
= 280 := by
unfold ippsOutlier ippsOperatingOutlier ippsCapitalOutlier ippsWageCola
outlierMarginal
norm_num
theorem ipps_is_formula : ceiling .ipps = .formula := by decide
theorem lead_is_absent : ceiling .lead = .absent := by decide
end Pay

View File

@@ -28,6 +28,15 @@ def payload : String :=
emit "qpp-2024" (Int.ofNat (paymentYear 2024)) 1,
emitRat "equipment-minute" (equipmentCostPerMinute 1000 5 10000 0),
emitRat "mppr-second" (mpprPe 4 2 (1 / 2)),
emitRat "ipps-operating-cola-one"
(ippsOperatingClaim 2 10 5 1 1 0 0 0),
emitRat "ipps-operating-claim"
(ippsOperatingClaim 2 10 5 1 1 (1 / 8) (1 / 8) 1),
emitRat "ipps-capital-gaf-one" (ippsCapitalClaim 2 10 1 0 0),
emitRat "ipps-capital-claim" (ippsCapitalClaim 2 10 1 (1 / 4) 0),
emitRat "ipps-outlier"
(ippsOutlier 1000 (1 / 4) (1 / 4) 30 20 100 (1 / 2) (1 / 2) 1 1 1
outlierMarginal),
]
"[" ++ String.intercalate "," rows ++ "]"

View File

@@ -58,6 +58,87 @@ def equipmentCostPerMinute
def mpprPe (pe : Rat) (rank : Nat) (reduction : Rat) : Rat :=
if rank = 1 then pe else pe * (1 - reduction)
/-- IPPS operating federal amount, before the cent round.
`weight × (labor × wageIndex + nonlabor × cola)`.
`labor` and `nonlabor` are the Table 1A dollars when the wage index is
above 1, and the Table 1B dollars otherwise. The caller picks the band.
COLA 1 leaves the nonlabor portion unchanged. -/
def ippsOperating
(weight labor nonlabor wageIndex cola : Rat) : Rat :=
weight * (labor * wageIndex + nonlabor * cola)
/-- Operating claim before the outlier and before the cent round.
`operatingDsh` is the empirically justified factor already printed on
the impact file. It is not multiplied by 1/4 again. A missing
uncompensated-care add-on is the caller's `0`. -/
def ippsOperatingClaim
(weight labor nonlabor wageIndex cola ime dsh ucp : Rat) : Rat :=
ippsOperating weight labor nonlabor wageIndex cola * (1 + ime + dsh) + ucp
/-- Capital amount at a geographic adjustment factor, before the cent round.
GAF 1 is `weight ×` the Table 1D national rate. A provider claim passes
the hospital GAF from the impact file. That factor already includes
capital COLA, so an area GAF is not applied as well. -/
def ippsCapital (weight rate gaf : Rat) : Rat :=
weight * rate * gaf
/-- Capital claim before the outlier and before the cent round. -/
def ippsCapitalClaim (weight rate gaf ime dsh : Rat) : Rat :=
ippsCapital weight rate gaf * (1 + ime + dsh)
/-- 42 CFR 412.84(k). Not a MAC Implementation File cell. -/
def outlierMarginal : Rat := 4 / 5
/-- 42 CFR 412.84(l), for a burn DRG the year's notice names.
No burn-DRG list is loaded. The caller passes this factor. -/
def outlierBurnMarginal : Rat := 9 / 10
/-- MAC labor and nonlabor shares for the outlier threshold.
These are not the Table 1A or Table 1B dollar split. A published
nonlabor share need not equal `1 - laborShare`. -/
def ippsWageCola
(laborShare nonlaborShare wageIndex cola : Rat) : Rat :=
laborShare * wageIndex + nonlaborShare * cola
/-- Operating outlier before the cent round.
`paid` is the operating claim including IME, the printed DSH factor,
and the uncompensated-care add-on. The fixed-loss threshold is split
by the CCR share, then adjusted by the MAC wage and COLA factor.
A non-positive excess pays nothing. -/
def ippsOperatingOutlier
(charges operatingCcr capitalCcr paid fixedLoss
laborShare nonlaborShare wageIndex cola marginal : Rat) : Rat :=
let cost := charges * operatingCcr
let share := operatingCcr / (operatingCcr + capitalCcr)
let gap :=
fixedLoss * share * ippsWageCola laborShare nonlaborShare wageIndex cola
let excess := cost - paid - gap
marginal * max excess 0
/-- Capital outlier before the cent round.
`paid` includes capital IME and capital DSH. The capital share of the
fixed-loss threshold is adjusted by the same GAF as the capital claim. -/
def ippsCapitalOutlier
(charges operatingCcr capitalCcr paid fixedLoss gaf marginal : Rat) : Rat :=
let cost := charges * capitalCcr
let share := capitalCcr / (operatingCcr + capitalCcr)
let excess := cost - paid - fixedLoss * share * gaf
marginal * max excess 0
/-- Operating outlier plus capital outlier, before the cent round. -/
def ippsOutlier
(charges operatingCcr capitalCcr operatingPaid capitalPaid fixedLoss
laborShare nonlaborShare wageIndex cola gaf marginal : Rat) : Rat :=
ippsOperatingOutlier charges operatingCcr capitalCcr operatingPaid fixedLoss
laborShare nonlaborShare wageIndex cola marginal
+ ippsCapitalOutlier charges operatingCcr capitalCcr capitalPaid fixedLoss
gaf marginal
/-- What kind of ceiling this repo has for a methodology. -/
inductive Method where
| pfs
@@ -76,12 +157,13 @@ inductive Ceiling where
| absent
deriving DecidableEq, Repr
/-- IPPS has no pricer here. MSSP and REACH settlements are the CMS
tables. LEAD in this repo is the review application, not a pricer.
REACH's quality earn-back is the one closed form, `reachEarnBack`. -/
/-- MSSP and REACH settlements are the CMS tables. LEAD in this repo
is the review application, not a pricer. REACH's quality earn-back is
the closed form `reachEarnBack`. IPPS claim payment is `ippsOperatingClaim`,
`ippsCapitalClaim`, and `ippsOutlier`. -/
def ceiling : Method → Ceiling
| .pfs | .opps | .partBAsp | .qpp => .formula
| .pfs | .opps | .partBAsp | .qpp | .ipps => .formula
| .mssp | .reach => .publishedTable
| .ipps | .lead => .absent
| .lead => .absent
end Pay

View File

@@ -22,9 +22,14 @@ does not link mathlib.
| MPPR on later PE ranks | `mpprPe` | `pfs.calcs.payment.mppr_reduction` |
| QPP year offset | `paymentYear` | `qpp` (`payment_year = performance_year + 2`) |
| REACH quality earn-back | `reachEarnBack` | Documented on the REACH quality table; CMS publishes the column |
| IPPS operating claim | `ippsOperatingClaim` | `ipps.calcs.payment.operating_claim` |
| IPPS capital claim | `ippsCapitalClaim` | `ipps.calcs.payment.capital_claim` |
| IPPS outlier | `ippsOutlier` | `ipps.calcs.payment.outlier_payment` |
A missing OPPS wage index is `1`. `oppsAdjusted_wageIndex_one` says the
labor share then cancels.
labor share then cancels. An IPPS claim at COLA 1 with IME, DSH, and
uncompensated care at 0 equals `ippsOperating`. Capital at GAF 1 with
IME and DSH at 0 equals `ippsCapital`.
## What is not a formula here
@@ -32,7 +37,6 @@ labor share then cancels.
- MSSP and REACH settlements are the published CMS tables under `src/aco`.
There is no shared-savings function to put a maximum on.
- IPPS has no pricer in this repo.
- LEAD in this repo is the review application (`src/lead`), not a payment
model. No LEAD pricer is invented here.
- QPP thresholds stay in `src/qpp`, cited to the Federal Register. Only
@@ -56,8 +60,9 @@ index is the IPPS final-rule table for that fiscal year (Table 3, or
Table 4A and 4B in FY2014 and FY2015). A blank pre-reclassification
index stays blank. Equipment maintenance is the published factor 5/100
for every item; the straight-line function still fills a missing factor
with 0, and that fill is not the CMS factor. There is no IPPS claim
pricer and no LEAD pricer. Standardized amounts and MS-DRG weights are
with 0, and that fill is not the CMS factor. IPPS claim payment is an
output of the formula, not a sampled point. There is no LEAD pricer.
Standardized amounts and MS-DRG weights are
published points and ranges. MSSP and REACH settlements stay published
tables; the observed dollar columns are separate rows, and there is no
savings function to sample. The budget-neutrality adjustor is already

View File

@@ -1 +1 @@
[{"id":"pfs-unit-gpci","num":60,"den":1},{"id":"limiting-100","num":437,"den":4},{"id":"opps-wage","num":103,"den":1},{"id":"opps-missing-wage","num":80,"den":1},{"id":"asp-100","num":106,"den":1},{"id":"reach-earn-back-85","num":17,"den":1000},{"id":"qpp-2024","num":2026,"den":1},{"id":"equipment-minute","num":1,"den":50},{"id":"mppr-second","num":2,"den":1}]
[{"id":"pfs-unit-gpci","num":60,"den":1},{"id":"limiting-100","num":437,"den":4},{"id":"opps-wage","num":103,"den":1},{"id":"opps-missing-wage","num":80,"den":1},{"id":"asp-100","num":106,"den":1},{"id":"reach-earn-back-85","num":17,"den":1000},{"id":"qpp-2024","num":2026,"den":1},{"id":"equipment-minute","num":1,"den":50},{"id":"mppr-second","num":2,"den":1},{"id":"ipps-operating-cola-one","num":30,"den":1},{"id":"ipps-operating-claim","num":77,"den":2},{"id":"ipps-capital-gaf-one","num":20,"den":1},{"id":"ipps-capital-claim","num":25,"den":1},{"id":"ipps-outlier","num":280,"den":1}]

View File

@@ -32,7 +32,9 @@ pipeline = Pipeline(
description=(
"MS-DRG weight times the full-update labor and nonlabor "
"standardized amounts, adjusted by the pre-reclassification "
"wage index. IME, DSH, and outliers are not applied."
"wage index. This table is the federal rate. The claim, "
"including IME, DSH, uncompensated care, the hospital "
"capital GAF, and outliers, is ipps.calcs.claim_payment."
),
),
],

View File

@@ -1,26 +1,50 @@
"""ipps — Inpatient Prospective Payment System operating federal rate.
"""ipps — Inpatient Prospective Payment System claim payment.
Prices an MS-DRG from the published Table 5 weight and the full-update
standardized amounts in Tables 1A and 1B::
The operating federal rate prices an MS-DRG from the published Table 5
weight and the full-update standardized amounts in Tables 1A and 1B::
weight × (labor × wage_index + nonlabor)
Table 1A applies when the wage index is above 1. Table 1B applies
otherwise. Capital is the Table 5 weight times the Table 1D national
rate, before the geographic adjustment factor.
otherwise. ``operating_dollars`` rounds that product at COLA 1.
``operating_payment`` is the same rate for every loaded CBSA. Capital
at GAF 1 is the Table 5 weight times the Table 1D national rate.
Indirect medical education, disproportionate share, and outliers are
not priced. Published area GAF, MAC File 1, and the final-rule hospital
factors are loaded beside this rate and are not applied here.
``src/lead`` is unrelated: it is the review application.
``claim_payment`` is the claim. It reads the final-rule impact file
for the hospital's payment wage index, COLA, IME, DSH, capital GAF,
CCRs, and uncompensated-care add-on. That file is not the quarterly
Provider Specific File. The printed operating DSH factor is not
multiplied by 0.25. The hospital GAF is not combined with the area
GAF. An outlier needs covered charges and a published fixed-loss
threshold; otherwise that add-on is absent. ``src/lead`` is unrelated.
"""
from ipps.calcs import capital_dollars, operating_dollars, operating_payment
from ipps.calcs import (
OUTLIER_BURN_MARGINAL,
OUTLIER_MARGINAL,
capital_claim,
capital_dollars,
capital_federal,
claim_payment,
operating_claim,
operating_dollars,
operating_federal,
operating_payment,
outlier_payment,
)
from ipps.rules import wage_index_table
__all__ = [
"OUTLIER_BURN_MARGINAL",
"OUTLIER_MARGINAL",
"capital_claim",
"capital_dollars",
"capital_federal",
"claim_payment",
"operating_claim",
"operating_dollars",
"operating_federal",
"operating_payment",
"outlier_payment",
"wage_index_table",
]

View File

@@ -1,5 +1,29 @@
"""IPPS payment calculations."""
from ipps.calcs.payment import capital_dollars, operating_dollars, operating_payment
from ipps.calcs.payment import (
OUTLIER_BURN_MARGINAL,
OUTLIER_MARGINAL,
capital_claim,
capital_dollars,
capital_federal,
claim_payment,
operating_claim,
operating_dollars,
operating_federal,
operating_payment,
outlier_payment,
)
__all__ = ["capital_dollars", "operating_dollars", "operating_payment"]
__all__ = [
"OUTLIER_BURN_MARGINAL",
"OUTLIER_MARGINAL",
"capital_claim",
"capital_dollars",
"capital_federal",
"claim_payment",
"operating_claim",
"operating_dollars",
"operating_federal",
"operating_payment",
"outlier_payment",
]

View File

@@ -1,22 +1,39 @@
"""IPPS operating federal rate.
"""IPPS operating federal rate and the claim built from published factors.
The rate for a hospital that submitted quality data and is a meaningful
EHR user is::
weight × (labor × wage_index + nonlabor)
weight × (labor × wage_index + nonlabor × COLA)
``labor`` and ``nonlabor`` come from Table 1A when the wage index is
above 1, and from Table 1B otherwise. A missing wage index is filled
with 1, which selects Table 1B. The two tables add to the same national
standardized amount, so a wage index of 1 pays that amount times the
weight either way.
weight either way. COLA 1 leaves the nonlabor portion unchanged, which
is what ``operating_dollars`` already rounds to cents.
Capital is ``weight ×`` the Table 1D national rate. That is the rate
before the capital geographic adjustment factor.
Capital at GAF 1 is ``weight ×`` the Table 1D national rate. A claim
multiplies that by the hospital capital GAF from the final-rule impact
file. That GAF already includes capital COLA, so the claim does not
apply the area GAF as well.
This is not the claim payment. Indirect medical education, disproportionate
share, and outliers are not applied. A reclassified wage index is not
substituted for a blank pre-reclassification cell.
The claim then applies the impact-file factors. Operating payment is
the federal amount times ``(1 + operating IME + operating DSH)`` plus
the uncompensated-care add-on. The printed operating DSH column is
already the empirically justified factor; it is not multiplied by
0.25 again. Capital payment is the GAF-adjusted amount times
``(1 + capital IME + capital DSH)``. The impact file is the final-rule
model, not the quarterly Provider Specific File.
An outlier, when the claim has covered charges, follows 42 CFR 412.84.
Cost is charges times the CCR. The fixed-loss threshold is split by
the operating and capital CCR shares, the operating share is adjusted
by the MAC labor share, wage index, and COLA, and the capital share is
adjusted by the GAF. The marginal factor is 4/5, or 9/10 when the
caller passes the burn factor. No burn-DRG list is loaded. A claim
with no charges, or a year with no published fixed-loss threshold,
has no outlier payment. MAC labor shares are the outlier-threshold
shares only. They do not replace the Table 1A and 1B dollar amounts.
"""
from __future__ import annotations
@@ -30,8 +47,13 @@ from ipps.rules import (
COMPONENT_ROLE,
WAGE_INDEX_GT1_TABLE,
WAGE_INDEX_LE1_TABLE,
wage_index_table,
)
# 42 CFR 412.84(k) and (l). Not cells in MAC Implementation File 1.
OUTLIER_MARGINAL = 4 / 5
OUTLIER_BURN_MARGINAL = 9 / 10
def operating_dollars(
weight: float, labor: float, nonlabor: float, wage_index: float
@@ -45,6 +67,190 @@ def capital_dollars(weight: float, capital_rate: float) -> float:
return round(weight * capital_rate, 2)
def _fill(value: float | None, default: float) -> float:
return default if value is None else float(value)
def operating_federal(
weight: float,
labor: float,
nonlabor: float,
wage_index: float,
cola: float = 1.0,
) -> float:
"""Unrounded operating federal amount. COLA multiplies nonlabor only."""
return weight * (labor * wage_index + nonlabor * cola)
def operating_claim(
weight: float,
labor: float,
nonlabor: float,
wage_index: float | None,
*,
cola: float | None = 1.0,
operating_ime: float | None = 0.0,
operating_dsh: float | None = 0.0,
ucp_per_claim: float | None = 0.0,
) -> float:
"""Operating claim in cents, before any outlier.
``operating_dsh`` is the factor already printed on the impact file.
A missing wage index is 1. A missing COLA is 1. A missing IME, DSH,
or uncompensated-care add-on contributes nothing. COLA 1 and zero
adjustments equal ``operating_dollars``.
"""
paid, cents = _operating_parts(
weight,
labor,
nonlabor,
wage_index,
cola=cola,
operating_ime=operating_ime,
operating_dsh=operating_dsh,
ucp_per_claim=ucp_per_claim,
)
del paid
return cents
def _operating_parts(
weight: float,
labor: float,
nonlabor: float,
wage_index: float | None,
*,
cola: float | None,
operating_ime: float | None,
operating_dsh: float | None,
ucp_per_claim: float | None,
) -> tuple[float, float]:
wage = _fill(wage_index, 1.0)
federal = operating_federal(weight, labor, nonlabor, wage, _fill(cola, 1.0))
paid = federal * (
1.0 + _fill(operating_ime, 0.0) + _fill(operating_dsh, 0.0)
) + _fill(ucp_per_claim, 0.0)
return paid, round(paid, 2)
def capital_federal(weight: float, capital_rate: float, gaf: float = 1.0) -> float:
"""Unrounded capital amount. GAF 1 is the Table 1D national identity."""
return weight * capital_rate * gaf
def capital_claim(
weight: float,
capital_rate: float,
*,
gaf: float | None = 1.0,
capital_ime: float | None = 0.0,
capital_dsh: float | None = 0.0,
) -> float:
"""Capital claim in cents, before any outlier.
``gaf`` is the hospital capital GAF when the claim names a provider,
and 1 for the national identity. It is not an area GAF stacked on a
hospital GAF. A missing IME or DSH contributes nothing. GAF 1 and
zero adjustments equal ``capital_dollars``.
"""
_paid, cents = _capital_parts(
weight,
capital_rate,
gaf=gaf,
capital_ime=capital_ime,
capital_dsh=capital_dsh,
)
return cents
def _capital_parts(
weight: float,
capital_rate: float,
*,
gaf: float | None,
capital_ime: float | None,
capital_dsh: float | None,
) -> tuple[float, float]:
federal = capital_federal(weight, capital_rate, _fill(gaf, 1.0))
paid = federal * (1.0 + _fill(capital_ime, 0.0) + _fill(capital_dsh, 0.0))
return paid, round(paid, 2)
def outlier_payment(
charges: float | None,
*,
operating_ccr: float | None,
capital_ccr: float | None,
operating_paid: float,
capital_paid: float,
fixed_loss: float | None,
wage_index: float,
cola: float | None = 1.0,
gaf: float | None = 1.0,
labor_share: float | None,
nonlabor_share: float | None,
marginal: float | None = OUTLIER_MARGINAL,
operating_ccr_ceiling: float | None = None,
capital_ccr_ceiling: float | None = None,
) -> float | None:
"""Outlier dollars, or ``None`` when the case cannot be priced.
``operating_paid`` and ``capital_paid`` are the unrounded claim
amounts. Operating paid includes IME, the printed DSH factor, and
the uncompensated-care add-on. Capital paid includes capital IME
and capital DSH. Neither includes an outlier.
``labor_share`` and ``nonlabor_share`` are the MAC shares for the
wage-index band, including a nonlabor share that does not equal
one minus the labor share. The fixed-loss threshold is split by
the CCR shares first. The operating piece is then multiplied by
``labor_share × wage_index + nonlabor_share × COLA``, and the
capital piece by the GAF.
Returns ``None`` when charges, the fixed-loss threshold, either
CCR, or either share is missing, when the CCRs sum to zero, or
when a CCR exceeds a published ceiling. The ceiling's replacement
is a statewide average, and that average is not loaded. A computed
case whose cost does not clear the threshold returns 0.
"""
if (
charges is None
or fixed_loss is None
or operating_ccr is None
or capital_ccr is None
or labor_share is None
or nonlabor_share is None
):
return None
if operating_ccr_ceiling is not None and operating_ccr > operating_ccr_ceiling:
return None
if capital_ccr_ceiling is not None and capital_ccr > capital_ccr_ceiling:
return None
total_ccr = operating_ccr + capital_ccr
if total_ccr == 0:
return None
wage_factor = labor_share * wage_index + nonlabor_share * _fill(cola, 1.0)
operating_gap = fixed_loss * (operating_ccr / total_ccr) * wage_factor
capital_gap = fixed_loss * (capital_ccr / total_ccr) * _fill(gaf, 1.0)
factor = _fill(marginal, OUTLIER_MARGINAL)
operating_excess = charges * operating_ccr - operating_paid - operating_gap
capital_excess = charges * capital_ccr - capital_paid - capital_gap
operating_out = factor * operating_excess if operating_excess > 0 else 0.0
capital_out = factor * capital_excess if capital_excess > 0 else 0.0
return round(operating_out + capital_out, 2)
def _provider_key(value: object) -> str | None:
if value is None:
return None
text = str(value).strip()
if text.endswith(".0") and text[:-2].isdigit():
text = text[:-2]
if text.isdigit() and len(text) <= 6:
return text.zfill(6)
return text
def _schedule(amounts: FrameT) -> FrameT:
"""Full-update labor and nonlabor for both wage-index bands, plus capital."""
best: dict[tuple[int, str, str], tuple[int, float]] = {}
@@ -168,3 +374,224 @@ def operating_payment(
"capital_payment",
)
)
_CLAIM_COLUMNS = (
"ms_drg",
"fiscal_year",
"provider",
"relative_weight",
"wage_index",
"cola",
"gaf",
"labor",
"nonlabor",
"operating_ime",
"operating_dsh",
"ucp_per_claim",
"capital_rate",
"capital_ime",
"capital_dsh",
"operating_payment",
"capital_payment",
"outlier_payment",
"payment",
)
def _maybe(value: object) -> float | None:
if isinstance(value, bool) or not isinstance(value, int | float):
return None
return float(value)
def _from(
hospital: dict[str, object] | None, row: dict[str, object], name: str
) -> float | None:
if hospital is not None:
found = _maybe(hospital.get(name))
if found is not None:
return found
return _maybe(row.get(name))
def _year_amount(
factors: dict[tuple[int, str], float], year: int, name: str
) -> float | None:
amount = factors.get((year, name))
if amount is None:
return None
return float(amount)
def _price_claim_row(
row: dict[str, object],
*,
weights: dict[tuple[int, str], float],
schedule: dict[int, dict[str, object]],
hospitals: dict[tuple[int, str], dict[str, object]],
factors: dict[tuple[int, str], float],
) -> dict[str, object]:
"""One claim. A named provider uses the impact-file factors.
No matching provider still prices the federal rate. The claim's own
wage index, COLA, and GAF are used, each filled with 1, and IME, DSH,
and uncompensated care stay at zero.
"""
year = int(row["fiscal_year"]) # required
ms_drg = None if row.get("ms_drg") is None else str(row["ms_drg"])
provider = _provider_key(row.get("provider"))
hospital = hospitals.get((year, provider)) if provider is not None else None
band = schedule.get(year)
weight = None if ms_drg is None else weights.get((year, ms_drg))
blank: dict[str, object] = {name: None for name in _CLAIM_COLUMNS}
blank["ms_drg"] = ms_drg
blank["fiscal_year"] = year
blank["provider"] = provider
if band is None or weight is None or _maybe(band.get("capital_rate")) is None:
return blank
provider_wage = (
None if hospital is None else _maybe(hospital.get("payment_wage_index"))
)
wage = (
provider_wage
if provider_wage is not None
else _fill(_maybe(row.get("wage_index")), 1.0)
)
cola = _from(hospital, row, "cola")
if cola is None:
cola = 1.0
gaf = _from(hospital, row, "gaf")
if gaf is None:
gaf = 1.0
ime = None if hospital is None else _maybe(hospital.get("operating_ime"))
dsh = None if hospital is None else _maybe(hospital.get("operating_dsh"))
ucp = None if hospital is None else _maybe(hospital.get("ucp_per_claim"))
capital_ime = None if hospital is None else _maybe(hospital.get("capital_ime"))
capital_dsh = None if hospital is None else _maybe(hospital.get("capital_dsh"))
gt1 = wage_index_table(wage) == WAGE_INDEX_GT1_TABLE
labor = float(band["labor_gt1"] if gt1 else band["labor_le1"]) # type: ignore[arg-type]
nonlabor = float(band["nonlabor_gt1"] if gt1 else band["nonlabor_le1"]) # type: ignore[arg-type]
capital_rate = float(band["capital_rate"]) # type: ignore[arg-type]
operating_paid, operating_cents = _operating_parts(
weight,
labor,
nonlabor,
wage,
cola=cola,
operating_ime=ime,
operating_dsh=dsh,
ucp_per_claim=ucp,
)
capital_paid, capital_cents = _capital_parts(
weight,
capital_rate,
gaf=gaf,
capital_ime=capital_ime,
capital_dsh=capital_dsh,
)
share = "gt1" if gt1 else "le1"
outlier = outlier_payment(
_maybe(row.get("charges")),
operating_ccr=_from(hospital, row, "operating_ccr"),
capital_ccr=_from(hospital, row, "capital_ccr"),
operating_paid=operating_paid,
capital_paid=capital_paid,
fixed_loss=_year_amount(factors, year, "fixed_loss_threshold"),
wage_index=wage,
cola=cola,
gaf=gaf,
labor_share=_year_amount(factors, year, f"labor_share_{share}"),
nonlabor_share=_year_amount(factors, year, f"nonlabor_share_{share}"),
marginal=_maybe(row.get("marginal")),
operating_ccr_ceiling=_year_amount(factors, year, "operating_ccr_ceiling"),
capital_ccr_ceiling=_year_amount(factors, year, "capital_ccr_ceiling"),
)
extra = 0.0 if outlier is None else outlier
return {
"ms_drg": ms_drg,
"fiscal_year": year,
"provider": provider,
"relative_weight": weight,
"wage_index": wage,
"cola": cola,
"gaf": gaf,
"labor": labor,
"nonlabor": nonlabor,
"operating_ime": ime,
"operating_dsh": dsh,
"ucp_per_claim": ucp,
"capital_rate": capital_rate,
"capital_ime": capital_ime,
"capital_dsh": capital_dsh,
"operating_payment": operating_cents,
"capital_payment": capital_cents,
"outlier_payment": outlier,
"payment": round(operating_cents + capital_cents + extra, 2),
}
@nw.narwhalify
def claim_payment(
claims: FrameT,
drg: FrameT,
amounts: FrameT,
providers: FrameT,
factors: FrameT,
) -> FrameT:
"""Price each claim from the published weights, rates, and factors.
``claims`` has ``ms_drg`` and ``fiscal_year``. ``provider`` selects
the final-rule impact file, which is not the quarterly Provider
Specific File. That row supplies the payment wage index, COLA,
operating and capital IME and DSH, the hospital capital GAF, CCRs,
and the uncompensated-care add-on. A claim with no provider uses
its own ``wage_index``, ``cola``, and ``gaf``, each filled with 1
when missing, and no IME, DSH, or uncompensated-care add-on.
``charges`` prices an outlier. Without charges the outlier column
is null and ``payment`` is the operating claim plus the capital
claim. The national wage-index cross join remains
``operating_payment``.
"""
weights: dict[tuple[int, str], float] = {}
for item in drg.select("ms_drg", "relative_weight", "fiscal_year").rows(named=True):
if item["ms_drg"] is None or item["relative_weight"] is None:
continue
weights[(int(item["fiscal_year"]), str(item["ms_drg"]))] = float(
item["relative_weight"]
)
schedule = {
int(item["fiscal_year"]): item for item in _schedule(amounts).rows(named=True)
}
hospitals: dict[tuple[int, str], dict[str, object]] = {}
for item in providers.rows(named=True):
key = _provider_key(item.get("provider"))
if key is None or item.get("fiscal_year") is None:
continue
hospitals[(int(item["fiscal_year"]), key)] = item
national: dict[tuple[int, str], float] = {}
for item in factors.rows(named=True):
if item.get("area") not in ("", None) or item.get("amount") is None:
continue
if item.get("fiscal_year") is None or item.get("factor") is None:
continue
national[(int(item["fiscal_year"]), str(item["factor"]))] = float(
item["amount"]
)
rows = [
_price_claim_row(
item,
weights=weights,
schedule=schedule,
hospitals=hospitals,
factors=national,
)
for item in claims.rows(named=True)
]
columns: dict[str, list[object]] = {name: [] for name in _CLAIM_COLUMNS}
for item in rows:
for name in _CLAIM_COLUMNS:
columns[name].append(item[name])
return nw.from_dict(columns, backend=nw.get_native_namespace(claims))

View File

@@ -5152,12 +5152,12 @@
"high": null,
"integer": false,
"item": "ipps",
"kind": "absent",
"kind": "derived",
"low": null,
"name": "payment",
"note": "Claim payment is not priced. The final-rule impact file supplies each hospital's operating and capital IME, DSH patient percentage and adjustments, CCRs, and capital GAF. MAC Implementation File 1 supplies the national fixed-loss threshold, labor shares, COLA, and CCR ceilings for the years CMS posted that file. Table 3, or Table 4A and 4B when that year has no Table 3, supplies the area capital GAF. The impact file models the final rule and is not the quarterly Provider Specific File. The operating federal rate and the GAF=1 Table 1D capital amount remain separate calculations.",
"note": "Output of the claim formula. Operating payment is the federal rate with COLA on the nonlabor portion, times (1 + operating IME + operating DSH), plus the uncompensated-care add-on. Capital payment is the weight times the Table 1D national rate times the hospital GAF, times (1 + capital IME + capital DSH). The impact-file operating DSH is already the empirically justified factor and is not multiplied by 0.25. Hospital factors come from the final-rule impact file, which is not the quarterly Provider Specific File. The hospital GAF is not combined with the area GAF. An outlier needs covered charges, CCRs, and a published fixed-loss threshold (MAC File 1, FY2018\u2013FY2027). A missing charge or a missing threshold produces no outlier. A CCR above the published ceiling is not replaced here: the replacement is a statewide average that is not loaded. New technology add-on, low-volume, and transfer proration are not priced. Do not sample a payment. The national wage-index-1 federal rate stays a separate reconciliation.",
"period": "",
"role": "payment",
"role": "output",
"rows": null,
"value": null
},
@@ -15665,6 +15665,32 @@
"rows": null,
"value": "15/100"
},
{
"high": "0.9",
"integer": false,
"item": "lean",
"kind": "constant",
"low": "0.9",
"name": "outlierBurnMarginal",
"note": "42 CFR 412.84(l). Marginal factor for a burn DRG named in that year's payment notice. No burn-DRG list is loaded, so the claim does not apply this factor on its own.",
"period": "",
"role": "payment",
"rows": null,
"value": "9/10"
},
{
"high": "0.8",
"integer": false,
"item": "lean",
"kind": "constant",
"low": "0.8",
"name": "outlierMarginal",
"note": "42 CFR 412.84(k). Marginal factor for an IPPS cost outlier. Not a cell in MAC Implementation File 1. The claim applies this unless the caller passes outlierBurnMarginal.",
"period": "",
"role": "payment",
"rows": null,
"value": "4/5"
},
{
"high": "0.05",
"integer": false,
@@ -15728,7 +15754,7 @@
"period": "",
"role": "payment",
"rows": null,
"value": "absent"
"value": "formula"
},
{
"high": null,

View File

@@ -106,6 +106,22 @@ _CONSTANTS = (
("mpprReduction", 1, 2, "Default PE reduction for rank 2 and later."),
("laborShare", 3, 5, "Default OPPS labor share, 0.60."),
("passThroughDrugs", 106, 100, "ASP times 1.06. Equals 1 + aspAddOn."),
(
"outlierMarginal",
4,
5,
"42 CFR 412.84(k). Marginal factor for an IPPS cost outlier."
" Not a cell in MAC Implementation File 1. The claim applies"
" this unless the caller passes outlierBurnMarginal.",
),
(
"outlierBurnMarginal",
9,
10,
"42 CFR 412.84(l). Marginal factor for a burn DRG named in"
" that year's payment notice. No burn-DRG list is loaded, so"
" the claim does not apply this factor on its own.",
),
)
# Lean Pay.ceiling. The value is the only legal label for that method.
@@ -116,7 +132,7 @@ _CEILINGS = (
("qpp", "formula"),
("mssp", "published_table"),
("reach", "published_table"),
("ipps", "absent"),
("ipps", "formula"),
("lead", "absent"),
)
@@ -660,20 +676,28 @@ def hole_rows() -> list[dict[str, Any]]:
element(
item="ipps",
name="payment",
kind="absent",
role="payment",
kind="derived",
role="output",
note=(
"Claim payment is not priced. The final-rule impact file"
" supplies each hospital's operating and capital IME, DSH"
" patient percentage and adjustments, CCRs, and capital GAF."
" MAC Implementation File 1 supplies the national fixed-loss"
" threshold, labor shares, COLA, and CCR ceilings for the"
" years CMS posted that file. Table 3, or Table 4A and 4B"
" when that year has no Table 3, supplies the area capital"
" GAF. The impact file models the final rule and is not the"
" quarterly Provider Specific File. The operating federal"
" rate and the GAF=1 Table 1D capital amount remain separate"
" calculations."
"Output of the claim formula. Operating payment is the"
" federal rate with COLA on the nonlabor portion, times"
" (1 + operating IME + operating DSH), plus the"
" uncompensated-care add-on. Capital payment is the weight"
" times the Table 1D national rate times the hospital GAF,"
" times (1 + capital IME + capital DSH). The impact-file"
" operating DSH is already the empirically justified factor"
" and is not multiplied by 0.25. Hospital factors come from"
" the final-rule impact file, which is not the quarterly"
" Provider Specific File. The hospital GAF is not combined"
" with the area GAF. An outlier needs covered charges, CCRs,"
" and a published fixed-loss threshold (MAC File 1,"
" FY2018–FY2027). A missing charge or a missing threshold"
" produces no outlier. A CCR above the published ceiling is"
" not replaced here: the replacement is a statewide average"
" that is not loaded. New technology add-on, low-volume, and"
" transfer proration are not priced. Do not sample a payment."
" The national wage-index-1 federal rate stays a separate"
" reconciliation."
),
),
element(

View File

@@ -10,7 +10,8 @@ Wage-index adjustment above or below 1 is ``ipps.calcs.operating_payment``.
It is not part of this comparison: there is no per-DRG published payment
at a hospital's own wage index in these tables.
IME, DSH, and outliers are not priced. Capital is not compared.
This comparison does not apply IME, DSH, uncompensated care, or outliers,
and it does not compare capital. Those are ``ipps.calcs.claim_payment``.
"""
from __future__ import annotations
@@ -30,7 +31,7 @@ class IppsPricer:
description: ClassVar[str] = (
"Inpatient PPS operating federal rate at wage index 1. "
"Table 1A full-update sum versus the Table 1B formula. "
"IME, DSH, and outliers are not priced."
"This comparison does not apply IME, DSH, uncompensated care, or outliers."
)
join_keys: ClassVar[list[str]] = ["fiscal_year", "ms_drg"]
compare_cols: ClassVar[list[str]] = ["operating_payment"]

View File

@@ -8,7 +8,19 @@ import duckdb
import polars as pl
import pytest
from ipps.calcs.payment import capital_dollars, operating_dollars, operating_payment
from ipps.calcs.payment import (
OUTLIER_BURN_MARGINAL,
OUTLIER_MARGINAL,
capital_claim,
capital_dollars,
capital_federal,
claim_payment,
operating_claim,
operating_dollars,
operating_federal,
operating_payment,
outlier_payment,
)
from ipps.rules import wage_index_table
from ipps.table import OperatingPayment
@@ -149,6 +161,252 @@ class TestOperatingPayment:
assert row["labor"][0] == _FY2026_GT1[0]
class TestClaim:
"""The claim applies published factors. The federal rate is unchanged."""
def test_zero_adjustments_match_the_federal_rate(self) -> None:
assert operating_claim(_DRG_470, *_FY2026_GT1, 1.2) == operating_dollars(
_DRG_470, *_FY2026_GT1, 1.2
)
assert operating_claim(_DRG_470, *_FY2026_GT1, 1.2) == 14744.42
assert operating_claim(_DRG_470, *_FY2026_LE1, 0.9) == 12217.55
assert operating_claim(_DRG_470, *_FY2026_LE1, 1.0) == 13025.11
assert operating_claim(_DRG_470, *_FY2026_LE1, None) == 13025.11
assert capital_claim(_DRG_470, _FY2026_CAPITAL) == capital_dollars(
_DRG_470, _FY2026_CAPITAL
)
assert capital_claim(_DRG_470, _FY2026_CAPITAL) == 1011.03
assert round(capital_federal(_DRG_470, _FY2026_CAPITAL, gaf=1), 2) == 1011.03
def test_cola_multiplies_only_the_nonlabor_portion(self) -> None:
plain = operating_federal(_DRG_470, *_FY2026_LE1, 0.9049, cola=1)
adjusted = operating_federal(_DRG_470, *_FY2026_LE1, 0.9049, cola=1.25)
assert adjusted - plain == pytest.approx(
_DRG_470 * _FY2026_LE1[1] * 0.25, rel=0, abs=1e-9
)
def test_fy2026_provider_010001_drg_470(self) -> None:
# Impact-file factors. WI 0.9049 selects Table 1B. Operating DSH
# is the printed 0.0298, not that number times 0.25.
operating = operating_claim(
_DRG_470,
*_FY2026_LE1,
0.9049,
cola=1,
operating_ime=0.0655,
operating_dsh=0.0298,
ucp_per_claim=1400.27,
)
capital = capital_claim(
_DRG_470,
_FY2026_CAPITAL,
gaf=0.933856364,
capital_ime=0.05496,
capital_dsh=0.05731,
)
assert operating == 14825.50
assert capital == 1050.16
assert round(operating + capital, 2) == 15875.66
doubled = operating_claim(
_DRG_470,
*_FY2026_LE1,
0.9049,
cola=1,
operating_ime=0.0655,
operating_dsh=0.0298 * 0.25,
ucp_per_claim=1400.27,
)
assert doubled == 14551.55
assert doubled != operating
def test_a_missing_uncompensated_care_addon_contributes_nothing(self) -> None:
assert operating_claim(
_DRG_470, *_FY2026_LE1, 1.0, ucp_per_claim=None
) == operating_claim(_DRG_470, *_FY2026_LE1, 1.0, ucp_per_claim=0)
def test_outlier_needs_charges_and_a_published_threshold(self) -> None:
kwargs = dict(
operating_ccr=0.25,
capital_ccr=0.25,
operating_paid=30.0,
capital_paid=20.0,
wage_index=1.0,
labor_share=0.5,
nonlabor_share=0.5,
)
assert outlier_payment(None, fixed_loss=100, **kwargs) is None
assert outlier_payment(1000, fixed_loss=None, **kwargs) is None
assert outlier_payment(1000, fixed_loss=100, **kwargs) == 280.0
assert (
outlier_payment(
1000, fixed_loss=100, marginal=OUTLIER_BURN_MARGINAL, **kwargs
)
== 315.0
)
assert outlier_payment(10, fixed_loss=100, **kwargs) == 0.0
assert OUTLIER_MARGINAL == 0.8
def test_mac_shares_that_do_not_sum_to_one_are_used_as_printed(self) -> None:
# FY2026 MAC shares are 0.66 and 0.324, not 0.66 and 0.34.
used = outlier_payment(
1000,
operating_ccr=0.25,
capital_ccr=0.25,
operating_paid=0,
capital_paid=0,
fixed_loss=100,
wage_index=1,
cola=1,
gaf=1,
labor_share=0.66,
nonlabor_share=0.324,
)
corrected = outlier_payment(
1000,
operating_ccr=0.25,
capital_ccr=0.25,
operating_paid=0,
capital_paid=0,
fixed_loss=100,
wage_index=1,
cola=1,
gaf=1,
labor_share=0.66,
nonlabor_share=0.34,
)
assert used is not None and corrected is not None
assert used != corrected
def test_a_ccr_above_the_published_ceiling_is_not_repriced(self) -> None:
assert (
outlier_payment(
1000,
operating_ccr=1.3,
capital_ccr=0.01,
operating_paid=0,
capital_paid=0,
fixed_loss=100,
wage_index=1,
labor_share=0.5,
nonlabor_share=0.5,
operating_ccr_ceiling=1.263,
)
is None
)
def test_claim_payment_uses_the_impact_file_for_a_named_provider(self) -> None:
claims = pl.DataFrame(
{
"ms_drg": ["470", "470"],
"fiscal_year": [2026, 2026],
"provider": ["010001", None],
"wage_index": [1.2, 1.2],
"cola": [9.0, 1.0],
"gaf": [9.0, 1.0],
"charges": [None, None],
}
)
providers = pl.DataFrame(
{
"fiscal_year": [2026],
"provider": ["010001"],
"payment_wage_index": [0.9049],
"cola": [1.0],
"operating_ime": [0.0655],
"operating_dsh": [0.0298],
"ucp_per_claim": [1400.27],
"capital_ime": [0.05496],
"capital_dsh": [0.05731],
"gaf": [0.933856364],
"operating_ccr": [0.187],
"capital_ccr": [0.013],
}
)
factors = pl.DataFrame(
{
"fiscal_year": [2026, 2026, 2026, 2026],
"factor": [
"fixed_loss_threshold",
"labor_share_le1",
"nonlabor_share_le1",
"cola",
],
"area": ["", "", "", "anchorage"],
"amount": [40397.0, 0.62, 0.34, 1.22],
}
)
priced = claim_payment(
claims,
_drg().filter(pl.col("fiscal_year") == 2026),
_amounts(),
providers,
factors,
)
named = priced.filter(pl.col("provider") == "010001")
assert named["wage_index"][0] == 0.9049
assert named["labor"][0] == _FY2026_LE1[0]
assert named["cola"][0] == 1.0
assert named["gaf"][0] == 0.933856364
assert named["operating_payment"][0] == 14825.50
assert named["capital_payment"][0] == 1050.16
assert named["outlier_payment"][0] is None
assert named["payment"][0] == 15875.66
area = priced.filter(pl.col("provider").is_null())
assert area["wage_index"][0] == 1.2
assert area["labor"][0] == _FY2026_GT1[0]
assert area["operating_payment"][0] == 14744.42
assert area["capital_payment"][0] == 1011.03
assert area["operating_ime"][0] is None
assert area["payment"][0] == round(14744.42 + 1011.03, 2)
def test_provider_numbers_match_the_stored_ccn(self) -> None:
claims = pl.DataFrame(
{"ms_drg": ["470"], "fiscal_year": [2026], "provider": ["10001"]}
)
providers = pl.DataFrame(
{
"fiscal_year": [2026],
"provider": ["010001"],
"payment_wage_index": [0.9049],
"cola": [1.0],
"gaf": [1.0],
}
)
factors = pl.DataFrame(
schema={
"fiscal_year": pl.Int64,
"factor": pl.Utf8,
"area": pl.Utf8,
"amount": pl.Float64,
}
)
priced = claim_payment(claims, _drg(), _amounts(), providers, factors)
assert priced["provider"][0] == "010001"
assert priced["wage_index"][0] == 0.9049
def test_a_missing_drg_does_not_invent_a_payment(self) -> None:
claims = pl.DataFrame(
{"ms_drg": ["999"], "fiscal_year": [2026], "provider": [None]}
)
providers = pl.DataFrame(
{
"fiscal_year": [2026],
"provider": ["010001"],
"payment_wage_index": [1.0],
}
)
factors = pl.DataFrame(
{
"fiscal_year": [2026],
"factor": ["fixed_loss_threshold"],
"area": [""],
"amount": [40397.0],
}
)
priced = claim_payment(claims, _drg(), _amounts(), providers, factors)
assert priced["payment"][0] is None
class TestPipe:
def test_step_writes_the_operating_payment_table(self) -> None:
from ipps.pipe import STEPS
@@ -215,3 +473,52 @@ class TestLoadedTables:
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)
def test_fy2026_provider_010001_drg_470_matches_the_impact_file(self) -> None:
con = duckdb.connect(str(_REPLICA), read_only=True)
try:
claims = pl.DataFrame(
{
"ms_drg": ["470"],
"fiscal_year": [2026],
"provider": ["010001"],
"charges": [None],
}
)
drg = con.execute(
"""
SELECT ms_drg, relative_weight, fiscal_year
FROM ipps.drg_weight
WHERE fiscal_year = 2026 AND ms_drg = '470'
"""
).pl()
amounts = con.execute(
"""
SELECT fiscal_year, table_code, component, amount
FROM ipps.standardized_amount
WHERE fiscal_year = 2026
"""
).pl()
providers = con.execute(
"""
SELECT *
FROM ipps.provider_factor
WHERE fiscal_year = 2026 AND provider = '010001'
"""
).pl()
factors = con.execute(
"""
SELECT fiscal_year, factor, area, amount
FROM ipps.national_factor
WHERE fiscal_year = 2026
"""
).pl()
finally:
con.close()
priced = claim_payment(claims, drg, amounts, providers, factors)
assert priced["operating_payment"][0] == 14825.50
assert priced["capital_payment"][0] == 1050.16
assert priced["outlier_payment"][0] is None
assert priced["payment"][0] == 15875.66
assert priced["wage_index"][0] == 0.9049
assert float(providers["ucp_per_claim"][0]) == 1400.27

View File

@@ -167,6 +167,10 @@ def test_lean_constants_match_the_definitions() -> None:
assert by_name["maintenanceFactor"]["low"] == bounds.num(0.05)
assert by_name["mpprReduction"]["value"] == "1/2"
assert by_name["paymentYearOffset"]["value"] == "2/1"
assert by_name["outlierMarginal"]["value"] == "4/5"
assert by_name["outlierBurnMarginal"]["value"] == "9/10"
assert "def outlierMarginal : Rat := 4 / 5" in DEFS
assert "def outlierBurnMarginal : Rat := 9 / 10" in DEFS
assert bounds.num(PAR_REDUCTION) == by_name["parReduction"]["low"]
assert bounds.num(NON_PAR_MARKUP) == by_name["nonParMarkup"]["low"]
assert bounds.num(LIMITING_CHARGE_FACTOR) == by_name["limitingChargeFactor"]["low"]
@@ -295,8 +299,9 @@ def test_published_flags_admit_only_the_stored_value() -> None:
"opps.rules.RuleYear", "skin_sub_payment_method", "pass_through", period=2026
)
assert bounds.allows("lean.ceiling", "pfs", "formula")
assert bounds.allows("lean.ceiling", "ipps", "absent")
assert not bounds.allows("lean.ceiling", "ipps", "formula")
assert bounds.allows("lean.ceiling", "ipps", "formula")
assert not bounds.allows("lean.ceiling", "ipps", "absent")
assert bounds.allows("lean.ceiling", "lead", "absent")
assert not bounds.allows("lean.ceiling", "pfs", 1)

View File

@@ -48,6 +48,11 @@ def test_case_ids() -> None:
"qpp-2024",
"equipment-minute",
"mppr-second",
"ipps-operating-cola-one",
"ipps-operating-claim",
"ipps-capital-gaf-one",
"ipps-capital-claim",
"ipps-outlier",
}
@@ -132,6 +137,52 @@ def test_equipment_cost_per_minute() -> None:
assert _rat(got) == BY_ID["equipment-minute"]
def test_ipps_claim_matches_the_ceiling() -> None:
from ipps.calcs.payment import (
OUTLIER_MARGINAL,
capital_claim,
operating_claim,
outlier_payment,
)
assert _rat(operating_claim(2, 10, 5, 1)) == BY_ID["ipps-operating-cola-one"]
assert (
_rat(
operating_claim(
2,
10,
5,
1,
cola=1,
operating_ime=0.125,
operating_dsh=0.125,
ucp_per_claim=1,
)
)
== BY_ID["ipps-operating-claim"]
)
assert _rat(capital_claim(2, 10)) == BY_ID["ipps-capital-gaf-one"]
assert (
_rat(capital_claim(2, 10, gaf=1, capital_ime=0.25, capital_dsh=0))
== BY_ID["ipps-capital-claim"]
)
got = outlier_payment(
1000,
operating_ccr=0.25,
capital_ccr=0.25,
operating_paid=30,
capital_paid=20,
fixed_loss=100,
wage_index=1,
cola=1,
gaf=1,
labor_share=0.5,
nonlabor_share=0.5,
marginal=OUTLIER_MARGINAL,
)
assert _rat(got) == BY_ID["ipps-outlier"]
def test_mppr_second_rank() -> None:
claims = pl.DataFrame(
{