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.
15 KiB
15 KiB