Files
stack/lean/Pay/README.md
kert d2b205fea8 feat(ci): typecheck Lean payment ceilings when lean/ changes
Gitea ignores path filters, so the job diffs the previous push and skips
unless lean/ or the workflow changed. Lean 4.34.0 comes from the GitHub
release; mathlib is the olean cache.
2026-11-17 13:57:31 -05:00

2.3 KiB
Raw Blame History

Pay

Lean 4 ceilings for the Medicare payment formulas this repo already computes. Python joins the CMS files. These definitions are the exact rational values those calculations have to meet.

Toolchain leanprover/lean4:v4.34.0, the same pin as the vendored Mathematics in Lean textbook. Mathlib is required at v4.34.0. Pay/Basic.lean checks the rational identities with norm_num and ring. pay-cases imports only the definitions, so printing the cases does not link mathlib.

What is a formula

Method Ceiling Where Python computes it
PFS fee schedule pfsPayment pfs.calcs.payment.payment
Non-PAR limiting charge limitingCharge pfs.calcs.payment.limiting_charge
OPPS wage adjustment oppsAdjusted opps.calcs.payment.payment
Part B drug limit aspPaymentLimit opps.express.payment.skin_sub_impact (ASP × 1.06)
Equipment cost / minute equipmentCostPerMinute pfs.calcs.payment.equipment_cost_per_use
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

A missing OPPS wage index is 1. oppsAdjusted_wageIndex_one says the labor share then cancels.

What is not a formula here

ceiling records the rest.

  • 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 the two-year offset is a formula in this slice.

Check

lake exe cache get   # mathlib oleans; do not build mathlib from source
lake build
lake exe pay-cases > cases.json

.gitea/workflows/lean-pay.yml runs that check when lean/ or the workflow file changes. The runner downloads Lean 4.34.0 from the GitHub release (releases.lean-lang.org times out from this network) and uses the mathlib olean cache.

tests/pay/test_ceiling.py runs the Python functions on these inputs and requires the rationals in cases.json. When lake is on PATH it also requires pay-cases to reprint that file.