Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NPI check digit calculator?

713 views
Skip to first unread message

JJ

unread,
Dec 14, 2006, 11:33:14 AM12/14/06
to
Hi there everyone...

It's been a long time since I've posted here...So I hope you don't mind a
request for help.

Does anyone know of or have an NPI check digit calculator? I believe it's
based on the Luhn formula for computing the modulus 10 "double-add-double"
check digit...

I found a website to do this, but would like to have our system (we use MSM
and Cache in MSM mode) validate at entry time itself. Here's the website we
are using in the mean time:
http://www.barrydebruin.com/php/npi/

I basically need MUMPS code to do this...

We do have check digit calcs in our system, but none seem to be for a number
of this size. NPIs are 10 digits total (nine + 1 check digit)..."Tweaking"
those doesn't seem to be working. I'm sure it's something I'm doing wrong.

Thx in advance for any assistance, JJ


Message has been deleted

JJ

unread,
Dec 14, 2006, 6:32:31 PM12/14/06
to
"Denver" <××DBraughler××@××bwcc·com> wrote in message
news:12o3499...@corp.supernews.com...

> JJ wrote:
>> Does anyone know of or have an NPI check digit calculator? I believe
>> it's based on the Luhn formula for computing the modulus 10
>> "double-add-double" check digit...
> So states:
> <http://www.cms.hhs.gov/NationalProvIdentStand/Downloads/NPIfinalrule.pdf>:
> ... the NPI check digit calculation must always be performed as though
> the NPI is preceded by "80840".
> This is easily accomplished by including a constant in the check digit
> calculation when the NPI is used without this prefix.
> The NPI check digit is calculated using the ISO standard Luhn check digit
> algorithm, a modulus10 "double-add-double" algorithm.
> The specification for calculation of the NPI check digit will be made
> available on the CMS Web site (http://www.cms.hhs.gov). The specification
> will explain how to compute the check digit and how to verify an NPI
> using the check digit, both when the "80840" prefix is present and when
> it is not.

>
>> I'm sure it's something I'm doing wrong.
>
> Are you including the "80840" prefix?
>
> I called Jim at +1 410.786-9317.
> He stated that the algorithm is secret but he would consider a formal FOIA
> request for it.
>
> Perhaps someone else will share it.
> If not, it can't be hard to figure out. I've done it for credit card
> numbers.

I've found the "what" to do, just wondered if there was some code already
out there...Thx! I appreciate your response, JJ


barryd...@gmail.com

unread,
Jan 24, 2007, 7:23:47 PM1/24/07
to
JJ,

I wrote the NPI calulator you mentioned below.

I have the same calculations in javscript and C# if that would help. I
wrote mine in php.

Barry

I don't know mumps, but

Herman Slagman

unread,
Jan 31, 2007, 9:01:46 AM1/31/07
to
"JJ" <jefferson...@hotmail.com> wrote in message
news:45817b63$0$27434$cc2e...@news.uslec.net...

> Does anyone know of or have an NPI check digit calculator? I believe it's
> based on the Luhn formula for computing the modulus 10 "double-add-double"
> check digit...

I had one for credit card numbers.
Added the stuff for NPI and converted it to standard Mumps.

HTH

Herman


hsNPIM
; Calculate and check a check digit according to Luhn's algorithm
; ISO 7812
; standard MUMPS version

Calculate(InputNumber, NPI, Debug)
; In NPI mode number can be:
; - 9 digits
; - idem plus one dash or space
; - 14 digits (first five fixed 80840)
; - idem plus one dash or space

New Number,Total,Count,Length,Error,i,Digit,CheckDigit

If $Get(Debug) Write "Calculate for : ",InputNumber,!
Set Number=$Translate(InputNumber,"- ","")
; optional additional checks on the number of spaces or dashes
Set Error=""
If $Get(NPI) Do
. If $Length(Number)=9 Set Number="80840"_Number
. If $Length(Number)'=14 Set Error="Error: not a valid NPI number"
. If $Extract(Number,1,5)'="80840" Set Error="Error: not a valid NPI
number"
If $Length(Error) Quit Error
Set Total="",Length=$Length(Number)
For i=Length:-1:1 Do
. If (Length+1-i)#2 Set Digit=($Extract(Number,i)*2)
. Else Set Digit=$Extract(Number,i)
. Set Total=Digit_Total

Set Count=0
For i=1:1:$Length(Total) Set Count=Count+$Extract(Total,i)
Set CheckDigit=10-Count#10
If $Get(Debug) Write "Check Digit: ",CheckDigit,!
Quit CheckDigit


Check(InputNumber,NPI,Debug)
New Number,InputCheck,CheckDigit

If $Get(Debug) Write "Check number: ",InputNumber,!
Set Number=$Translate(InputNumber," -","")
Set InputCheck=$Extract(Number,$Length(Number))
Set Number=$Extract(Number,1,$Length(Number)-1)
Set CheckDigit=$$Calculate(Number,.NPI)
If CheckDigit=InputCheck Quit "OK"
Quit "Invalid number: "_InputCheck_" should be "_CheckDigit


Test
Kill
Set NPI=1
Set Debug=1
; NPI numbers
For Number=123456789,"12345-6789","12 3456789" {
For Prefix="","80840" {
Set CheckNumber=$$Calculate(Prefix_Number,NPI,Debug)
Set TestNumber=Prefix_Number_CheckNumber
Set Check=$$Check(TestNumber,NPI,Debug)
If Check'="OK" Write Check,!
}
}
; Other numbers, such as credit cards
Set NPI=0
For Number="5413 3027 3931 020","4563 5302 2224 656" {
Set Check=$$Calculate(Number,NPI,Debug)
Set TestNumber=Number_Check
Set Check=$$Check(TestNumber,NPI,Debug)
If Check'="OK" Write Check,!
}


0 new messages