Jump to content

[SOLVED] NPI validation in php - URGENT


rsammy

Recommended Posts

i need help in validating a physicians NPI. anyone has any idea how to do this in php or javascript?

 

this is my code in vb...!

 

Private Function validPIN() As Boolean
    ' PIN is exactly 10 digits numeric only string
    Dim txtPIN As String
    
    txtPIN = Trim(pin_txt.Text)
    If Len(txtPIN) = 10 And IsNumeric(txtPIN) Then
        ' 1/12/2007 - Perform the CDV Digit Check
        Dim totDoubleOdd As Long
        Dim totEven As Long
        Dim totPIN As Long
        Dim cdvPINdigit As Long
        ' Use double-add-double algorithm for odd numbered digits
        Dim i As Long
        Dim j As Long
                
        i = 1
        totDoubleOdd = 0
        For i = 1 To 9 Step 2
            j = 2 * CLng(Mid(txtPIN, i, 1))
            If j > 9 Then
                totDoubleOdd = totDoubleOdd + (j - 9)
            Else
                totDoubleOdd = totDoubleOdd + j
            End If
        Next
        
        ' Now add Even and calculate totPIN
        totEven = CLng(Mid(txtPIN, 2, 1)) + CLng(Mid(txtPIN, 4, 1)) + CLng(Mid(txtPIN, 6, 1)) + CLng(Mid(txtPIN, 8, 1))
        totPIN = 24 + totDoubleOdd + totEven
        cdvPINdigit = totPIN Mod 10
        If cdvPINdigit > 0 Then
            cdvPINdigit = 10 - cdvPINdigit
        End If
        ' Check against last digit of PIN
        If Right(txtPIN, 1) = CStr(cdvPINdigit) Then
            validPIN = True     ' Success
        Else
            MsgBox "PIN Check Digit Failure - Verify your PIN and re-enter", vbOKOnly
        End If
    Else
        MsgBox "Please enter a valid PIN - Exactly 10 digits numeric string only", vbOKOnly
    End If
End Function

Link to comment
https://forums.phpfreaks.com/topic/39332-solved-npi-validation-in-php-urgent/
Share on other sites

more specifically, i need some help with this VB line  here...

 

totEven = CLng(Mid(txtPIN, 2, 1)) + CLng(Mid(txtPIN, 4, 1)) + CLng(Mid(txtPIN, 6, 1)) + CLng(Mid(txtPIN, 8, 1))

 

how do i code this one in javascript?!

 

help with the whole function wud be great. but even this may help me a bit...

 

THANX in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.