Cause 1: Luhn without prefix
- Input
- 123456789 -> 1234567897
- Expected output
- O Luhn ingênuo dá 7; o oficial é 3 e 1234567893 é o NPI válido
The difference is always 4 modulo 10.
why my NPI validator rejects a valid number
When a real NPI is rejected by a form, the culprit is almost never the number. There are four recurring causes, and all of them reproduce by typing the same cases into the Validate tab. See each one, the symptom and the fix.
The difference is always 4 modulo 10.
A strict 10-digit validator would reject it.
Normalize before validating: strip spaces, hyphens and any non-digit character.
Anyone rejecting individual NPIs that start with 2 is inventing a rule.
It is the unique 10-digit identifier of US health care providers, created by the final rule of January 23, 2004 (69 FR 3434). CMS issues and maintains it through the NPPES registry. The number has no embedded meaning: it does not indicate state, specialty or provider type.
Test with 1234567893, the CMS example. If it is rejected and 1234567897 is accepted, your calculation is missing the prefix, and every real NPI will fail.
For a format check, no: the local Luhn is enough and answers instantly. To confirm that the NPI exists and check the name, then yes, query the CMS NPPES registry.
Yes. Spaces and hyphens are removed before the calculation, and the 15-digit form with 80840 is accepted as well.
1234567893
The NPI does not reveal whether it is Type 1 (individual) or Type 2 (organization). That only shows up in the official NPPES registry.
| Digit | 8 | 0 | 8 | 4 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 3 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Double | x2 | x2 | x2 | x2 | x2 | x2 | x2 | ||||||||
| Value | 8 | 0 | 8 | 8 | 0 | 2 | 2 | 6 | 4 | 1 | 6 | 5 | 8 | 9 | 3 |
8 + 0 + 8 + 8 + 0 + 2 + 2 + 6 + 4 + 1 + 6 + 5 + 8 + 9 + 3 = 70 | mod 10 = 0
The first 5 digits (80840) are the constant prefix. Digits in alternating positions are doubled starting next to the last one, and doubles above 9 lose 9. The total must be a multiple of 10.
Everything runs in your browser. No NPI you type or generate is sent to a server, and analytics only receives the action and the overall result, never the number.