Using The OnRecord Report Event Dr. Peter Wayne NY Alpha User ...
Using the OnRecord Report Event
Dr. Peter Wayne
NY Alpha User Group
July 12, 2006
Scope of the problem:
The counterpart to electronic billing for medical offices is electronic remittance notices. The electronic
remittance file lists each claim, tells what is not being paid, what is, and how much, and why.
Each individual claim remittance is usually accompanied by one to several “remarks” and “reasons,” such as
“Duplicate claim/service” or “The diagnosis is inconsistent with the patient's gender.” All in all, there are over
900 possible remarks and reasons defined for remittances. Rather than provide the full text of the remark, the
insurer only sends predefined remark codes or reason codes in the electronic file.
The standard printed remittance advice for multiple claims has included the remark codes with an explanation
of the remarks used at the end of the (paper) remittance advice. My goal was to create an Alpha Five report that
mimics the one that billing personnel are accustomed to reading, e.g.:
In this image, I've blocked out patient names and insurance identification numbers. This Alpha Five report
looks just like the notice we get from Medicare, down to the font selection. The remarks seen here include
MA01, MA18, and CO42. The last page of the report shows the explanation of the remarks:
Page 1
Using the OnRecord Report Event
Dr. Peter Wayne
NY Alpha User Group
July 12, 2006
The electronic remittance advice is known as an ANSI 835 file, defined in a 252-page document that makes
great bedtime reading. I won't go into the parsing of the file; suffice it to say that the file is read and is parsed
into an Alpha Five table, imaginatively called “ansi835.dbf”, whose structure includes a 30-character field
called “reason_codes” and another called “remark_codes”. The fields get filled with whatever remark or reason
codes accompany the bill's remittance advice, as in this example from a different insurer:
Page 2
Using the OnRecord Report Event
Dr. Peter Wayne
NY Alpha User Group
July 12, 2006
I could have made the “remark” field into a memo field and filled it with the expanded text of all the remarks,
but that would create a very long report indeed, and one in which the essential remittance information is lost in
a blizzard of redundant remarks. After all, an experienced biller soon learns that “CO18” means a “duplicate
claim/service” and does not need to see it written out; the “long form” of the remarks at the end of the report is
a reference for the inexperienced biller as well as for unfamiliar remark codes.
The plan, then, is to read each claim in sequence. If there is a previously unencountered remark or reason code,
I should add it to the list of reason codes I need to expand at the end of the report. I could do this in Xbasic
using two little-used features of Alpha Five: the report's OnRecord event and collections.
I had to remind myself what a collection is: it's an array whose index is character, not numeric. For example, I
could set up this collection:
dim members as U
members.set("weiss","daniel")
members.set("talbott","jay")
members.set("rochford","barry")
You can retrieve an element of a collection with its index:
? members.get("rochford")
= "barry"
And you can see if an element exists in the collection:
? members.exist("rabins")
= .F.
? members.exist("talbott")
= .T.
So now we know everything we need to know about collections.
Page 3
Using the OnRecord Report Event
Dr. Peter Wayne
NY Alpha User Group
July 12, 2006
The event we'll write code for is the Detail Section's OnRecord event. The OnRecord event fires each time a
new detail record is read:
The code for one such event follows:
dim shared reasonsU as U
dim shared reasons as C
dim remark_code as c
dim reason_code as c
if ansi835ma->reason_codes>""
for i=1 to w_count(ansi835ma->reason_codes," CO")
reason_code=trim(word(ansi835ma->reason_codes,i," CO"))
if reason_code>"" then
if reasonsU.get(reason_code)="" then
reasonsU.set(reason_code,reason_code)
reasons=reasons+reason_code+" : "+\
table.external_record_content_get("mc_msg",\
"word(Message,1,crlf())","","msg_code="+quote(reason_code))+crlf()
end if
end if
next
end if
The 932 different remark codes and their explanations are in the table, “mc_msg.dbf”. Since this script is called
once for each record, the collection reasonsU has to be defined as shared so it persists from one record to the
next. I build a shared character string, reasons, that is also defined in the report's Variables as a “Session”
variable:
Page 4
Using the OnRecord Report Event
Dr. Peter Wayne
NY Alpha User Group
July 12, 2006
Finally, I placed the “reasons” character variable in a rich text field in the report footer, making sure to check
off “allow growth while printing” so that the rich text field could accommodate as many reasons as needed:
And that's how I learned to appreciate collections and the OnRecord event!
Page 5