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