Files
stack/tests/pfs/test_codetables.py
kert d1d4187f95 feat(pfs): families from the CPT manual hierarchy — lowest multi-code heading names the family; use-with and parent edges; FamilyRow.note (refs #687)
For CPT codes, the family is now the lowest heading (by section path,
walking up) that groups >= 2 codes in the newest ingested edition —
cpt_groups() builds this as one trie-style rollup pass, not a per-code
rescan. Heading co-membership is itself a union-find edge (so a heading
with no extracted elements still becomes a family), on top of use-with
instructions (single-target only, same #687 discipline as the existing
multi-code-event guard — a live corpus use-with note can name 228
codes) and pfs.cpt_code.parent. Hand families still win when a CPT
group intersects them; FamilyRow.note carries each code's own heading
path so it survives even when the family name comes from elsewhere.
HCPCS codes keep the slice-1 derivation unchanged.

FamilyRow gains note (last field, defaulted); ensure_tables upgrades a
pre-existing pfs.code_family table in place. stack pfs families feeds
the CPT tables when present and prints a summary line.

Fixed two bugs found against the live corpus while verifying: the
walk-up heading match was unioning a code's full descendant rollup
(not just the codes that actually settle at that heading), collapsing
861 real headings into ~76 giant blobs (one was all of Surgery, 5860
codes); and the code-shape filter (CODE_RE) was silently dropping
Category II/III/PLA codes (4 digits + letter) from every family.
2026-09-09 19:34:44 -04:00

15 KiB