S
Steven Larsen
Hi there,
I have a rather knotty problem with Microsoft Access (both
97 and 2000) that I haven't been able to resolve. I hope
that you can help me!
I'm creating an export to a physician databank which has,
of course, certain export specifications. Everthing is
pretty straight forward and is working well with the
exception of the last specification requirement, which is
a Checksum.
Please see sample submission below. The checksum
calculates all the ACSII characters in the text file
(including <LF>) then dividing this sum by 256 and the
remainder is the checksum value. The count begins with
the "HDR" string at the top of the attached file and ends
with the"TRLR" string at bottom.
My problem is that for some reason, my calculations are
not correct according the databank I'm submitting to. You
will see at the at and the end of the attached file (after
the TRLR) is "211." This is the value that the databank
wants to see for this particular submission. However, for
reasons unbeknowest to me, I get 159 if I count delimiters
(which, according to their specs, can either be null - chr
(0)- or "~", we have been using the nulls). I get 131 if
do not count delimiters in the calculation. The
documentation does not say if the delimiters are counted
or not.
If you would like to see the databanks documentation on
this, you can find it in a pdf at http://www.npdb-
hipdb.com/pubs/ICD-Query.pdf on page 105.
Here is the function I am using to calculate this:
Public Function fnChecksum(sLine As String) As Long
Dim checksum As Long, i As Integer
checksum = 0
For i = 1 To Len(sLine)
'If Mid(sLine, i, 1) <> Chr(0) Then
If Mid(sLine, i, 1) <> "~" Then
checksum = checksum + Asc(Mid(sLine, i, 1))
End If
Next i
fnChecksum = checksum
End Function
Where sLine is the entire string that populates the text
file from the HDR to the TRLR.
To get the final checksum value, first I add 324 to the
checksum (for the "TRLR" value) then I use the the mod
operator like so: checksum Mod 256
to get the final value.
I hope this makes sense and I hope that you can help.
Thanks!
Steve Larsen
The text file is below++++++++++++++++++++++++++++++++++++
~|~NPDB-Q~|~ VER: 3.00
TY1NY
HDR~230171300000369~sue7kathy~1L~R6.0~37826160~10222003~399
700000025565~administrator~
QRY~P~1~A~~~~
CERT~Renee Dengler~Director,
Credentials~7736985210~~10222003~
ISUBJ~Agarwala~Grojendra~~~M~248 Wood Glen
Lane~~Oakbrook~IL~~60521~~Bethany Hospital~~~3435 West Van
Buren Street~~Chicago~IL~~60624~~01151944~~~
DEA~AA5454788~
ISOFL~010~036-046669~IL~99~010~
GRAD~Christian Medical College~1967~
ALIAS~~~~~
SSN~126428099~
FEIN~
NPI~~
UPIN~C42881~
CUSE~BETH_000020~
TRLR~211~
I have a rather knotty problem with Microsoft Access (both
97 and 2000) that I haven't been able to resolve. I hope
that you can help me!
I'm creating an export to a physician databank which has,
of course, certain export specifications. Everthing is
pretty straight forward and is working well with the
exception of the last specification requirement, which is
a Checksum.
Please see sample submission below. The checksum
calculates all the ACSII characters in the text file
(including <LF>) then dividing this sum by 256 and the
remainder is the checksum value. The count begins with
the "HDR" string at the top of the attached file and ends
with the"TRLR" string at bottom.
My problem is that for some reason, my calculations are
not correct according the databank I'm submitting to. You
will see at the at and the end of the attached file (after
the TRLR) is "211." This is the value that the databank
wants to see for this particular submission. However, for
reasons unbeknowest to me, I get 159 if I count delimiters
(which, according to their specs, can either be null - chr
(0)- or "~", we have been using the nulls). I get 131 if
do not count delimiters in the calculation. The
documentation does not say if the delimiters are counted
or not.
If you would like to see the databanks documentation on
this, you can find it in a pdf at http://www.npdb-
hipdb.com/pubs/ICD-Query.pdf on page 105.
Here is the function I am using to calculate this:
Public Function fnChecksum(sLine As String) As Long
Dim checksum As Long, i As Integer
checksum = 0
For i = 1 To Len(sLine)
'If Mid(sLine, i, 1) <> Chr(0) Then
If Mid(sLine, i, 1) <> "~" Then
checksum = checksum + Asc(Mid(sLine, i, 1))
End If
Next i
fnChecksum = checksum
End Function
Where sLine is the entire string that populates the text
file from the HDR to the TRLR.
To get the final checksum value, first I add 324 to the
checksum (for the "TRLR" value) then I use the the mod
operator like so: checksum Mod 256
to get the final value.
I hope this makes sense and I hope that you can help.
Thanks!
Steve Larsen
The text file is below++++++++++++++++++++++++++++++++++++
~|~NPDB-Q~|~ VER: 3.00
TY1NY
HDR~230171300000369~sue7kathy~1L~R6.0~37826160~10222003~399
700000025565~administrator~
QRY~P~1~A~~~~
CERT~Renee Dengler~Director,
Credentials~7736985210~~10222003~
ISUBJ~Agarwala~Grojendra~~~M~248 Wood Glen
Lane~~Oakbrook~IL~~60521~~Bethany Hospital~~~3435 West Van
Buren Street~~Chicago~IL~~60624~~01151944~~~
DEA~AA5454788~
ISOFL~010~036-046669~IL~99~010~
GRAD~Christian Medical College~1967~
ALIAS~~~~~
SSN~126428099~
FEIN~
NPI~~
UPIN~C42881~
CUSE~BETH_000020~
TRLR~211~