fix(cli): stack pfs elements --family is repeatable (refs #684)
Claude-Session: https://claude.ai/code/session_01Aum3pEMAM3yQVdFSdVe6Gc
This commit is contained in:
@@ -76,16 +76,19 @@ def _run_elements(
|
||||
typer.echo(f"{c}: {len(x.rows)} elements, {len(x.reviews)} for review")
|
||||
|
||||
|
||||
def _codes_for(con: Any, codes: list[str], family: str, all_payable: bool) -> list[str]:
|
||||
def _codes_for(
|
||||
con: Any, codes: list[str], families: list[str], all_payable: bool
|
||||
) -> list[str]:
|
||||
out: list[str] = [c.upper() for c in codes]
|
||||
if family:
|
||||
if families:
|
||||
refresh_from(con)
|
||||
fam = FAMILIES.get(family.upper())
|
||||
if fam is None:
|
||||
raise typer.BadParameter(
|
||||
f"unknown family {family!r}; known: {', '.join(FAMILIES)}"
|
||||
)
|
||||
out.extend(fam.codes)
|
||||
for family in families:
|
||||
fam = FAMILIES.get(family.upper())
|
||||
if fam is None:
|
||||
raise typer.BadParameter(
|
||||
f"unknown family {family!r}; known: {', '.join(FAMILIES)}"
|
||||
)
|
||||
out.extend(fam.codes)
|
||||
if all_payable:
|
||||
rows = con.execute(
|
||||
"SELECT DISTINCT hcpcs FROM pfs.rvu WHERE status_code IN ('A','R','T') "
|
||||
@@ -100,7 +103,9 @@ def _codes_for(con: Any, codes: list[str], family: str, all_payable: bool) -> li
|
||||
@app.command()
|
||||
def elements(
|
||||
code: list[str] = typer.Option([], "--code", help="HCPCS/CPT code (repeatable)."),
|
||||
family: str = typer.Option("", help="Expand a registered family (CCM, APCM, …)."),
|
||||
family: list[str] = typer.Option(
|
||||
[], "--family", help="Expand a registered family (CCM, APCM, …); repeatable."
|
||||
),
|
||||
all_payable: bool = typer.Option(
|
||||
False, "--all-payable", help="Every A/R/T code in the newest RVU year."
|
||||
),
|
||||
|
||||
@@ -157,6 +157,37 @@ class TestElements:
|
||||
)
|
||||
assert res.exit_code == 0 and seen == ["99490"]
|
||||
|
||||
def test_repeated_family_option_expands_every_family(self, con, monkeypatch):
|
||||
# #684 regression: --family used to be a single str, so a second
|
||||
# --family silently discarded the first. It must now be repeatable
|
||||
# and expand every family named.
|
||||
seen = []
|
||||
monkeypatch.setattr(
|
||||
pfs_cli,
|
||||
"extract_code",
|
||||
lambda s, c, code, *, classify=None: (
|
||||
seen.append(code) or Extraction(code, (), ())
|
||||
),
|
||||
)
|
||||
res = runner.invoke(
|
||||
app,
|
||||
[
|
||||
"pfs",
|
||||
"elements",
|
||||
"--family",
|
||||
"CCM",
|
||||
"--family",
|
||||
"APCM",
|
||||
"--no-llm",
|
||||
"--dry-run",
|
||||
],
|
||||
)
|
||||
assert res.exit_code == 0, res.output
|
||||
from pfs.families import HAND_FAMILIES
|
||||
|
||||
expected = set(HAND_FAMILIES["CCM"].codes) | set(HAND_FAMILIES["APCM"].codes)
|
||||
assert set(seen) == expected
|
||||
|
||||
|
||||
class TestLineage:
|
||||
def test_prints_and_writes(self, con, monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user