feat(pfs): stance_eval is the out-of-sample held-out measurement, tuning set beside it (R82)
Some checks failed
CI / lint (push) Successful in 36s
CI / notebooks-smoke (push) Successful in 1m44s
Deploy / changes (push) Successful in 16s
CI / test (push) Failing after 3m22s
Infra CI / zotero (push) Successful in 16s
Infra CI / notebooks (push) Successful in 57s
Infra CI / api (push) Successful in 1m13s
Infra CI / docs (push) Successful in 1m18s
Infra CI / llm (push) Successful in 1m0s
Infra CI / mc (push) Successful in 15s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Infra CI / bcda (push) Successful in 2m7s
Deploy / api (push) Successful in 1m29s
Deploy / bcda (push) Successful in 1m53s
Deploy / mc (push) Has been skipped
Deploy / llm (push) Successful in 1m17s
Deploy / report (push) Successful in 17s

This commit is contained in:
kert
2026-11-12 19:40:27 -05:00
parent e330f90cdc
commit 5774f97584
6 changed files with 974 additions and 45 deletions

View File

@@ -20,6 +20,7 @@ from __future__ import annotations
import json
import logging
from collections import Counter
from collections.abc import Sequence
from dataclasses import replace
from pathlib import Path
from types import SimpleNamespace
@@ -106,6 +107,7 @@ from pfs.stance import (
DEFAULT_MODEL,
GENERATIONS,
GOLDEN_PATH,
HELDOUT_PATHS,
METHODS,
TEXT_CHARS,
TEXT_CHUNKS,
@@ -1737,7 +1739,12 @@ def stance(
golden: Path = typer.Option(
GOLDEN_PATH,
"--golden",
help="Golden set whose measurement --write records (its family only).",
help="Tuning (in-sample) golden set --write records as in_sample_record.",
),
heldout: list[Path] = typer.Option(
list(HELDOUT_PATHS),
"--heldout",
help="Held-out golden sets; the primary one is the stamped measurement.",
),
generation: str = typer.Option(
DEFAULT_GENERATION,
@@ -1862,7 +1869,9 @@ def stance(
rollup(rows, base=base, order=order, n_commenters=len(commenter_rows)),
stance_method=f"{prompt_version(method, generation)}:{name}",
stance_agreement=None,
stance_eval=_method_eval(golden, method, name, fam.key, generation),
stance_eval=_method_eval(
golden, method, name, fam.key, generation, tuple(heldout)
),
)
keep = [
r
@@ -1878,22 +1887,66 @@ def stance(
def _method_eval(
golden: Path, method: str, name: str, family: str, generation: str | None = None
golden: Path,
method: str,
name: str,
family: str,
generation: str | None = None,
heldout: Sequence[Path] = HELDOUT_PATHS,
) -> str | None:
"""The method's measurement on the golden set as ``stance_eval`` JSON
(R66a), replayed from the ledger (no model call). ``None`` when there is
no golden file, the golden set is another family's, or its ledger is
incomplete."""
if not golden.exists():
"""The method's published measurement as ``stance_eval`` JSON (R82):
the family's PRIMARY held-out set for *generation*, replayed from the
ledger (no model call), with the in-sample tuning set's scores beside it
as ``in_sample_record``. ``None`` when no primary set matches the family
and generation; a set the ledger does not fully cover is an error, never
a partial measurement."""
gen = generation or DEFAULT_GENERATION
primary = None
for path in heldout:
if not path.exists():
continue
data = json.loads(path.read_text(encoding="utf-8"))
if (
data.get("role") == "primary"
and data.get("family") == family
and data.get("generation", gen) == gen
):
primary = data
break
if primary is None:
return None
data = json.loads(golden.read_text(encoding="utf-8"))
if data.get("family") != family:
return None
sc, _ = _golden_run(data, method, ask=None, name=name, generation=generation)
sc, _ = _golden_run(primary, method, ask=None, name=name, generation=generation)
if sc is None:
typer.echo(f"golden set not fully classified for {method} on {name}")
return None
return json.dumps(eval_record(data, sc))
raise typer.BadParameter(
f"held-out set not fully classified for {method} on {name}; "
"run stack pfs stance-eval on it first"
)
rec = eval_record(primary, sc)
rec.pop("docket")
rec["generation"] = gen
if golden.exists():
tuning = json.loads(golden.read_text(encoding="utf-8"))
if tuning.get("family") == family:
tsc, _ = _golden_run(
tuning, method, ask=None, name=name, generation=generation
)
if tsc is None:
raise typer.BadParameter(
f"tuning set not fully classified for {method} on {name}"
)
t = eval_record(tuning, tsc)
rec["in_sample_record"] = {
k: t[k]
for k in (
"cell",
"recall",
"direction",
"n_items",
"n_positions",
"docket",
)
}
return json.dumps(rec)
def _golden_run(

View File

@@ -0,0 +1,400 @@
{
"family": "HOME-VISITS",
"docket": "CMS-2025-0304",
"seed": 20261113,
"in_sample": false,
"text_window": {
"max_chars": 6000,
"max_chunks": 8,
"source": "pfs.commenters.family_comment_items + pfs.stance.clean_text, as the stance command builds it"
},
"events": {
"HOME-VISITS:2026:coding": "Coding changes. Rule text: [¶718] In the CY 2024 PFS final rule (88 FR 78818, 78971), we stated that the values we established for the revised O/O E/M CPT codes in the CY 2021 PFS final rule were finalized in concert with separate payment for HCPCS code G2211 (85 FR 84569, 87 FR 69588), and that we finalized work RVUs for the nursing facility E/M visit codes (87 FR 69604 through 69606) and the home or residence services code family (87 FR 69608 and 69609) subsequently in the CY 2023 PFS final rule. We stated that we may nevertheless consider in future rulemaking whether home or residence evaluation and management services",
"HOME-VISITS:2026:G2211": "Linked code G2211 (add-on), new in the CY2026 rule. Rule text: [¶718] For this reason, we believe it is appropriate to extend the application of HCPCS code G2211 to home and residence E/M visits at this time. Therefore, we are proposing to allow HCPCS code G2211 to be billed as an add-on code with the home or residence evaluation and management visits code family (CPT codes 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350). The HCPCS code G2211 descriptor would read as follows, “ (Visit complexity inherent to evaluation and management associated with medical care services that serve as the continuing focal point for all needed health care services and/or",
"HOME-VISITS:2026:other": "Any other aspect of this family's own codes (99341, 99342, 99344, 99345 and 99347–99350), not covered above; positions on other codes or services are not given"
},
"items": [
{
"item_key": "8UA4AE7F",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "3I37U6ZS",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "ZI8KKQAN",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "7CDVVEIT",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "RF8UUZ9A",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "2VSNPYUU",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "modify",
"quote": "believes health centers should be eligible to bill for this add-on code to allow for financial assuagement from the complexity of home visits.",
"reason": "Wants the home-visit add-on (G2211) extended to health centers, beyond the proposal."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "HJRCB8GU",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "modify",
"quote": "our concern is not with the policy change itself but with the underlying utilization assumptions,",
"reason": "Accepts extending G2211 to home visits but disputes the utilization/budget-neutrality assumptions behind it."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "4Y9HCKQ2",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "finalize the proposed policies (without modification) to (1) pay for G2211 when billed alongside home-based primary care visits",
"reason": "Asks CMS to finalize G2211 with home visits without modification."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "IMCAB7K6",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "69R45ZPG",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "4PBIMSRS",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "FCDR3D82",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "4RY4EKFU",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "KSTGZAKX",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "finalize the proposed policies (without modification) to (1) pay for G2211 when billed alongside home-based primary care visits",
"reason": "Asks CMS to finalize G2211 with home visits without modification."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "6HKK8CUN",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "finalize the proposed policies (without modification) to (1) pay for G2211 when billed alongside home-based primary care visits",
"reason": "Asks CMS to finalize G2211 with home visits without modification."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "NKB5SZ4D",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "modify",
"quote": "community health centers should be eligible to bill for this add-on code to allow for financial assuagement from the complexity of home visits.",
"reason": "Wants the home-visit add-on (G2211) extended to community health centers, beyond the proposal."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "CRMJEN6K",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "3PE5E6PP",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "finalize the proposed policies (without modification) to (1) pay for G2211 when billed alongside home-based primary care visits",
"reason": "Asks CMS to finalize G2211 with home visits without modification."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
},
{
"item_key": "CJ5RJV74",
"cells": {
"HOME-VISITS:2026:coding": {
"label": "none",
"quote": "",
"reason": ""
},
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "CMS should finalize the proposal to allow G2211 to be billed with E/M services in ALFs and homes",
"reason": "Urges CMS to finalize G2211 billing with home/ALF E/M visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none",
"quote": "",
"reason": ""
}
}
}
],
"note": "R77: EEQUNJT5 excluded (no longer blind)",
"role": "footnote"
}

View File

@@ -0,0 +1,399 @@
{
"family": "HOME-VISITS",
"dockets": [
"CMS-2025-0304",
"CMS-2026-2377"
],
"seed": 20261114,
"in_sample": false,
"distinct": true,
"generation": "stance-v5",
"text_window": {
"max_chars": 6000,
"max_chunks": 8
},
"sampling": "pool: pfs.commenter rows for HOME-VISITS on both dockets with classifier text (family_comment_items, TEXT_CHARS/TEXT_CHUNKS), sorted by (docket, item_key); kept the first item per non-empty form_group and dropped items with token Jaccard >= 0.6 (pfs.stance._words on clean_text) against any kept item; removed the 20 item_keys of stance-golden-cy2026-heldout.json and 2 kept items that duplicate one of them (2AEINFVV: same form group as 12 first-set items; 7CDS7DY8: Jaccard 0.61 with NKB5SZ4D); distinct pool 51 (CMS-2025-0304) + 35 (CMS-2026-2377); one random.Random(20261114) drew sample(sorted keys, 10) for CMS-2025-0304, then for CMS-2026-2377",
"events": {
"CMS-2025-0304": {
"HOME-VISITS:2026:G2211": "Linked code G2211 (add-on), new in the CY2026 rule. Rule text: [¶718] For this reason, we believe it is appropriate to extend the application of HCPCS code G2211 to home and residence E/M visits at this time. Therefore, we are proposing to allow HCPCS code G2211 to be billed as an add-on code with the home or residence evaluation and management visits code family (CPT codes 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350). The HCPCS code G2211 descriptor would read as follows, “ (Visit complexity inherent to evaluation and management associated with medical care services that serve as the continuing focal point for all needed health care services and/or [¶717] specific to home-based visits or expand use of the O/O E/M visit complexity add-on code HCPCS code G2211 to be reported alongside home and residence E/M visits furnished to beneficiaries in nursing facilities, assisted living facilities, and the beneficiary's home. Interested parties have explained that home-based primary care practices provide access to primary care services for patients who otherwise would not be able to leave the house to see a primary care practitioner, and include the development of longitudinal, “high-touch” relationships with their patients.",
"HOME-VISITS:2026:other": "Any other aspect of this family's own codes (99341, 99342, 99344, 99345 and 99347–99350), not covered above; positions on other codes or services are not given"
},
"CMS-2026-2377": {
"HOME-VISITS:2027:telehealth": "Medicare Telehealth Services List status of this family's codes (99341, 99342, 99344, 99345 and 99347–99350) and of the new linked codes (lineage: telehealth list change for 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350). Rule text: [¶231] 99213, 99214, 99215, 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350)) to the Medicare Telehealth Services List. If finalized, these services will be separately payable under the PFS. These services will be subject to the provisions of section 1834(m) of the Act, as they are inherently face-to-face services and would serve as a substitute for an in-person encounter. We also believe that the elements of these services as described by the HCPCS codes are capable of being furnished using an interactive telecommunications system as defined in § 410.78(a)(3). We refer readers to the",
"HOME-VISITS:2027:B1": "Linked code B1 (modifier), new in the CY2027 rule",
"HOME-VISITS:2027:B2": "Linked code B2 (modifier), new in the CY2027 rule",
"HOME-VISITS:2027:other": "Any other aspect of this family's own codes (99341, 99342, 99344, 99345 and 99347–99350), not covered above; positions on other codes or services are not given"
}
},
"items": [
{
"item_key": "3UEHCMYU",
"docket": "CMS-2025-0304",
"commenter": "Families USA on behalf of Consumers First Coalition",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "We strongly support CMS’ proposal under Section II.F to expand billing for the G2211 add-on codes to include home and residence visits.",
"reason": "Strongly supports extending G2211 billing to home and residence visits as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "5TCRM3NG",
"docket": "CMS-2025-0304",
"commenter": "OSU Physicians Group, Wexner Medical Center at The Ohio State University",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "OSU Physicians agree with CMS' proposal to allow the visit complexity add-on code to be billed with the listed visit codes.",
"reason": "Agrees with allowing G2211 with 99341-99350 as proposed."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "7DYMAPHF",
"docket": "CMS-2025-0304",
"commenter": "AAMC",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "The AAMC strongly supports the proposal to expand the use of G2211 to be reported alongside home and residence-based E/Ms.",
"reason": "Strongly supports reporting G2211 with home and residence E/M visits."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "AHJ8JRNS",
"docket": "CMS-2025-0304",
"commenter": "Curana Health Medical Group",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "modify",
"quote": "but we request that it also be allowed as an add-on for nursing facility codes when billed under POS 32.",
"reason": "Supports G2211 with home visits but asks CMS to also allow it with nursing facility codes under POS 32."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "IK5JMU42",
"docket": "CMS-2025-0304",
"commenter": "Legacy Health",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "We commend expanding the use of G2211 with Home or Residence E/Ms.",
"reason": "Commends the home/residence extension; its modifier-25 request concerns the separate O/O G2211 policy."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "MRSUNFJY",
"docket": "CMS-2025-0304",
"commenter": "",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "none"
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "N6GKKM6K",
"docket": "CMS-2025-0304",
"commenter": "Independent Wound Specialist Society (IWSS)",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "We appreciate and fully support this proposal.",
"reason": "Fully supports applying G2211 to home and residence E/M visits."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "PQ76WGU3",
"docket": "CMS-2025-0304",
"commenter": "American Nurses Association - Illinois",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "Expand G2211 to home and residence visits. Same work, same add-on.",
"reason": "Endorses expanding G2211 to home and residence visits."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "T5HXJCS8",
"docket": "CMS-2025-0304",
"commenter": "American Association of Nurse Practitioners",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "we support the proposal to extend G2211 to be billed as an add-on code with the home or residence E/M visits code family.",
"reason": "Supports the proposal to bill G2211 with the home or residence E/M family."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "UFP4RT2T",
"docket": "CMS-2025-0304",
"commenter": "AARP",
"cells": {
"HOME-VISITS:2026:G2211": {
"label": "support",
"quote": "AARP supports expanding the use of this add-on payment code for home visits",
"reason": "Supports allowing G2211 with home or residence E/M visits."
},
"HOME-VISITS:2026:other": {
"label": "none"
}
}
},
{
"item_key": "4ZCE99J4",
"docket": "CMS-2026-2377",
"commenter": "Healthcare Business Management Association",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "modify",
"quote": "While HBMA supports replacing G2211 with MOD1 and MOD2, we encourage CMS to thoughtfully evaluate why the reporting of G2211 has been well below CMS expectations",
"reason": "Supports replacing G2211 with MOD1 but asks CMS to evaluate low G2211 uptake first."
},
"HOME-VISITS:2027:B2": {
"label": "modify",
"quote": "HBMA suggests clarity of reporting requirements in the final rule to avoid incorrect reporting.",
"reason": "Supports MOD1/MOD2 but asks for clearer reporting and documentation requirements for the new modifiers."
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "AG48FU2Y",
"docket": "CMS-2026-2377",
"commenter": "Post-Acute and Long-Term Care Medical Association",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "modify",
"quote": "Extending the complexity modifier to the nursing facility setting would strengthen exactly the longitudinal, coordinated primary care relationships",
"reason": "Asks CMS to extend the complexity modifiers to nursing facility visit codes."
},
"HOME-VISITS:2027:B2": {
"label": "modify",
"quote": "the MOD2 proposal, by restricting the higher 32 percent add-on to clinicians participating in a Shared Savings Program ACO or the LEAD Model, compounds the disadvantage",
"reason": "Criticizes MOD2's ACO/LEAD-only restriction and asks CMS to consider non-ACO nursing facility clinicians."
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "D9SGQDKQ",
"docket": "CMS-2026-2377",
"commenter": "Stephanie Witwer",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "none"
},
"HOME-VISITS:2027:B2": {
"label": "none"
},
"HOME-VISITS:2027:other": {
"label": "modify",
"quote": "RN-delivered home visits would expand access, reduce cost, and support care continuity for patients with chronic conditions or mobility limitations.",
"reason": "Asks CMS to let registered nurses furnish and bill established-patient home visits 99347-99349."
}
}
},
{
"item_key": "GFAHW7EW",
"docket": "CMS-2026-2377",
"commenter": "The Bowman Family Foundation",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "modify",
"quote": "support converting the HCPCS code G2211 to a modifier and enhancing payment",
"reason": "Supports converting G2211 to a modifier but wants the new modifiers also allowed with CoCM codes."
},
"HOME-VISITS:2027:B2": {
"label": "modify",
"quote": "enhancing payment for ACOs, but recommend that the new modifiers also be permitted to accompany CoCM codes",
"reason": "Supports the enhanced ACO modifier but recommends extending it to CoCM codes 99492/99493."
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "M9C93I3J",
"docket": "CMS-2026-2377",
"commenter": "Anonymous Anonymous",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "none"
},
"HOME-VISITS:2027:B2": {
"label": "none"
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "MUC7DXQ4",
"docket": "CMS-2026-2377",
"commenter": "Bayou City Breastfeeding LLC",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "none"
},
"HOME-VISITS:2027:B2": {
"label": "none"
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "SFHKUPNQ",
"docket": "CMS-2026-2377",
"commenter": "Curana Health",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "modify",
"quote": "While we support the proposed modifiers, we remain disappointed in the continued exclusion of primary care in long-term care (LTC) settings with POS 32.",
"reason": "Supports MOD1 but objects that it excludes long-term care (POS 32) primary care."
},
"HOME-VISITS:2027:B2": {
"label": "modify",
"quote": "The MOD1/MOD2 proposal as written will deprive physicians caring for individuals who reside in nursing homes of equal compensation",
"reason": "Supports MOD2 but wants nursing-home (POS 32) primary care included."
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "U6A3EGWI",
"docket": "CMS-2026-2377",
"commenter": "WoundX",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "none"
},
"HOME-VISITS:2027:B2": {
"label": "none"
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
},
{
"item_key": "VT6V9YYN",
"docket": "CMS-2026-2377",
"commenter": "Ennoble Care",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "modify",
"quote": "CMS should confirm in the final rule that the modifiers apply when the underlying service is furnished via telehealth;",
"reason": "Asks CMS to confirm the new linked modifiers apply to home visits furnished via telehealth."
},
"HOME-VISITS:2027:B1": {
"label": "modify",
"quote": "CMS should state in the final rule that the visit complexity described by MOD1 and MOD2 is within the scope of basic benefits,",
"reason": "Urges finalizing MOD1 at 16 percent but adds requests (MA basic benefits, documentation guidance)."
},
"HOME-VISITS:2027:B2": {
"label": "modify",
"quote": "CMS should pay MOD1 and MOD2 amounts on a fee-for-service basis outside LEAD Model primary care capitation, tied to the visit;",
"reason": "Urges finalizing MOD2 at 32 percent but asks that it be paid fee-for-service outside LEAD capitation."
},
"HOME-VISITS:2027:other": {
"label": "modify",
"quote": "CMS should replace the uniform clinical labor input across CPT codes 99341 through 99350 with inputs that vary by the typical time and complexity of each service",
"reason": "Asks CMS to vary the clinical labor inputs of 99341-99350 and spare home visits from the same-day reduction."
}
}
},
{
"item_key": "YMP79ZWX",
"docket": "CMS-2026-2377",
"commenter": "HarmonyCares",
"cells": {
"HOME-VISITS:2027:telehealth": {
"label": "none"
},
"HOME-VISITS:2027:B1": {
"label": "modify",
"quote": "ensure, through guidance or rulemaking as appropriate, that MA plans cover and operationalize MOD1 and MOD2 consistent with traditional Medicare.",
"reason": "Strongly supports MOD1 but asks CMS to make MA plans recognize the modifiers."
},
"HOME-VISITS:2027:B2": {
"label": "modify",
"quote": "First, home and residence E/M visits should qualify for MOD2-level valuation.",
"reason": "Supports MOD2 but recommends MOD2-level valuation for all home and residence visits."
},
"HOME-VISITS:2027:other": {
"label": "none"
}
}
}
],
"role": "primary"
}

View File

@@ -10,6 +10,10 @@ comment, and a position on an event that is not offered is dropped.
The roll-up (``rollup``) counts distinct commenters into ``pfs.code_reaction``.
It takes only our own ``StanceRow``s: CMS's summaries of comments
(``pfs.cms_comment_summary``) are a separate source and never feed it.
Measurement (R82): the published accuracy is the held-out set's
(``HELDOUT_PATHS``). Any future prompt or filter change needs a NEW held-out
set, never tuning on these.
"""
from __future__ import annotations
@@ -77,6 +81,14 @@ STANCE_PROMPT_VERSION = PROMPT_VERSIONS[DEFAULT_METHOD]
#: the hand-coded golden set that scores a method (R63), packaged with pfs
#: (R67): 20 CY2023 HOME-VISITS commenters, every (item, event) cell labelled
GOLDEN_PATH = Path(__file__).resolve().parent / "golden/stance_home_visits_cy2023.json"
#: R82: the two HELD-OUT measurement sets (hand-coded blind, ``in_sample``
#: false): the ``primary`` one is the published accuracy, the ``footnote`` one
#: a secondary figure. Any future prompt or filter change needs a NEW held-out
#: set; never tune on these, or the measurement no longer applies.
HELDOUT_PATHS = (
Path(__file__).resolve().parent / "golden/stance_home_visits_heldout_distinct.json",
Path(__file__).resolve().parent / "golden/stance_home_visits_heldout_cy2026.json",
)
#: the comment text window handed to the model: ~6,000 characters is under
#: 2,000 tokens, and with the event texts (<= ~6,000 characters) it sits well
#: inside the ``num_ctx`` 8192 that ``JsonExtractor`` sends (llm.config

View File

@@ -10,6 +10,7 @@ from unittest.mock import MagicMock
import duckdb
import pytest
import typer
from typer.testing import CliRunner
import cli.pfs as pfs_cli
@@ -2535,36 +2536,28 @@ class TestStanceMethodRecord:
got = {r.period: r for r in read_reaction(con._real, "HOME-VISITS")}
d1 = got["D1"]
assert d1.stance_method == f"{pfs_cli.prompt_version('multi')}:qwen-x"
# R66a: the measurement is the stance_eval JSON; the single figure is gone
# R82: the measurement is the out-of-sample record, the tuning set secondary
assert d1.stance_agreement is None
assert json.loads(d1.stance_eval) == {
"cell": 0.83,
"recall": 0.556,
"direction": 0.667,
"n_items": 20,
"n_positions": 27,
"family": "HOME-VISITS",
"docket": "CMS-2022-0113",
"in_sample": True,
}
ev = json.loads(d1.stance_eval)
assert ev["in_sample"] is False
assert ev["generation"] == "stance-v5"
assert ev["in_sample_record"]["docket"] == "CMS-2022-0113"
assert got["R1"].stance_method is None and got["R1"].stance_eval is None
assert seen["ask"] is ASK
res = runner.invoke(app, t._args("--model", "huge"))
assert res.exit_code != 0 and "--model must be instruct or large" in res.output
def test_eval_is_stamped_only_for_the_golden_family(
self, con, monkeypatch, tmp_path
):
"""A golden set of another family is never replayed nor stamped."""
def test_other_family_tuning_set_adds_no_record(self, con, monkeypatch, tmp_path):
"""A tuning set of another family is never replayed nor recorded."""
t = TestStance()
t._patch(con, monkeypatch)
monkeypatch.setattr(pfs_cli, "_golden_run", lambda *a, **k: 1 / 0)
g = tmp_path / "g.json"
g.write_text(json.dumps({"family": "CCM", "docket": "D9", "items": []}))
res = runner.invoke(app, t._args("--golden", str(g), "--write"))
assert res.exit_code == 0, res.output
d1 = {r.period: r for r in read_reaction(con._real, "HOME-VISITS")}["D1"]
assert d1.stance_method and d1.stance_eval is None
ev = json.loads(d1.stance_eval)
assert ev["in_sample"] is False and "in_sample_record" not in ev
assert d1.stance_agreement is None
def test_large_model_builds_the_large_asker(self, con, monkeypatch):
@@ -2579,21 +2572,81 @@ class TestStanceMethodRecord:
runner.invoke(app, t._args()) # the default model is the large one
assert calls == [True, False, pfs_cli.DEFAULT_MODEL == "large"]
def test_eval_is_none_without_golden_or_with_pending(self, monkeypatch, tmp_path):
def _sets(self, tmp_path, family="HOME-VISITS", generation="stance-v5"):
prim = tmp_path / "p.json"
prim.write_text(json.dumps({
"family": family, "dockets": ["H1", "H2"], "in_sample": False,
"role": "primary", "generation": generation, "items": [{}, {}, {}],
})) # fmt: skip
foot = tmp_path / "f.json"
foot.write_text(json.dumps({
"family": family, "docket": "H3", "in_sample": False,
"role": "footnote", "items": [{}],
})) # fmt: skip
tuning = tmp_path / "t.json"
tuning.write_text(json.dumps({
"family": family, "docket": "T1", "items": [{}, {}],
})) # fmt: skip
return tuning, (foot, prim)
def test_eval_is_out_of_sample_with_the_tuning_record(self, monkeypatch, tmp_path):
tuning, held = self._sets(tmp_path)
seen = []
def run(data, method, **kw):
seen.append(data["items"].__len__())
return SCORES, {}
monkeypatch.setattr(pfs_cli, "_golden_run", run)
got = json.loads(
pfs_cli._method_eval(tuning, "multi", "m", "HOME-VISITS", "stance-v5", held)
)
assert seen == [3, 2] # primary then tuning; the footnote is not stamped
assert got == {
"cell": 0.83, "recall": 0.556, "direction": 0.667, "n_items": 3,
"n_positions": 27, "family": "HOME-VISITS", "dockets": ["H1", "H2"],
"in_sample": False, "generation": "stance-v5",
"in_sample_record": {
"cell": 0.83, "recall": 0.556, "direction": 0.667, "n_items": 2,
"n_positions": 27, "docket": "T1",
},
} # fmt: skip
def test_eval_is_none_without_a_matching_primary(self, monkeypatch, tmp_path):
monkeypatch.setattr(pfs_cli, "_golden_run", lambda *a, **k: 1 / 0)
tuning, held = self._sets(tmp_path)
F = "HOME-VISITS"
assert pfs_cli._method_eval(tmp_path / "none.json", "multi", "m", F) is None
g = tmp_path / "g.json"
g.write_text(json.dumps({"family": F, "docket": "D1", "items": [{}]}))
monkeypatch.setattr(
pfs_cli, "_golden_run", lambda data, method, **kw: (None, {})
# another family, another generation, no files: no measurement
assert pfs_cli._method_eval(tuning, "multi", "m", "CCM", None, held) is None
assert pfs_cli._method_eval(tuning, "multi", "m", F, "stance-v4", held) is None
assert pfs_cli._method_eval(tuning, "multi", "m", F, None, ()) is None
assert (
pfs_cli._method_eval(
tuning, "multi", "m", F, None, (tmp_path / "gone.json",)
)
is None
)
assert pfs_cli._method_eval(g, "multi", "m", F) is None
monkeypatch.setattr(
pfs_cli, "_golden_run", lambda data, method, **kw: (SCORES, {})
)
got = json.loads(pfs_cli._method_eval(g, "multi", "m", F))
assert (got["recall"], got["direction"], got["n_items"]) == (0.556, 0.667, 1)
assert pfs_cli._method_eval(g, "multi", "m", "CCM") is None
def test_eval_without_tuning_set_omits_the_record(self, monkeypatch, tmp_path):
_, held = self._sets(tmp_path)
other = tmp_path / "ccm"
other.mkdir()
monkeypatch.setattr(pfs_cli, "_golden_run", lambda d, m, **kw: (SCORES, {}))
for tuning in (tmp_path / "none.json", self._sets(other, "CCM")[0]):
got = json.loads(
pfs_cli._method_eval(tuning, "multi", "m", "HOME-VISITS", None, held)
)
assert "in_sample_record" not in got
def test_partial_ledger_fails_loudly(self, monkeypatch, tmp_path):
tuning, held = self._sets(tmp_path)
monkeypatch.setattr(pfs_cli, "_golden_run", lambda d, m, **kw: (None, {}))
with pytest.raises(typer.BadParameter, match="held-out"):
pfs_cli._method_eval(tuning, "multi", "m", "HOME-VISITS", None, held)
calls = iter([(SCORES, {}), (None, {})])
monkeypatch.setattr(pfs_cli, "_golden_run", lambda d, m, **kw: next(calls))
with pytest.raises(typer.BadParameter, match="tuning"):
pfs_cli._method_eval(tuning, "multi", "m", "HOME-VISITS", None, held)
def test_model_of_and_slow_post(self, monkeypatch):
import httpx

View File

@@ -1505,3 +1505,15 @@ def test_eval_record_names_every_docket():
rec = eval_record(golden, score(golden, rows))
assert rec["dockets"] == ["D1", "D2"] and rec["docket"] == "D1; D2"
assert (rec["recall"], rec["direction"], rec["n_items"]) == (1.0, 1.0, 2)
def test_heldout_sets_are_packaged_out_of_sample():
from pfs.stance import HELDOUT_PATHS
roles = {}
for p in HELDOUT_PATHS:
d = json.loads(p.read_text())
assert p.parent == GOLDEN_PATH.parent
assert d["in_sample"] is False and d["family"] == "HOME-VISITS"
roles[d["role"]] = len(d["items"])
assert roles == {"primary": 20, "footnote": 19}