Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ABSPECA4

ABSPECA4.m

Go to the documentation of this file.
  1. ABSPECA4 ; IHS/FCS/DRS - Parse Claim Response ; [ 08/09/2002 11:08 AM ]
  1. ;;1.0;PHARMACY POINT OF SALE;**3,42**;JUN 21, 2001;Build 38
  1. ;----------------------------------------------------------------------
  1. ;----------------------------------------------------------------------
  1. ;Parse ASCII Response Claim Record and Sup FDATA() Array
  1. ;
  1. ;Parameters: RREC - Ascii Response Record
  1. ; RESPIEN - Claim Response IEN (90023130.3)
  1. ;----------------------------------------------------------------------
  1. ; Calls ABSPECA5
  1. ;
  1. ;----------------------------------------------------------------------
  1. ; IHS/SD/lwj 8/6/02 NCPDP 5.1 changes
  1. ; NCPDP 5.1 response segments are completely different than the
  1. ; 3.2 response. Of significant importance are:
  1. ; In 3.2, there were 4 basic repsonse segments (header required,
  1. ; header option, information required, information optional.)
  1. ; In 5.1, there are 8 possible segments (header, message, insurance,
  1. ; status, claim, pricing, DUR/PPS, and prior authorization)
  1. ;
  1. ; In 5.1, for all segments following the header, a segment separator
  1. ; is used.
  1. ;
  1. ; In 5.1, field separators, and field identifiers are used for all
  1. ; fields not appearing on the header segment.
  1. ;
  1. ; To adjust to these changes, this routine has been modified. The
  1. ; first thing we will try to establish is which version of response
  1. ; we are working with. A new subroutine was created to hold the
  1. ; 3.2 basic parsing of claim information, and a new routine
  1. ; (ABSPOSH4) was created to perform the parsing of a 5.1 claim.
  1. ;----------------------------------------------------------------------
  1. PARSE(RREC,RESPIEN) ;EP - from ABSPOSQL from ABSPOSQ4
  1. N GS,FS,RHEADER,RHEADERR,RHEADERO,MEDN,RDATA,RDATAR,RDATAO
  1. N INDEX,FDATA,ID,XDATA,RINFO
  1. ;
  1. ;Make sure input varaibles are defined
  1. Q:$G(RREC)=""
  1. Q:$G(RESPIEN)=""
  1. Q:'$D(^ABSPR(RESPIEN,0))
  1. ;
  1. ;group and field separator characters
  1. S GS=$C(29),FS=$C(28)
  1. ;
  1. ; Special handling for what appears to be a corrupt response
  1. ; from First Health for Alaska Medicaid. It's missing a GS.
  1. I RREC'[GS D AKMEDFIX
  1. ;
  1. ;Parse response header section from ascii record
  1. S RHEADER=$P(RREC,GS,1)
  1. S RHEADERR=$P(RHEADER,FS,1)
  1. ;
  1. ;IHS/SD/lwj 8/6/02 NCPDP 5.1 changes - begin changes
  1. ; Need to split out the parsing of 3.2 and 5.1 claims - we will
  1. ; check the version, and if it is 3.2, we will call the PARSE32
  1. ; subroutine - if it's 5.1, we will call the ABSPOSH4 routine.
  1. ;
  1. S FDATA(102)=$E(RHEADERR,1,2)
  1. I FDATA(102)[3 D PARSE32
  1. ;IHS/OIT/CASSEVERN/RAN - 02/10/2011 - Patch 42 -Allows us to parse the response coming back from a D.0 Claim
  1. I (FDATA(102)[5)!(FDATA(102)["D") D PARSE51^ABSPOSH4(RREC,RESPIEN)
  1. ;
  1. ;IHS/SD/lwj 8/6/02 NCPDP 5.1 end changes other than subroutine
  1. ; PARSE32 tag
  1. ;
  1. Q
  1. ;
  1. ;
  1. PARSE32 ;IHS/SD/lwj 8/6/02 NCPDP 5.1 forced the splitting of the parsing -
  1. ; this subroutine is the original code that will parse 3.2 still
  1. ;
  1. S RHEADERO=$P(RHEADER,FS,2)
  1. ;
  1. ;Parse required response header fields
  1. S FDATA(102)=$E(RHEADERR,1,2)
  1. S FDATA(103)=$E(RHEADERR,3,4)
  1. S FDATA(501)=$E(RHEADERR,5,5)
  1. ;
  1. ; Reversal response: doesn't have the GS, though it does have
  1. ; some prescription-multiple-type fields. Fake it out.
  1. ; Right now, this works only for PCS REVERSAL format.
  1. ; May learn more as other reversals come along.
  1. I FDATA(103)=11 D PCSREV G AROUND
  1. ;
  1. ;Parse optional response header fields
  1. S FDATA(524)=RHEADERO
  1. ;
  1. ;Parse repsonse information section from ascii record
  1. S RINFO=$P(RREC,GS,2,999)
  1. ;
  1. ;Parse response information sections for each medication
  1. F MEDN=1:1:$L(RINFO,GS) D
  1. .S RDATA=$P(RINFO,GS,MEDN)
  1. .S RDATAR=$P(RDATA,FS,1)
  1. .S RDATAO=$P(RDATA,FS,2,999)
  1. .;
  1. .;Parse required response information section
  1. .S FDATA("M",MEDN,501)=$E(RDATAR,1,1)
  1. .;
  1. .;Duplicate claim response information fields
  1. .I FDATA("M",MEDN,501)="D" D
  1. ..S FDATA("M",MEDN,1000)=$E(RDATAR,2,85)
  1. ..; Was it a duplicate Paid or Captured claim?
  1. ..N X S X=$S($$PAID^ABSPECA7($E(RDATAR,2,85)):"P",1:"C")
  1. ..S FDATA("M",MEDN,501)="D"_X
  1. .;
  1. .;Payable claim response information fields
  1. .I FDATA("M",MEDN,501)="P"!(FDATA("M",MEDN,501)="DP") D
  1. ..S FDATA("M",MEDN,505)=$E(RDATAR,2,7)
  1. ..S FDATA("M",MEDN,506)=$E(RDATAR,8,13)
  1. ..S FDATA("M",MEDN,507)=$E(RDATAR,14,19)
  1. ..S FDATA("M",MEDN,508)=$E(RDATAR,20,25)
  1. ..S FDATA("M",MEDN,509)=$E(RDATAR,26,31)
  1. ..S FDATA("M",MEDN,503)=$E(RDATAR,32,45)
  1. ..S FDATA("M",MEDN,504)=$E(RDATAR,46,85)
  1. .;
  1. .;Caputured claim response information fields
  1. .I FDATA("M",MEDN,501)="C"!(FDATA("M",MEDN,501)="DC") D
  1. ..S FDATA("M",MEDN,503)=$E(RDATAR,2,15)
  1. ..S FDATA("M",MEDN,504)=$E(RDATAR,16,85)
  1. .;
  1. .;Rejected claim response information fields
  1. .I FDATA("M",MEDN,501)="R" D
  1. ..S FDATA("M",MEDN,510)=$E(RDATAR,2,3)
  1. ..S FDATA("M",MEDN,511,1)=$E(RDATAR,4,5)
  1. ..S FDATA("M",MEDN,511,2)=$E(RDATAR,6,7)
  1. ..S FDATA("M",MEDN,511,3)=$E(RDATAR,8,9)
  1. ..S FDATA("M",MEDN,511,4)=$E(RDATAR,10,11)
  1. ..S FDATA("M",MEDN,511,5)=$E(RDATAR,12,13)
  1. ..S FDATA("M",MEDN,511,6)=$E(RDATAR,14,15)
  1. ..S FDATA("M",MEDN,511,7)=$E(RDATAR,16,17)
  1. ..S FDATA("M",MEDN,511,8)=$E(RDATAR,18,19)
  1. ..S FDATA("M",MEDN,511,9)=$E(RDATAR,20,21)
  1. ..S FDATA("M",MEDN,511,10)=$E(RDATAR,22,23)
  1. ..S FDATA("M",MEDN,511,11)=$E(RDATAR,24,25)
  1. ..S FDATA("M",MEDN,511,12)=$E(RDATAR,26,27)
  1. ..S FDATA("M",MEDN,511,13)=$E(RDATAR,28,29)
  1. ..S FDATA("M",MEDN,511,14)=$E(RDATAR,30,31)
  1. ..S FDATA("M",MEDN,511,15)=$E(RDATAR,32,33)
  1. ..S FDATA("M",MEDN,511,16)=$E(RDATAR,34,35)
  1. ..S FDATA("M",MEDN,511,17)=$E(RDATAR,36,37)
  1. ..S FDATA("M",MEDN,511,18)=$E(RDATAR,38,39)
  1. ..S FDATA("M",MEDN,511,19)=$E(RDATAR,40,41)
  1. ..S FDATA("M",MEDN,511,20)=$E(RDATAR,42,43)
  1. ..S FDATA("M",MEDN,504)=$E(RDATAR,44,85)
  1. .;
  1. .;Parse optional response information section
  1. .D OPTR(MEDN,RDATAO)
  1. ;
  1. AROUND ;
  1. ;File FDATA() in Claim Response File (9002313.03)
  1. D FILE^ABSPECA5(RESPIEN)
  1. Q
  1. PCSREV ; split off of PCS REVERSAL processing - RHEADER has everything
  1. ; Make it look like a prescription multiple
  1. ; It has no GS or FS stuff, so everything is in RHEADERR
  1. N X S X=RHEADERR
  1. I FDATA(501)="A" D ; accepted reversal
  1. .S FDATA("M",1,503)=$E(X,6,19)
  1. .S FDATA("M",1,504)=$E(X,20,$L(X))
  1. E I FDATA(501)="R" D ; rejected reversal
  1. .S FDATA("M",1,510)=$E(X,6,7)
  1. .N I F I=8:2:26 D
  1. ..S FDATA("M",1,511,I-8/2+1)=$E(X,I,I+1)
  1. .S FDATA("M",1,504)=$E(X,28,100)
  1. E D ; corrupt
  1. .S FDATA("M",1,504)=X
  1. S MEDN=1
  1. Q
  1. ;---------------------------------------------------------------------
  1. ;Process Optional Response Information Section
  1. ;
  1. ;Parameters: MEDN - Current medication sequence #
  1. ; RDATAO - Optional response information section
  1. ;---------------------------------------------------------------------
  1. OPTR(MEDN,RDATAO) ;
  1. ;Manage local variables
  1. N INDEX,ID,XDATA
  1. ;
  1. ;Make sure input variables are defined
  1. Q:$G(MEDN)=""
  1. Q:$G(RDATAO)=""
  1. ;
  1. F INDEX=1:1:$L(RDATAO,FS) D
  1. .S FDATA=$P(RDATAO,FS,INDEX)
  1. .Q:FDATA=""
  1. .;
  1. .S ID=$E(FDATA,1,2)
  1. .S XDATA=$E(FDATA,3,$L(FDATA))
  1. .I ID="F9" S FDATA("M",MEDN,509)=XDATA Q ; PCS 1997 Packet Emulator Test #2 sends Patient Pay Amount here - mistakenly? Let's record it anyhow.
  1. .I ID="FC" S FDATA("M",MEDN,512)=XDATA Q
  1. .I ID="FD" S FDATA("M",MEDN,513)=XDATA Q
  1. .I ID="FE" S FDATA("M",MEDN,514)=XDATA Q
  1. .I ID="FH" S FDATA("M",MEDN,517)=XDATA Q
  1. .I ID="FI" S FDATA("M",MEDN,518)=XDATA Q
  1. .I ID="FJ" S FDATA("M",MEDN,519)=XDATA Q
  1. .I ID="FK" S FDATA("M",MEDN,520)=XDATA Q
  1. .I ID="FL" S FDATA("M",MEDN,521)=XDATA Q
  1. .I ID="FM" S FDATA("M",MEDN,522)=XDATA Q
  1. .I ID="FN" S FDATA("M",MEDN,523)=XDATA Q
  1. .I ID="FP" D Q
  1. . . I XDATA?159" "1N Q ; no DUR data, just the overflow flag
  1. . . S FDATA("M",MEDN,525)=XDATA
  1. .I ID="FQ" S FDATA("M",MEDN,526)=XDATA Q
  1. Q
  1. AKMEDFIX ; as noted, above ; Alaska Medicaid while sleeping - you get
  1. ; this corrupt message. May be true of other insurers, too.
  1. ; This looks like it might be an NDC message.
  1. ; We'll find out as time goes on.
  1. ; Here - we make sure that it's one of those packets,
  1. ; and we insert GS characters so that it parses correctly.
  1. I $E(RREC,7,21)'="FO R0199" Q
  1. I $E(RREC,1,5)'?1"3C0"1N1"A" Q
  1. I $E(RREC,6)'=FS Q
  1. I $E(RREC,22,59)'?." " Q
  1. I $E(RREC,60,99)'="PRT010 CARRIER DISABLED -B1ON99CR" Q
  1. N NPIECES S NPIECES=$L(RREC,"R0199") ; = header + 1 for each claim
  1. I NPIECES-1'=$E(RREC,4) Q
  1. ; Length requirement: don't be so strict if it's only one piece
  1. ; We have seen this packet be 439 bytes on day, but 421 the next
  1. ; (See ANMC devel. system 9002313.03, `249; 11/04/2000 - 421 bytes.
  1. ; Compare with `247 from 11/03/2000 - 439 bytes)
  1. I NPIECES>1,NPIECES-1*423+16'=$L(RREC) Q
  1. ; Okay, we're pretty sure this is it! Insert the GS characters.
  1. N X S X=$E(RREC,1,16)
  1. N I F I=17:423:$L(RREC) S X=X_GS_$E(RREC,I,I+423-1)
  1. S RREC=X
  1. Q