Reference Implementations OverviewSpec-to-Code Map

Spec-to-Code Map

Written in this docs repository, against specification v3.4.0 and cms-hte-patient-matching 0.0.12 (published on PyPI 2026-10-07). The project's intent is for the library maintainers to keep it current, but the library repository has no process for that yet. The code is in the library repository, under patient_matching/matching/. If this page and the repository differ, the repository is correct. See also the Compatibility Matrix.

Category 1 rules

Specification rule IDs 01 to 30 (Table 2: Category 1 Rules). The library defines each rule in table2_rules.py, in the APPROVED_RULES tuple, with the same two-digit rule_id.

Spec ruleApproved field combinationLibrary
01First Name* + Last Name* + DOB* + Street Line*01 in APPROVED_RULES
02First Name + Last Name* + DOB* + Phone Number02 in APPROVED_RULES
03First Name* + Last Name* + DOB* + Email Address03 in APPROVED_RULES
04First Name* + Last Name + DOB + SSN Last 404 in APPROVED_RULES
05First Name + Last Name* + DOB + SSN Last 405 in APPROVED_RULES
06First Name* + Last Name + DOB + ITIN Last 406 in APPROVED_RULES
07First Name + Last Name* + DOB + ITIN Last 407 in APPROVED_RULES
08First Name + DOB + MBI08 in APPROVED_RULES
09First Name + DOB + Legal ID09 in APPROVED_RULES
10Last Name* + DOB* + Legal ID10 in APPROVED_RULES
11First Name + DOB + Phone Number11 in APPROVED_RULES
12First Name + DOB + Email Address12 in APPROVED_RULES
13First Name + Phone Number + SSN Last 413 in APPROVED_RULES
14First Name + Phone Number + ITIN Last 414 in APPROVED_RULES
15First Name + Email Address + SSN Last 415 in APPROVED_RULES
16First Name + Email Address + ITIN Last 416 in APPROVED_RULES
17Phone Number + MBI17 in APPROVED_RULES
18Phone Number + Legal ID (w/issuing-authority namespace)18 in APPROVED_RULES
19Email Address + MBI19 in APPROVED_RULES
20Email Address + Legal ID (w/issuing-authority namespace)20 in APPROVED_RULES
21Legal ID + MBI21 in APPROVED_RULES
22Namespace bound unique identifiers (e.g. EMPI, FHIR Patient Identifier, CSP UUID, etc)22 in APPROVED_RULES
23First Name + DOB + Member ID (w/ Payer namespace)23 in APPROVED_RULES
24Last Name* + DOB* + Member ID (w/ Payer namespace)24 in APPROVED_RULES
25Phone Number + Member ID (w/ Payer namespace)25 in APPROVED_RULES
26Email Address + Member ID (w/ Payer namespace)26 in APPROVED_RULES
27First Name* + Last Name + DOB + Subscriber ID (w/ Payer namespace)27 in APPROVED_RULES
28First Name + Last Name* + DOB + Subscriber ID (w/ Payer namespace)28 in APPROVED_RULES
29First Name* + Last Name* + Phone Number + ZIPNot implemented (see note)
30Last Name* + DOB + Phone Number30 in APPROVED_RULES

Rule 29. The specification v3.4.0 lists rule 29. The library does not implement it, ahead of proposal v3.4.1 (remove rule 29), which is under review (issue #7). Its ID is left unassigned in the library, and rule 30 is not renumbered.

Category 2 rules

The specification's Category 2 section lists ten pairings in its section III.C.4 table: eight household-then-individual pairings, and two relationship-linkage pairings. The specification does not assign them IDs. Its section III.C.8 prose refers to "Rules 13, 14, 15, 16, 34, 35, 37, and 38" for the eight household-then-individual pairings, using numbers from an earlier proposal. Those numbers collide with Category 1 rules 13 to 16, so the library prefixes them with C2-.

Spec section III.C.4 pairingLibrary ruleCode
H-01 (SSN Last 4 + Phone) with I-01 (First Name + DOB)C2-13household_rules.py, CATEGORY_2_RULES
H-04 (ITIN Last 4 + Phone) with I-01C2-14household_rules.py
H-02 (SSN Last 4 + Email) with I-01C2-15household_rules.py
H-05 (ITIN Last 4 + Email) with I-01C2-16household_rules.py
H-12 (Phone + ZIP) with I-01C2-34household_rules.py
H-13 (Email + ZIP) with I-01C2-35household_rules.py
H-14 (Phone + Street Line) with I-01C2-37household_rules.py
H-07 (Subscriber ID + Phone) with I-01C2-38household_rules.py
Guardian's identity (independently matched under Table 2) + Street Line, with Relationship Linkage (clinical, child-of guardian) + First Name + DOBC2-39relationship_linkage_rules.py
Mother's identity (independently matched under Table 2), with Relationship Linkage (clinical, newborn-of mother) + DOB + per-encounter namespace-bound birth-encounter IDC2-40relationship_linkage_rules.py

The household rows (Table 2-H, H-01 to H-14) and individual rows (Table 2-I, I-01 to I-03) are defined as building blocks in household_rules.py (HOUSEHOLD_ROWS, INDIVIDUAL_ROWS). Only the rules above are built from them.

Other behavior

SpecificationLibrary
Multiple births (Multiple Births)Tie-resolution logic in matching_engine.py, not additional rule IDs
Generational suffix conflict negates a match (Required Normalization, Names, and Demographic Fields, V.B item 5)Normalization pipeline; the README calls this the suffix conflict rule
Placeholder suppression (Placeholder Values)PlaceholderDetector in patient_matching/normalization/

Differences to be aware of

These come from comparing the library's README and source comments with specification v3.4.0. They are for the library maintainers to confirm or correct.

  • Rule 29 is not implemented (above).
  • P(collision) figures. The library README's rule table lists fuzzy P(collision) of 1.50e-12 for rules 04, 06, and 27, where the specification's Table 2 lists 2e-12. It lists 1.00e-15 for rule 22, where the specification lists ≈0. The library computes its figures from per-field u-values in collision.py rather than copying the specification's table.
  • C2-37. A source comment says the household leg should be gated on an institutional-address exclusion (proposal v3.3.6, under review) and that this is not yet implemented.
  • C2-39 and C2-40. The specification's III.C.4 table flags unresolved caveats for both (a dependency discount for the Street Line term in the guardian rule, and the need for a per-encounter identifier in the newborn rule). The library implements them on a best-effort basis and carries the same caveats in source comments.