feat(pfs): dossier assembly — cited facts, computed gaps, model prose behind a sentence-level citation check
pfs.cite (Cite + builders; rule_label moved from llm.lineage and re-exported), pfs.citecheck (sentence split, number normalization, check_prose; plus grounding_problems: words, codes and CMS-vs-ours attribution of model prose), pfs.dossier (facts with resolved cites from every Task 1-12 table, timeline, stakeholder panels with names from pfs.commenter, stance accuracy beside every count, computed coverage gaps, ledgered model prose with template fallback, pfs.dossier table), llm.search item_keys filter, `stack pfs dossier`. Lineage rows reach the dossier only when a final rule's own plain sentence states them. HOME-VISITS live: 558 facts, 28 timeline events, check passed, prose model:qwen2.5:14b+template (8 of 29 units on templates).
This commit is contained in:
106
src/cli/pfs.py
106
src/cli/pfs.py
@@ -10,6 +10,7 @@
|
||||
uv run stack pfs review [--code G0556]
|
||||
uv run stack pfs cpt-ingest --edition 2024 [--edition 2022 …] [--dry-run]
|
||||
uv run stack pfs cpt-ingest --all
|
||||
uv run stack pfs dossier --family HOME-VISITS [--no-llm] [--limit N] [--write]
|
||||
|
||||
Writes go through ``duckdb_batch`` (single-writer rule) and republish
|
||||
the read-only replica so the chat and notebooks see them.
|
||||
@@ -65,6 +66,14 @@ from pfs.codetables import (
|
||||
from pfs.commenters import family_comment_items, identify, regs_for
|
||||
from pfs.cpt_load import ingest as cpt_ingest
|
||||
from pfs.curated import apply_curated, load_curated
|
||||
from pfs.dossier import (
|
||||
build_dossier,
|
||||
collect_facts,
|
||||
governance_excerpts,
|
||||
stakeholder_lines,
|
||||
write_dossier,
|
||||
)
|
||||
from pfs.dossier import timeline as dossier_timeline
|
||||
from pfs.exposure import build as build_exposures
|
||||
from pfs.exposure import control_codes
|
||||
from pfs.extract import extract_codes
|
||||
@@ -2373,3 +2382,100 @@ def _model_of(ask: Any, large: bool) -> str:
|
||||
if ask is not None:
|
||||
return ask.model
|
||||
return _model_name(large=True) if large else _model_name()
|
||||
|
||||
|
||||
def _excerpts(store: Any, name: str) -> list[Any]:
|
||||
"""Governance excerpts for a family (embeddings on the llm pool; no
|
||||
generation)."""
|
||||
from llm import config as llm_config
|
||||
from llm.pool import HostPool
|
||||
|
||||
cfg = llm_config.load()
|
||||
return governance_excerpts(cfg, HostPool.from_config(cfg), store, name)
|
||||
|
||||
|
||||
@app.command("dossier")
|
||||
def dossier_cmd(
|
||||
family: str = typer.Option("", "--family", help="Curated family key."),
|
||||
all_families: bool = typer.Option(False, "--all", help="Every curated family."),
|
||||
no_llm: bool = typer.Option(
|
||||
False,
|
||||
"--no-llm",
|
||||
help="Make no model calls; the finished prose ledger is replayed.",
|
||||
),
|
||||
limit: int = typer.Option(0, "--limit", help="Cap new model calls (0 = all)."),
|
||||
dry_run: bool = typer.Option(
|
||||
False,
|
||||
"--dry-run",
|
||||
help="Count facts and timeline events; no model calls, no writes.",
|
||||
),
|
||||
write: bool = typer.Option(False, "--write"),
|
||||
) -> None:
|
||||
"""Assemble a family's dossier (pfs.dossier): every stored fact with its
|
||||
resolved citation, the computed gaps, and model prose that passes the
|
||||
sentence-level citation check (template lines otherwise), through a
|
||||
resumable ledger. Prints the fact count, the gaps, the stakeholder table
|
||||
and the check result; --write stores it."""
|
||||
if all_families:
|
||||
registry = load_curated()
|
||||
fams = [registry[k] for k in sorted(registry)]
|
||||
elif family:
|
||||
fam = curated_family(normalize_key(family))
|
||||
if fam is None:
|
||||
raise typer.BadParameter(f"unknown curated family {family!r}")
|
||||
fams = [fam]
|
||||
else:
|
||||
raise typer.BadParameter("give --family KEY or --all")
|
||||
store = _store()
|
||||
built = []
|
||||
for fam in fams:
|
||||
con = _read()
|
||||
try:
|
||||
if dry_run:
|
||||
facts = collect_facts(con, store, fam)
|
||||
events = dossier_timeline(facts)
|
||||
typer.echo(
|
||||
f"{fam.key}: {len(facts)} facts, {len(events)} timeline events; "
|
||||
f"model calls a run would make: {len(events) + 1} "
|
||||
"(each retried once at most)"
|
||||
)
|
||||
continue
|
||||
d = build_dossier(
|
||||
con,
|
||||
store,
|
||||
fam,
|
||||
ask=None if no_llm else _asker(),
|
||||
excerpts=[] if no_llm else _excerpts(store, fam.name),
|
||||
log=RunLog(ledger_path("prose", fam.key)),
|
||||
replay_model=_model_name() if no_llm else None,
|
||||
limit=limit,
|
||||
)
|
||||
finally:
|
||||
con.close()
|
||||
kinds = Counter(f.kind for f in d.facts.values())
|
||||
typer.echo(
|
||||
f"{fam.key}: {len(d.facts)} facts ("
|
||||
+ ", ".join(f"{k} {n}" for k, n in sorted(kinds.items()))
|
||||
+ ")"
|
||||
)
|
||||
typer.echo(
|
||||
"timeline years: "
|
||||
+ ", ".join(str(y) for y in sorted({e.year for e in d.timeline}))
|
||||
)
|
||||
for gap in d.gaps:
|
||||
typer.echo(f"gap: {gap}")
|
||||
for line in stakeholder_lines(d):
|
||||
typer.echo(line)
|
||||
typer.echo(
|
||||
f"check: {'passed' if d.check_passed else 'FAILED'}; prose {d.extractor}"
|
||||
)
|
||||
if d.extractor != "template" and d.fallbacks:
|
||||
typer.echo("template fallback: " + "; ".join(d.fallbacks))
|
||||
built.append(d)
|
||||
if write and built:
|
||||
with _batch() as bcon:
|
||||
ensure_tables(bcon)
|
||||
for d in built:
|
||||
write_dossier(bcon, d)
|
||||
typer.echo(f"wrote dossier {d.family}")
|
||||
_publish()
|
||||
|
||||
@@ -36,6 +36,7 @@ from typing import Any, Sequence
|
||||
|
||||
from llm.config import LlmConfig
|
||||
from llm.links import as_source
|
||||
from pfs.cite import rule_label # moved there (dossier task 13); re-exported
|
||||
from pfs.codetables import (
|
||||
ElementRow,
|
||||
EventRow,
|
||||
@@ -45,7 +46,6 @@ from pfs.codetables import (
|
||||
read_events,
|
||||
read_guidance,
|
||||
)
|
||||
from pfs.descriptors import rule_year_of
|
||||
from pfs.families import detect_codes
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -338,36 +338,6 @@ class LineageEvidence:
|
||||
return out
|
||||
|
||||
|
||||
def rule_label(
|
||||
title: str,
|
||||
date_published: str,
|
||||
p_id: int,
|
||||
*,
|
||||
vol: str = "",
|
||||
page: int = 0,
|
||||
kind: str = "",
|
||||
) -> str:
|
||||
"""``"CY2021 PFS final 85 FR 84639 ¶1578"`` when *vol*/*page* are
|
||||
known (Ruling B13 — ``I2``), else the shorter
|
||||
``"CY2021 PFS final ¶1578"`` / ``"CY2027 PFS proposed ¶394"``.
|
||||
|
||||
*kind* is ``proposed`` / ``final`` / ``correction`` / ``rule`` as
|
||||
decided by ``bib.frlink.rule_kind`` from the rule's own text (the
|
||||
chat passes it via ``_rule_kind``). Without it the title decides
|
||||
(``bib.frlink.kind_from_title``) — and a title that says neither
|
||||
labels the row ``rule``, never ``final``: since CY2018 the CMS
|
||||
titles carry no proposed/final word, and a proposed rule presented
|
||||
as final is a false statement of policy. The year comes from
|
||||
``rule_year_of``."""
|
||||
from bib.frlink import kind_from_title # bib is an optional extra
|
||||
|
||||
year = rule_year_of(title, date_published)
|
||||
kind = kind or kind_from_title(title)
|
||||
if vol and page:
|
||||
return f"CY{year} PFS {kind} {vol} FR {page} ¶{p_id}"
|
||||
return f"CY{year} PFS {kind} ¶{p_id}"
|
||||
|
||||
|
||||
# ── The bib Store, opened lazily once PER THREAD (sqlite, cheap) ───────
|
||||
#
|
||||
# Ruling B14 / C1: bib.Store's sqlite connection is check_same_thread=True
|
||||
|
||||
@@ -88,6 +88,25 @@ def _store_filter(filters: dict[str, str]) -> dict[str, Any]:
|
||||
return out
|
||||
|
||||
|
||||
def _with_item_keys(
|
||||
store_filter: dict[str, Any], item_keys: Sequence[str] | None
|
||||
) -> dict[str, Any]:
|
||||
"""*store_filter* restricted to the bib items *item_keys* (``None``: no
|
||||
restriction) with an ``{"item_key": {"$in": [...]}}`` condition — merged
|
||||
into a plain field mapping, else joined under ``$and`` (an operator
|
||||
filter, or one that already pins ``item_key``)."""
|
||||
if item_keys is None:
|
||||
return store_filter
|
||||
cond = {"item_key": {"$in": list(item_keys)}}
|
||||
if not store_filter:
|
||||
return cond
|
||||
if "$and" in store_filter:
|
||||
return {"$and": [*store_filter["$and"], cond]}
|
||||
if any(k.startswith("$") for k in store_filter) or "item_key" in store_filter:
|
||||
return {"$and": [store_filter, cond]}
|
||||
return {**store_filter, **cond}
|
||||
|
||||
|
||||
def _year_ok(md: dict[str, Any], year: str) -> bool:
|
||||
if not year:
|
||||
return True
|
||||
@@ -135,6 +154,7 @@ def search(
|
||||
filters: dict[str, str] | None = None,
|
||||
limit: int = 10,
|
||||
offset: int = 0,
|
||||
item_keys: Sequence[str] | None = None,
|
||||
) -> list[dict]:
|
||||
"""Metadata-filtered similarity search across the selected
|
||||
collection(s), embedding *q* once.
|
||||
@@ -150,13 +170,19 @@ def search(
|
||||
Validation (empty *q*, ``limit``/``collection``/``kind`` ranges) is
|
||||
the API layer's job — this function assumes its inputs are already
|
||||
sane.
|
||||
|
||||
*item_keys* (dossier task 13) restricts the search to those bib items,
|
||||
pushed into the store filter as ``{"item_key": {"$in": [...]}}``; an
|
||||
empty set finds nothing (no embedding call).
|
||||
"""
|
||||
from llm.index import vectorstore
|
||||
|
||||
if item_keys is not None and not item_keys:
|
||||
return []
|
||||
filters = filters or {}
|
||||
year = str(filters.get("year") or "")
|
||||
theme = str(filters.get("theme") or "")
|
||||
store_filter = _store_filter(filters)
|
||||
store_filter = _with_item_keys(_store_filter(filters), item_keys)
|
||||
fetch = limit + offset
|
||||
|
||||
vec = PoolEmbeddings(pool, cfg.embed_model).embed_query(q)
|
||||
|
||||
267
src/pfs/cite.py
Normal file
267
src/pfs/cite.py
Normal file
@@ -0,0 +1,267 @@
|
||||
"""Citations for dossier facts (dossier task 13).
|
||||
|
||||
Every statement on a dossier carries one :class:`Cite`: what kind of source
|
||||
it is, the label a reader sees, a resolved URL (or ``""`` when none can be
|
||||
resolved) and, so a fact without a link still says where it comes from, a
|
||||
human-readable ``locator`` ("87 FR 69608", "CPT Changes 2023 p. 49",
|
||||
"42 CFR 425.400(c)"). The page never builds a URL itself (R10): every
|
||||
builder here resolves it once, at assembly time.
|
||||
|
||||
``rule_label`` (the chat's FR paragraph label) lives here so the dossier and
|
||||
``llm.lineage`` label a rule paragraph the same way; ``llm.lineage``
|
||||
re-exports it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from pfs.descriptors import rule_year_of
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
KINDS: tuple[str, ...] = (
|
||||
"fr_para",
|
||||
"fr_page",
|
||||
"comment",
|
||||
"cms_file",
|
||||
"cpt_book",
|
||||
"iom",
|
||||
"cfr",
|
||||
"mln",
|
||||
"statute",
|
||||
"study",
|
||||
"rvu_file",
|
||||
"dataset",
|
||||
)
|
||||
|
||||
#: CMS's page listing the PFS relative value files, every year's release
|
||||
RVU_FILES_URL = (
|
||||
"https://www.cms.gov/medicare/payment/fee-schedules/physician/"
|
||||
"pfs-relative-value-files"
|
||||
)
|
||||
REGS_COMMENT_URL = "https://www.regulations.gov/comment/{id}"
|
||||
SSA_SECTION_URL = "https://www.ssa.gov/OP_Home/ssact/title18/{section}.htm"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Cite:
|
||||
"""One citation: ``kind`` (one of :data:`KINDS`), the ``label`` shown, the
|
||||
resolved ``url`` (``""`` when unresolved), the bib ``item_key`` /
|
||||
paragraph ``p_id`` / printed ``page`` behind it, and a ``locator`` a
|
||||
reader can follow without the link."""
|
||||
|
||||
kind: str
|
||||
label: str
|
||||
url: str
|
||||
item_key: str = ""
|
||||
p_id: int = 0
|
||||
page: int = 0
|
||||
locator: str = ""
|
||||
|
||||
|
||||
def rule_label(
|
||||
title: str,
|
||||
date_published: str,
|
||||
p_id: int,
|
||||
*,
|
||||
vol: str = "",
|
||||
page: int = 0,
|
||||
kind: str = "",
|
||||
) -> str:
|
||||
"""``"CY2021 PFS final 85 FR 84639 ¶1578"`` when *vol*/*page* are
|
||||
known (Ruling B13 — ``I2``), else the shorter
|
||||
``"CY2021 PFS final ¶1578"`` / ``"CY2027 PFS proposed ¶394"``.
|
||||
|
||||
*kind* is ``proposed`` / ``final`` / ``correction`` / ``rule`` as
|
||||
decided by ``bib.frlink.rule_kind`` from the rule's own text (the
|
||||
chat passes it via ``_rule_kind``). Without it the title decides
|
||||
(``bib.frlink.kind_from_title``) — and a title that says neither
|
||||
labels the row ``rule``, never ``final``: since CY2018 the CMS
|
||||
titles carry no proposed/final word, and a proposed rule presented
|
||||
as final is a false statement of policy. The year comes from
|
||||
``rule_year_of``."""
|
||||
from bib.frlink import kind_from_title # bib is an optional extra
|
||||
|
||||
year = rule_year_of(title, date_published)
|
||||
kind = kind or kind_from_title(title)
|
||||
if vol and page:
|
||||
return f"CY{year} PFS {kind} {vol} FR {page} ¶{p_id}"
|
||||
return f"CY{year} PFS {kind} ¶{p_id}"
|
||||
|
||||
|
||||
# ── Federal Register ────────────────────────────────────────────────
|
||||
|
||||
|
||||
def _rule_meta(store: Any, item_key: str) -> tuple[str, str, str, str] | None:
|
||||
"""``(title, date_published, FR volume, rule kind)`` of a rule item, or
|
||||
``None`` when the item is not in the store."""
|
||||
from bib.frlink import rule_kind
|
||||
|
||||
con = store._con() # noqa: SLF001 — same pattern as pfs.descriptors
|
||||
row = con.execute(
|
||||
"SELECT title, date_published FROM items WHERE key = ?", (item_key,)
|
||||
).fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
vol = con.execute(
|
||||
"SELECT fr_volume FROM fr_anchor_docs WHERE item_key = ?", (item_key,)
|
||||
).fetchone()
|
||||
title, dp = row[0] or "", row[1] or ""
|
||||
return (
|
||||
title,
|
||||
dp,
|
||||
str(vol[0]) if vol else "",
|
||||
rule_kind(store, item_key, title=title),
|
||||
)
|
||||
|
||||
|
||||
def _resolve(store: Any, ref: str, item_key: str) -> str:
|
||||
"""``bib.frlink.resolve(ref).url``, ``""`` on any failure (logged)."""
|
||||
from bib import frlink
|
||||
|
||||
try:
|
||||
return frlink.resolve(ref, store=store, item_key=item_key).url
|
||||
except Exception as exc: # noqa: BLE001 — an unresolved link is a stated blank
|
||||
log.warning("FR link unresolved (%s %s): %s", item_key, ref, exc)
|
||||
return ""
|
||||
|
||||
|
||||
def fr_para_cite(store: Any, item_key: str, p_id: int) -> Cite:
|
||||
"""Paragraph *p_id* of the FR rule *item_key*: labelled like the chat
|
||||
(``rule_label``), the ``#p-N`` jump link, the printed page and the
|
||||
``"<vol> FR <page>"`` locator. An unknown item or paragraph keeps a
|
||||
label and a locator, with no URL."""
|
||||
meta = _rule_meta(store, item_key)
|
||||
if meta is None:
|
||||
where = f"{item_key} ¶{p_id}"
|
||||
return Cite("fr_para", where, "", item_key, p_id, 0, where)
|
||||
title, dp, vol, kind = meta
|
||||
row = (
|
||||
store._con() # noqa: SLF001
|
||||
.execute(
|
||||
"SELECT page FROM fr_anchors WHERE item_key = ? AND p_id = ?",
|
||||
(item_key, p_id),
|
||||
)
|
||||
.fetchone()
|
||||
)
|
||||
if row is None:
|
||||
return Cite(
|
||||
"fr_para",
|
||||
rule_label(title, dp, p_id, kind=kind),
|
||||
"",
|
||||
item_key,
|
||||
p_id,
|
||||
0,
|
||||
f"{item_key} ¶{p_id}",
|
||||
)
|
||||
page = int(row[0] or 0)
|
||||
return Cite(
|
||||
"fr_para",
|
||||
rule_label(title, dp, p_id, vol=vol, page=page, kind=kind),
|
||||
_resolve(store, f"p-{p_id}", item_key),
|
||||
item_key,
|
||||
p_id,
|
||||
page,
|
||||
f"{vol} FR {page}" if vol and page else f"{item_key} ¶{p_id}",
|
||||
)
|
||||
|
||||
|
||||
def fr_page_cite(store: Any, item_key: str, page: int, *, table: str = "") -> Cite:
|
||||
"""Printed page *page* of the FR rule *item_key* (a table cell's page):
|
||||
``"CY2008 PFS final 72 FR 66361 Table 14"``."""
|
||||
meta = _rule_meta(store, item_key)
|
||||
if meta is None:
|
||||
where = f"{item_key} p. {page}"
|
||||
return Cite("fr_page", where, "", item_key, 0, page, where)
|
||||
title, dp, vol, kind = meta
|
||||
cite = f"{vol} FR {page}"
|
||||
label = f"CY{rule_year_of(title, dp)} PFS {kind} {cite}"
|
||||
if table:
|
||||
label += f" {table}"
|
||||
return Cite(
|
||||
"fr_page", label, _resolve(store, cite, item_key), item_key, 0, page, cite
|
||||
)
|
||||
|
||||
|
||||
# ── comments, files, books, datasets ────────────────────────────────
|
||||
|
||||
|
||||
def comment_cite(comment_id: str) -> Cite:
|
||||
return Cite(
|
||||
"comment",
|
||||
f"Comment {comment_id}",
|
||||
REGS_COMMENT_URL.format(id=comment_id),
|
||||
locator=comment_id,
|
||||
)
|
||||
|
||||
|
||||
def rvu_cite(year: int, *, proposed: bool = False) -> Cite:
|
||||
"""The PFS relative value file of *year* (``proposed``: the NPRM's)."""
|
||||
label = f"PFS CY{year} {'NPRM ' if proposed else ''}RVU file"
|
||||
return Cite("rvu_file", label, RVU_FILES_URL, locator=label)
|
||||
|
||||
|
||||
def book_cite(item_key: str, edition_label: str, page_label: str) -> Cite:
|
||||
"""A page of a licensed book (cited, never quoted): ``"<edition> p. N"``,
|
||||
or ``"<edition>, <locator>"`` for a locator that is not a bare page
|
||||
("tab 10, PDF p. 4")."""
|
||||
page = page_label.strip()
|
||||
if re.fullmatch(r"\d+", page):
|
||||
label = f"{edition_label} p. {page}"
|
||||
elif re.fullmatch(r"p\.\s*\d+", page):
|
||||
label = f"{edition_label} {page}"
|
||||
else:
|
||||
label = f"{edition_label}, {page}"
|
||||
return Cite("cpt_book", label, "", item_key, locator=label)
|
||||
|
||||
|
||||
def dataset_cite(item_key: str, label: str, url: str) -> Cite:
|
||||
return Cite("dataset", label, url, item_key, locator=label)
|
||||
|
||||
|
||||
def _cfr_url(locator: str) -> str:
|
||||
from bib import cfrlink
|
||||
|
||||
try:
|
||||
return cfrlink.url(cfrlink.parse_cite(locator))
|
||||
except ValueError:
|
||||
return ""
|
||||
|
||||
|
||||
def reference_cite(
|
||||
kind: str, locator: str, *, item_key: str = "", p_id: int = 0, page: int = 0
|
||||
) -> Cite:
|
||||
"""A CFR, IOM or MLN reference (``kind``), the eCFR link for a CFR cite;
|
||||
*item_key*/*p_id* are the source that cites it."""
|
||||
url = _cfr_url(locator) if kind == "cfr" else ""
|
||||
return Cite(kind, locator, url, item_key, p_id, page, locator)
|
||||
|
||||
|
||||
def guidance_cite(row: Any) -> Cite:
|
||||
"""A ``pfs.code_guidance`` row (``GuidanceRow``): the reference itself,
|
||||
keyed to the resolved bib item when there is one, else to the paragraph
|
||||
that cites it."""
|
||||
return reference_cite(
|
||||
row.kind,
|
||||
row.locator,
|
||||
item_key=row.item_key or row.item_key_src,
|
||||
p_id=row.p_id_src,
|
||||
page=row.page,
|
||||
)
|
||||
|
||||
|
||||
_SSA_SECTION = re.compile(r"\bsection\s+(18\d\d[A-Z]?)(?=[\s(]|$)", re.I)
|
||||
_OF_THE_ACT = re.compile(r"\bof\s+the\s+(?:Social\s+Security\s+)?Act\b", re.I)
|
||||
|
||||
|
||||
def ssa_section_url(reference: str) -> str:
|
||||
"""The SSA compilation page of a title XVIII section the reference names
|
||||
as "section 18NN… of the Act", else ``""``."""
|
||||
m = _SSA_SECTION.search(reference or "")
|
||||
if m is None or not _OF_THE_ACT.search(reference):
|
||||
return ""
|
||||
return SSA_SECTION_URL.format(section=m.group(1).upper())
|
||||
278
src/pfs/citecheck.py
Normal file
278
src/pfs/citecheck.py
Normal file
@@ -0,0 +1,278 @@
|
||||
"""The sentence-level citation check on dossier prose (dossier task 13).
|
||||
|
||||
Model-written prose reaches a page only when every sentence carries at least
|
||||
one ``[F<n>]`` tag naming a stored fact, every tag names a fact that exists,
|
||||
and every number the sentence writes is a number its cited facts carry (in
|
||||
their text or their values). A neighbour's number ("99342's 1.65" cited to
|
||||
99341's round) is rejected; the same value written another way ("1.0" for
|
||||
"1.00", "$131.17" for "131.17", "−16.5%" for "-16.5%") is accepted.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Any, Iterable, Mapping
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from pfs.dossier import Fact
|
||||
|
||||
PROBLEM_KINDS = ("uncited", "unknown_fact", "number_mismatch")
|
||||
#: what ``grounding_problems`` adds for model prose
|
||||
GROUNDING_KINDS = ("ungrounded", "code_mismatch", "merged", "unattributed")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Problem:
|
||||
sentence: str
|
||||
kind: str # one of PROBLEM_KINDS
|
||||
detail: str
|
||||
|
||||
|
||||
# ── sentences ───────────────────────────────────────────────────────
|
||||
|
||||
#: tokens ending in a period that never end a sentence
|
||||
_ABBREV = (
|
||||
"U.S.",
|
||||
"e.g.",
|
||||
"i.e.",
|
||||
"No.",
|
||||
"Nos.",
|
||||
"p.",
|
||||
"pp.",
|
||||
"ch.",
|
||||
"Ch.",
|
||||
"vs.",
|
||||
"Dr.",
|
||||
"Mr.",
|
||||
"Mrs.",
|
||||
"Ms.",
|
||||
"Inc.",
|
||||
"Co.",
|
||||
"Corp.",
|
||||
"Jr.",
|
||||
"Sr.",
|
||||
"St.",
|
||||
"al.",
|
||||
"Vol.",
|
||||
"Sec.",
|
||||
"Fig.",
|
||||
"approx.",
|
||||
)
|
||||
#: a sentence end: terminal punctuation (and a closing quote or bracket),
|
||||
#: whitespace, then what can start a sentence
|
||||
_END = re.compile(r"(?<=[.!?])[\"'”)]?\s+(?=[\[A-Z0-9“\"(¶§$])")
|
||||
_TAG = re.compile(r"\[(F\d+(?:\s*,\s*F\d+)*)\]")
|
||||
_LEADING_TAGS = re.compile(r"^((?:\[F\d+(?:\s*,\s*F\d+)*\]\s*)+)")
|
||||
|
||||
|
||||
def _ends_with_abbrev(chunk: str) -> bool:
|
||||
last = chunk.rsplit(None, 1)[-1] if chunk.split() else ""
|
||||
last = last.lstrip("(\"'“")
|
||||
return last in _ABBREV or bool(re.fullmatch(r"(?:[A-Z]\.){1,3}", last))
|
||||
|
||||
|
||||
def split_sentences(text: str) -> list[str]:
|
||||
"""Sentences of *text*. Abbreviations ("U.S.", "e.g.", "i.e.", "No.",
|
||||
"p.") and decimals do not end a sentence; ``[F#]`` tags written after the
|
||||
period stay with the sentence they close."""
|
||||
text = " ".join((text or "").split())
|
||||
if not text:
|
||||
return []
|
||||
out: list[str] = []
|
||||
start = 0
|
||||
for m in _END.finditer(text):
|
||||
chunk = text[start : m.start()].strip()
|
||||
# the end match sits after the punctuation; a lone closing char is
|
||||
# part of the sentence
|
||||
chunk = text[start : m.end()].strip()
|
||||
if _ends_with_abbrev(text[start : m.start() + 1]):
|
||||
continue
|
||||
out.append(chunk)
|
||||
start = m.end()
|
||||
out.append(text[start:].strip())
|
||||
# tags written after the period belong to the sentence before them
|
||||
merged: list[str] = []
|
||||
for s in out:
|
||||
lead = _LEADING_TAGS.match(s)
|
||||
if lead and merged:
|
||||
merged[-1] = f"{merged[-1]} {lead.group(1).strip()}"
|
||||
s = s[lead.end() :].strip()
|
||||
if s:
|
||||
merged.append(s)
|
||||
return merged
|
||||
|
||||
|
||||
# ── numbers ─────────────────────────────────────────────────────────
|
||||
|
||||
_BRACKETS = re.compile(r"\[[^\]]*\]")
|
||||
_NUMBER = re.compile(
|
||||
r"(?P<code>\b[A-Z]\d{4}\b)"
|
||||
r"|(?P<cy>\bCY\s?(?P<year>\d{4})\b)"
|
||||
r"|(?<![A-Za-z0-9.,])(?P<num>[-−–+]?\$?\d[\d,]*(?:\.\d+)?)"
|
||||
r"(?P<suffix>%|(?:st|nd|rd|th)\b)?"
|
||||
)
|
||||
|
||||
|
||||
def _norm_number(raw: str) -> str:
|
||||
s = raw.replace("−", "-").replace("–", "-").replace("$", "")
|
||||
s = s.replace(",", "").lstrip("+")
|
||||
if "." in s:
|
||||
s = s.rstrip("0").rstrip(".")
|
||||
if s in ("-0", ""):
|
||||
s = "0"
|
||||
return s
|
||||
|
||||
|
||||
def number_tokens(text: str) -> set[str]:
|
||||
"""The numbers *text* writes, normalized: bracketed segments (``[F3]``,
|
||||
a cite label) removed first; ``$``, thousands commas and a leading ``+``
|
||||
dropped; ``−``/``–`` read as ``-``; trailing decimal zeros dropped
|
||||
(``1.00`` → ``1``, ``3.60`` → ``3.6``); ``%`` and ordinal suffixes kept
|
||||
(``25th``). ``CY2023`` gives ``2023``; a HCPCS code such as ``G0318`` is
|
||||
one token; digits inside a word (``B1``, ``MOD1``) are not numbers; a
|
||||
dash between two digits is a range, not a sign."""
|
||||
out: set[str] = set()
|
||||
for m in _NUMBER.finditer(_BRACKETS.sub(" ", text or "")):
|
||||
if m.group("code"):
|
||||
out.add(m.group("code"))
|
||||
elif m.group("cy"):
|
||||
out.add(m.group("year"))
|
||||
else:
|
||||
out.add(_norm_number(m.group("num")) + (m.group("suffix") or ""))
|
||||
return out
|
||||
|
||||
|
||||
def _value_tokens(values: Mapping[str, Any]) -> set[str]:
|
||||
out: set[str] = set()
|
||||
for v in values.values():
|
||||
if isinstance(v, bool) or v is None:
|
||||
continue
|
||||
if isinstance(v, int | float):
|
||||
out.add(_norm_number(f"{float(v):.6f}"))
|
||||
else:
|
||||
out |= number_tokens(str(v))
|
||||
return out
|
||||
|
||||
|
||||
def _supported(facts: Iterable[Fact]) -> set[str]:
|
||||
out: set[str] = set()
|
||||
for f in facts:
|
||||
out |= number_tokens(f.text) | _value_tokens(f.values)
|
||||
return out
|
||||
|
||||
|
||||
# ── the check ───────────────────────────────────────────────────────
|
||||
|
||||
|
||||
def tags_of(sentence: str) -> list[str]:
|
||||
"""The fact ids a sentence cites, in order (``[F1][F2]`` or ``[F1, F2]``)."""
|
||||
return [t.strip() for m in _TAG.finditer(sentence) for t in m.group(1).split(",")]
|
||||
|
||||
|
||||
def check_prose(prose: str, facts: Mapping[str, Fact]) -> list[Problem]:
|
||||
"""One :class:`Problem` per failing sentence of *prose*: ``uncited`` (no
|
||||
``[F#]`` tag), ``unknown_fact`` (a tag naming no fact in *facts*) or
|
||||
``number_mismatch`` (a number none of the sentence's cited facts carries).
|
||||
``[]`` means every sentence passed."""
|
||||
problems: list[Problem] = []
|
||||
for sentence in split_sentences(prose):
|
||||
tags = tags_of(sentence)
|
||||
if not tags:
|
||||
problems.append(Problem(sentence, "uncited", "no [F#] tag"))
|
||||
continue
|
||||
unknown = [t for t in tags if t not in facts]
|
||||
if unknown:
|
||||
problems.append(
|
||||
Problem(sentence, "unknown_fact", "no such fact: " + ", ".join(unknown))
|
||||
)
|
||||
continue
|
||||
extra = number_tokens(sentence) - _supported(facts[t] for t in tags)
|
||||
if extra:
|
||||
problems.append(
|
||||
Problem(
|
||||
sentence,
|
||||
"number_mismatch",
|
||||
"not in the cited facts: " + ", ".join(sorted(extra)),
|
||||
)
|
||||
)
|
||||
return problems
|
||||
|
||||
|
||||
# ── grounding: the anti-goals a number check cannot see ─────────────
|
||||
|
||||
#: words connective prose may use that a cited fact need not contain
|
||||
_PROSE_GENERIC = frozenset(
|
||||
"family families cms year years later then after before since first "
|
||||
"following together respectively through value values both also rvu rvus".split()
|
||||
)
|
||||
_CODE5 = re.compile(r"\b\d{5}\b")
|
||||
|
||||
|
||||
def grounding_problems(prose: str, facts: Mapping[str, Fact]) -> list[Problem]:
|
||||
"""What model prose must also respect beyond :func:`check_prose` (the
|
||||
spec's anti-goals: no invented history, CMS's summary never merged with
|
||||
our counts): every content word of a sentence occurs (stemmed) in the text
|
||||
of the facts it cites, generic connective words aside (``ungrounded``);
|
||||
every code it names, ranges expanded, is one those facts name
|
||||
(``code_mismatch``); a sentence citing CMS's summary says "CMS" and one
|
||||
citing our classification says "classified" (``unattributed``), and no
|
||||
sentence cites both (``merged``). Sentences without a known tag are left
|
||||
to ``check_prose``."""
|
||||
from pfs.guideline_facts import _GENERIC, _content, _stem
|
||||
from pfs.lineage import _expand_ranges
|
||||
|
||||
generic = {_stem(w) for w in _GENERIC | _PROSE_GENERIC}
|
||||
out: list[Problem] = []
|
||||
for sentence in split_sentences(prose):
|
||||
cited = [facts[t] for t in tags_of(sentence) if t in facts]
|
||||
if not cited:
|
||||
continue
|
||||
body = _BRACKETS.sub(" ", sentence)
|
||||
known = set().union(*(_content(f.text) for f in cited)) | generic
|
||||
missing = sorted({w for w in _content(body) if w not in known})
|
||||
if missing:
|
||||
out.append(
|
||||
Problem(
|
||||
sentence,
|
||||
"ungrounded",
|
||||
"words not in the cited facts: " + ", ".join(missing),
|
||||
)
|
||||
)
|
||||
continue
|
||||
# a range a fact itself writes may be restated
|
||||
have = set().union(
|
||||
*(set(f.codes) | set(_CODE5.findall(_expand_ranges(f.text))) for f in cited)
|
||||
)
|
||||
extra = sorted(set(_CODE5.findall(_expand_ranges(body))) - have)
|
||||
if extra:
|
||||
out.append(
|
||||
Problem(
|
||||
sentence,
|
||||
"code_mismatch",
|
||||
"codes not in the cited facts: " + ", ".join(extra),
|
||||
)
|
||||
)
|
||||
continue
|
||||
kinds = {f.kind for f in cited}
|
||||
if {"cms_summary", "stance_split"} <= kinds:
|
||||
out.append(
|
||||
Problem(
|
||||
sentence,
|
||||
"merged",
|
||||
"CMS's summary and our classification in one sentence",
|
||||
)
|
||||
)
|
||||
elif "cms_summary" in kinds and "CMS" not in body:
|
||||
out.append(
|
||||
Problem(sentence, "unattributed", "CMS's summary not attributed to CMS")
|
||||
)
|
||||
elif "stance_split" in kinds and "classif" not in body.lower():
|
||||
out.append(
|
||||
Problem(
|
||||
sentence,
|
||||
"unattributed",
|
||||
'our classification not labelled as ours ("we classified")',
|
||||
)
|
||||
)
|
||||
return out
|
||||
@@ -6,6 +6,9 @@
|
||||
``pfs.code_family`` derived family membership with roles
|
||||
``pfs.code_exposure`` the exposure calendar (#693): dated payable /
|
||||
revalued / status / ends / telehealth events
|
||||
``pfs.dossier`` one assembled, checked dossier per family (task
|
||||
13; its writer and reader live in ``pfs.dossier``,
|
||||
which builds on this module)
|
||||
|
||||
``pfs.cpt_*`` (docs/superpowers/specs/2026-09-09-cpt-canonical-schema-design.md
|
||||
§3) hold one CPT codebook edition's own organizing structure —
|
||||
@@ -665,6 +668,9 @@ CREATE TABLE IF NOT EXISTS pfs.commenter (
|
||||
org_type VARCHAR, specialty VARCHAR, form_group VARCHAR, form_size INTEGER,
|
||||
basis VARCHAR, reg_category VARCHAR, extractor VARCHAR, family VARCHAR,
|
||||
submitter_name VARCHAR);
|
||||
CREATE TABLE IF NOT EXISTS pfs.dossier (
|
||||
family VARCHAR, built_at TIMESTAMP, version INTEGER, json VARCHAR,
|
||||
check_passed BOOLEAN, extractor VARCHAR);
|
||||
CREATE TABLE IF NOT EXISTS pfs.comment_stance (
|
||||
family VARCHAR, item_key VARCHAR, docket VARCHAR, event_key VARCHAR,
|
||||
stance VARCHAR, reason VARCHAR, evidence VARCHAR, extractor VARCHAR,
|
||||
|
||||
2514
src/pfs/dossier.py
Normal file
2514
src/pfs/dossier.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3591,3 +3591,139 @@ class TestSeats:
|
||||
|
||||
def test_seat_root_sits_beside_the_primary_database():
|
||||
assert str(pfs_cli._seat_root()).endswith("ama/rosters")
|
||||
|
||||
|
||||
# ── stack pfs dossier (task 13) ──────────────────────────────────────
|
||||
|
||||
from tests.pfs.home_visits_fixture import FakeAsk, home # noqa: E402
|
||||
|
||||
|
||||
def _echo_prose(system, user):
|
||||
import re as _re
|
||||
|
||||
m = _re.search(r"^\[(F\d+)\] (.+)$", user, _re.M)
|
||||
return {"text": f"{m.group(2).rstrip('.')} [{m.group(1)}]."}
|
||||
|
||||
|
||||
class TestDossier:
|
||||
@pytest.fixture
|
||||
def env(self, monkeypatch, tmp_path):
|
||||
with home(tmp_path / "home") as parts:
|
||||
yield self._env(parts, monkeypatch, tmp_path)
|
||||
|
||||
def _env(self, parts, monkeypatch, tmp_path):
|
||||
con, store, family, _ask = parts
|
||||
published: list[bool] = []
|
||||
|
||||
class _Batch:
|
||||
def __enter__(self):
|
||||
return con
|
||||
|
||||
def __exit__(self, *a):
|
||||
return False
|
||||
|
||||
monkeypatch.setattr(pfs_cli, "_batch", lambda: _Batch())
|
||||
monkeypatch.setattr(pfs_cli, "_read", lambda: con.cursor())
|
||||
monkeypatch.setattr(pfs_cli, "_store", lambda: store)
|
||||
monkeypatch.setattr(pfs_cli, "_publish", lambda: published.append(True))
|
||||
monkeypatch.setattr(pfs_cli, "_model_name", lambda large=False: "fake-14b")
|
||||
monkeypatch.setattr(
|
||||
pfs_cli, "ledger_path", lambda task, fam: tmp_path / f"{task}-{fam}.jsonl"
|
||||
)
|
||||
excerpts: list[tuple] = []
|
||||
monkeypatch.setattr(
|
||||
pfs_cli, "_excerpts", lambda store, name: excerpts.append(name) or []
|
||||
)
|
||||
return SimpleNamespace(con=con, published=published, excerpts=excerpts)
|
||||
|
||||
def test_no_llm_prints_facts_gaps_and_the_check(self, env):
|
||||
res = runner.invoke(
|
||||
app, ["pfs", "dossier", "--family", "HOME-VISITS", "--no-llm"]
|
||||
)
|
||||
assert res.exit_code == 0, res.output
|
||||
assert "HOME-VISITS:" in res.output and " facts (" in res.output
|
||||
assert (
|
||||
"gap: Federal Register PFS rules before CY2002 not yet captured."
|
||||
in res.output
|
||||
)
|
||||
assert "check: passed; prose template" in res.output
|
||||
assert "timeline years: 2008" in res.output
|
||||
assert "stakeholders (CY2023, HOME-VISITS:2023:valuation" in res.output
|
||||
assert env.published == [] and env.excerpts == []
|
||||
from pfs.dossier import dossier_families
|
||||
|
||||
assert dossier_families(env.con) == ()
|
||||
|
||||
def test_write_stores_the_dossier_and_publishes(self, env):
|
||||
res = runner.invoke(
|
||||
app, ["pfs", "dossier", "--family", "home-visits", "--no-llm", "--write"]
|
||||
)
|
||||
assert res.exit_code == 0, res.output
|
||||
from pfs.dossier import read_dossier
|
||||
|
||||
d = read_dossier(env.con, "HOME-VISITS")
|
||||
assert d is not None and d.check_passed
|
||||
assert "wrote dossier HOME-VISITS" in res.output
|
||||
assert env.published == [True]
|
||||
|
||||
def test_all_builds_every_curated_family(self, env):
|
||||
res = runner.invoke(app, ["pfs", "dossier", "--all", "--no-llm"])
|
||||
assert res.exit_code == 0, res.output
|
||||
assert "HOME-VISITS:" in res.output
|
||||
|
||||
def test_needs_a_family_or_all(self, env):
|
||||
res = runner.invoke(app, ["pfs", "dossier"])
|
||||
assert res.exit_code != 0 and "--family" in res.output
|
||||
res = runner.invoke(app, ["pfs", "dossier", "--family", "NOPE", "--no-llm"])
|
||||
assert res.exit_code != 0 and "unknown curated family" in res.output
|
||||
|
||||
def test_model_prose_through_the_ledger(self, env, monkeypatch, tmp_path):
|
||||
ask = FakeAsk(default=_echo_prose)
|
||||
monkeypatch.setattr(pfs_cli, "_asker", lambda large=False: ask)
|
||||
res = runner.invoke(
|
||||
app, ["pfs", "dossier", "--family", "HOME-VISITS", "--limit", "2"]
|
||||
)
|
||||
assert res.exit_code == 0, res.output
|
||||
assert len(ask.calls) == 2
|
||||
assert "prose model:fake-14b+template" in res.output
|
||||
assert "template fallback:" in res.output
|
||||
assert env.excerpts == ["Home or Residence Services"]
|
||||
res = runner.invoke(app, ["pfs", "dossier", "--family", "HOME-VISITS"])
|
||||
assert res.exit_code == 0, res.output
|
||||
assert "check: passed; prose model:fake-14b" in res.output
|
||||
# --no-llm replays the finished ledger: no new calls, same prose
|
||||
n = len(ask.calls)
|
||||
res = runner.invoke(
|
||||
app, ["pfs", "dossier", "--family", "HOME-VISITS", "--no-llm"]
|
||||
)
|
||||
assert "prose model:fake-14b" in res.output and len(ask.calls) == n
|
||||
assert (tmp_path / "prose-HOME-VISITS.jsonl").exists()
|
||||
|
||||
def test_dry_run_makes_no_calls_and_no_writes(self, env, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
pfs_cli, "_asker", lambda large=False: pytest.fail("no model on a dry run")
|
||||
)
|
||||
res = runner.invoke(
|
||||
app, ["pfs", "dossier", "--family", "HOME-VISITS", "--dry-run", "--write"]
|
||||
)
|
||||
assert res.exit_code == 0, res.output
|
||||
assert "model calls a run would make:" in res.output
|
||||
assert env.published == []
|
||||
|
||||
|
||||
def test_dossier_excerpts_use_the_llm_pool(monkeypatch):
|
||||
from llm import config as llm_config
|
||||
from llm import pool as llm_pool
|
||||
|
||||
calls = []
|
||||
monkeypatch.setattr(llm_config, "load", lambda: "CFG")
|
||||
monkeypatch.setattr(
|
||||
llm_pool.HostPool, "from_config", classmethod(lambda c, cfg: "POOL")
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
pfs_cli,
|
||||
"governance_excerpts",
|
||||
lambda cfg, pool, store, name: calls.append((cfg, pool, store, name)) or [],
|
||||
)
|
||||
assert pfs_cli._excerpts("STORE", "Home or Residence Services") == []
|
||||
assert calls == [("CFG", "POOL", "STORE", "Home or Residence Services")]
|
||||
|
||||
@@ -244,6 +244,13 @@ class TestKindRank:
|
||||
|
||||
|
||||
class TestRuleLabel:
|
||||
def test_rule_label_lives_in_pfs_cite(self):
|
||||
"""Dossier task 13 moved ``rule_label`` to ``pfs.cite``; the chat's
|
||||
import keeps working through the re-export."""
|
||||
import pfs.cite
|
||||
|
||||
assert lineage.rule_label is pfs.cite.rule_label
|
||||
|
||||
def test_title_without_a_kind_word_is_rule_not_final(self):
|
||||
"""Since CY2018 the CMS titles say neither "Proposed" nor
|
||||
"Final"; without a decided kind the label must not claim
|
||||
|
||||
@@ -425,3 +425,54 @@ class TestDedupeByLabel:
|
||||
"",
|
||||
]
|
||||
assert out[0]["item_key"] == "B"
|
||||
|
||||
|
||||
class TestItemKeys:
|
||||
"""Dossier task 13: ``item_keys`` restricts a search to a set of items."""
|
||||
|
||||
def test_item_key_set_is_pushed_into_the_store_filter(self):
|
||||
assert search._with_item_keys({}, ["K1", "K2"]) == {
|
||||
"item_key": {"$in": ["K1", "K2"]}
|
||||
}
|
||||
assert search._with_item_keys({"kind": "corpus"}, ("K1",)) == {
|
||||
"kind": "corpus",
|
||||
"item_key": {"$in": ["K1"]},
|
||||
}
|
||||
theme_or = {"$or": [{"theme_1": "x"}]}
|
||||
assert search._with_item_keys(theme_or, ["K1"]) == {
|
||||
"$and": [theme_or, {"item_key": {"$in": ["K1"]}}]
|
||||
}
|
||||
both = {"$and": [{"doctype": "manual"}, theme_or]}
|
||||
assert search._with_item_keys(both, ["K1"]) == {
|
||||
"$and": [{"doctype": "manual"}, theme_or, {"item_key": {"$in": ["K1"]}}]
|
||||
}
|
||||
# an equality on item_key and the set are both kept
|
||||
assert search._with_item_keys({"item_key": "K9"}, ["K1"]) == {
|
||||
"$and": [{"item_key": "K9"}, {"item_key": {"$in": ["K1"]}}]
|
||||
}
|
||||
assert search._with_item_keys({"kind": "x"}, None) == {"kind": "x"}
|
||||
|
||||
@patch("llm.search.PoolEmbeddings")
|
||||
@patch("llm.index.vectorstore")
|
||||
def test_search_passes_item_keys_to_the_store(self, mock_vs, MockEmb):
|
||||
MockEmb.return_value.embed_query.return_value = [0.0, 0.0, 0.0]
|
||||
store = MagicMock()
|
||||
store.similarity_search_with_score_by_vector.return_value = []
|
||||
mock_vs.return_value = store
|
||||
run_search(
|
||||
"q",
|
||||
cfg=CFG,
|
||||
pool=MagicMock(),
|
||||
collection="corpus",
|
||||
item_keys=["K1", "K2"],
|
||||
limit=3,
|
||||
)
|
||||
kwargs = store.similarity_search_with_score_by_vector.call_args.kwargs
|
||||
assert kwargs["filter"] == {"item_key": {"$in": ["K1", "K2"]}}
|
||||
|
||||
@patch("llm.search.PoolEmbeddings")
|
||||
@patch("llm.index.vectorstore")
|
||||
def test_an_empty_key_set_finds_nothing(self, mock_vs, MockEmb):
|
||||
assert run_search("q", cfg=CFG, pool=MagicMock(), item_keys=[]) == []
|
||||
mock_vs.assert_not_called()
|
||||
MockEmb.assert_not_called()
|
||||
|
||||
3
tests/pfs/conftest.py
Normal file
3
tests/pfs/conftest.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""Shared pfs fixtures: the HOME-VISITS proof family (dossier task 13)."""
|
||||
|
||||
from tests.pfs.home_visits_fixture import home_fixture # noqa: F401
|
||||
33
tests/pfs/fixtures/home_visits_fr.jsonl
Normal file
33
tests/pfs/fixtures/home_visits_fr.jsonl
Normal file
@@ -0,0 +1,33 @@
|
||||
{"item_key": "PETM225D", "p_id": 390, "page": 69440, "ordinal": 4, "text": "When we establish values for codes or consider whether codes are potentially misvalued under the PFS, we take into account the resources involved in furnishing the specific service as described by the CPT code. As such, historically, we do not take into account: (1) travel costs incurred by the physician or other practitioner; (2) potential opportunity costs to a physician or other practitioner when care is delivered in one setting versus another; or (3) the physician or other practitioner's work and time expended in performing activities that are outside the scope of the specific service as described by the CPT code. These are not considered to be resources involved in furnishing the service, and they are not included in establishing payment rates under the PFS in accordance with section 1848 of the Act, and, as such, do not provide justification for potential misvaluation of those payments. That said, in February 2021, the AMA CPT Editorial Panel deleted the family of domiciliary codes, CPT codes 99324 to 99340, and merged the services described by those codes into the existing family of home-based E/M visits, CPT codes 99341 to 99350 (a range of codes that includes CPT codes 99344, 99345, 99349, and 99350). In addition, the AMA RUC made recommendations regarding the values for these home-based E/M codes as discussed in section II.F. of the CY 2023 PFS proposed rule (87 FR 45999) and in section II.F. of this final rule. Since CMS had already received AMA RUC recommendations for these home-based E/M visit codes, we considered those recommendations and solicited additional public comments, recommendations, and independent analysis as supporting evidence from all interested parties regarding the valuations for the home-based E/M visits, including CPT codes 99344, 99345, 99349, and 99350. Because we discussed and solicited public comment on the valuation of these codes in the proposed rule, we stated that we were not considering these home-based E/M ( printed page 69441) visits as potentially misvalued for CY 2023.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1672, "page": 69608, "ordinal": 6, "text": "More specifically, in its February 2021 meeting, effective beginning in 2023, the CPT Editorial Panel deleted the nine CPT codes in the Domiciliary, Rest Home (for example, Boarding Home), or Custodial Care Services code family (CPT codes 99324-99328, and 99334-99337), and one CPT code in the Home Services family (CPT code 99343), to merge these services with the eight remaining home visit services. The eight remaining home services CPT codes (99341, 99342, 99344, 99345, and 99347-99350) were revised to describe Home or Residence Services to align with the principles of the O/O E/M visit codes by allowing physicians and NPPs to document and select the level of service based on total practitioner time or MDM level. These changes include combining the domiciliary, rest home and custodial care CPT codes with the home visit CPT codes, resulting in a single family of CPT codes that describe these types of services. In addition, CPT revised the descriptors to allow reporting that is based on time or MDM level—in alignment with the O/O E/M visit CPT codes. We proposed to accept these coding revisions.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1674, "page": 69608, "ordinal": 8, "text": "Comment: The commenters supported our proposal to accept the CPT coding changes for Home or Residence Services codes.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1675, "page": 69608, "ordinal": 9, "text": "Response: We appreciate the feedback from the commenters regarding our proposal, and are finalizing as proposed to adopt the CPT merger of the home and domiciliary visits into one family, and adopt the CPT codes as revised for reporting these services.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1676, "page": 69608, "ordinal": 10, "text": "The RUC survey time includes pre-service time 3 days before the date of encounter, intraservice time on the date of encounter, and post-service time that includes 7 days after the date of encounter. These eight CPT codes were reviewed at the October 2021 RUC meeting with recommendations submitted to CMS for the CY 2023 rule cycle. The RUC recommended the survey 25th percentile value for all CPT codes in the Home or Residence Services code family, except for CPT code 99350, for which the RUC recommended the median value. We proposed the RUC-recommended work RVU for all eight CPT codes in the Home or Residence Services CPT code family. We proposed a work RVU of 1.00 for CPT code 99341 [CPT descriptor omitted], a work RVU of 1.65 for CPT code 99342 [CPT descriptor omitted], a work RVU of 2.87 for CPT code 99344 [CPT descriptor omitted], a work RVU of 3.88 for CPT code 99345 [CPT descriptor omitted], a work RVU of 0.90 for CPT code 99347 [CPT descriptor omitted], a work RVU of 1.50 for CPT code 99348 [CPT descriptor omitted], a work RVU of 2.44 for CPT code 99349 [CPT descriptor omitted], and a work RVU of 3.60 for CPT code 99350 [CPT descriptor omitted].", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1677, "page": 69608, "ordinal": 11, "text": "We proposed the RUC-recommended direct PE inputs for CPT codes 99345 and 99347-99350 without refinement. For CPT codes 99341 and 99342, we are refining the direct PE inputs by removing supply item SK062 (patient education booklet). For CPT code 99344, we are refining the direct PE inputs by removing supply items SK062 (patient education booklet), SJ053 (swab-pad, alcohol), and SJ061 (tongue depressor). Per the PE Summary of Recommendations provided by the RUC, CPT codes 99341, 99342, 99344, and 99347 would typically have procedures performed on the same date of service. For those CPT codes, the RUC stated that they removed supplies that would be duplicative, such as gloves, alcohol wipes, booklet, and tongue depressor. However, we found that not all of these duplicative supplies had been removed from CPT codes ( printed page 69609) 99341, 99342, and 99344 by the RUC. Therefore, we proposed to remove these duplicative supplies from CPT codes 99341, 99342, and 99344, and accept the remaining RUC-recommended direct PE inputs without refinement.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1678, "page": 69609, "ordinal": 1, "text": "The following is a summary of the comments we received and our responses.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1679, "page": 69609, "ordinal": 2, "text": "Comment: The majority of commenters supported our proposal to accept the RUC-recommended RVUs for all of the Home or Residence Services codes.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1680, "page": 69609, "ordinal": 3, "text": "Response: We appreciate the feedback from the commenters regarding our proposal.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1681, "page": 69609, "ordinal": 4, "text": "Comment: A few commenters stated the RVUs for the Home or Residence Services code family were too low, and fail to adequately account for travel, addressing social determinants of health, and other comprehensive care. One commenter suggested that we maintain the current RVUs for codes 99341, 99344, 99345, 99347, and 99348, for which the RUC-recommended RVUs decreased, while supporting our proposal to accept the increased RVUs for codes 99342, 99349, and 99350 recommended by the RUC. Another commenter suggested that we increase the RVUs for the entire code family to reflect travel expenses, and expressed concern that unreimbursed travel will be detrimental to the care provided to very ill patients and threaten the financial viability of physician practices that provide home or residence visits.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1682, "page": 69609, "ordinal": 5, "text": "Response: We continue to believe that the RUC-recommended RVUs are the appropriate values for CPT codes 99341, 99342, 99344, 99345, and 99347-99350. We appreciate the commenters' remarks, and we acknowledge the concerns regarding providing patient care and addressing social determinants of health and other issues during home or residence visits. Historically, travel costs incurred by the physician or practitioner are not included in the valuation of E/M codes, since travel time and/or mileage is not considered a resource involved in furnishing the service. The RUC survey for the Home or Residence Services code family did not include information on physician travel or mileage. Also, the CPT E/M guidelines for selecting the level of home or residence service, when performed based on time, specifically says not to count the time spent on travel (2023 CPT Codebook, p. 26). Therefore, we are finalizing the RUC-recommended work RVUs as proposed.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1683, "page": 69609, "ordinal": 6, "text": "Comment: One commenter requested that we not refine the direct PE inputs for codes 99341, 99342, and 99344 as proposed. For CPT codes 99341 and 99342, we proposed removing supply item SK062 (patient education booklet). For CPT code 99344, we proposed removing supply items SK062 (patient education booklet), SJ053 (swab-pad, alcohol), and SJ061 (tongue depressor).", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1684, "page": 69609, "ordinal": 7, "text": "Response: Per the PE Summary of Recommendations provided by the RUC, CPT codes 99341, 99342, 99344, and 99347 would typically have procedures performed on the same date of service, which would already include some of the same supply items. For these CPT codes, the RUC stated that they had removed the PE inputs for supplies that would be duplicative with the procedure on the same day, such as gloves, alcohol wipes, a booklet, and a tongue depressor. Although the RUC did remove the duplicative supplies for CPT code 99347 from the direct PE inputs they recommended, we found that the RUC had not removed all of these duplicative supplies from CPT codes 99341, 99342, and 99344. Therefore, we proposed to remove these duplicative supplies from the direct PE inputs for CPT codes 99341, 99342, and 99344. We continue to believe these supplies are duplicative with a same-day procedure, and are, therefore, finalizing the direct PE inputs for CPT codes 99341, 99342, 99344, and 99347 as proposed.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1685, "page": 69609, "ordinal": 8, "text": "After consideration of the public comments, we are finalizing the work RVU values for the Home or Residence Services code family as proposed. We are also finalizing the direct PE inputs for these codes as proposed.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1686, "page": 69609, "ordinal": 9, "text": "We proposed that prolonged home or residence services by a physician or NPP would be reportable using HCPCS code G0318 ( Prolonged home or residence evaluation and management service(s) beyond the total time for the primary service (when the primary service has been selected using time on the date of the primary service); each additional 15 minutes by the physician or qualified healthcare professional, with or without direct patient contact (list separately in addition to CPT codes 99345, 99350 for home or residence evaluation and management services). (Do not report G0318 on the same date of service as other prolonged services for evaluation and management 99358, 99359, 99417). (Do not report G0318 for any time unit less than 15 minutes)). Code G0318 would be reportable when the total time for the home or residence visit (specified in the time file) is exceeded by 15 or more minutes. Prolonged services (whether on the same date or another date within the surveyed timeframe) would be reportable as an add-on code to CPT codes 99345 or 99350 once the practitioner spends 15+ minutes beyond the total time finalized for the primary service (as specified in the time file). We would allow the physician or NPP to include any prolonged service time spent within the surveyed timeframe for the Home or Residence Services code family, which includes pre-service time 3 days before the date of encounter, intraservice time on the date of encounter, and post-service time that includes 7 days after the date of encounter. This means that for CPT code 99345, assuming we finalized the RUC-recommended total time of 126 minutes, prolonged services would be reportable once 141 or more minutes are spent by a physician or NPP providing the home or residence visit. Likewise, for CPT code 99350, assuming we finalized the RUC-recommended total time of 97 minutes, prolonged services would be reportable once 112 or more minutes are spent by a physician or NPP providing the home or residence visit. See Table 18 in our proposed rule for a table summarizing this information.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 1694, "page": 69610, "ordinal": 6, "text": "After consideration of the public comments, we are finalizing our proposal to create new code G0318 for a prolonged home or residence visit. We are also finalizing our proposal to change the status indicator for prolonged CPT codes 99358 and 99359 to “I,” which indicates that these codes are not valid for Medicare purposes, and that Medicare uses another code for reporting of, and payment for, these services.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "PETM225D", "p_id": 3607, "page": 69823, "ordinal": 3, "text": "As proposed, CPT codes 99341 through 99350 would be described as codes for evaluation and management services furnished in a patient's home, without the place of service 12 identifier. The place of service logic is included in claims processing algorithms, and therefore, accounted for in paid claims used by the Shared Savings Program in determining beneficiary assignment. As described in Medicare Claims Processing Manual, Publication 100-04, Chapter 26, place of service codes are two-digit codes placed on health care professional claims to indicate the setting in which a service was provided. Claims submitted for services that are allowable when provided in certain settings will process only when the appropriate place of service is included on the claim. Place of service 12 is defined as “location, other than a hospital or other facility, where the patient receives care in a private residence.” In previous rulemaking, we updated the reference to CPT codes 99341 through 99350 in the definition of primary care services at § 425.400(c) to include place of service 12 for clarity; however, as discussed in the proposed rule, we now believe it is no longer accurate as these codes have been revised to include multiple places of service, any of which we would consider to be the patient's home.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; Implementing Requirements for Manufacturers of Certain Single-dose Container or Single-use Package Drugs To Provide Refunds With Respect to Discarded Amounts; and COVID-19 Interim Final Rules", "date_published": "2022-11-18", "document_number": "2022-23873", "html_url": "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 69404, "end_page": 70700, "fr_volume": 87}
|
||||
{"item_key": "54GTKR5G", "p_id": 2240, "page": 66361, "ordinal": 13, "text": "For CPT code 99326 [CPT descriptor omitted]; CPT code 99327 [CPT descriptor omitted]; CPT code 99328 [CPT descriptor omitted]; CPT code 99334 [CPT descriptor omitted]; CPT code 99335 [CPT descriptor omitted]; CPT code 99336 [CPT descriptor omitted]; CPT code 99337 [CPT descriptor omitted]; CPT code 99343 [CPT descriptor omitted]; CPT code 99344 [CPT descriptor omitted]; CPT code 99345 [CPT descriptor omitted]; CPT code 99347 [CPT descriptor omitted]; CPT code 99348 [CPT descriptor omitted]; CPT code 99349 [CPT descriptor omitted]; and CPT code 99350 [CPT descriptor omitted], the RUC recommended that the work RVUs for these codes be maintained at their current values: 2.27 work RVUs for CPT code 99326; 3.03 work RVUs for CPT code 99327; 3.78 work RVUs for CPT code 99328; 0.76 work RVUs for CPT code 99334; 1.26 work RVUs for CPT code 99335; 2.02 work RVUs for CPT code 99336; 3.03 work RVUs for CPT code 99337; 2.27 work RVUs for CPT code 99343; 3.03 for CPT code 99344; 3.78 work RVUs for CPT code 99345; 0.76 work RVUs for CPT code 99347; 1.26 work RVUs for CPT code 99348; 2.02 work RVUs for CPT code 99349; and 3.03 work RVUs for CPT code 99350, which we accepted.", "title": "Medicare Program; CY 2008 PFS Final Rule", "date_published": "2007-11-27", "document_number": "07-5506", "html_url": "https://www.federalregister.gov/documents/2007/11/27/07-5506/medicare-program-revisions-to-payment-policies-under-the-physician-fee-schedule-and-other-part-b", "start_page": 66222, "end_page": 66578, "fr_volume": 72}
|
||||
{"item_key": "54GTKR5G", "p_id": 2241, "page": 66362, "ordinal": 1, "text": "Comment: Commenters disagreed with the RUC-recommended work values for these services, which we had accepted. The commenters disagreed with the RUC-recommended work RVUs and believed the services were undervalued. The commenters also believed that the home visit work RVUs should remain “relatively” the same with respect to office visit codes as they did prior to the five-year review and requested that CMS reject the RUC recommended work RVUs and follow their survey values. Based on these comments, we referred these codes to the multi-specialty validation panel for review.", "title": "Medicare Program; CY 2008 PFS Final Rule", "date_published": "2007-11-27", "document_number": "07-5506", "html_url": "https://www.federalregister.gov/documents/2007/11/27/07-5506/medicare-program-revisions-to-payment-policies-under-the-physician-fee-schedule-and-other-part-b", "start_page": 66222, "end_page": 66578, "fr_volume": 72}
|
||||
{"item_key": "54GTKR5G", "p_id": 2242, "page": 66362, "ordinal": 2, "text": "Response: As a result of the statistical analysis of the 2007 multi-specialty validation panel ratings, we have assigned 2.63 work RVUs to CPT code 99326; 3.46 work RVUs to CPT code 99327; 4.09 work RVUs to CPT code 99328; 1.07 work RVUs to CPT code 99334; 1.72 work RVUs to CPT code 99335; 2.46 work RVUs to CPT code 99336; 3.58 work RVUs to CPT code 99337; 2.53 work RVUs to CPT code 99343; 3.38 work RVUs to CPT code 99344; 4.09 work RVUs to CPT code 99345; 1.00 work RVUs to CPT code 99347; 1.56 work RVUs to CPT code 99348; 2.33 work RVUs to CPT code 99349; and 3.28 work RVUs to CPT code 99350.", "title": "Medicare Program; CY 2008 PFS Final Rule", "date_published": "2007-11-27", "document_number": "07-5506", "html_url": "https://www.federalregister.gov/documents/2007/11/27/07-5506/medicare-program-revisions-to-payment-policies-under-the-physician-fee-schedule-and-other-part-b", "start_page": 66222, "end_page": 66578, "fr_volume": 72}
|
||||
{"item_key": "NHRGIHGD", "p_id": 1469, "page": 49463, "ordinal": 9, "text": "After reviewing all the comments, we are finalizing as proposed, to allow HCPCS code G2211 to be billed as an add-on code with the home or residence E/M visits code family (CPT codes 99341, 99342, 99344, 99345, 99347, 99348, 99349, 99350). We are also finalizing refinement of the HCPCS code G2211 code descriptor to 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 with medical care services that are part of ongoing care related to a patient's single, serious ( printed page 49464) condition or a complex condition. (Add-on code, list separately in addition to home or residence or office/outpatient evaluation and management service, new or established)) ”.", "title": "Medicare and Medicaid Programs; CY 2026 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; and Medicare Prescription Drug Inflation Rebate Program", "date_published": "2025-11-05", "document_number": "2025-19787", "html_url": "https://www.federalregister.gov/documents/2025/11/05/2025-19787/medicare-and-medicaid-programs-cy-2026-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 49266, "end_page": 50481, "fr_volume": 90}
|
||||
{"item_key": "JCWARTJD", "p_id": 1168, "page": 71098, "ordinal": 11, "text": "After consideration of public comments, we are finalizing the creation of modifier B1 as proposed. We note that modifier MOD1 was a placeholder code in the proposed rule. The finalized modifier descriptor for modifier B1 is: ( Visit complexity inherent to new or established office/outpatient or home or residence evaluation and management service, associated with medical care services that serve as the continuing focal point for all needed health care services and/or with medical care services that are part of ongoing care related to a patient's single, serious condition or a complex condition).", "title": "Medicare and Medicaid Programs; CY 2027 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; and Medicare Prescription Drug Inflation Rebate Program", "date_published": "2026-11-09", "document_number": "2026-22743", "html_url": "https://www.federalregister.gov/documents/2026/11/09/2026-22743/medicare-and-medicaid-programs-cy-2027-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 70992, "end_page": 72020, "fr_volume": 91}
|
||||
{"item_key": "JCWARTJD", "p_id": 1205, "page": 71102, "ordinal": 5, "text": "After consideration of public comments, we are finalizing modifier B2 as proposed. We note that modifier MOD2 was a placeholder code in the proposed rule. The finalized modifier descriptor is B2 ( Visit complexity inherent to new or established office/outpatient or home or residence evaluation and management service, associated with medical care services furnished by a participant or practitioner participating in a Medicare accountable care organization. Services must serve as the continuing focal point for all needed health care services and/or be part of ongoing care related to a patient's single, serious condition or complex condition.).", "title": "Medicare and Medicaid Programs; CY 2027 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; and Medicare Prescription Drug Inflation Rebate Program", "date_published": "2026-11-09", "document_number": "2026-22743", "html_url": "https://www.federalregister.gov/documents/2026/11/09/2026-22743/medicare-and-medicaid-programs-cy-2027-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 70992, "end_page": 72020, "fr_volume": 91}
|
||||
{"item_key": "MZ24MX5S", "p_id": 877, "page": 45999, "ordinal": 6, "text": "In February 2021, the CPT Editorial Panel deleted the nine CPT codes in the Domiciliary, Rest Home (for example, Boarding Home), or Custodial Care Services code family (CPT codes 99324-99328, and 99334-99337), and one CPT code in the Home Services family (CPT code 99343), to merge these services with the eight remaining home visit services. The eight remaining home services CPT codes (99341, 99342, 99344, 99345, and 99347-99350) were revised to describe Home or Residence Services to align with the principles of the O/O E/M visit codes by allowing physicians and NPPs to document and select the level of service based on total practitioner time or MDM level. For CY 2023, the home and domiciliary E/M code family will be revised by the CPT to include services provided in assisted living facilities, group homes, custodial care facilities, and residential substance abuse treatment facilities, as well as a patient's home. These changes include combining the domiciliary and rest home CPT codes with the home visit CPT codes, resulting in a single family of CPT codes that describe these types of services. In addition, CPT revised the descriptors to allow reporting that is based on time or MDM level—in alignment with the O/O E/M visit CPT codes. The RUC survey time includes pre-service time 3 days before the date of encounter, intraservice time on the date of encounter, and post-service time that includes 7 days after the date of encounter. These eight CPT codes were reviewed at the October 2021 RUC meeting with recommendations submitted to CMS for the CY 2023 rule cycle. The RUC recommended the survey 25th percentile value for all CPT codes in the Home or Residence Services code family, except for CPT code 99350, for which the RUC recommended the median value. ( printed page 46000)", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment Policies; Medicare Shared Savings Program Requirements; Medicare and Medicaid Provider Enrollment Policies, Including for Skilled Nursing Facilities; Conditions of Payment for Suppliers of Durable Medicaid Equipment, Prosthetics, Orthotics, and Supplies (DMEPOS); and Implementing Requirements for Manufacturers of Certain Single-Dose Container or Single-Use Package Drugs To Provide Refunds With Respect to Discarded Amounts", "date_published": "2022-07-29", "document_number": "2022-14562", "html_url": "https://www.federalregister.gov/documents/2022/07/29/2022-14562/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 45860, "end_page": 46843, "fr_volume": 87}
|
||||
{"item_key": "MZ24MX5S", "p_id": 878, "page": 46000, "ordinal": 1, "text": "We are proposing the RUC-recommended work RVU for all eight CPT codes in the Home or Residence Services CPT code family. We are proposing a work RVU of 1.00 for CPT code 99341 [CPT descriptor omitted], a work RVU of 1.65 for CPT code 99342 [CPT descriptor omitted], a work RVU of 2.87 for CPT code 99344 [CPT descriptor omitted], a work RVU of 3.88 for CPT code 99345 [CPT descriptor omitted], a work RVU of 0.90 for CPT code 99347 [CPT descriptor omitted], a work RVU of 1.50 for CPT code 99348 [CPT descriptor omitted], a work RVU of 2.44 for CPT code 99349 [CPT descriptor omitted], and a work RVU of 3.60 for CPT code 99350 [CPT descriptor omitted].", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment Policies; Medicare Shared Savings Program Requirements; Medicare and Medicaid Provider Enrollment Policies, Including for Skilled Nursing Facilities; Conditions of Payment for Suppliers of Durable Medicaid Equipment, Prosthetics, Orthotics, and Supplies (DMEPOS); and Implementing Requirements for Manufacturers of Certain Single-Dose Container or Single-Use Package Drugs To Provide Refunds With Respect to Discarded Amounts", "date_published": "2022-07-29", "document_number": "2022-14562", "html_url": "https://www.federalregister.gov/documents/2022/07/29/2022-14562/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 45860, "end_page": 46843, "fr_volume": 87}
|
||||
{"item_key": "MZ24MX5S", "p_id": 880, "page": 46000, "ordinal": 3, "text": "We are proposing that prolonged home or residence services by a physician or NPP would be reportable under GXXX3 ( Prolonged home or residence evaluation and management service(s) beyond the total time for the primary service (when the primary service has been selected using time on the date of the primary service); each additional 15 minutes by the physician or qualified healthcare professional, with or without direct patient contact (list separately in addition to CPT codes 99345, 99350 for home or residence evaluation and management services). (Do not report GXXX3 on the same date of service as other prolonged services for evaluation and management 99358, 99359, 99417). (Do not report GXXX3 for any time unit less than 15 minutes)). Code GXXX3 would be reportable when the total time (in the time file) is exceeded by 15 or more minutes. Prolonged services (whether on the same date or another date within the surveyed timeframe) would be reportable as an add-on code to CPT codes 99345 or 99350 once the practitioner spends 15+ minutes beyond the total time finalized for the primary service (in time file). We would allow the physician or NPP to include any prolonged service time spent within the surveyed timeframe for the home or residence services code family, which includes pre-service time 3 days before the date of encounter, intraservice time on the date of encounter, and post-service time that includes 7 days after the date of encounter. This means that for CPT code 99345, assuming we finalize the RUC-recommended total time of 126 minutes, prolonged services would be reportable once 141 or more minutes are spent by a physician or NPP providing home or residence services. Likewise, for CPT code 99350, assuming we finalize the RUC-recommended total time of 97 minutes, prolonged services would be reportable once 112 or more minutes are spent by a physician or NPP providing home or residence services. See Table 18 in section II.F.11.e. of this proposed rule for a table summarizing this information.", "title": "Medicare and Medicaid Programs; CY 2023 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment Policies; Medicare Shared Savings Program Requirements; Medicare and Medicaid Provider Enrollment Policies, Including for Skilled Nursing Facilities; Conditions of Payment for Suppliers of Durable Medicaid Equipment, Prosthetics, Orthotics, and Supplies (DMEPOS); and Implementing Requirements for Manufacturers of Certain Single-Dose Container or Single-Use Package Drugs To Provide Refunds With Respect to Discarded Amounts", "date_published": "2022-07-29", "document_number": "2022-14562", "html_url": "https://www.federalregister.gov/documents/2022/07/29/2022-14562/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 45860, "end_page": 46843, "fr_volume": 87}
|
||||
{"item_key": "5ITGVDJV", "p_id": 521, "page": 43898, "ordinal": 9, "text": "Since we began actively paying for HCPCS code G2211 in CY 2024, we have come to believe that the resource costs of furnishing longitudinal care for beneficiaries is not best characterized as a separate service requiring a separate code. Rather, we believe that since this work is an inherent part of the visit, it would be more accurately valued as a modifier to the base E/M code. We also believe that transitioning HCPCS code G2211 from an add-on code to a modifier will be more streamlined from an operational perspective. This should also reduce operational burden, as it will not require the submission of a separate claim line, because the modifier will be placed on the claim ( printed page 43899) line for the associated E/M code. We are therefore proposing to replace HCPCS code G2211 with a modifier, which we will refer to in this proposed rule as MOD1, which is a placeholder that would be replaced with a two-digit HCPCS modifier, if finalized.", "title": "Medicare and Medicaid Programs; CY 2027 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; and Medicare Prescription Drug Inflation Rebate Program", "date_published": "2026-07-16", "document_number": "2026-14327", "html_url": "https://www.federalregister.gov/documents/2026/07/16/2026-14327/medicare-and-medicaid-programs-cy-2027-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 43842, "end_page": 44557, "fr_volume": 91}
|
||||
{"item_key": "5ITGVDJV", "p_id": 537, "page": 43900, "ordinal": 7, "text": "We believe that MOD2 aligns with the goals of the Shared Savings Program and LEAD, which involve groups of health care providers working together to enhance beneficiary health through high quality, longitudinal primary and preventative care. One of the features of Shared Savings Program and LEAD ACOs is that beneficiaries benefit from ACO participants balancing goals of having total cost of care accountability and improving quality of care, while avoiding unnecessary services and ( printed page 43901) medical errors. While the specifics vary between the Shared Savings Program and the LEAD model, in general, participating ACOs are required to report quality measures that align with these objectives, and they are measured against their past performance, and the performance of similar ACOs.[20]", "title": "Medicare and Medicaid Programs; CY 2027 Payment Policies Under the Physician Fee Schedule and Other Changes to Part B Payment and Coverage Policies; Medicare Shared Savings Program Requirements; and Medicare Prescription Drug Inflation Rebate Program", "date_published": "2026-07-16", "document_number": "2026-14327", "html_url": "https://www.federalregister.gov/documents/2026/07/16/2026-14327/medicare-and-medicaid-programs-cy-2027-payment-policies-under-the-physician-fee-schedule-and-other", "start_page": 43842, "end_page": 44557, "fr_volume": 91}
|
||||
{"item_key": "78F558TF", "p_id": 2818, "page": 73431, "ordinal": 10, "text": "Section 1833(x)(2)(B) of the Act (as added by section 5501(a)(2)(B) of the ACA) defines primary care services as those services identified by the following HCPCS codes as of January 1, 2009 (and as subsequently modified by the Secretary, as applicable):", "title": "Medicare Program; CY 2011 PFS Final Rule", "date_published": "2010-11-29", "document_number": "2010-27969", "html_url": "https://www.federalregister.gov/documents/2010/11/29/2010-27969/medicare-program-payment-policies-under-the-physician-fee-schedule-and-other-revisions-to-part-b-for", "start_page": 73170, "end_page": 73860, "fr_volume": 75}
|
||||
{"item_key": "78F558TF", "p_id": 2819, "page": 73431, "ordinal": 11, "text": "99201 through 99215 for new and established patient office or other outpatient E/M visits;", "title": "Medicare Program; CY 2011 PFS Final Rule", "date_published": "2010-11-29", "document_number": "2010-27969", "html_url": "https://www.federalregister.gov/documents/2010/11/29/2010-27969/medicare-program-payment-policies-under-the-physician-fee-schedule-and-other-revisions-to-part-b-for", "start_page": 73170, "end_page": 73860, "fr_volume": 75}
|
||||
{"item_key": "78F558TF", "p_id": 2820, "page": 73431, "ordinal": 12, "text": "99304 through 99340 for initial, subsequent, discharge, and other nursing facility E/M services; new and ( printed page 73432) established patient domiciliary, rest home (eg, boarding home), or custodial care E/M services; and domiciliary, rest home (eg, assisted living facility), or home care plan oversight services; and", "title": "Medicare Program; CY 2011 PFS Final Rule", "date_published": "2010-11-29", "document_number": "2010-27969", "html_url": "https://www.federalregister.gov/documents/2010/11/29/2010-27969/medicare-program-payment-policies-under-the-physician-fee-schedule-and-other-revisions-to-part-b-for", "start_page": 73170, "end_page": 73860, "fr_volume": 75}
|
||||
{"item_key": "78F558TF", "p_id": 2821, "page": 73432, "ordinal": 1, "text": "99341 through 99350 for new and established patient home E/M visits. These codes are displayed in Table 66. All of these codes remain active in CY 2011 and there are no other codes used to describe these services.", "title": "Medicare Program; CY 2011 PFS Final Rule", "date_published": "2010-11-29", "document_number": "2010-27969", "html_url": "https://www.federalregister.gov/documents/2010/11/29/2010-27969/medicare-program-payment-policies-under-the-physician-fee-schedule-and-other-revisions-to-part-b-for", "start_page": 73170, "end_page": 73860, "fr_volume": 75}
|
||||
{"item_key": "GD84NJ2Y", "p_id": 8, "page": 55246, "ordinal": 8, "text": "Mail written comments (1 original and 2 copies) to the following address: Centers for Medicare & Medicaid Services, Department of Health and Human Services, Attention: CMS-1169-FC, P.O. Box 8013, Baltimore, MD 21244-8013.", "title": "Medicare Program; CY 2002 PFS Final Rule", "date_published": "2001-11-01", "document_number": "01-27275", "html_url": "https://www.federalregister.gov/documents/2001/11/01/01-27275/medicare-program-revisions-to-payment-policies-and-five-year-review-of-and-adjustments-to-the", "start_page": 55246, "end_page": 55503, "fr_volume": 66}
|
||||
217
tests/pfs/fixtures/home_visits_rvu.csv
Normal file
217
tests/pfs/fixtures/home_visits_rvu.csv
Normal file
@@ -0,0 +1,217 @@
|
||||
hcpcs,mod,description,status_code,not_used_for_medicare,work_rvu,non_fac_pe_rvu,fac_pe_rvu,mp_rvu,non_fac_total,fac_total,pctc_ind,glob_days,pre_op,intra_op,post_op,mult_proc,bilat_surg,asst_surg,co_surg,team_surg,endo_base,conv_factor,physician_supervision,calc_flag,diag_imaging_family,non_fac_pe_used_for_opps,fac_pe_used_for_opps,mp_used_for_opps,year,cms_rule_id
|
||||
99324,,,A,,1.01,0.48,0.48,0.06,1.55,1.55,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99325,,,A,,1.52,0.64,0.64,0.1,2.26,2.26,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99326,,,A,,2.63,1.12,1.12,0.16,3.91,3.91,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99327,,,A,,3.46,1.55,1.55,0.21,5.22,5.22,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99328,,,A,,4.09,1.76,1.76,0.26,6.11,6.11,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99334,,,A,,1.07,0.56,0.56,0.06,1.69,1.69,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99335,,,A,,1.72,0.85,0.85,0.1,2.67,2.67,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99336,,,A,,2.46,1.17,1.17,0.15,3.78,3.78,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99337,,,A,,3.58,1.62,1.62,0.21,5.41,5.41,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99339,,,B,+,1.25,0.86,0.86,0.09,2.2,2.2,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99340,,,B,+,1.8,1.15,1.15,0.12,3.07,3.07,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99341,,,A,,1.01,0.47,0.47,0.06,1.54,1.54,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99342,,,A,,1.52,0.61,0.61,0.11,2.24,2.24,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99343,,,A,,2.53,0.95,0.95,0.17,3.65,3.65,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99344,,,A,,3.38,1.52,1.52,0.22,5.12,5.12,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99345,,,A,,4.09,1.84,1.84,0.27,6.2,6.2,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99347,,,A,,1.0,0.5,0.5,0.06,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99348,,,A,,1.56,0.7,0.7,0.1,2.36,2.36,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99349,,,A,,2.33,1.12,1.12,0.15,3.6,3.6,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99350,,,A,,3.28,1.49,1.49,0.21,4.98,4.98,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9335,09,0,99,0.0,0.0,0.0,2015,
|
||||
99324,,,A,,1.01,0.48,0.48,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99325,,,A,,1.52,0.65,0.65,0.1,2.27,2.27,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99326,,,A,,2.63,1.12,1.12,0.17,3.92,3.92,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99327,,,A,,3.46,1.55,1.55,0.22,5.23,5.23,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99328,,,A,,4.09,1.76,1.76,0.26,6.11,6.11,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99334,,,A,,1.07,0.56,0.56,0.07,1.7,1.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99335,,,A,,1.72,0.85,0.85,0.11,2.68,2.68,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99336,,,A,,2.46,1.17,1.17,0.16,3.79,3.79,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99337,,,A,,3.58,1.61,1.61,0.24,5.43,5.43,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99339,,,B,+,1.25,0.86,0.86,0.07,2.18,2.18,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99340,,,B,+,1.8,1.15,1.15,0.11,3.06,3.06,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99341,,,A,,1.01,0.47,0.47,0.07,1.55,1.55,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99342,,,A,,1.52,0.61,0.61,0.1,2.23,2.23,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99343,,,A,,2.53,0.96,0.96,0.17,3.66,3.66,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99344,,,A,,3.38,1.52,1.52,0.23,5.13,5.13,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99345,,,A,,4.09,1.84,1.84,0.29,6.22,6.22,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99347,,,A,,1.0,0.49,0.49,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99348,,,A,,1.56,0.7,0.7,0.11,2.37,2.37,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99349,,,A,,2.33,1.12,1.12,0.16,3.61,3.61,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99350,,,A,,3.28,1.5,1.5,0.23,5.01,5.01,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8043,09,0,99,0.0,0.0,0.0,2016,
|
||||
99324,,,A,,1.01,0.48,0.48,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99325,,,A,,1.52,0.65,0.65,0.1,2.27,2.27,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99326,,,A,,2.63,1.14,1.14,0.17,3.94,3.94,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99327,,,A,,3.46,1.57,1.57,0.22,5.25,5.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99328,,,A,,4.09,1.79,1.79,0.27,6.15,6.15,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99334,,,A,,1.07,0.56,0.56,0.07,1.7,1.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99335,,,A,,1.72,0.85,0.85,0.11,2.68,2.68,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99336,,,A,,2.46,1.19,1.19,0.16,3.81,3.81,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99337,,,A,,3.58,1.63,1.63,0.24,5.45,5.45,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99339,,,B,+,1.25,0.86,0.86,0.07,2.18,2.18,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99340,,,B,+,1.8,1.15,1.15,0.11,3.06,3.06,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99341,,,A,,1.01,0.47,0.47,0.07,1.55,1.55,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99342,,,A,,1.52,0.62,0.62,0.1,2.24,2.24,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99343,,,A,,2.53,0.98,0.98,0.17,3.68,3.68,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99344,,,A,,3.38,1.55,1.55,0.23,5.16,5.16,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99345,,,A,,4.09,1.87,1.87,0.29,6.25,6.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99347,,,A,,1.0,0.49,0.49,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99348,,,A,,1.56,0.71,0.71,0.11,2.38,2.38,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99349,,,A,,2.33,1.14,1.14,0.16,3.63,3.63,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99350,,,A,,3.28,1.52,1.52,0.23,5.03,5.03,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.8887,09,0,99,0.0,0.0,0.0,2017,
|
||||
99324,,,A,,1.01,0.48,0.48,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99325,,,A,,1.52,0.65,0.65,0.1,2.27,2.27,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99326,,,A,,2.63,1.14,1.14,0.17,3.94,3.94,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99327,,,A,,3.46,1.58,1.58,0.23,5.27,5.27,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99328,,,A,,4.09,1.82,1.82,0.26,6.17,6.17,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99334,,,A,,1.07,0.56,0.56,0.07,1.7,1.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99335,,,A,,1.72,0.85,0.85,0.11,2.68,2.68,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99336,,,A,,2.46,1.2,1.2,0.17,3.83,3.83,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99337,,,A,,3.58,1.65,1.65,0.24,5.47,5.47,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99339,,,B,+,1.25,0.87,0.87,0.07,2.19,2.19,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99340,,,B,+,1.8,1.16,1.16,0.11,3.07,3.07,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99341,,,A,,1.01,0.47,0.47,0.07,1.55,1.55,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99342,,,A,,1.52,0.62,0.62,0.11,2.25,2.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99343,,,A,,2.53,0.98,0.98,0.18,3.69,3.69,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99344,,,A,,3.38,1.56,1.56,0.23,5.17,5.17,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99345,,,A,,4.09,1.9,1.9,0.29,6.28,6.28,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99347,,,A,,1.0,0.49,0.49,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99348,,,A,,1.56,0.71,0.71,0.11,2.38,2.38,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99349,,,A,,2.33,1.15,1.15,0.16,3.64,3.64,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99350,,,A,,3.28,1.55,1.55,0.23,5.06,5.06,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,35.9996,09,0,99,0.0,0.0,0.0,2018,
|
||||
99324,,,A,,1.01,0.48,0.48,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99325,,,A,,1.52,0.64,0.64,0.1,2.26,2.26,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99326,,,A,,2.63,1.12,1.12,0.17,3.92,3.92,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99327,,,A,,3.46,1.57,1.57,0.23,5.26,5.26,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99328,,,A,,4.09,1.83,1.83,0.27,6.19,6.19,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99334,,,A,,1.07,0.56,0.56,0.07,1.7,1.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99335,,,A,,1.72,0.85,0.85,0.11,2.68,2.68,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99336,,,A,,2.46,1.19,1.19,0.17,3.82,3.82,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99337,,,A,,3.58,1.65,1.65,0.24,5.47,5.47,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99339,,,B,+,1.25,0.85,0.85,0.07,2.17,2.17,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99340,,,B,+,1.8,1.14,1.14,0.11,3.05,3.05,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99341,,,A,,1.01,0.48,0.48,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99342,,,A,,1.52,0.62,0.62,0.11,2.25,2.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99343,,,A,,2.53,0.96,0.96,0.18,3.67,3.67,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99344,,,A,,3.38,1.53,1.53,0.23,5.14,5.14,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99345,,,A,,4.09,1.88,1.88,0.28,6.25,6.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99347,,,A,,1.0,0.49,0.49,0.07,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99348,,,A,,1.56,0.7,0.7,0.11,2.37,2.37,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99349,,,A,,2.33,1.15,1.15,0.16,3.64,3.64,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99350,,,A,,3.28,1.54,1.54,0.23,5.05,5.05,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0391,09,0,99,0.0,0.0,0.0,2019,
|
||||
99324,,,A,,1.01,0.48,0.48,0.05,1.54,1.54,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99325,,,A,,1.52,0.64,0.64,0.08,2.24,2.24,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99326,,,A,,2.63,1.14,1.14,0.13,3.9,3.9,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99327,,,A,,3.46,1.59,1.59,0.19,5.24,5.24,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99328,,,A,,4.09,1.86,1.86,0.25,6.2,6.2,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99334,,,A,,1.07,0.57,0.57,0.06,1.7,1.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99335,,,A,,1.72,0.88,0.88,0.09,2.69,2.69,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99336,,,A,,2.46,1.21,1.21,0.13,3.8,3.8,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99337,,,A,,3.58,1.68,1.68,0.22,5.48,5.48,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99339,,,B,+,1.25,0.85,0.85,0.09,2.19,2.19,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99340,,,B,+,1.8,1.12,1.12,0.13,3.05,3.05,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99341,,,A,,1.01,0.48,0.48,0.05,1.54,1.54,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99342,,,A,,1.52,0.61,0.61,0.08,2.21,2.21,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99343,,,A,,2.53,0.97,0.97,0.13,3.63,3.63,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99344,,,A,,3.38,1.55,1.55,0.22,5.15,5.15,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99345,,,A,,4.09,1.9,1.9,0.28,6.27,6.27,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99347,,,A,,1.0,0.49,0.49,0.05,1.54,1.54,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99348,,,A,,1.56,0.72,0.72,0.09,2.37,2.37,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99349,,,A,,2.33,1.17,1.17,0.13,3.63,3.63,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99350,,,A,,3.28,1.56,1.56,0.22,5.06,5.06,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,36.0896,09,0,99,0.0,0.0,0.0,2020,
|
||||
99324,,,A,,1.01,0.49,0.49,0.05,1.55,1.55,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99325,,,A,,1.52,0.66,0.66,0.09,2.27,2.27,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99326,,,A,,2.63,1.2,1.2,0.14,3.97,3.97,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99327,,,A,,3.46,1.66,1.66,0.2,5.32,5.32,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99328,,,A,,4.09,1.92,1.92,0.25,6.26,6.26,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99334,,,A,,1.07,0.6,0.6,0.05,1.72,1.72,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99335,,,A,,1.72,0.92,0.92,0.1,2.74,2.74,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99336,,,A,,2.46,1.27,1.27,0.15,3.88,3.88,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99337,,,A,,3.58,1.76,1.76,0.21,5.55,5.55,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99339,,,B,+,1.25,0.87,0.87,0.1,2.22,2.22,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99340,,,B,+,1.8,1.15,1.15,0.15,3.1,3.1,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99341,,,A,,1.01,0.5,0.5,0.05,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99342,,,A,,1.52,0.62,0.62,0.06,2.2,2.2,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99343,,,A,,2.53,0.98,0.98,0.13,3.64,3.64,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99344,,,A,,3.38,1.6,1.6,0.21,5.19,5.19,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99345,,,A,,4.09,1.92,1.92,0.31,6.32,6.32,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99347,,,A,,1.0,0.52,0.52,0.05,1.57,1.57,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99348,,,A,,1.56,0.75,0.75,0.09,2.4,2.4,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99349,,,A,,2.33,1.22,1.22,0.15,3.7,3.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99350,,,A,,3.28,1.62,1.62,0.22,5.12,5.12,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.8931,09,0,99,0.0,0.0,0.0,2021,
|
||||
99324,,,A,,1.01,0.5,0.5,0.05,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99325,,,A,,1.52,0.67,0.67,0.09,2.28,2.28,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99326,,,A,,2.63,1.2,1.2,0.12,3.95,3.95,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99327,,,A,,3.46,1.66,1.66,0.2,5.32,5.32,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99328,,,A,,4.09,1.92,1.92,0.25,6.26,6.26,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99334,,,A,,1.07,0.61,0.61,0.07,1.75,1.75,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99335,,,A,,1.72,0.93,0.93,0.1,2.75,2.75,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99336,,,A,,2.46,1.29,1.29,0.14,3.89,3.89,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99337,,,A,,3.58,1.77,1.77,0.22,5.57,5.57,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99339,,,B,+,1.25,0.87,0.87,0.1,2.22,2.22,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99340,,,B,+,1.8,1.17,1.17,0.14,3.11,3.11,9,XXX,0.0,0.0,0.0,9,9,9,9,9,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99341,,,A,,1.01,0.5,0.5,0.05,1.56,1.56,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99342,,,A,,1.52,0.62,0.62,0.08,2.22,2.22,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99343,,,A,,2.53,0.96,0.96,0.12,3.61,3.61,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99344,,,A,,3.38,1.6,1.6,0.22,5.2,5.2,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99345,,,A,,4.09,1.93,1.93,0.28,6.3,6.3,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99347,,,A,,1.0,0.53,0.53,0.05,1.58,1.58,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99348,,,A,,1.56,0.75,0.75,0.09,2.4,2.4,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99349,,,A,,2.33,1.23,1.23,0.14,3.7,3.7,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99350,,,A,,3.28,1.62,1.62,0.23,5.13,5.13,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,34.6062,09,0,99,0.0,0.0,0.0,2022,
|
||||
99341,,,A,,1.0,0.4,0.4,0.04,1.44,1.44,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99342,,,A,,1.65,0.57,0.57,0.08,2.3,2.3,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99344,,,A,,2.87,1.2,1.2,0.18,4.25,4.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99345,,,A,,3.88,1.85,1.85,0.25,5.98,5.98,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99347,,,A,,0.9,0.38,0.38,0.04,1.32,1.32,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99348,,,A,,1.5,0.67,0.67,0.08,2.25,2.25,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99349,,,A,,2.44,1.16,1.16,0.17,3.77,3.77,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99350,,,A,,3.6,1.65,1.65,0.25,5.5,5.5,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.8872,09,0,99,0.0,0.0,0.0,2023,
|
||||
99341,,,A,,1.0,0.42,0.42,0.05,1.47,1.47,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99342,,,A,,1.65,0.6,0.6,0.08,2.33,2.33,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99344,,,A,,2.87,1.2,1.2,0.16,4.23,4.23,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99345,,,A,,3.88,1.88,1.88,0.25,6.01,6.01,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99347,,,A,,0.9,0.4,0.4,0.05,1.35,1.35,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99348,,,A,,1.5,0.7,0.7,0.08,2.28,2.28,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99349,,,A,,2.44,1.19,1.19,0.16,3.79,3.79,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99350,,,A,,3.6,1.68,1.68,0.24,5.52,5.52,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.2875,09,0,99,0.0,0.0,0.0,2024,
|
||||
99341,,,A,,1.0,0.43,0.43,0.04,1.47,1.47,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99342,,,A,,1.65,0.62,0.62,0.07,2.34,2.34,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99344,,,A,,2.87,1.2,1.2,0.16,4.23,4.23,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99345,,,A,,3.88,1.86,1.86,0.25,5.99,5.99,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99347,,,A,,0.9,0.41,0.41,0.04,1.35,1.35,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99348,,,A,,1.5,0.71,0.71,0.08,2.29,2.29,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99349,,,A,,2.44,1.19,1.19,0.16,3.79,3.79,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99350,,,A,,3.6,1.67,1.67,0.23,5.5,5.5,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,32.3465,09,0,99,0.0,0.0,0.0,2025,
|
||||
99341,,,A,,1.0,0.43,0.43,0.04,1.47,1.47,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99342,,,A,,1.65,0.64,0.64,0.07,2.36,2.36,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99344,,,A,,2.87,1.36,1.36,0.16,4.39,4.39,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99345,,,A,,3.88,2.16,2.16,0.25,6.29,6.29,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99347,,,A,,0.9,0.44,0.44,0.04,1.38,1.38,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99348,,,A,,1.5,0.79,0.79,0.07,2.36,2.36,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99349,,,A,,2.44,1.36,1.36,0.16,3.96,3.96,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99350,,,A,,3.6,1.94,1.94,0.24,5.78,5.78,0,XXX,0.0,0.0,0.0,0,0,0,0,0,,33.4009,09,0,99,0.0,0.0,0.0,2026,
|
||||
99341,,,A,,1.0,0.46,,0.03,1.49,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99342,,,A,,1.65,0.68,,0.09,2.42,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99344,,,A,,2.87,1.38,,0.16,4.41,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99345,,,A,,3.88,2.06,,0.25,6.19,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99347,,,A,,0.9,0.47,,0.05,1.42,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99348,,,A,,1.5,0.81,,0.09,2.4,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99349,,,A,,2.44,1.29,,0.15,3.88,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99350,,,A,,3.6,1.85,,0.24,5.69,,,XXX,,,,,,,,,,,,,,,,,2027,
|
||||
99341,,,A,,1.0,0.43,,0.04,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99342,,,A,,1.65,0.64,,0.06,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99344,,,A,,2.87,1.37,,0.18,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99345,,,A,,3.88,2.14,,0.27,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99347,,,A,,0.9,0.44,,0.04,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99348,,,A,,1.5,0.78,,0.07,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99349,,,A,,2.44,1.35,,0.17,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99350,,,A,,3.6,1.93,,0.25,,,,,,,,,,,,,,,,,,,,,,CMS-1832-P
|
||||
99341,,,A,,1.0,0.46,,0.05,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99342,,,A,,1.65,0.68,,0.07,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99344,,,A,,2.87,1.39,,0.17,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99345,,,A,,3.88,2.05,,0.26,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99347,,,A,,0.9,0.47,,0.05,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99348,,,A,,1.5,0.82,,0.09,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99349,,,A,,2.44,1.29,,0.15,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
99350,,,A,,3.6,1.85,,0.25,,,,,,,,,,,,,,,,,,,,,,CMS-1848-P
|
||||
|
750
tests/pfs/home_visits_fixture.py
Normal file
750
tests/pfs/home_visits_fixture.py
Normal file
@@ -0,0 +1,750 @@
|
||||
"""The HOME-VISITS proof family as a self-contained fixture (dossier task 13).
|
||||
|
||||
``home_fixture`` returns ``(con, store, family, ask)``:
|
||||
|
||||
* ``store`` — a ``Store(":memory:")`` holding the Federal Register paragraphs
|
||||
of ``fixtures/home_visits_fr.jsonl`` (public-domain FR text; the CPT
|
||||
descriptors CMS printed inside a few paragraphs are replaced by
|
||||
``[CPT descriptor omitted]``), their rule items and anchor maps, three
|
||||
regulations.gov comment items whose bib titles name a person ("Jane Doe:
|
||||
CMS-2022-0113-0001" style) and the CY2023 docket;
|
||||
* ``con`` — a ``:memory:`` DuckDB with ``ensure_tables``, ``pfs.rvu`` and
|
||||
``pfs.rvu_proposed`` from ``fixtures/home_visits_rvu.csv`` (descriptors
|
||||
blank), and the rows of Tasks 2-11 produced by running those tasks'
|
||||
functions over the fixture: lineage (T2), valuation rounds from the FR
|
||||
paragraphs and the CY2008 Table 14 (T4/T5), guidance and origin (T6), CMS's
|
||||
Comment:/Response: summaries (T7), the stance roll-up (T9). Commenters
|
||||
(T8), stance positions (T9), guideline facts (T9b), PSPS billing and
|
||||
specialty impacts (T10) and roster seats (T11) need regulations.gov, the
|
||||
licensed books, data.cms.gov or the AMA site, so their rows are written
|
||||
directly through the tables' own dataclasses;
|
||||
* ``family`` — ``load_curated()["HOME-VISITS"]``;
|
||||
* ``ask`` — a fake ``JsonExtractor`` answering from canned replies keyed by a
|
||||
fragment of the prompt (``FakeAsk``).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import json
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any, Mapping
|
||||
|
||||
import duckdb
|
||||
import pytest
|
||||
|
||||
from bib.dockets import Docket
|
||||
from bib.item import Rule, Source
|
||||
from bib.store import Store
|
||||
from pfs.cms_summaries import summaries
|
||||
from pfs.codetables import (
|
||||
CommenterRow,
|
||||
GuidelineFactRow,
|
||||
ImpactRow,
|
||||
PspsRow,
|
||||
ReactionRow,
|
||||
SeatRow,
|
||||
StanceRow,
|
||||
ensure_tables,
|
||||
write_cms_summaries,
|
||||
write_commenters,
|
||||
write_events,
|
||||
write_guidance,
|
||||
write_guideline_facts,
|
||||
write_origin,
|
||||
write_psps,
|
||||
write_reaction,
|
||||
write_rounds,
|
||||
write_seats,
|
||||
write_specialty_impacts,
|
||||
write_stances,
|
||||
)
|
||||
from pfs.curated import load_curated
|
||||
from pfs.guidance import build as build_guidance
|
||||
from pfs.lineage import lineage
|
||||
from pfs.origin import family_origin
|
||||
from pfs.rounds import family_rounds
|
||||
from pfs.runlog import RunLog
|
||||
from pfs.stance import rollup
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
FR_PATH = FIXTURES / "home_visits_fr.jsonl"
|
||||
RVU_PATH = FIXTURES / "home_visits_rvu.csv"
|
||||
|
||||
DOCKET = "CMS-2022-0113"
|
||||
FAMILY = "HOME-VISITS"
|
||||
|
||||
#: CY2008 final rule Table 14 (72 FR 66361) for the family's rows: codes and
|
||||
#: Federal Register numbers only, the descriptor column left blank
|
||||
TABLE14 = """[[Page 66361]]
|
||||
|
||||
Table 14.--Work RVU Revisions for Additional 5-Year Review Codes
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Work RVUs
|
||||
CPT/HCPCS code \\1\\ Mod Descriptor Proposed work requested by RUC rec 2008 work RVU Basis for decision
|
||||
RVU commenters
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
99326................... ........... - 2.27 2.85 2.27 2.63 Refinement.
|
||||
99343................... ........... - 2.27 2.65 2.27 2.53 Refinement.
|
||||
99350................... ........... - 3.03 3.45 3.03 3.28 Refinement.
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
class FakeAsk:
|
||||
"""A fake ``JsonExtractor``: ``ask(system, user, schema)`` returns the
|
||||
canned reply whose key occurs in *user* (first match, in insertion
|
||||
order), else ``default`` (a reply, or a callable of ``(system, user)``).
|
||||
Every call is recorded in ``calls``."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
replies: Mapping[str, Any] | None = None,
|
||||
default: Any = None,
|
||||
model: str = "fake-14b",
|
||||
) -> None:
|
||||
self.replies = dict(replies or {})
|
||||
self.default = default
|
||||
self.model = model
|
||||
self.calls: list[tuple[str, str]] = []
|
||||
|
||||
def __call__(self, system: str, user: str, schema: Any) -> Any:
|
||||
self.calls.append((system, user))
|
||||
for key, reply in self.replies.items():
|
||||
if key in user:
|
||||
return reply(system, user) if callable(reply) else reply
|
||||
if callable(self.default):
|
||||
return self.default(system, user)
|
||||
return self.default
|
||||
|
||||
|
||||
def fr_rows() -> list[dict]:
|
||||
return [json.loads(line) for line in FR_PATH.read_text().splitlines() if line]
|
||||
|
||||
|
||||
def build_store(storage: Path) -> Store:
|
||||
s = Store(":memory:", storage_dir=storage)
|
||||
rows = fr_rows()
|
||||
con = s._con()
|
||||
seen: set[str] = set()
|
||||
for r in rows:
|
||||
if r["item_key"] in seen:
|
||||
continue
|
||||
seen.add(r["item_key"])
|
||||
s.create(
|
||||
Rule(
|
||||
key=r["item_key"],
|
||||
title=r["title"],
|
||||
date_published=r["date_published"],
|
||||
document_number=r["document_number"],
|
||||
)
|
||||
)
|
||||
con.execute(
|
||||
"INSERT INTO fr_anchor_docs (item_key, document_number, html_url, "
|
||||
"start_page, end_page, fr_volume) VALUES (?,?,?,?,?,?)",
|
||||
(
|
||||
r["item_key"],
|
||||
r["document_number"],
|
||||
r["html_url"],
|
||||
r["start_page"],
|
||||
r["end_page"],
|
||||
r["fr_volume"],
|
||||
),
|
||||
)
|
||||
con.executemany(
|
||||
"INSERT INTO fr_anchors (item_key, p_id, page, ordinal, text) "
|
||||
"VALUES (?,?,?,?,?)",
|
||||
[(r["item_key"], r["p_id"], r["page"], r["ordinal"], r["text"]) for r in rows],
|
||||
)
|
||||
# three comment items whose bib titles carry a person's name: never the
|
||||
# source of a name on the dossier (pfs.commenter is)
|
||||
for n, person in enumerate(("Jane Doe", "John Roe", "Ann Poe"), 1):
|
||||
cid = f"{DOCKET}-{n:04d}"
|
||||
s.create(
|
||||
Source(
|
||||
key=f"CMT{n:05d}",
|
||||
title=f"{person}: {cid}",
|
||||
url=f"https://www.regulations.gov/comment/{cid}",
|
||||
)
|
||||
)
|
||||
s.docket_upsert(
|
||||
Docket(id=DOCKET, rule_cms_id="CMS-1770-P", comment_end_date="2022-09-06")
|
||||
)
|
||||
s.docket_upsert(
|
||||
Docket(
|
||||
id="CMS-2025-0304", rule_cms_id="CMS-1832-P", comment_end_date="2025-09-12"
|
||||
)
|
||||
)
|
||||
con.commit()
|
||||
table = storage.parent / "07-5506.txt"
|
||||
table.write_text(TABLE14)
|
||||
s.attach_file("54GTKR5G", table)
|
||||
return s
|
||||
|
||||
|
||||
def load_rvu(con: Any) -> None:
|
||||
with RVU_PATH.open() as f:
|
||||
rows = list(csv.DictReader(f))
|
||||
cols = [c for c in rows[0] if c != "cms_rule_id"]
|
||||
num = {
|
||||
"work_rvu",
|
||||
"non_fac_pe_rvu",
|
||||
"fac_pe_rvu",
|
||||
"mp_rvu",
|
||||
"non_fac_total",
|
||||
"fac_total",
|
||||
"pre_op",
|
||||
"intra_op",
|
||||
"post_op",
|
||||
"conv_factor",
|
||||
}
|
||||
|
||||
def typed(c: str) -> str:
|
||||
if c == "year":
|
||||
return "INTEGER"
|
||||
return "DOUBLE" if c in num else "VARCHAR"
|
||||
|
||||
con.execute(
|
||||
"CREATE TABLE pfs.rvu (" + ", ".join(f"{c} {typed(c)}" for c in cols) + ")"
|
||||
)
|
||||
con.execute(
|
||||
"CREATE TABLE pfs.rvu_proposed (hcpcs VARCHAR, mod VARCHAR, description "
|
||||
"VARCHAR, status_code VARCHAR, work_rvu DOUBLE, non_fac_pe_rvu DOUBLE, "
|
||||
"fac_pe_rvu DOUBLE, mp_rvu DOUBLE, cms_rule_id VARCHAR)"
|
||||
)
|
||||
|
||||
def val(c: str, v: str) -> Any:
|
||||
if v == "":
|
||||
return None
|
||||
return int(v) if c == "year" else float(v) if c in num else v
|
||||
|
||||
final = [r for r in rows if not r["cms_rule_id"]]
|
||||
con.executemany(
|
||||
f"INSERT INTO pfs.rvu VALUES ({','.join('?' * len(cols))})",
|
||||
[[val(c, r[c]) for c in cols] for r in final],
|
||||
)
|
||||
pcols = (
|
||||
"hcpcs",
|
||||
"mod",
|
||||
"description",
|
||||
"status_code",
|
||||
"work_rvu",
|
||||
"non_fac_pe_rvu",
|
||||
"fac_pe_rvu",
|
||||
"mp_rvu",
|
||||
"cms_rule_id",
|
||||
)
|
||||
con.executemany(
|
||||
"INSERT INTO pfs.rvu_proposed VALUES (?,?,?,?,?,?,?,?,?)",
|
||||
[[val(c, r[c]) for c in pcols] for r in rows if r["cms_rule_id"]],
|
||||
)
|
||||
|
||||
|
||||
# ── rows the fixture writes directly (no live source in tests) ────────
|
||||
|
||||
COMMENTERS = (
|
||||
# item_key, comment id, org_name, org_type, specialty, posted name
|
||||
("CMT00001", "0001", "", "individual_clinician", "FAMILY PRACTICE", "Mary Major"),
|
||||
(
|
||||
"CMT00002",
|
||||
"0002",
|
||||
"American Academy of Home Care Medicine",
|
||||
"specialty_society",
|
||||
"INTERNAL MEDICINE",
|
||||
"",
|
||||
),
|
||||
("CMT00003", "0003", "Fixture Health System", "health_system", "NONE", ""),
|
||||
("CMT00004", "0004", "", "individual", "", ""),
|
||||
(
|
||||
"CMT00005",
|
||||
"0005",
|
||||
"American Academy of Family Physicians",
|
||||
"specialty_society",
|
||||
"FAMILY PRACTICE",
|
||||
"",
|
||||
),
|
||||
("CMT00006", "0006", "Fixture Health Plan", "payer", "", ""),
|
||||
)
|
||||
|
||||
STANCES = (
|
||||
("CMT00001", "valuation", "support"),
|
||||
("CMT00002", "valuation", "modify"),
|
||||
("CMT00002", "G0318", "support"),
|
||||
("CMT00003", "valuation", "oppose"),
|
||||
("CMT00004", "other", "unclear"),
|
||||
("CMT00005", "coding", "support"),
|
||||
)
|
||||
|
||||
#: the method's measurement as task 9c stamps it on the golden family
|
||||
STANCE_EVAL = {
|
||||
"cell": 0.817,
|
||||
"recall": 0.792,
|
||||
"direction": 0.737,
|
||||
"n_items": 20,
|
||||
"n_positions": 24,
|
||||
"family": FAMILY,
|
||||
"dockets": ["CMS-2025-0304", "CMS-2026-2377"],
|
||||
"in_sample": False,
|
||||
"generation": "stance-v5",
|
||||
"in_sample_record": {
|
||||
"cell": 0.82,
|
||||
"recall": 0.407,
|
||||
"direction": 0.818,
|
||||
"n_items": 20,
|
||||
"n_positions": 27,
|
||||
"docket": DOCKET,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _commenter_rows() -> list[CommenterRow]:
|
||||
return [
|
||||
CommenterRow(
|
||||
item_key=key,
|
||||
docket=DOCKET,
|
||||
comment_id=f"{DOCKET}-{cid}",
|
||||
org_name=org,
|
||||
org_type=typ,
|
||||
specialty=spec,
|
||||
form_group="",
|
||||
form_size=0,
|
||||
basis="letterhead_model",
|
||||
reg_category="",
|
||||
extractor="model:fake-14b@identity-v5",
|
||||
family=FAMILY,
|
||||
submitter_name=name,
|
||||
)
|
||||
for key, cid, org, typ, spec, name in COMMENTERS
|
||||
]
|
||||
|
||||
|
||||
def _stance_rows() -> list[StanceRow]:
|
||||
return [
|
||||
StanceRow(
|
||||
family=FAMILY,
|
||||
item_key=key,
|
||||
docket=DOCKET,
|
||||
event_key=f"{FAMILY}:2023:{slug}",
|
||||
stance=stance,
|
||||
reason="",
|
||||
evidence="",
|
||||
extractor="model:fake-32b@stance-v5",
|
||||
)
|
||||
for key, slug, stance in STANCES
|
||||
]
|
||||
|
||||
|
||||
def _reaction_rows(stances: list[StanceRow]) -> list[ReactionRow]:
|
||||
order = [f"{FAMILY}:2023:{s}" for s in ("valuation", "coding", "G0318", "other")]
|
||||
base = ReactionRow(FAMILY, DOCKET, "docket", 2022, 6, 24341, 0, 0, 0, 0, "[]")
|
||||
classified = rollup(stances, base=base, order=order, n_commenters=6)
|
||||
classified = ReactionRow(
|
||||
**{
|
||||
**classified.__dict__,
|
||||
"stance_method": "stance-v5:fake-32b",
|
||||
"stance_eval": json.dumps(STANCE_EVAL),
|
||||
}
|
||||
)
|
||||
# a docket with commenters but no classification yet: NULL n_classified
|
||||
pending = ReactionRow(
|
||||
FAMILY, "CMS-2025-0304", "docket", 2025, 3, 14104, 0, 0, 0, 0, "[]"
|
||||
)
|
||||
return [classified, pending]
|
||||
|
||||
|
||||
def _guideline_rows() -> list[GuidelineFactRow]:
|
||||
rows = []
|
||||
for code, mdm, typical in (
|
||||
("99341", "straightforward", "20"),
|
||||
("99350", "high", "60"),
|
||||
):
|
||||
rows += [
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
code,
|
||||
2022,
|
||||
"selection_basis",
|
||||
"history_exam_mdm",
|
||||
"T6H4ZPEQ",
|
||||
"p. 39",
|
||||
"cpt-book",
|
||||
),
|
||||
GuidelineFactRow(
|
||||
FAMILY, code, 2022, "mdm_level", mdm, "T6H4ZPEQ", "p. 39", "cpt-book"
|
||||
),
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
code,
|
||||
2022,
|
||||
"typical_time_min",
|
||||
typical,
|
||||
"T6H4ZPEQ",
|
||||
"p. 39",
|
||||
"cpt-book",
|
||||
),
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
code,
|
||||
2024,
|
||||
"selection_basis",
|
||||
"mdm_or_time",
|
||||
"GQGTPGYV",
|
||||
"p. 29",
|
||||
"cpt-book",
|
||||
),
|
||||
GuidelineFactRow(
|
||||
FAMILY, code, 2024, "mdm_level", mdm, "GQGTPGYV", "p. 29", "cpt-book"
|
||||
),
|
||||
]
|
||||
rows.append(
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
"99341",
|
||||
2024,
|
||||
"time_threshold_min",
|
||||
"15",
|
||||
"GQGTPGYV",
|
||||
"p. 29",
|
||||
"cpt-book",
|
||||
)
|
||||
)
|
||||
rows += [
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
code,
|
||||
2023,
|
||||
"deleted_in_edition",
|
||||
"2022",
|
||||
"3ANRT854",
|
||||
"p. 48",
|
||||
"cpt-book",
|
||||
)
|
||||
for code in ("99324", "99343")
|
||||
]
|
||||
# paraphrases written for this fixture (never book text)
|
||||
rows.append(
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
"99341-99350",
|
||||
2024,
|
||||
"scope_point",
|
||||
"Fixture paraphrase: these visits are reported where the patient lives.",
|
||||
"GQGTPGYV",
|
||||
"p. 28",
|
||||
"model:fake-14b@guideline-v2",
|
||||
)
|
||||
)
|
||||
rows.append(
|
||||
GuidelineFactRow(
|
||||
FAMILY,
|
||||
"99324-99350",
|
||||
2023,
|
||||
"panel_action",
|
||||
"Fixture paraphrase: the Panel merged the domiciliary codes into the "
|
||||
"home visit codes.",
|
||||
"F7SRZJD2",
|
||||
"tab 10, PDF p. 4",
|
||||
"cpt-panel",
|
||||
)
|
||||
)
|
||||
return rows
|
||||
|
||||
|
||||
def _psps_rows() -> list[PspsRow]:
|
||||
"""Synthetic national totals per (year, code, specialty) for the money
|
||||
stakes; ``lower`` rows carry a suppressed line (a lower bound)."""
|
||||
out = []
|
||||
for year in (2021, 2022, 2025, 2026):
|
||||
for code, fp, im, np_ in (
|
||||
("99341", 1000.0, 500.0, 40.0),
|
||||
("99350", 3000.0, 2500.0, 60.0),
|
||||
):
|
||||
out += [
|
||||
PspsRow(
|
||||
year,
|
||||
code,
|
||||
"08",
|
||||
"Family Practice",
|
||||
fp,
|
||||
None,
|
||||
None,
|
||||
"psps",
|
||||
"PSPSKEY1",
|
||||
fp,
|
||||
0,
|
||||
),
|
||||
PspsRow(
|
||||
year,
|
||||
code,
|
||||
"11",
|
||||
"Internal Medicine",
|
||||
im,
|
||||
None,
|
||||
None,
|
||||
"psps",
|
||||
"PSPSKEY1",
|
||||
im,
|
||||
0,
|
||||
),
|
||||
PspsRow(
|
||||
year,
|
||||
code,
|
||||
"50",
|
||||
"Nurse Practitioner",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
"psps",
|
||||
"PSPSKEY1",
|
||||
np_,
|
||||
2,
|
||||
),
|
||||
]
|
||||
return out
|
||||
|
||||
|
||||
def _impact_rows() -> list[ImpactRow]:
|
||||
return [
|
||||
ImpactRow(
|
||||
2023,
|
||||
"final",
|
||||
"Family Practice",
|
||||
"TOTAL",
|
||||
6000.0,
|
||||
0.0,
|
||||
0.01,
|
||||
0.0,
|
||||
0.01,
|
||||
"fr",
|
||||
"PETM225D",
|
||||
70500,
|
||||
),
|
||||
ImpactRow(
|
||||
2023,
|
||||
"final",
|
||||
"Internal Medicine",
|
||||
"TOTAL",
|
||||
10000.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-0.005,
|
||||
"fr",
|
||||
"PETM225D",
|
||||
70500,
|
||||
),
|
||||
ImpactRow(
|
||||
2023,
|
||||
"final",
|
||||
"Portable X-Ray Supplier",
|
||||
"TOTAL",
|
||||
90.0,
|
||||
0.0,
|
||||
-0.01,
|
||||
0.0,
|
||||
-0.01,
|
||||
"fr",
|
||||
"PETM225D",
|
||||
70500,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def _seat_rows() -> list[SeatRow]:
|
||||
url = "https://www.ama-assn.org/about/rvs-update-committee-ruc/composition-rvs-update-committee-ruc"
|
||||
cpt = "https://www.ama-assn.org/about/cpt-editorial-panel/purpose-cpt-coding-system-cpt-editorial-panel"
|
||||
return [
|
||||
SeatRow(
|
||||
"RUC",
|
||||
2022,
|
||||
"American Academy of Family Physicians",
|
||||
"FAMILY PRACTICE",
|
||||
"permanent",
|
||||
url,
|
||||
"ROSTER22",
|
||||
"20220124185004",
|
||||
"organization",
|
||||
1,
|
||||
),
|
||||
SeatRow(
|
||||
"RUC",
|
||||
2022,
|
||||
"American College of Physicians",
|
||||
"INTERNAL MEDICINE",
|
||||
"permanent",
|
||||
url,
|
||||
"ROSTER22",
|
||||
"20220124185004",
|
||||
"organization",
|
||||
1,
|
||||
),
|
||||
SeatRow(
|
||||
"RUC",
|
||||
2022,
|
||||
"Primary Care Rotating Seat",
|
||||
"",
|
||||
"rotating",
|
||||
url,
|
||||
"ROSTER22",
|
||||
"20220124185004",
|
||||
"organization",
|
||||
1,
|
||||
),
|
||||
SeatRow(
|
||||
"RUC",
|
||||
2023,
|
||||
"American Academy of Family Physicians",
|
||||
"FAMILY PRACTICE",
|
||||
"permanent",
|
||||
url,
|
||||
"ROSTER23",
|
||||
"20230323114408",
|
||||
"organization",
|
||||
1,
|
||||
),
|
||||
SeatRow(
|
||||
"CPT_PANEL",
|
||||
2026,
|
||||
"national medical specialty societies",
|
||||
"",
|
||||
"other",
|
||||
cpt,
|
||||
"ROSTERC26",
|
||||
"20260129091331",
|
||||
"category",
|
||||
12,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def _seat_log(con: Any) -> None:
|
||||
from cms.ingest_log import ensure_table, log_ingest
|
||||
|
||||
ensure_table(con)
|
||||
url = "https://www.ama-assn.org/about/rvs-update-committee-ruc/composition-rvs-update-committee-ruc"
|
||||
for y in (2018, 2019, 2019): # a duplicate gap row is read once
|
||||
log_ingest(
|
||||
con,
|
||||
module="pfs.seats",
|
||||
table_name="pfs.governance_seat",
|
||||
rows=0,
|
||||
source_file=f"{url}#{y} (no archive capture)",
|
||||
rule_id="gap",
|
||||
)
|
||||
log_ingest(
|
||||
con,
|
||||
module="pfs.seats",
|
||||
table_name="pfs.governance_seat",
|
||||
rows=31,
|
||||
source_file=f"{url}#2024 note: parsed 31 seats, the page says 32 members",
|
||||
rule_id="note",
|
||||
)
|
||||
|
||||
|
||||
# ── the run ─────────────────────────────────────────────────────────
|
||||
|
||||
#: the canned origin reply: CY2011 final ¶2821 states the statute (¶2818)
|
||||
ORIGIN_REPLIES = {
|
||||
"99341 through 99350 for new and established patient home E/M visits": {
|
||||
"origins": [
|
||||
{
|
||||
"kind": "statute",
|
||||
"reference": "section 1833(x)(2)(B) of the Act",
|
||||
"year": None,
|
||||
"codes": [
|
||||
"99341",
|
||||
"99342",
|
||||
"99344",
|
||||
"99345",
|
||||
"99347",
|
||||
"99348",
|
||||
"99349",
|
||||
"99350",
|
||||
],
|
||||
"summary": "Defines primary care services to include home E/M "
|
||||
"visit codes 99341-99350.",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def build_con(store: Store, tmp: Path, family: Any) -> Any:
|
||||
con = duckdb.connect(":memory:")
|
||||
ensure_tables(con)
|
||||
load_rvu(con)
|
||||
# T2 lineage: every member code and link target
|
||||
for code in [*family.codes, *(ln.target for ln in family.links)]:
|
||||
write_events(con, code, lineage(con, store, code))
|
||||
# T4/T5 rounds: Table 14 + FR paragraphs (regex; the model declines)
|
||||
rows, _ = family_rounds(
|
||||
con, store, family, ask=FakeAsk(), log=RunLog(tmp / "rounds.jsonl")
|
||||
)
|
||||
write_rounds(con, family.key, rows)
|
||||
# T6 guidance and origin
|
||||
write_guidance(
|
||||
con, family.key, build_guidance(con, store, family.codes, family=family.key)
|
||||
)
|
||||
origin, _ = family_origin(
|
||||
con,
|
||||
store,
|
||||
family,
|
||||
ask=FakeAsk(ORIGIN_REPLIES),
|
||||
log=RunLog(tmp / "origin.jsonl"),
|
||||
books=(),
|
||||
)
|
||||
write_origin(con, family.key, origin)
|
||||
# T7 CMS's summaries (stance asked of a fake closed-vocabulary classifier)
|
||||
write_cms_summaries(
|
||||
con,
|
||||
family.key,
|
||||
summaries(
|
||||
store,
|
||||
family,
|
||||
classify=lambda text, labels: "support",
|
||||
model="fake-14b",
|
||||
log=RunLog(tmp / "cms.jsonl"),
|
||||
),
|
||||
)
|
||||
# T8/T9 commenters, positions and the roll-up
|
||||
write_commenters(con, _commenter_rows(), docket=DOCKET, family=family.key)
|
||||
stances = _stance_rows()
|
||||
write_stances(con, family.key, DOCKET, stances)
|
||||
write_reaction(con, family.key, _reaction_rows(stances))
|
||||
# T9b, T10, T11
|
||||
write_guideline_facts(con, family.key, _guideline_rows())
|
||||
for (year, code), group in _grouped(_psps_rows()).items():
|
||||
write_psps(con, year, code, group)
|
||||
write_specialty_impacts(con, 2023, "final", "fr", _impact_rows())
|
||||
write_seats(con, "RUC", [r for r in _seat_rows() if r.body == "RUC"])
|
||||
write_seats(con, "CPT_PANEL", [r for r in _seat_rows() if r.body == "CPT_PANEL"])
|
||||
_seat_log(con)
|
||||
return con
|
||||
|
||||
|
||||
def _grouped(rows: list[PspsRow]) -> dict[tuple[int, str], list[PspsRow]]:
|
||||
out: dict[tuple[int, str], list[PspsRow]] = {}
|
||||
for r in rows:
|
||||
out.setdefault((r.year, r.hcpcs), []).append(r)
|
||||
return out
|
||||
|
||||
|
||||
@contextmanager
|
||||
def home(tmp_path: Path):
|
||||
"""The fixture as a context manager: ``(con, store, family, ask)``."""
|
||||
tmp_path.mkdir(parents=True, exist_ok=True)
|
||||
family = load_curated()[FAMILY]
|
||||
store = build_store(tmp_path / "storage")
|
||||
con = build_con(store, tmp_path, family)
|
||||
try:
|
||||
yield con, store, family, FakeAsk()
|
||||
finally:
|
||||
con.close()
|
||||
store.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def home_fixture(tmp_path: Path):
|
||||
with home(tmp_path) as parts:
|
||||
yield parts
|
||||
188
tests/pfs/test_cite.py
Normal file
188
tests/pfs/test_cite.py
Normal file
@@ -0,0 +1,188 @@
|
||||
"""pfs.cite — one citation per dossier fact (dossier task 13)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from pfs.cite import (
|
||||
KINDS,
|
||||
Cite,
|
||||
book_cite,
|
||||
comment_cite,
|
||||
dataset_cite,
|
||||
fr_page_cite,
|
||||
fr_para_cite,
|
||||
guidance_cite,
|
||||
rule_label,
|
||||
rvu_cite,
|
||||
ssa_section_url,
|
||||
)
|
||||
from pfs.codetables import GuidanceRow
|
||||
|
||||
PETM = "https://www.federalregister.gov/documents/2022/11/18/2022-23873/medicare-and-medicaid-programs-cy-2023-payment-policies-under-the-physician-fee-schedule-and-other"
|
||||
|
||||
|
||||
def test_kinds():
|
||||
assert KINDS == (
|
||||
"fr_para",
|
||||
"fr_page",
|
||||
"comment",
|
||||
"cms_file",
|
||||
"cpt_book",
|
||||
"iom",
|
||||
"cfr",
|
||||
"mln",
|
||||
"statute",
|
||||
"study",
|
||||
"rvu_file",
|
||||
"dataset",
|
||||
)
|
||||
|
||||
|
||||
def test_rule_label_moved_verbatim():
|
||||
assert (
|
||||
rule_label("Medicare Program; CY 2015 PFS Final Rule", "2014-11-13", 1251)
|
||||
== "CY2015 PFS final ¶1251"
|
||||
)
|
||||
assert (
|
||||
rule_label(
|
||||
"CY 2021 PFS", "2020-12-28", 1578, vol="85", page=84639, kind="final"
|
||||
)
|
||||
== "CY2021 PFS final 85 FR 84639 ¶1578"
|
||||
)
|
||||
|
||||
|
||||
def test_fr_para_cite(home_fixture):
|
||||
_con, store, _fam, _ask = home_fixture
|
||||
c = fr_para_cite(store, "PETM225D", 1672)
|
||||
assert c == Cite(
|
||||
kind="fr_para",
|
||||
label="CY2023 PFS final 87 FR 69608 ¶1672",
|
||||
url=f"{PETM}#p-1672",
|
||||
item_key="PETM225D",
|
||||
p_id=1672,
|
||||
page=69608,
|
||||
locator="87 FR 69608",
|
||||
)
|
||||
|
||||
|
||||
def test_fr_para_cite_unresolved_keeps_a_locator(home_fixture):
|
||||
_con, store, _fam, _ask = home_fixture
|
||||
c = fr_para_cite(store, "PETM225D", 99999) # no such paragraph
|
||||
assert c.url == ""
|
||||
assert c.label == "CY2023 PFS final ¶99999"
|
||||
assert c.locator == "PETM225D ¶99999"
|
||||
c = fr_para_cite(store, "NOSUCH", 3) # no such item
|
||||
assert (c.url, c.label, c.locator) == ("", "NOSUCH ¶3", "NOSUCH ¶3")
|
||||
|
||||
|
||||
def test_fr_page_cite(home_fixture):
|
||||
_con, store, _fam, _ask = home_fixture
|
||||
c = fr_page_cite(store, "54GTKR5G", 66361, table="Table 14")
|
||||
assert c.label == "CY2008 PFS final 72 FR 66361 Table 14"
|
||||
assert c.url.endswith("#page-66361")
|
||||
assert (c.kind, c.item_key, c.page, c.locator) == (
|
||||
"fr_page",
|
||||
"54GTKR5G",
|
||||
66361,
|
||||
"72 FR 66361",
|
||||
)
|
||||
assert (
|
||||
fr_page_cite(store, "54GTKR5G", 66361).label == "CY2008 PFS final 72 FR 66361"
|
||||
)
|
||||
bad = fr_page_cite(store, "54GTKR5G", 1) # outside the rule's pages
|
||||
assert bad.url == "" and bad.locator == "72 FR 1"
|
||||
none = fr_page_cite(store, "NOSUCH", 5)
|
||||
assert (none.url, none.label) == ("", "NOSUCH p. 5")
|
||||
|
||||
|
||||
def test_comment_cite():
|
||||
c = comment_cite("CMS-2022-0113-0001")
|
||||
assert c.label == "Comment CMS-2022-0113-0001"
|
||||
assert c.url == "https://www.regulations.gov/comment/CMS-2022-0113-0001"
|
||||
assert c.kind == "comment"
|
||||
|
||||
|
||||
def test_rvu_cite():
|
||||
assert rvu_cite(2023).label == "PFS CY2023 RVU file"
|
||||
assert rvu_cite(2027, proposed=True).label == "PFS CY2027 NPRM RVU file"
|
||||
assert rvu_cite(2023).url.startswith("https://www.cms.gov/")
|
||||
assert rvu_cite(2023).kind == "rvu_file"
|
||||
|
||||
|
||||
def test_book_cite():
|
||||
c = book_cite("3ANRT854", "CPT Changes 2023", "49")
|
||||
assert (c.kind, c.label, c.item_key, c.url) == (
|
||||
"cpt_book",
|
||||
"CPT Changes 2023 p. 49",
|
||||
"3ANRT854",
|
||||
"",
|
||||
)
|
||||
assert c.locator == "CPT Changes 2023 p. 49"
|
||||
assert book_cite("K", "CPT 2024", "p. 29").label == "CPT 2024 p. 29"
|
||||
assert (
|
||||
book_cite("F7", "Panel summary", "tab 10, PDF p. 4").label
|
||||
== "Panel summary, tab 10, PDF p. 4"
|
||||
)
|
||||
|
||||
|
||||
def test_dataset_cite():
|
||||
c = dataset_cite("K1", "PSPS CY2022", "https://data.cms.gov/x")
|
||||
assert c == Cite(
|
||||
"dataset", "PSPS CY2022", "https://data.cms.gov/x", "K1", 0, 0, "PSPS CY2022"
|
||||
)
|
||||
|
||||
|
||||
def test_guidance_cite():
|
||||
cfr = guidance_cite(
|
||||
GuidanceRow(
|
||||
"F", "99341", "cfr", "42 CFR 425.400(c)", "", "PETM225D", 3607, 69823
|
||||
)
|
||||
)
|
||||
assert cfr.kind == "cfr"
|
||||
assert cfr.label == "42 CFR 425.400(c)"
|
||||
assert (
|
||||
cfr.url == "https://www.ecfr.gov/current/title-42/section-425.400#p-425.400(c)"
|
||||
)
|
||||
assert (cfr.item_key, cfr.p_id, cfr.locator) == (
|
||||
"PETM225D",
|
||||
3607,
|
||||
"42 CFR 425.400(c)",
|
||||
)
|
||||
iom = guidance_cite(
|
||||
GuidanceRow(
|
||||
"F", "99341", "iom", "100-04 ch.26", "IOMKEY", "PETM225D", 3607, 0, 4
|
||||
)
|
||||
)
|
||||
assert (iom.kind, iom.url, iom.item_key, iom.page) == ("iom", "", "IOMKEY", 4)
|
||||
junk = guidance_cite(GuidanceRow("F", "x", "cfr", "not a cite", "", "", 0, 0))
|
||||
assert junk.url == "" and junk.locator == "not a cite"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ref,url",
|
||||
[
|
||||
(
|
||||
"section 1834(m) of the Act",
|
||||
"https://www.ssa.gov/OP_Home/ssact/title18/1834.htm",
|
||||
),
|
||||
(
|
||||
"section 1899(c) of the Act",
|
||||
"https://www.ssa.gov/OP_Home/ssact/title18/1899.htm",
|
||||
),
|
||||
(
|
||||
"section 1866E of the Social Security Act",
|
||||
"https://www.ssa.gov/OP_Home/ssact/title18/1866E.htm",
|
||||
),
|
||||
("section 5501(a) of the Affordable Care Act", ""),
|
||||
("42 CFR 410.78", ""),
|
||||
("section 1902 of the Act", ""),
|
||||
],
|
||||
)
|
||||
def test_ssa_section_url(ref, url):
|
||||
assert ssa_section_url(ref) == url
|
||||
|
||||
|
||||
def test_cite_round_trips_through_a_dict():
|
||||
c = comment_cite("X-1")
|
||||
assert Cite(**c.__dict__) == c
|
||||
214
tests/pfs/test_citecheck.py
Normal file
214
tests/pfs/test_citecheck.py
Normal file
@@ -0,0 +1,214 @@
|
||||
"""pfs.citecheck — the sentence-level citation check (dossier task 13)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from pfs.cite import Cite
|
||||
from pfs.citecheck import (
|
||||
Problem,
|
||||
check_prose,
|
||||
grounding_problems,
|
||||
number_tokens,
|
||||
split_sentences,
|
||||
)
|
||||
from pfs.dossier import Fact
|
||||
|
||||
|
||||
def fact(text, values=None, fid="F1"):
|
||||
return Fact(
|
||||
id=fid,
|
||||
kind="round",
|
||||
year=2023,
|
||||
codes=(),
|
||||
text=text,
|
||||
values=values or {},
|
||||
cite=Cite(kind="fr_para", label="x", url="u"),
|
||||
)
|
||||
|
||||
|
||||
F = {
|
||||
"F1": fact(
|
||||
"For CY2023, the RUC recommended a work RVU of 1.00 for 99341 and CMS "
|
||||
"finalized 1.00 (accept).",
|
||||
{"final": 1.0},
|
||||
),
|
||||
"F2": fact(
|
||||
"For CY2023, the RUC recommended a work RVU of 1.65 for 99342 and CMS "
|
||||
"finalized 1.65 (accept).",
|
||||
{"final": 1.65},
|
||||
"F2",
|
||||
),
|
||||
"F3": fact(
|
||||
"In CY2023 the payment for 99350 was $131.17 and the total changed −16.5%.",
|
||||
{},
|
||||
"F3",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def test_uncited_sentence_rejected():
|
||||
assert check_prose("CMS accepted the RUC values.", F)[0].kind == "uncited"
|
||||
|
||||
|
||||
def test_number_from_uncited_fact_rejected():
|
||||
[p] = check_prose("99341 was finalized at 1.65 [F1].", F)
|
||||
assert p.kind == "number_mismatch"
|
||||
assert "1.65" in p.detail
|
||||
|
||||
|
||||
def test_equivalent_number_formats_accepted():
|
||||
assert check_prose("In CY2023 99341 was set at 1.0 work RVUs [F1].", F) == []
|
||||
|
||||
|
||||
def test_unknown_fact_rejected():
|
||||
[p] = check_prose("CMS finalized 1.00 for 99341 [F9].", F)
|
||||
assert p.kind == "unknown_fact"
|
||||
assert "F9" in p.detail
|
||||
|
||||
|
||||
def test_abbreviations_do_not_split():
|
||||
text = (
|
||||
"The U.S. statute, e.g. section 1833, i.e. the Act, No. 5 and p. 49 "
|
||||
"set 1.00 for 99341 [F1]."
|
||||
)
|
||||
assert split_sentences(text) == [text]
|
||||
assert len(split_sentences("A one [F1]. B two [F2].")) == 2
|
||||
|
||||
|
||||
def test_tags_after_the_period_stay_with_their_sentence():
|
||||
assert split_sentences("CMS finalized 1.00 for 99341. [F1] Next [F2].") == [
|
||||
"CMS finalized 1.00 for 99341. [F1]",
|
||||
"Next [F2].",
|
||||
]
|
||||
assert check_prose("CMS finalized 1.00 for 99341 in CY2023. [F1]", F) == []
|
||||
|
||||
|
||||
def test_money_and_percent_normalized():
|
||||
assert number_tokens("$131.17") == {"131.17"}
|
||||
assert number_tokens("−16.5%") == number_tokens("-16.5%") == {"-16.5%"}
|
||||
assert number_tokens("–16.5%") == {"-16.5%"}
|
||||
assert check_prose("99350 paid 131.17 in CY2023 and moved -16.5% [F3].", F) == []
|
||||
|
||||
|
||||
def test_number_tokens_normalization():
|
||||
assert number_tokens("1.00 3.60 +2 1,234 25th 2.0") == {
|
||||
"1",
|
||||
"3.6",
|
||||
"2",
|
||||
"1234",
|
||||
"25th",
|
||||
}
|
||||
# bracketed segments (fact tags, labels) carry no numbers
|
||||
assert number_tokens("x [F12] [87 FR 69608 ¶1672] y") == set()
|
||||
# a range is two codes, never a negative number
|
||||
assert number_tokens("99324–99328") == {"99324", "99328"}
|
||||
# CY years and docket ids
|
||||
assert number_tokens("CY2023") == {"2023"}
|
||||
assert number_tokens("CMS-2022-0113") == {"2022", "0113"}
|
||||
# HCPCS letters codes are whole tokens; modifiers carry no number
|
||||
assert number_tokens("G0318 and B1") == {"G0318"}
|
||||
|
||||
|
||||
def test_values_count_as_supported_numbers():
|
||||
facts = {"F1": fact("CMS finalized the value for 99341 (accept).", {"final": 1.0})}
|
||||
assert check_prose("99341 was finalized at 1.00 [F1].", facts) == []
|
||||
facts = {"F1": fact("x", {"share": "12.5%", "label": "n/a"})}
|
||||
assert check_prose("It was 12.5% [F1].", facts) == []
|
||||
|
||||
|
||||
def test_several_tags_in_one_bracket():
|
||||
assert check_prose("99341 and 99342 got 1.00 and 1.65 [F1, F2].", F) == []
|
||||
|
||||
|
||||
def test_problem_carries_the_sentence():
|
||||
p = check_prose("Uncited one. Fine 99341 1.00 [F1].", F)
|
||||
assert p == [Problem("Uncited one.", "uncited", "no [F#] tag")]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text", ["", " "])
|
||||
def test_empty_prose_has_no_problems(text):
|
||||
assert check_prose(text, F) == []
|
||||
|
||||
|
||||
def test_zero_and_empty_values():
|
||||
assert number_tokens("-0.00 and +0") == {"0"}
|
||||
facts = {"F1": fact("x", {"none": None, "flag": True, "n": 0})}
|
||||
assert check_prose("It was 0 [F1].", facts) == []
|
||||
|
||||
|
||||
def _kind(text, kind="round", fid="F1", codes=()):
|
||||
return Fact(fid, kind, 2023, codes, text, {}, Cite("fr_para", "x", "u"))
|
||||
|
||||
|
||||
G = {
|
||||
"F1": _kind(
|
||||
"For CY2008, the RUC recommended a work RVU of 2.27 for 99326 and CMS finalized 2.63 (refine).",
|
||||
codes=("99326",),
|
||||
),
|
||||
"F2": _kind(
|
||||
"For CY2008, CMS finalized a work RVU of 3.28 for 99350.",
|
||||
fid="F2",
|
||||
codes=("99350",),
|
||||
),
|
||||
"F3": _kind(
|
||||
"CMS reported that commenters supported the proposal (CY2005 final rule).",
|
||||
"cms_summary",
|
||||
"F3",
|
||||
),
|
||||
"F4": _kind(
|
||||
"Of 3 CY2023 commenters we classified on the work RVU valuation, 1 supported.",
|
||||
"stance_split",
|
||||
"F4",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def test_grounded_restatement_passes():
|
||||
assert (
|
||||
grounding_problems(
|
||||
"For CY2008, CMS finalized work RVUs for 99326 and 99350 [F1][F2].", G
|
||||
)
|
||||
== []
|
||||
)
|
||||
assert grounding_problems("No tag here.", G) == [] # left to check_prose
|
||||
|
||||
|
||||
def test_invented_words_are_ungrounded():
|
||||
[p] = grounding_problems(
|
||||
"The CPT 2019 codebook introduced new codes for office visits [F1].", G
|
||||
)
|
||||
assert p.kind == "ungrounded" and "introduc" in p.detail
|
||||
|
||||
|
||||
def test_a_range_spanning_uncited_codes_is_rejected():
|
||||
[p] = grounding_problems(
|
||||
"CMS finalized work RVUs for 99326 through 99350 [F1][F2].", G
|
||||
)
|
||||
assert p.kind == "code_mismatch" and "99341" in p.detail
|
||||
|
||||
|
||||
def test_cms_summary_stays_attributed_and_apart():
|
||||
[p] = grounding_problems(
|
||||
"Commenters supported the proposal (CY2005 final rule) [F3].", G
|
||||
)
|
||||
assert p.kind == "unattributed"
|
||||
assert (
|
||||
grounding_problems(
|
||||
"CMS reported that commenters supported the proposal [F3].", G
|
||||
)
|
||||
== []
|
||||
)
|
||||
[m] = grounding_problems(
|
||||
"CMS reported that commenters supported; we classified 3 [F3][F4].", G
|
||||
)
|
||||
assert m.kind == "merged"
|
||||
[u] = grounding_problems(
|
||||
"Of 3 CY2023 commenters, 1 supported the work RVU valuation [F4].", G
|
||||
)
|
||||
assert u.kind == "unattributed" and "classified" in u.detail
|
||||
|
||||
|
||||
def test_a_range_the_fact_writes_may_be_restated():
|
||||
facts = {"F1": _kind("The Panel deleted codes 99324-99328.", "formation")}
|
||||
assert grounding_problems("The Panel deleted codes 99324-99328 [F1].", facts) == []
|
||||
1864
tests/pfs/test_dossier.py
Normal file
1864
tests/pfs/test_dossier.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user