Some checks failed
CI / lint (push) Failing after 48s
CI / notebooks-smoke (push) Successful in 2m0s
Deploy / changes (push) Successful in 18s
CI / test (push) Successful in 4m23s
Infra CI / notebooks (push) Successful in 1m5s
Infra CI / zotero (push) Successful in 16s
Infra CI / docs (push) Successful in 19s
Infra CI / api (push) Successful in 1m19s
Infra CI / bcda (push) Successful in 1m48s
Infra CI / mc (push) Successful in 18s
Infra CI / llm (push) Successful in 56s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Successful in 2m34s
Lean Pay / pay (push) Successful in 3m22s
Deploy / llm (push) Successful in 1m43s
Deploy / mc (push) Has been skipped
Deploy / bcda (push) Successful in 2m10s
Deploy / report (push) Successful in 16s
The wage index, pass-through rates, the missing APC years, the CY2027 work GPCI, equipment usage, IPPS standardized amounts, MS-DRG weights, and the MSSP and REACH financial results now come from the CMS files. The snapshot records those observed ranges. Maintenance stays the published 5/100. There is still no IPPS or LEAD pricer.
123 lines
3.7 KiB
Python
123 lines
3.7 KiB
Python
"""Addendum A workbooks sometimes hide the payment sheet behind a lookup."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import io
|
|
import sys
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
import pandas as pd
|
|
|
|
_SCRIPT = Path(__file__).resolve().parents[2] / "dev" / "scripts" / "ingest_opps.py"
|
|
_spec = importlib.util.spec_from_file_location("ingest_opps", _SCRIPT)
|
|
assert _spec is not None and _spec.loader is not None
|
|
ingest_opps = importlib.util.module_from_spec(_spec)
|
|
sys.modules["ingest_opps"] = ingest_opps
|
|
_spec.loader.exec_module(ingest_opps)
|
|
|
|
|
|
def _zip_with(dest: Path, sheets: dict[str, pd.DataFrame]) -> Path:
|
|
buf = io.BytesIO()
|
|
with pd.ExcelWriter(buf, engine="openpyxl") as writer:
|
|
for name, frame in sheets.items():
|
|
frame.to_excel(writer, sheet_name=name, index=False, header=False)
|
|
with zipfile.ZipFile(dest, "w") as zf:
|
|
zf.writestr("Addendum A.xlsx", buf.getvalue())
|
|
return dest
|
|
|
|
|
|
def test_payment_sheet_wins_over_the_category_lookup(tmp_path: Path) -> None:
|
|
category = pd.DataFrame(
|
|
[
|
|
["APC Category Names", None],
|
|
["APC", "Description"],
|
|
["0001", "Level 1"],
|
|
]
|
|
)
|
|
payment = pd.DataFrame(
|
|
[
|
|
["CY 2015 Addendum A", None, None, None, None, None, None],
|
|
[
|
|
"APC",
|
|
"Group Title",
|
|
"SI",
|
|
"Relative Weight",
|
|
"Payment Rate",
|
|
"National Unadjusted Copayment",
|
|
"Minimum Unadjusted Copayment",
|
|
],
|
|
["0701", "Sr89 strontium", "K", "2045.702", "100.00", "20", "10"],
|
|
]
|
|
)
|
|
zpath = _zip_with(
|
|
tmp_path / "addenda.zip",
|
|
{"APC Category Names New": category, "2015 FR Addendum A": payment},
|
|
)
|
|
df = ingest_opps.read_from_zip(
|
|
zpath, ingest_opps.ADDENDUM_A_COL_MAP, pattern="addendum a"
|
|
)
|
|
assert list(df["apc"]) == ["0701"]
|
|
assert list(df["relative_weight"]) == ["2045.702"]
|
|
|
|
|
|
def test_the_first_sheet_is_used_when_it_is_the_payment_sheet(tmp_path: Path) -> None:
|
|
payment = pd.DataFrame(
|
|
[
|
|
[
|
|
"APC",
|
|
"Group Title",
|
|
"SI",
|
|
"Relative Weight",
|
|
"Payment Rate",
|
|
"Minimum Unadjusted Copayment",
|
|
],
|
|
["5071", "Level 1", "T", "1.234", "80.00", "16"],
|
|
]
|
|
)
|
|
zpath = _zip_with(tmp_path / "addenda.zip", {"2018 FR Addendum A": payment})
|
|
df = ingest_opps.read_from_zip(
|
|
zpath, ingest_opps.ADDENDUM_A_COL_MAP, pattern="addendum a"
|
|
)
|
|
assert list(df["apc"]) == ["5071"]
|
|
assert list(df["payment_rate"]) == ["80.00"]
|
|
|
|
|
|
def test_pass_through_copies_status_indicators_g_and_h() -> None:
|
|
import duckdb
|
|
|
|
con = duckdb.connect()
|
|
con.execute("CREATE SCHEMA opps")
|
|
con.execute(
|
|
"""
|
|
CREATE TABLE opps.addendum_b (
|
|
hcpcs VARCHAR,
|
|
short_description VARCHAR,
|
|
status_indicator VARCHAR,
|
|
payment_rate DOUBLE,
|
|
year INTEGER
|
|
)
|
|
"""
|
|
)
|
|
con.execute(
|
|
"""
|
|
INSERT INTO opps.addendum_b VALUES
|
|
('J0120', 'drug', 'G', 12.5, 2024),
|
|
('C1747', 'device', 'H', NULL, 2024),
|
|
('J9999', 'separately payable', 'K', 40.0, 2024),
|
|
('99213', 'visit', 'J1', 80.0, 2024)
|
|
"""
|
|
)
|
|
n = ingest_opps.load_pass_through(con)
|
|
assert n == 2
|
|
rows = con.execute(
|
|
"SELECT hcpcs, pass_through_type, status_indicator, payment_rate, "
|
|
"asp_per_unit FROM opps.pass_through ORDER BY hcpcs"
|
|
).fetchall()
|
|
assert rows == [
|
|
("C1747", "device", "H", None, None),
|
|
("J0120", "drug", "G", 12.5, None),
|
|
]
|
|
con.close()
|