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

BPSOSQ4.m

Go to the documentation of this file.
  1. BPSOSQ4 ;BHAM ISC/FCS/DRS/DLF - Process responses ;12/7/07 15:48
  1. ;;1.0;E CLAIMS MGMT ENGINE;**1,5,7,10,30**;JUN 2004;Build 19
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; This routine has two components
  1. ; Procedures to report Response info
  1. ; Procedures to handle insurer asleep functions
  1. Q
  1. ;
  1. ; The following are separate little utilities called from elsewhere.
  1. ;
  1. N TMP D RESPINFO(IEN59,.TMP) Q:'$D(TMP("RSP")) 0
  1. N X S X=TMP("RSP")
  1. I X="Payable" Q 1
  1. Q 0
  1. RESPINFO(IEN59,DST) ;EP - BPSOS6M
  1. ; quick way to get all the response info for a given BPS Transaction
  1. ; IMPORTANT!! Do not change spelling, case, wording, or spacing!!!
  1. ; If a reversal was attempted, it complicates things.
  1. ; fills DST array as follows:
  1. ; DST("HDR")=Response Status (header)
  1. ; DST("RSP")=Response Status (transaction)
  1. ; This could be: "Payable", "Rejected", "Accepted", "Captured",
  1. ; "Duplicate", or "null"
  1. ; DST("REJ",0)=count of reject codes
  1. ; DST("REJ",n)=each reject code
  1. ; DST("MSG")=message with the response
  1. ; All of these are defined, even if originals were '$D.
  1. ; The external forms are returned.
  1. N REVERSAL S REVERSAL=$G(^BPST(IEN59,4))>0
  1. N RESP
  1. I 'REVERSAL S RESP=$P(^BPST(IEN59,0),U,5)
  1. E S RESP=$P(^BPST(IEN59,4),U,2)
  1. I 'RESP Q
  1. N ECME S POS=$P(^BPST(IEN59,0),U,9) Q:'POS
  1. N FMT S FMT="E"
  1. S DST("HDR")=$$RESP500(RESP,FMT)
  1. S DST("RSP")=$$RESP1000(RESP,POS,FMT)
  1. S DST("REJ",0)=$$REJCOUNT(RESP,POS,FMT)
  1. I DST("REJ",0) D
  1. . N I F I=1:1:DST("REJ",0) S DST("REJ",I)=$$REJCODE(RESP,POS,I,FMT)
  1. S DST("MSG")=$$RESPMSG(RESP,POS)
  1. ; Dealing with oddities of PCS (and others'?) response to reversals
  1. I REVERSAL,DST("RSP")["null" D
  1. . I DST("RSP")["null" S DST("RSP")=DST("HDR")_" reversal"
  1. Q
  1. ; In the following quickies:
  1. ; RESP = RESPIEN, pointer to 9002313.03
  1. ; FMT = "I" for internal, "E" for external, defaults to internal
  1. RESP500(RESP,FMT) ;EP - BPSOS57,BPSOSUC
  1. ; returns the response header status
  1. N X S X=$P($G(^BPSR(RESP,500)),U)
  1. I $G(FMT)'="E" Q X
  1. I X="" S X="null"
  1. S X=$S(X="A":"Accepted",X="R":"Rejected",1:"?"_X)
  1. Q X
  1. RESP1000(RESP,POS,FMT) ;EP - BPSOSUC
  1. ; returns the transaction response status
  1. ; Note! Could be DP or DC for duplicates
  1. N X S X=$P($G(^BPSR(RESP,1000,POS,500)),U)
  1. I $G(FMT)'="E" Q X
  1. I X="" S X="null"
  1. ;
  1. ;IHS/SD/lwj 10/07/02 NCPDP 5.1 changes - they will send an "A" back
  1. ; now on the transaction level to indicate that it has been accepted
  1. ; Next code line remarked out - following added
  1. ;
  1. S X=$S(X="A":"Accepted",X="P":"Payable",X="R":"Rejected",X="C":"Captured",X="D"!(X="DP")!(X="DC"):"Duplicate",1:"?"_X)
  1. Q X
  1. ;
  1. REJCOUNT(RESP,POS,FMT) ; returns rejection count
  1. Q +$P($G(^BPSR(RESP,1000,POS,511,0)),U,3)
  1. ;
  1. REJCODE(RESP,POS,N,FMT) ; returns Nth rejection code
  1. ; if FMT="E", returns code:text
  1. N CODE S CODE=$P($G(^BPSR(RESP,1000,POS,511,N,0)),U)
  1. I CODE="" S CODE="null"
  1. I FMT'="E" Q CODE
  1. N X S X=$O(^BPSF(9002313.93,"B",CODE,0))
  1. I X]"" S CODE=CODE_":"_$P($G(^BPSF(9002313.93,X,0)),U,2)
  1. E S CODE="?"_CODE
  1. Q CODE
  1. ;
  1. ; NCPDP 5.1 changes - message may not come back in 504. They may
  1. ; come back in 526 instead
  1. ; NCPDP D.0 change - 526 is a repeating field
  1. RESPMSG(RESP,POS) ; response message - additional text from insurer
  1. ;
  1. I '$G(RESP) Q ""
  1. I '$G(POS) S POS=1
  1. N MSG
  1. S MSG=""
  1. S MSG=$G(^BPSR(RESP,504))
  1. I MSG]"" Q MSG
  1. N ADDMESS,N
  1. D ADDMESS^BPSSCRLG(RESP,POS,.ADDMESS)
  1. S N="" F S N=$O(ADDMESS(N)) Q:'N S MSG=MSG_$S(N=1:"",1:"~")_ADDMESS(N)
  1. Q MSG
  1. ;
  1. ;
  1. NOW() ;
  1. Q $$NOW^XLFDT
  1. ;
  1. ; The xxxSLEEP functions are called from BPSOSQL
  1. ; ISASLEEP also called by BPSOSQA
  1. ;
  1. REJSLEEP(BPSRESP,BPSPOS,IEN59) ;
  1. ; Check if the insurer should be asleep based on the reject codes
  1. ; Input
  1. ; BPSRESP - BPS Response IEN
  1. ; BPSPOS - Multiple IEN
  1. ; IEN59 - BPS TRANSACTION IEN
  1. ; Return
  1. ; 1 if the insurer should go to sleep
  1. ; 0 if the insurer should not go to sleep
  1. ;
  1. N BPSSITE,REJCD,GRPLAN,BPSRET
  1. ;
  1. ; Validate parameters
  1. I '$G(BPSRESP) Q 0
  1. I '$G(BPSPOS) Q 0
  1. I '$G(IEN59) Q 0
  1. ;
  1. ; Check asleep parameters to see asleep functionality is disabled
  1. S BPSSITE=$G(^BPS(9002313.99,1,0))
  1. I '$P(BPSSITE,"^",5)!('$P(BPSSITE,"^",6)) Q 0
  1. ;
  1. ; Do not do insurer asleep for Eligibility Verification requests
  1. I $P($G(^BPST(IEN59,0)),U,15)="E" Q 0
  1. ;
  1. ; Get the Group Insurance Plan and verify if asleep functionality is on
  1. S GRPLAN=$$GETPLN59^BPSUTIL2(IEN59) I 'GRPLAN Q 0
  1. I $$IGNORE^BPSOSQF(+GRPLAN) Q 0
  1. ;
  1. ; Don't sleep if response has reject 88 (DUR), 943 (DUR), or 79 (Refill Too Soon)
  1. I $D(^BPSR(BPSRESP,1000,BPSPOS,511,"B",88)) Q 0
  1. I $D(^BPSR(BPSRESP,1000,BPSPOS,511,"B",943)) Q 0
  1. I $D(^BPSR(BPSRESP,1000,BPSPOS,511,"B",79)) Q 0
  1. ;
  1. ; Is this a reject code to consider?
  1. S BPSRET=0
  1. F REJCD=90,91,92,95,96,97,98 I $D(^BPSR(BPSRESP,1000,BPSPOS,511,"B",REJCD)) S BPSRET=1 Q
  1. ;
  1. Q BPSRET
  1. ;
  1. ADDSLEEP(IEN59) ;
  1. ; Adds a payer (if not already there) to the Asleep file
  1. ; Input
  1. ; IEN59 - BPS TRANSACTION IEN
  1. ; Return
  1. ; 0 - No BPS Asleep Payer record created
  1. ; BPS Asleep Payer IEN
  1. ;
  1. I '$G(IEN59) Q 0
  1. N GRPLAN,DIC,X,Y,DO,DTOUT,DUOUT
  1. ;
  1. ; Find the Group Insurance Plan
  1. S GRPLAN=$$GETPLN59^BPSUTIL2(IEN59) I 'GRPLAN Q 0
  1. ;
  1. ; If already in file quit
  1. I $D(^BPS(9002313.15,"B",+GRPLAN)) Q 0
  1. ;
  1. S DIC=9002313.15,DIC(0)="",X=+GRPLAN
  1. S DIC("DR")=".02///0;.03///0;.04////^S X=IEN59"
  1. D FILE^DICN
  1. ;
  1. Q Y
  1. ;
  1. INCSLEEP(IEN59) ; called from BPSOSQL
  1. ; INCSLEEP - Increment sleep time for this insurer
  1. ; Input
  1. ; IEN59 - BPS TRANSACTION IEN
  1. ; Return
  1. ; 0 - Awake now
  1. ; 1 - Still asleep
  1. ;
  1. I '$G(IEN59) Q 0
  1. N GRPLAN,BPSIEN15,RETCNT,BPSPARAM,BPSRETRY,PROBER,IEN59T
  1. N DIE,DA,DR,DTOUT
  1. ;
  1. ; Get GROUP INSURANCE PLAN
  1. S GRPLAN=$$GETPLN59^BPSUTIL2(IEN59) I 'GRPLAN Q 0
  1. ;
  1. ; If the payer is not already asleep, add it to the BPS ASLEEP PAYERS file
  1. S BPSIEN15=$O(^BPS(9002313.15,"B",+GRPLAN,0))
  1. I 'BPSIEN15 S BPSIEN15=+$$ADDSLEEP(IEN59)
  1. I BPSIEN15<1 Q 0
  1. ;
  1. ; Get the prober.
  1. S PROBER=$P($G(^BPS(9002313.15,BPSIEN15,0)),U,4)
  1. ;
  1. ; If there is a prober and this is not it, just put this transaction to sleep and quit
  1. I PROBER,IEN59'=PROBER D SETSLEEP(IEN59,BPSIEN15,$T(+0)_"-Insurer Asleep-Waiting for Prober Transaction "_PROBER_" to complete") Q 1
  1. ;
  1. ; Get Asleep Paramters from BPS SETUP
  1. ; If the parameters are off, return 0
  1. S BPSPARAM=^BPS(9002313.99,1,0)
  1. I '$P(BPSPARAM,"^",5)!('$P(BPSPARAM,"^",6)) Q 0
  1. ;
  1. ; If maximum retries reached, flag to wake up and set status to complete.
  1. S RETCNT=$P($G(^BPS(9002313.15,BPSIEN15,0)),U,2)+1
  1. I RETCNT>$P(BPSPARAM,"^",6) D Q 0
  1. . D LOG^BPSOSL(IEN59,$T(+0)_"-Maximum retries reached for insurer. Completing BPS TRANSACTION: "_IEN59)
  1. ;
  1. ; Set RETRY TIME based on site parameters and update retry count and retry time
  1. S BPSRETRY=$$FMADD^XLFDT($$NOW^XLFDT,,,$P(BPSPARAM,"^",5))
  1. I $$FILLFLDS^BPSUTIL2(9002313.15,".02",BPSIEN15,RETCNT)<1 Q 0
  1. I $$FILLFLDS^BPSUTIL2(9002313.15,".05",BPSIEN15,BPSRETRY)<1 Q 0
  1. ;
  1. ; Put the prober to Sleep
  1. S MSG="Retry number "_RETCNT_" scheduled for "_$$FMTE^XLFDT(BPSRETRY)
  1. D SETSLEEP(IEN59,BPSIEN15,$T(+0)_"-Insurer Asleep for "_$P(GRPLAN,U,2)_". "_MSG)
  1. ;
  1. ; Update the Last Update date/time for associated claims so that they don't
  1. ; end up on the View/Unstand Submission Screen
  1. S IEN59T="" F S IEN59T=$O(^BPST("ASL",BPSIEN15,IEN59T)) Q:IEN59T="" D
  1. . I IEN59T=PROBER Q
  1. . S DIE=9002313.59,DA=IEN59T,DR="7///NOW" D ^DIE
  1. . D LOG^BPSOSL(IEN59T,$T(+0)_"-INCSLEEP is resetting the LAST UPDATE field to the current date/time")
  1. ;
  1. ; Queue packeter to restart at next retry time+10 seconds
  1. D TASKAT^BPSOSQA($$FMADD^XLFDT(BPSRETRY,,,,10))
  1. ;
  1. Q 1
  1. ;
  1. SETSLEEP(IEN59,BPSIEN15,MSG) ;
  1. ; Put transaction to sleep
  1. ; Input
  1. ; IEN59 - BPS Transaction IEN
  1. ; BPSIEN15 - BPS Asleep Payer IEN
  1. ; MSG - Message used for Log
  1. ;
  1. I '$G(IEN59) Q
  1. I '$G(BPSIEN15) Q
  1. N DIE,DA,DR,DTOUT
  1. ;
  1. ; If the BPS TRANSACTION is not already pointing to the asleep payer, update it
  1. I '$D(^BPST("ASL",BPSIEN15,IEN59)) S DIE=9002313.59,DA=IEN59,DR="801////^S X=BPSIEN15" D ^DIE
  1. ;
  1. ; Set to 31% (Wait for retry (insurer asleep)) and log message
  1. D SETSTAT^BPSOSU(IEN59,31)
  1. I $G(MSG)="" S MSG=$T(+0)_"-Transaction being put to sleep by SETSLEEP"
  1. D LOG^BPSOSL(IEN59,MSG)
  1. Q
  1. ;
  1. CLRSLEEP(GRPLAN,IEN59) ;EP - BPSOSQL
  1. ; Clear insurer sleeping condition
  1. ; Input:
  1. ; GRPLAN - Group Insurance Plan IEN
  1. ; IEN59 - BPS Transaction IEN
  1. ;
  1. I '$G(GRPLAN) Q
  1. N BPSIEN15,DA,DIE,DR,DTOUT,DIK,IEN59T
  1. ;
  1. ; Get the BPS ASLEEP PAYER record
  1. S BPSIEN15=$O(^BPS(9002313.15,"B",+GRPLAN,0))
  1. I BPSIEN15="" Q
  1. ;
  1. ; Logging message and creating a comment
  1. I $G(IEN59) D LOG^BPSOSL(IEN59,$T(+0)_"-Clearing sleep for "_$P(GRPLAN,U,2))
  1. ;
  1. ; Delete the BPS ASLEEP PAYER record
  1. S DA=BPSIEN15,DIK="^BPS(9002313.15," D ^DIK
  1. ;
  1. ; Clear any pointers to the sleep payer
  1. S IEN59T="" F S IEN59T=$O(^BPST("ASL",BPSIEN15,IEN59T)) Q:IEN59T="" D
  1. . S DIE=9002313.59,DA=IEN59T,DR="801///@" D ^DIE
  1. . D LOG^BPSOSL(IEN59T,$T(+0)_"-CLRSLEEP is clearing pointer to ASLEEP PAYER")
  1. ;
  1. ; Run the packeter to resubmit any other claims for the this payer
  1. D TASK^BPSOSQA
  1. Q