 # DayNight

## Tuesday, July 31, 2012

### National Provider Identifier (NPI) Validation using Luhn Algorithm

A National Provider Identifier (NPI) is a unique 10-digit identification number issued to health care providers in the United States by the Centers for Medicare and Medicaid Services (CMS).

A 10-digit NPI Number may be validated using the Luhn algorithm by prefixing "80840" to the 10-digit number (80 indicates health applications and 840 indicates the United States).

The Luhn algorithm or Luhn formula, also known as the "modulus 10"  or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, NPI numbers in US and Canadian Social Insurance Numbers. It was created by IBM scientist Hans Peter Luhn.

The last digit is the check digit. So the check is performed on the first 9 digits so that the last digit is obtained.

### Steps Involved

1. Take only the first 9 digits from the NPI to be validated.
2. Prefix 80840 to the number from step 1.
3. Double the value of alternate digits beginning with the rightmost digit.
4. Add the individual digits of the products resulting from step 3 to the unaffected digits from the original number.
5. Subtract the total obtained in step 4 from the next higher number ending in zero. This is the check digit. If the total obtained in step 4 is a number ending in zero, the check digit is zero.
6. If the check digit is equal to the 10th digit in the NPI, then the given NPI is valid.

### Examples

NPI to be validated : 1558598797

Step 1: Take only the first 9 digits from NPI
1 5 5 8 5 9 8 7 9

Step 2: Prefix 80840 to the above number
8 0 8 4 0 1 5 5 8 5 9 8 7 9

Step 3: Double the value of alternate digits, beginning with the rightmost digit.
8 0 8 4 0 1 5 5 8 5 9 8 7 9
0 8 2 10 10 16 18

Step 4: Add the individual digits of products of doubling, plus unaffected digits.
8 0 8 4 0 1 5 5 8 5 9 8 7 9
0 8 2 10 10 16 18
--------------------------------
8 + 8 + 0 + 5 + 8 + 9 + 7 +
0 + 8 + 2 + 1+0+ 1+0 + 1+6 + 1+8 = 73

Step 5: Subtract from next higher number ending in zero.
80-73 = 7

Step 6: If the check digit is equal to the 10th digit in the NPI, then the given NPI is valid.
Check Digit is 7  