Skip to content

Add Type-2 NPI Luhn test cases to us_npi_recognizer tests - #2237

Open
jbisaccia-9 wants to merge 1 commit into
data-privacy-stack:mainfrom
jbisaccia-9:npi-type2-tests
Open

Add Type-2 NPI Luhn test cases to us_npi_recognizer tests#2237
jbisaccia-9 wants to merge 1 commit into
data-privacy-stack:mainfrom
jbisaccia-9:npi-type2-tests

Conversation

@jbisaccia-9

Copy link
Copy Markdown

The parametrized case labeled "Valid NPI starting with 2 (Type 2 = organization)"
in tests/test_us_npi_recognizer.py actually used 1003000126, an NPI starting
with 1 (Type 1 = individual). The recognizer's Type-2 (organization) branch had
no dedicated Luhn test coverage.

Per the CMS NPI spec, the check digit is a standard Luhn check computed over the
10-digit NPI prefixed with "80840". I verified the following against the
recognizer's own __npi_luhn_checksum implementation:

  • 2123456784 — Type 2 (starts with 2), passes Luhn → should be recognized
  • 2123456783 — same 9-digit body, invalid check digit, fails Luhn → should be
    filtered out

This PR adds both cases and fixes the comment on the pre-existing case to
correctly say "Type 1".

No source changes — test-only.

The parametrized case labeled "Valid NPI starting with 2 (Type 2 =
organization)" actually used 1003000126, an NPI starting with 1
(Type 1 = individual) — the recognizer's Type-2 (organization) branch
had no dedicated Luhn coverage.

Adds:
- 2123456784: a genuine Type-2 NPI (starts with 2) that passes the
  "80840"-prefixed Luhn check per the CMS NPI spec.
- 2123456783: the same body with a Luhn-failing check digit, to
  confirm the recognizer rejects it.

Both values were verified against the recognizer's own
__npi_luhn_checksum implementation before being added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant