Showing posts with label National Provider Identifier. Show all posts
Showing posts with label National Provider Identifier. Show all posts

Tuesday, May 13, 2014

Valid NPI Number Generator

If you're in the health care industry, you might be familiar with the term National Provider Identifier (NPI). This is a number used to identify medical providers in many various systems, including the SureScripts network.

NPIs are generated with a Luhn Check Digit, so you can't just dummy them up the way you can with other data elements, such as SSNs.

Here's a handy piece of JavaScript for helping you to generate the appropriate check digit for your NPIs. Just another reminder that other people have probably already solved most of the problems I encounter. :-)

And, for the benefit of future generations, here's the copypasta from that excellent blog:

var newNPI = ”; var base = this.value; var count = 0; var newCount = 0; for(i=base.length-1; i>=0; i–) { if(count % 2 == 0) {var tempNum = base.charAt(i)*2; if(tempNum >= 10) {var tempRemainder = tempNum % 10; newCount = newCount + tempRemainder + 1; } else { newCount = newCount + tempNum; } } else { newCount = newCount + parseInt(base.charAt(i)); } count++; } newCount = newCount + 24; var newMod = newCount % 10; var checkDigit = (10 – newMod) % 10; newNPI = base + checkDigit.toString(); alert(newNPI);