IBCNEHL3 ;DAOU/ALA - HL7 Process Incoming RPI Continued ;03-JUL-2002 ; Compiled June 2, 2005 14:20:19
;;2.0;INTEGRATED BILLING;**300,416,497,506,595,621,602,737**;21-MAR-94;Build 19
;;Per VA Directive 6402, this routine should not be modified.
;
;**Program Description**
; This is a continuation of IBCNEHL1 which processes an incoming
; RPI IIV message.
;
; This routine is based on IBCNEHLS which was introduced with patch 184, and subsequently
; patched with patch 271. IBCNEHLS is obsolete and deleted with patch 300.
;
;
Q ; no direct calls allow
;
ERROR(TQN,ERACT,ERCON,TRCN) ; Entry point
; Input: TQN - IEN for eIV Transmission Queue (#365.1), required
; ERACT - Error Action Code (#365.14), required
; ERCON - Error Condition Code (#365.17), required
; TRCN - Trace # from eIV Response (#365)
;
; IIVSTAT - IIV status transmitted by EC
; Note: MAP(IIVSTAT) = IIV STATUS IEN
N MSG,ERDESC,ERIEN,XMY,DA,DIE,DR
;
I $G(TQN)="" G ERRORX
;
;/Removed the following lines of code as part of IB*2.0*506 but wanted to
;/leave this code available if it should be needed in the future.
; Scenarios:
; #1 - If error message = "Resubmission Allowed" OR "Please Resubmit
; Original Transaction" - set TQ
; Fut Trans Dt to T + Comm Failure Days and Status to "Hold"
;I ERACT="R"!(ERACT="P") D G ERRORX
;. I $P($G(^IBCN(365.1,TQN,0)),U,9)="" D Q ; first time payer asked us to resubmit
;. . ; Update IIV TQ fields: "Hold" (4), IIV Site Param Comm Failure Days
;. . D UPDATE(TQN,4,+$P($G(^IBE(350.9,1,51)),U,5),ERACT)
;. . ;
;. ; payer asked us to resubmit for the 2nd time for this inquiry
;. ; Update IIV TQ fields: "Response Received" (3), n/a ("")
;. D UPDATE(TQN,3,"",ERACT,ERCON)
;. ; clear future transmission date so it won't display in the buffer
;. S DA=TQN,DIE="^IBCN(365.1,",DR=".09///@" D ^DIE
;
; #2 - If error message = "Please Wait 30 Days and Resubmit" - set TQ
; Fut Trans Dt to T + 30 and Status to "Hold"
;I ERACT="W" D G ERRORX
;. ; Update IIV TQ fields: "Hold" (4), 30
;. D UPDATE(TQN,4,30,ERACT)
;
; #3 - If error message = "Please Wait 10 Days and Resubmit" - set TQ
; Fut Trans Dt to T + 10 and Status to "Hold"
;I ERACT="X" D G ERRORX
;. ; Update IIV TQ fields: "Hold" (4), 10
;. D UPDATE(TQN,4,10,ERACT)
;
; #4 - If error message = "Resubmission Not Allowed" or
; "Do not resubmit ...." OR "Please correct and resubmit"
; - set TQ Status to "Response Received"
; If we receive error txt, treat as an "N"
;I ERACT="" S ERACT="N"
;I ERACT="N"!(ERACT="Y")!(ERACT="S")!(ERACT="C") D G ERRORX
;. ; Update IIV TQ fields: "Response Received" (3), n/a ("")
;. D UPDATE(TQN,3,"",ERACT,ERCON)
;
; #5 - Error message is unfamiliar - new Error Action Code
; *** Currently processed in IBCNEHL1 ***
;/End of removed code for IB*2.0*506
;
; /IB*2.0*506 Beginning
; For all Scenarios 1 thru 5, set TQ Status to "Response Received"
I ERACT="" S ERACT="N"
I ",R,P,W,X,N,Y,S,C,"[(","_ERACT_",") D G ERRORX
. ; Update IIV TQ fields: "Response Received" (3), n/a ("")
. D UPDATE(TQN,3,"",ERACT,ERCON)
; /IB*2.0*506 End
;
ERRORX ; ERROR exit pt
Q
;
UPDATE(TQN,TSTS,TDAYS,ERACT,ERCON) ; Update Transmission Queue (#365.1)
; Update/Create Buffer information as necessary
; * If unsolicited error or negative Verification response do not
; update TQ entry. However, create a new Buffer entry.
; Input Variables
; ERACT,ERCON,IIVSTAT,TDAYS,TQN,TSTS
;
; Output Variables
; IIVSTAT (updated)
;
; Init optional param
S ERCON=$G(ERCON)
;
; Init vars
N D,D0,DA,DFN,DI,DIC,DIE,DQ,DR,FTDT,IBDATA,IBIEN,IBQFL,IBSTS,IBSYM
N INSIEN,RSTYPE,SYMBOL,TQDATA,X
;
; If no ZEB segment received, set IIVSTAT to "V"
I $TR(IIVSTAT," ")="" S IIVSTAT="V"
;
S TQDATA=$G(^IBCN(365.1,TQN,0))
I TQDATA="" G UPDATX
;
; Ins Buffer IEN
S IBIEN=$P(TQDATA,U,5)
S IBQFL=$P(TQDATA,U,11)
S RSTYPE=$P($G(^IBCN(365,RIEN,0)),U,10)
;
; If unsolicited error or negative Identification response DON'T
; update TQ entry or Buffer (includes not creating a new buffer)
I RSTYPE="U",(IBQFL="I") G UPDATX
;
I RSTYPE="U" S IBIEN="" ; makes sure a new buffer is created
;
; Ins Buffer processing
I IBIEN'="" D
. ; Ins Buf data
. S IBDATA=$G(^IBA(355.33,+IBIEN,0))
. S IBSTS=$P(IBDATA,U,4) ; Status
. S IBSYM=$P(IBDATA,U,12) ; Symbol
. ; If IB status is (A)ccepted or (R)ejected or IB symbol is "*"
. ; (verified) or IB symbol is "-" (denied), update TQ status to
. ; Resp Rec'd (3) and DON'T update the Ins Buffer symbol
. I IBSTS="A"!(IBSTS="R")!(IBSYM=8)!(IBSYM=9) S TSTS=3 Q
. ; If TQ status is "Hold", update buffer symbol to "?" (10)
. I TSTS=4 D BUFF^IBCNEUT2(IBIEN,10) Q ; Set buffer symbol to "?"
. ; If TQ status is "Response Received", update buffer symbol to "-" (9) for Error
. ; Action Codes ('N','Y','S') & Action Codes ('P','R', if 2nd time payer sent that code)
. I TSTS=3,(ERACT="N"!(ERACT="Y")!(ERACT="S")!(ERACT="C")!(ERACT="P")!(ERACT="R")) D Q
.. S SYMBOL=MAP(IIVSTAT)
.. D BUFF^IBCNEUT2(IBIEN,SYMBOL) ; Set buffer symbol to EC value
.. D IIVPROC(IBIEN) ; Set IIV process date & IIV status
. ; If TQ status is "Response Received", update buffer symbol to "!" (12 = B9) for new Error Action Code
. I TSTS=3,",W,X,R,P,C,N,Y,S,"'[(","_ERACT_",") D BUFF^IBCNEUT2(IBIEN,22) Q
;
; Non-Ins Buffer processing, create entry only for Verification queries
I IBIEN="",IBQFL="V" D
. ; Determine Patient DFN
. S DFN=$P(TQDATA,U,2)
. ; Determine Patient Ins record IEN
. S INSIEN=$P(TQDATA,U,13) ; If INSIEN="" avoids TQ update
. ; If ERACT="C" symbol is passed by EC
. I ERACT="C" S SYMBOL=MAP(IIVSTAT) D BUF Q
. ; Resubmission Not Allowed or Do Not Resubmit ...
. I ERACT="N"!(ERACT="Y")!(ERACT="S") S SYMBOL=MAP(IIVSTAT) D BUF Q
. ; An unknown error action - generate a '#'
. I ",W,X,R,P,C,N,Y,S,"'[(","_ERACT_",") S SYMBOL=22 D BUF Q
;
I RSTYPE="U" G UPDATX ; finished creating new buffer
;
; Update TQ record - Status
D SST^IBCNEUT2(TQN,TSTS)
;
; If TQ Status = "Hold", update TQ record - Future Transmission Date
I TSTS=4,+$G(TDAYS) D
. S FTDT=$$FMADD^XLFDT($$DT^XLFDT,TDAYS)
. S DIE="^IBCN(365.1,",DA=TQN,DR=".09///^S X=FTDT"
. D ^DIE
I TSTS=4,$P(TQDATA,U,8) D
. S DIE="^IBCN(365.1,",DA=TQN,DR=".08///0"
. D ^DIE
;
UPDATX ; UPDATE exit point
Q
;
PCK ; Payer Check
; Find the associated Response IEN
;
; Input Variables
; MSGID
;
; Output Variables
; RIEN,ERFLG
;
;IB*737/TAZ - Remove references to Most Popular Payer and "~NO PAYER"
;
N BUFF,DA,DFN,DIE,DR,IEN,IERN,IN1DATA,MDTM,QFL,PAYR,PIEN,PP
N PRDATA,PRIEN,RSIEN,X
N TQIEN
;
K ^TMP("IBCNEMID",$J)
D FIND^DIC(365,"","","P",MSGID,"","B","","","^TMP(""IBCNEMID"",$J)")
;
S PP=0,QFL=0,(RIEN,PIEN)=""
S TQIEN=$O(^IBCN(365.1,"C",MSGID,""))
F S PP=$O(^TMP("IBCNEMID",$J,"DILIST",PP)) Q:'PP D Q:QFL
. S PRIEN=$P(^TMP("IBCNEMID",$J,"DILIST",PP,0),U,1)
. ;
. ; If this is a response w/o an IN1 segment
. ; Get payer IEN from TQ as original response shell will change
. ; if a payer response is received
. S IN1DATA=$S(EVENTYP=1:"",1:$$GIN1()) ; IB*2.0*621
. I IN1DATA="",PRIEN'="",TQIEN'="" D
.. S QFL=1,PIEN=$P(^IBCN(365.1,TQIEN,0),U,3)
. ;
. I 'PIEN D PFN(IN1DATA) I 'PIEN S QFL=1 Q
. ;
. ; If message id/payer found & Response (#365) status is NOT
. ; 'Response Received' update the existing response entry (set RIEN)
. I $P(^IBCN(365,PRIEN,0),U,3)=PIEN,($P(^IBCN(365,PRIEN,0),U,6)'=3) D Q
.. S RIEN=PRIEN,QFL=1
..;
..; If message id/payer found & Response (#365) status equals
. ; 'Response Received', RIEN is still null so that this tag knows
. ; to create a new unsolicited response entry
;
; If message id/payer not found or unsolicited response, create new response entry
I RIEN="" D Q:ERFLG
. I $G(PRIEN)'="" D
.. S PRDATA=$G(^IBCN(365,PRIEN,0))
.. S DFN=$P(PRDATA,U,2),IEN=$P(PRDATA,U,5),MDTM=$P(PRDATA,U,8)
. ;
. I PIEN="" D Q:ERFLG
.. S IN1DATA=$$GIN1()
.. I IN1DATA]"" D PFN(IN1DATA) I 'PIEN S PIEN="",QFL=1
. S PAYR=PIEN,(RSTYPE,BUFF)=""
. ;I MDTM="" S MDTM=$$NOW^XLFDT
. D RESP^IBCNEDEQ
. S RIEN=RSIEN
;
; If no payer in response file, set it
; IB*2*595/DM correctly identify a payer when the payer name begins with numbers
I $G(PIEN)'="",$G(RIEN)'="",$P($G(^IBCN(365,RIEN,0)),U,3)="" D
. S DIE="^IBCN(365,",DA=RIEN,DR=".03////^S X=PIEN" D ^DIE ;stuff internal value for payer
Q
;
BUF ; Create Buffer Record if Doesn't Exist
;
; Input Variables
; RIEN,RSTYPE,TQN
;
; Output Variables
; ERROR,SYMBOL is killed,TQIEN and IRIEN may be reset
;
N BUFF,IBFDA,UP
I $G(RSTYPE)="U" S (TQIEN,IRIEN)=""
D RP^IBCNEBF(RIEN,1)
S BUFF=+IBFDA
S UP(365,RIEN_",",.04)=+IBFDA
I RSTYPE="O" S UP(365.1,TQN_",",.05)=+IBFDA
D FILE^DIE("I","UP","ERROR")
K SYMBOL
Q
;
IIVPROC(BUFF) ; Set IIV Processed Date to current dt/tm & IIV stat (aka SYMBOL)
; Input Variables
; BUFF
;
; Output Variables
; SYMBOL
;
N IDUZ,UP
S UP(355.33,BUFF_",",.15)=$$NOW^XLFDT()
; Set IDUZ to the specific, non-human user.
S IDUZ=$$FIND1^DIC(200,"","X","INTERFACE,IB EIV")
D FILE^DIE("I","UP","ERROR")
; set the symbol of the buffer entry
D BUFF^IBCNEUT2(BUFF,SYMBOL) ; reset symbol to appropriate value
Q
;
PFN(IN1DATA) ; Find Payer from HL7 msg
;
; Input Variables
; IN1DATA, TRACE
;
; Output Variables
; ERFLG,ERROR,PIEN
;
N IERN,PAYRID
S PAYRID=$$CLNSTR^IBCNEHLU($P($P(IN1DATA,HLFS,4),$E(HL("ECH"))),HL("ECH"),$E(HL("ECH")))
S PIEN=+$$FIND1^DIC(365.12,"","MX",PAYRID)
I PIEN=0 D Q
. S ERFLG=1,IERN=$$ERRN^IBCNEUT7("ERROR(""DIERR"")")
. S ERROR("DIERR",IERN,"TEXT",1)="National Id: "_PAYRID_" not found in Payer Table"
. S ERROR("DIERR",IERN,"TEXT",2)="for Trace Number: "_TRACE
Q
;
GIN1() ;Get IN1 segment
;
; Input Variables
; HCT
;
; Returns value of SEGMT
;
N IPCT,SEGMT
S IPCT=HCT,SEGMT=""
F S IPCT=$O(^TMP($J,"IBCNEHLI",IPCT)) Q:IPCT="" D
. I $E(^TMP($J,"IBCNEHLI",IPCT,0),1,3)="IN1" S SEGMT=^TMP($J,"IBCNEHLI",IPCT,0)
Q SEGMT
;
; =================================================================
WARN ; Create and send a response processing error warning message
;
; Input Variables
; ERROR, TRACE
;
; Output Variables
; ERFLG=1
;
N MCT,MSG,SUBCNT,VEN,XMY
S VEN=0,MCT=9,ERFLG=1,SUBCNT=""
S MSG(1)="IMPORTANT: Error While Processing Response Message from the EC"
S MSG(2)="-------------------------------------------------------------"
S MSG(3)="*** IRM *** Please contact Help Desk because the"
S MSG(4)="response message received from the Eligibility Communicator"
S MSG(5)="could not be processed. Programming changes may be necessary"
S MSG(6)="to properly handle the response."
S MSG(7)="The associated Trace # is "_$S($G(TRACE)="":"Unknown",1:TRACE)_". If applicable,"
S MSG(8)="please review the response with the eIV Response Report by Trace#."
S MSG(9)=" "
F S VEN=$O(ERROR("DIERR",VEN)) Q:'VEN D
.S MCT=MCT+1,MSG(MCT)="Error:"
.F S SUBCNT=$O(ERROR("DIERR",VEN,"TEXT",SUBCNT)) Q:'SUBCNT S MCT=MCT+1,MSG(MCT)=ERROR("DIERR",VEN,"TEXT",SUBCNT)
.S MCT=MCT+1,MSG(MCT)=" "
.I $G(ERROR("DIERR",VEN,"PARAM","FILE"))'="" S MCT=MCT+1,MSG(MCT)="File: "_ERROR("DIERR",VEN,"PARAM","FILE")
.I $G(ERROR("DIERR",VEN,"PARAM","IENS"))'="" S MCT=MCT+1,MSG(MCT)="IENS: "_ERROR("DIERR",VEN,"PARAM","IENS")
.I $G(ERROR("DIERR",VEN,"PARAM","FIELD"))'="" S MCT=MCT+1,MSG(MCT)="Field: "_ERROR("DIERR",VEN,"PARAM","FIELD")
.S MCT=MCT+1,MSG(MCT)=" "
.Q
D MSG^IBCNEUT5(MGRP,MSG(1),"MSG(",,.XMY)
Q
;
; =================================================================
UEACT ; Send warning msg if Unknown Error Action Code was received or
; encountered problem filing date
;
; Input Variables
; ERROR, IBIEN, IBQFL, RIEN, RSTYPE, TQDATA, TRACE
;
; Output Variables
; ERFLG=1 (SET IN WARN TAG)
;
N DFN,SYMBOL
D WARN ; send warning msg
;
; If the response could not be created or there is no associated TQ entry, stop processing
I '$G(RIEN)!(TQDATA="") Q
;
; For an original response, set the Transmission Queue Status to 'Response Received' &
; update remaining retries to comm failure (5)
I $G(RSTYPE)="O" D SST^IBCNEUT2(TQN,3),RSTA^IBCNEUT7(TQN)
;
; If it is an identification and policy is not active don't
; create buffer entry
I IBQFL="I",IIVSTAT'=1 Q
;
; If unsolicited message or no buffer in TQ, create new buffer entry
I RSTYPE="U" S IBIEN=""
I IBIEN="" D Q
. S DFN=$P(TQDATA,U,2) ; Determine Patient DFN
. S SYMBOL=22 D BUF^IBCNEHL3 ; Create a new buffer entry
;
;Update buffer symbol
D BUFF^IBCNEUT2(IBIEN,22)
;
Q
;
CHK1() ; check auto-update criteria for patient who is the subscriber
; called from tag AUTOUPD, uses variables defined there
;
; returns 1 if given policy satisfies auto-update criteria, returns 0 otherwise
N RES
S RES=0
I $P(RDATA13,U,2)'=$P(IDATA7,U,2) G CHK1X ; Subscriber ID doesn't match ; IB*2.0*497 compare subscriber ID data at their new locations
I $P(RDATA1,U,2)'=$P(IDATA3,U) G CHK1X ; DOB doesn't match
I '$$NAMECMP^IBCNEHLU($P(RDATA13,U),$P(IDATA7,U)) G CHK1X ; Insured's name doesn't match ; IB*2.0*497 compare name of insured data at their new locations
S RES=1
CHK1X ;
Q RES
;
CHK2(MWNRTYP) ; check auto-update criteria for patient who is not the subscriber
; called from tag AUTOUPD, uses variables defined there
;
; returns 1 if policy satisfies auto-update criteria, returns 0 otherwise
N DOB,ID,IDATA5,IENS,NAME,PDOB,PNAME,RES
S RES=0
S IDATA5=$G(^DPT(IEN2,.312,IEN312,5))
S IENS=IEN2_","
S ID=$P(RDATA13,U,2) ; IB*2.0*497 Subscriber ID needs to be retrieved from its new location
I ID'=$P(IDATA7,U,2),ID'=$P(IDATA5,U) G CHK2X ; both Subscriber ID and Patient ID don't match ; IB*2.0*497 compare subscriber ID at new locations
S DOB=$P(RDATA1,U,2),PDOB=$$GET1^DIQ(2,IENS,.03,"I")
I DOB'=$P(IDATA3,U),DOB'=PDOB G CHK2X ; both Subscriber and Patient DOB don't match
S NAME=$P(RDATA13,U),PNAME=$$GET1^DIQ(2,IENS,.01) ; IB*2.0*497 get name of insured at its new location
I '+MWNRTYP,'$$NAMECMP^IBCNEHLU(NAME,$P(IDATA7,U)),'$$NAMECMP^IBCNEHLU(NAME,PNAME) G CHK2X ; non-Medicare, both Subscriber and Patient name don't match ; IB*2*497
I +MWNRTYP,'$$NAMECMP^IBCNEHLU(NAME,PNAME) G CHK2X ; Medicare, Patient name doesn't match
S RES=1
CHK2X ;
Q RES
;
UPDIREC(RIEN,IEN312) ; IB*2*595/DM update INSUR RECORD IEN in the response file (#365,.12)
; RIEN - ien in eIV Response file (365)
; IEN312 - ien in pat. insurance multiple (2.312)
;
N DATA,ERROR,IENS
I RIEN'>0!(IEN312'>0) Q
; IB*2*595/DM do not update TQ file.
; The proper INSUR RECORD IEN field is now located in the response file
;S IENS=$P($G(^IBCN(365,RIEN,0)),U,5)_"," I IENS="," Q
;S DATA(365.1,IENS,.13)=IEN312
S DATA(365,RIEN_",",.12)=IEN312
D FILE^DIE("ET","DATA","ERROR")
Q
;
LCKERR ; send locking error message
N MSG,XMY
S MSG(1)="WARNING: Unable to Auto-file Response Message from the EC"
S MSG(2)="---------------------------------------------------------"
S MSG(3)="Failed to lock patient insurance entry:"
S MSG(4)=" Patient name - "_$$GET1^DIQ(2,DFN_",",.01)
S MSG(5)=" Insurance - "_$$GET1^DIQ(2.312,IENS,.01)
S MSG(6)=" IENS - "_$S($G(IENS)="":"Unknown",1:IENS)
S MSG(7)=" "
S MSG(8)="The response will be filed into Insurance Buffer instead."
S MSG(9)=" "
D MSG^IBCNEUT5(MGRP,MSG(1),"MSG(",,.XMY)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNEHL3 15720 printed Nov 22, 2024@17:24:41 Page 2
IBCNEHL3 ;DAOU/ALA - HL7 Process Incoming RPI Continued ;03-JUL-2002 ; Compiled June 2, 2005 14:20:19
+1 ;;2.0;INTEGRATED BILLING;**300,416,497,506,595,621,602,737**;21-MAR-94;Build 19
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ;**Program Description**
+5 ; This is a continuation of IBCNEHL1 which processes an incoming
+6 ; RPI IIV message.
+7 ;
+8 ; This routine is based on IBCNEHLS which was introduced with patch 184, and subsequently
+9 ; patched with patch 271. IBCNEHLS is obsolete and deleted with patch 300.
+10 ;
+11 ;
+12 ; no direct calls allow
QUIT
+13 ;
ERROR(TQN,ERACT,ERCON,TRCN) ; Entry point
+1 ; Input: TQN - IEN for eIV Transmission Queue (#365.1), required
+2 ; ERACT - Error Action Code (#365.14), required
+3 ; ERCON - Error Condition Code (#365.17), required
+4 ; TRCN - Trace # from eIV Response (#365)
+5 ;
+6 ; IIVSTAT - IIV status transmitted by EC
+7 ; Note: MAP(IIVSTAT) = IIV STATUS IEN
+8 NEW MSG,ERDESC,ERIEN,XMY,DA,DIE,DR
+9 ;
+10 IF $GET(TQN)=""
GOTO ERRORX
+11 ;
+12 ;/Removed the following lines of code as part of IB*2.0*506 but wanted to
+13 ;/leave this code available if it should be needed in the future.
+14 ; Scenarios:
+15 ; #1 - If error message = "Resubmission Allowed" OR "Please Resubmit
+16 ; Original Transaction" - set TQ
+17 ; Fut Trans Dt to T + Comm Failure Days and Status to "Hold"
+18 ;I ERACT="R"!(ERACT="P") D G ERRORX
+19 ;. I $P($G(^IBCN(365.1,TQN,0)),U,9)="" D Q ; first time payer asked us to resubmit
+20 ;. . ; Update IIV TQ fields: "Hold" (4), IIV Site Param Comm Failure Days
+21 ;. . D UPDATE(TQN,4,+$P($G(^IBE(350.9,1,51)),U,5),ERACT)
+22 ;. . ;
+23 ;. ; payer asked us to resubmit for the 2nd time for this inquiry
+24 ;. ; Update IIV TQ fields: "Response Received" (3), n/a ("")
+25 ;. D UPDATE(TQN,3,"",ERACT,ERCON)
+26 ;. ; clear future transmission date so it won't display in the buffer
+27 ;. S DA=TQN,DIE="^IBCN(365.1,",DR=".09///@" D ^DIE
+28 ;
+29 ; #2 - If error message = "Please Wait 30 Days and Resubmit" - set TQ
+30 ; Fut Trans Dt to T + 30 and Status to "Hold"
+31 ;I ERACT="W" D G ERRORX
+32 ;. ; Update IIV TQ fields: "Hold" (4), 30
+33 ;. D UPDATE(TQN,4,30,ERACT)
+34 ;
+35 ; #3 - If error message = "Please Wait 10 Days and Resubmit" - set TQ
+36 ; Fut Trans Dt to T + 10 and Status to "Hold"
+37 ;I ERACT="X" D G ERRORX
+38 ;. ; Update IIV TQ fields: "Hold" (4), 10
+39 ;. D UPDATE(TQN,4,10,ERACT)
+40 ;
+41 ; #4 - If error message = "Resubmission Not Allowed" or
+42 ; "Do not resubmit ...." OR "Please correct and resubmit"
+43 ; - set TQ Status to "Response Received"
+44 ; If we receive error txt, treat as an "N"
+45 ;I ERACT="" S ERACT="N"
+46 ;I ERACT="N"!(ERACT="Y")!(ERACT="S")!(ERACT="C") D G ERRORX
+47 ;. ; Update IIV TQ fields: "Response Received" (3), n/a ("")
+48 ;. D UPDATE(TQN,3,"",ERACT,ERCON)
+49 ;
+50 ; #5 - Error message is unfamiliar - new Error Action Code
+51 ; *** Currently processed in IBCNEHL1 ***
+52 ;/End of removed code for IB*2.0*506
+53 ;
+54 ; /IB*2.0*506 Beginning
+55 ; For all Scenarios 1 thru 5, set TQ Status to "Response Received"
+56 IF ERACT=""
SET ERACT="N"
+57 IF ",R,P,W,X,N,Y,S,C,"[(","_ERACT_",")
Begin DoDot:1
+58 ; Update IIV TQ fields: "Response Received" (3), n/a ("")
+59 DO UPDATE(TQN,3,"",ERACT,ERCON)
End DoDot:1
GOTO ERRORX
+60 ; /IB*2.0*506 End
+61 ;
ERRORX ; ERROR exit pt
+1 QUIT
+2 ;
UPDATE(TQN,TSTS,TDAYS,ERACT,ERCON) ; Update Transmission Queue (#365.1)
+1 ; Update/Create Buffer information as necessary
+2 ; * If unsolicited error or negative Verification response do not
+3 ; update TQ entry. However, create a new Buffer entry.
+4 ; Input Variables
+5 ; ERACT,ERCON,IIVSTAT,TDAYS,TQN,TSTS
+6 ;
+7 ; Output Variables
+8 ; IIVSTAT (updated)
+9 ;
+10 ; Init optional param
+11 SET ERCON=$GET(ERCON)
+12 ;
+13 ; Init vars
+14 NEW D,D0,DA,DFN,DI,DIC,DIE,DQ,DR,FTDT,IBDATA,IBIEN,IBQFL,IBSTS,IBSYM
+15 NEW INSIEN,RSTYPE,SYMBOL,TQDATA,X
+16 ;
+17 ; If no ZEB segment received, set IIVSTAT to "V"
+18 IF $TRANSLATE(IIVSTAT," ")=""
SET IIVSTAT="V"
+19 ;
+20 SET TQDATA=$GET(^IBCN(365.1,TQN,0))
+21 IF TQDATA=""
GOTO UPDATX
+22 ;
+23 ; Ins Buffer IEN
+24 SET IBIEN=$PIECE(TQDATA,U,5)
+25 SET IBQFL=$PIECE(TQDATA,U,11)
+26 SET RSTYPE=$PIECE($GET(^IBCN(365,RIEN,0)),U,10)
+27 ;
+28 ; If unsolicited error or negative Identification response DON'T
+29 ; update TQ entry or Buffer (includes not creating a new buffer)
+30 IF RSTYPE="U"
IF (IBQFL="I")
GOTO UPDATX
+31 ;
+32 ; makes sure a new buffer is created
IF RSTYPE="U"
SET IBIEN=""
+33 ;
+34 ; Ins Buffer processing
+35 IF IBIEN'=""
Begin DoDot:1
+36 ; Ins Buf data
+37 SET IBDATA=$GET(^IBA(355.33,+IBIEN,0))
+38 ; Status
SET IBSTS=$PIECE(IBDATA,U,4)
+39 ; Symbol
SET IBSYM=$PIECE(IBDATA,U,12)
+40 ; If IB status is (A)ccepted or (R)ejected or IB symbol is "*"
+41 ; (verified) or IB symbol is "-" (denied), update TQ status to
+42 ; Resp Rec'd (3) and DON'T update the Ins Buffer symbol
+43 IF IBSTS="A"!(IBSTS="R")!(IBSYM=8)!(IBSYM=9)
SET TSTS=3
QUIT
+44 ; If TQ status is "Hold", update buffer symbol to "?" (10)
+45 ; Set buffer symbol to "?"
IF TSTS=4
DO BUFF^IBCNEUT2(IBIEN,10)
QUIT
+46 ; If TQ status is "Response Received", update buffer symbol to "-" (9) for Error
+47 ; Action Codes ('N','Y','S') & Action Codes ('P','R', if 2nd time payer sent that code)
+48 IF TSTS=3
IF (ERACT="N"!(ERACT="Y")!(ERACT="S")!(ERACT="C")!(ERACT="P")!(ERACT="R"))
Begin DoDot:2
+49 SET SYMBOL=MAP(IIVSTAT)
+50 ; Set buffer symbol to EC value
DO BUFF^IBCNEUT2(IBIEN,SYMBOL)
+51 ; Set IIV process date & IIV status
DO IIVPROC(IBIEN)
End DoDot:2
QUIT
+52 ; If TQ status is "Response Received", update buffer symbol to "!" (12 = B9) for new Error Action Code
+53 IF TSTS=3
IF ",W,X,R,P,C,N,Y,S,"'[(","_ERACT_",")
DO BUFF^IBCNEUT2(IBIEN,22)
QUIT
End DoDot:1
+54 ;
+55 ; Non-Ins Buffer processing, create entry only for Verification queries
+56 IF IBIEN=""
IF IBQFL="V"
Begin DoDot:1
+57 ; Determine Patient DFN
+58 SET DFN=$PIECE(TQDATA,U,2)
+59 ; Determine Patient Ins record IEN
+60 ; If INSIEN="" avoids TQ update
SET INSIEN=$PIECE(TQDATA,U,13)
+61 ; If ERACT="C" symbol is passed by EC
+62 IF ERACT="C"
SET SYMBOL=MAP(IIVSTAT)
DO BUF
QUIT
+63 ; Resubmission Not Allowed or Do Not Resubmit ...
+64 IF ERACT="N"!(ERACT="Y")!(ERACT="S")
SET SYMBOL=MAP(IIVSTAT)
DO BUF
QUIT
+65 ; An unknown error action - generate a '#'
+66 IF ",W,X,R,P,C,N,Y,S,"'[(","_ERACT_",")
SET SYMBOL=22
DO BUF
QUIT
End DoDot:1
+67 ;
+68 ; finished creating new buffer
IF RSTYPE="U"
GOTO UPDATX
+69 ;
+70 ; Update TQ record - Status
+71 DO SST^IBCNEUT2(TQN,TSTS)
+72 ;
+73 ; If TQ Status = "Hold", update TQ record - Future Transmission Date
+74 IF TSTS=4
IF +$GET(TDAYS)
Begin DoDot:1
+75 SET FTDT=$$FMADD^XLFDT($$DT^XLFDT,TDAYS)
+76 SET DIE="^IBCN(365.1,"
SET DA=TQN
SET DR=".09///^S X=FTDT"
+77 DO ^DIE
End DoDot:1
+78 IF TSTS=4
IF $PIECE(TQDATA,U,8)
Begin DoDot:1
+79 SET DIE="^IBCN(365.1,"
SET DA=TQN
SET DR=".08///0"
+80 DO ^DIE
End DoDot:1
+81 ;
UPDATX ; UPDATE exit point
+1 QUIT
+2 ;
PCK ; Payer Check
+1 ; Find the associated Response IEN
+2 ;
+3 ; Input Variables
+4 ; MSGID
+5 ;
+6 ; Output Variables
+7 ; RIEN,ERFLG
+8 ;
+9 ;IB*737/TAZ - Remove references to Most Popular Payer and "~NO PAYER"
+10 ;
+11 NEW BUFF,DA,DFN,DIE,DR,IEN,IERN,IN1DATA,MDTM,QFL,PAYR,PIEN,PP
+12 NEW PRDATA,PRIEN,RSIEN,X
+13 NEW TQIEN
+14 ;
+15 KILL ^TMP("IBCNEMID",$JOB)
+16 DO FIND^DIC(365,"","","P",MSGID,"","B","","","^TMP(""IBCNEMID"",$J)")
+17 ;
+18 SET PP=0
SET QFL=0
SET (RIEN,PIEN)=""
+19 SET TQIEN=$ORDER(^IBCN(365.1,"C",MSGID,""))
+20 FOR
SET PP=$ORDER(^TMP("IBCNEMID",$JOB,"DILIST",PP))
if 'PP
QUIT
Begin DoDot:1
+21 SET PRIEN=$PIECE(^TMP("IBCNEMID",$JOB,"DILIST",PP,0),U,1)
+22 ;
+23 ; If this is a response w/o an IN1 segment
+24 ; Get payer IEN from TQ as original response shell will change
+25 ; if a payer response is received
+26 ; IB*2.0*621
SET IN1DATA=$SELECT(EVENTYP=1:"",1:$$GIN1())
+27 IF IN1DATA=""
IF PRIEN'=""
IF TQIEN'=""
Begin DoDot:2
+28 SET QFL=1
SET PIEN=$PIECE(^IBCN(365.1,TQIEN,0),U,3)
End DoDot:2
+29 ;
+30 IF 'PIEN
DO PFN(IN1DATA)
IF 'PIEN
SET QFL=1
QUIT
+31 ;
+32 ; If message id/payer found & Response (#365) status is NOT
+33 ; 'Response Received' update the existing response entry (set RIEN)
+34 IF $PIECE(^IBCN(365,PRIEN,0),U,3)=PIEN
IF ($PIECE(^IBCN(365,PRIEN,0),U,6)'=3)
Begin DoDot:2
+35 SET RIEN=PRIEN
SET QFL=1
+36 ;
+37 ; If message id/payer found & Response (#365) status equals
End DoDot:2
QUIT
+38 ; 'Response Received', RIEN is still null so that this tag knows
+39 ; to create a new unsolicited response entry
End DoDot:1
if QFL
QUIT
+40 ;
+41 ; If message id/payer not found or unsolicited response, create new response entry
+42 IF RIEN=""
Begin DoDot:1
+43 IF $GET(PRIEN)'=""
Begin DoDot:2
+44 SET PRDATA=$GET(^IBCN(365,PRIEN,0))
+45 SET DFN=$PIECE(PRDATA,U,2)
SET IEN=$PIECE(PRDATA,U,5)
SET MDTM=$PIECE(PRDATA,U,8)
End DoDot:2
+46 ;
+47 IF PIEN=""
Begin DoDot:2
+48 SET IN1DATA=$$GIN1()
+49 IF IN1DATA]""
DO PFN(IN1DATA)
IF 'PIEN
SET PIEN=""
SET QFL=1
End DoDot:2
if ERFLG
QUIT
+50 SET PAYR=PIEN
SET (RSTYPE,BUFF)=""
+51 ;I MDTM="" S MDTM=$$NOW^XLFDT
+52 DO RESP^IBCNEDEQ
+53 SET RIEN=RSIEN
End DoDot:1
if ERFLG
QUIT
+54 ;
+55 ; If no payer in response file, set it
+56 ; IB*2*595/DM correctly identify a payer when the payer name begins with numbers
+57 IF $GET(PIEN)'=""
IF $GET(RIEN)'=""
IF $PIECE($GET(^IBCN(365,RIEN,0)),U,3)=""
Begin DoDot:1
+58 ;stuff internal value for payer
SET DIE="^IBCN(365,"
SET DA=RIEN
SET DR=".03////^S X=PIEN"
DO ^DIE
End DoDot:1
+59 QUIT
+60 ;
BUF ; Create Buffer Record if Doesn't Exist
+1 ;
+2 ; Input Variables
+3 ; RIEN,RSTYPE,TQN
+4 ;
+5 ; Output Variables
+6 ; ERROR,SYMBOL is killed,TQIEN and IRIEN may be reset
+7 ;
+8 NEW BUFF,IBFDA,UP
+9 IF $GET(RSTYPE)="U"
SET (TQIEN,IRIEN)=""
+10 DO RP^IBCNEBF(RIEN,1)
+11 SET BUFF=+IBFDA
+12 SET UP(365,RIEN_",",.04)=+IBFDA
+13 IF RSTYPE="O"
SET UP(365.1,TQN_",",.05)=+IBFDA
+14 DO FILE^DIE("I","UP","ERROR")
+15 KILL SYMBOL
+16 QUIT
+17 ;
IIVPROC(BUFF) ; Set IIV Processed Date to current dt/tm & IIV stat (aka SYMBOL)
+1 ; Input Variables
+2 ; BUFF
+3 ;
+4 ; Output Variables
+5 ; SYMBOL
+6 ;
+7 NEW IDUZ,UP
+8 SET UP(355.33,BUFF_",",.15)=$$NOW^XLFDT()
+9 ; Set IDUZ to the specific, non-human user.
+10 SET IDUZ=$$FIND1^DIC(200,"","X","INTERFACE,IB EIV")
+11 DO FILE^DIE("I","UP","ERROR")
+12 ; set the symbol of the buffer entry
+13 ; reset symbol to appropriate value
DO BUFF^IBCNEUT2(BUFF,SYMBOL)
+14 QUIT
+15 ;
PFN(IN1DATA) ; Find Payer from HL7 msg
+1 ;
+2 ; Input Variables
+3 ; IN1DATA, TRACE
+4 ;
+5 ; Output Variables
+6 ; ERFLG,ERROR,PIEN
+7 ;
+8 NEW IERN,PAYRID
+9 SET PAYRID=$$CLNSTR^IBCNEHLU($PIECE($PIECE(IN1DATA,HLFS,4),$EXTRACT(HL("ECH"))),HL("ECH"),$EXTRACT(HL("ECH")))
+10 SET PIEN=+$$FIND1^DIC(365.12,"","MX",PAYRID)
+11 IF PIEN=0
Begin DoDot:1
+12 SET ERFLG=1
SET IERN=$$ERRN^IBCNEUT7("ERROR(""DIERR"")")
+13 SET ERROR("DIERR",IERN,"TEXT",1)="National Id: "_PAYRID_" not found in Payer Table"
+14 SET ERROR("DIERR",IERN,"TEXT",2)="for Trace Number: "_TRACE
End DoDot:1
QUIT
+15 QUIT
+16 ;
GIN1() ;Get IN1 segment
+1 ;
+2 ; Input Variables
+3 ; HCT
+4 ;
+5 ; Returns value of SEGMT
+6 ;
+7 NEW IPCT,SEGMT
+8 SET IPCT=HCT
SET SEGMT=""
+9 FOR
SET IPCT=$ORDER(^TMP($JOB,"IBCNEHLI",IPCT))
if IPCT=""
QUIT
Begin DoDot:1
+10 IF $EXTRACT(^TMP($JOB,"IBCNEHLI",IPCT,0),1,3)="IN1"
SET SEGMT=^TMP($JOB,"IBCNEHLI",IPCT,0)
End DoDot:1
+11 QUIT SEGMT
+12 ;
+13 ; =================================================================
WARN ; Create and send a response processing error warning message
+1 ;
+2 ; Input Variables
+3 ; ERROR, TRACE
+4 ;
+5 ; Output Variables
+6 ; ERFLG=1
+7 ;
+8 NEW MCT,MSG,SUBCNT,VEN,XMY
+9 SET VEN=0
SET MCT=9
SET ERFLG=1
SET SUBCNT=""
+10 SET MSG(1)="IMPORTANT: Error While Processing Response Message from the EC"
+11 SET MSG(2)="-------------------------------------------------------------"
+12 SET MSG(3)="*** IRM *** Please contact Help Desk because the"
+13 SET MSG(4)="response message received from the Eligibility Communicator"
+14 SET MSG(5)="could not be processed. Programming changes may be necessary"
+15 SET MSG(6)="to properly handle the response."
+16 SET MSG(7)="The associated Trace # is "_$SELECT($GET(TRACE)="":"Unknown",1:TRACE)_". If applicable,"
+17 SET MSG(8)="please review the response with the eIV Response Report by Trace#."
+18 SET MSG(9)=" "
+19 FOR
SET VEN=$ORDER(ERROR("DIERR",VEN))
if 'VEN
QUIT
Begin DoDot:1
+20 SET MCT=MCT+1
SET MSG(MCT)="Error:"
+21 FOR
SET SUBCNT=$ORDER(ERROR("DIERR",VEN,"TEXT",SUBCNT))
if 'SUBCNT
QUIT
SET MCT=MCT+1
SET MSG(MCT)=ERROR("DIERR",VEN,"TEXT",SUBCNT)
+22 SET MCT=MCT+1
SET MSG(MCT)=" "
+23 IF $GET(ERROR("DIERR",VEN,"PARAM","FILE"))'=""
SET MCT=MCT+1
SET MSG(MCT)="File: "_ERROR("DIERR",VEN,"PARAM","FILE")
+24 IF $GET(ERROR("DIERR",VEN,"PARAM","IENS"))'=""
SET MCT=MCT+1
SET MSG(MCT)="IENS: "_ERROR("DIERR",VEN,"PARAM","IENS")
+25 IF $GET(ERROR("DIERR",VEN,"PARAM","FIELD"))'=""
SET MCT=MCT+1
SET MSG(MCT)="Field: "_ERROR("DIERR",VEN,"PARAM","FIELD")
+26 SET MCT=MCT+1
SET MSG(MCT)=" "
+27 QUIT
End DoDot:1
+28 DO MSG^IBCNEUT5(MGRP,MSG(1),"MSG(",,.XMY)
+29 QUIT
+30 ;
+31 ; =================================================================
UEACT ; Send warning msg if Unknown Error Action Code was received or
+1 ; encountered problem filing date
+2 ;
+3 ; Input Variables
+4 ; ERROR, IBIEN, IBQFL, RIEN, RSTYPE, TQDATA, TRACE
+5 ;
+6 ; Output Variables
+7 ; ERFLG=1 (SET IN WARN TAG)
+8 ;
+9 NEW DFN,SYMBOL
+10 ; send warning msg
DO WARN
+11 ;
+12 ; If the response could not be created or there is no associated TQ entry, stop processing
+13 IF '$GET(RIEN)!(TQDATA="")
QUIT
+14 ;
+15 ; For an original response, set the Transmission Queue Status to 'Response Received' &
+16 ; update remaining retries to comm failure (5)
+17 IF $GET(RSTYPE)="O"
DO SST^IBCNEUT2(TQN,3)
DO RSTA^IBCNEUT7(TQN)
+18 ;
+19 ; If it is an identification and policy is not active don't
+20 ; create buffer entry
+21 IF IBQFL="I"
IF IIVSTAT'=1
QUIT
+22 ;
+23 ; If unsolicited message or no buffer in TQ, create new buffer entry
+24 IF RSTYPE="U"
SET IBIEN=""
+25 IF IBIEN=""
Begin DoDot:1
+26 ; Determine Patient DFN
SET DFN=$PIECE(TQDATA,U,2)
+27 ; Create a new buffer entry
SET SYMBOL=22
DO BUF^IBCNEHL3
End DoDot:1
QUIT
+28 ;
+29 ;Update buffer symbol
+30 DO BUFF^IBCNEUT2(IBIEN,22)
+31 ;
+32 QUIT
+33 ;
CHK1() ; check auto-update criteria for patient who is the subscriber
+1 ; called from tag AUTOUPD, uses variables defined there
+2 ;
+3 ; returns 1 if given policy satisfies auto-update criteria, returns 0 otherwise
+4 NEW RES
+5 SET RES=0
+6 ; Subscriber ID doesn't match ; IB*2.0*497 compare subscriber ID data at their new locations
IF $PIECE(RDATA13,U,2)'=$PIECE(IDATA7,U,2)
GOTO CHK1X
+7 ; DOB doesn't match
IF $PIECE(RDATA1,U,2)'=$PIECE(IDATA3,U)
GOTO CHK1X
+8 ; Insured's name doesn't match ; IB*2.0*497 compare name of insured data at their new locations
IF '$$NAMECMP^IBCNEHLU($PIECE(RDATA13,U),$PIECE(IDATA7,U))
GOTO CHK1X
+9 SET RES=1
CHK1X ;
+1 QUIT RES
+2 ;
CHK2(MWNRTYP) ; check auto-update criteria for patient who is not the subscriber
+1 ; called from tag AUTOUPD, uses variables defined there
+2 ;
+3 ; returns 1 if policy satisfies auto-update criteria, returns 0 otherwise
+4 NEW DOB,ID,IDATA5,IENS,NAME,PDOB,PNAME,RES
+5 SET RES=0
+6 SET IDATA5=$GET(^DPT(IEN2,.312,IEN312,5))
+7 SET IENS=IEN2_","
+8 ; IB*2.0*497 Subscriber ID needs to be retrieved from its new location
SET ID=$PIECE(RDATA13,U,2)
+9 ; both Subscriber ID and Patient ID don't match ; IB*2.0*497 compare subscriber ID at new locations
IF ID'=$PIECE(IDATA7,U,2)
IF ID'=$PIECE(IDATA5,U)
GOTO CHK2X
+10 SET DOB=$PIECE(RDATA1,U,2)
SET PDOB=$$GET1^DIQ(2,IENS,.03,"I")
+11 ; both Subscriber and Patient DOB don't match
IF DOB'=$PIECE(IDATA3,U)
IF DOB'=PDOB
GOTO CHK2X
+12 ; IB*2.0*497 get name of insured at its new location
SET NAME=$PIECE(RDATA13,U)
SET PNAME=$$GET1^DIQ(2,IENS,.01)
+13 ; non-Medicare, both Subscriber and Patient name don't match ; IB*2*497
IF '+MWNRTYP
IF '$$NAMECMP^IBCNEHLU(NAME,$PIECE(IDATA7,U))
IF '$$NAMECMP^IBCNEHLU(NAME,PNAME)
GOTO CHK2X
+14 ; Medicare, Patient name doesn't match
IF +MWNRTYP
IF '$$NAMECMP^IBCNEHLU(NAME,PNAME)
GOTO CHK2X
+15 SET RES=1
CHK2X ;
+1 QUIT RES
+2 ;
UPDIREC(RIEN,IEN312) ; IB*2*595/DM update INSUR RECORD IEN in the response file (#365,.12)
+1 ; RIEN - ien in eIV Response file (365)
+2 ; IEN312 - ien in pat. insurance multiple (2.312)
+3 ;
+4 NEW DATA,ERROR,IENS
+5 IF RIEN'>0!(IEN312'>0)
QUIT
+6 ; IB*2*595/DM do not update TQ file.
+7 ; The proper INSUR RECORD IEN field is now located in the response file
+8 ;S IENS=$P($G(^IBCN(365,RIEN,0)),U,5)_"," I IENS="," Q
+9 ;S DATA(365.1,IENS,.13)=IEN312
+10 SET DATA(365,RIEN_",",.12)=IEN312
+11 DO FILE^DIE("ET","DATA","ERROR")
+12 QUIT
+13 ;
LCKERR ; send locking error message
+1 NEW MSG,XMY
+2 SET MSG(1)="WARNING: Unable to Auto-file Response Message from the EC"
+3 SET MSG(2)="---------------------------------------------------------"
+4 SET MSG(3)="Failed to lock patient insurance entry:"
+5 SET MSG(4)=" Patient name - "_$$GET1^DIQ(2,DFN_",",.01)
+6 SET MSG(5)=" Insurance - "_$$GET1^DIQ(2.312,IENS,.01)
+7 SET MSG(6)=" IENS - "_$SELECT($GET(IENS)="":"Unknown",1:IENS)
+8 SET MSG(7)=" "
+9 SET MSG(8)="The response will be filed into Insurance Buffer instead."
+10 SET MSG(9)=" "
+11 DO MSG^IBCNEUT5(MGRP,MSG(1),"MSG(",,.XMY)
+12 QUIT
+13 ;