[613] | 1 | BPSOSQL ;BHAM ISC/FCS/DRS/FLS - Process responses ;06/01/2004
|
---|
| 2 | ;;1.0;E CLAIMS MGMT ENGINE;**1,5**;JUN 2004;Build 45
|
---|
| 3 | ;;Per VHA Directive 2004-038, this routine should not be modified.
|
---|
| 4 | ;
|
---|
| 5 | Q
|
---|
| 6 | ;
|
---|
| 7 | ; ONE(CLAIMIEN,RESPIEN)
|
---|
| 8 | ; Process the Response for the claim. Loop through the
|
---|
| 9 | ; transaction associated with the claim and call RESP1
|
---|
| 10 | ; RESP1
|
---|
| 11 | ; The real work of response handling for one IEN59 is in here
|
---|
| 12 | ; RESPBAD
|
---|
| 13 | ; Branch from RESP1 if there is no response value in the
|
---|
| 14 | ; prescription
|
---|
| 15 | ;
|
---|
| 16 | ; ONE - Both the claim and response record are correct and complete
|
---|
| 17 | ; Now update all of the prescription records affected by them.
|
---|
| 18 | ONE(CLAIMIEN,RESPIEN) ;
|
---|
| 19 | N ISREVERS,INDEX,IEN59
|
---|
| 20 | S ISREVERS=$$ISREVERS^BPSOSU(CLAIMIEN)
|
---|
| 21 | S INDEX=$S(ISREVERS:"AER",1:"AE")
|
---|
| 22 | S IEN59=0
|
---|
| 23 | F S IEN59=$O(^BPST(INDEX,CLAIMIEN,IEN59)) Q:IEN59="" D
|
---|
| 24 | . D RESP1(IEN59,ISREVERS,CLAIMIEN,RESPIEN)
|
---|
| 25 | Q
|
---|
| 26 | ;
|
---|
| 27 | ; RESP1 - Process each transaction associated with the claim
|
---|
| 28 | RESP1(IEN59,REVERSAL,CLAIMIEN,RESPIEN) ; called from ONE
|
---|
| 29 | N ERROR,ERRTXT,X,MSG
|
---|
| 30 | ;
|
---|
| 31 | ; Store pointer to response
|
---|
| 32 | N DIE,DA,DR
|
---|
| 33 | S DIE=9002313.59,DA=IEN59
|
---|
| 34 | S DR=$S(REVERSAL:402,1:4)_"////"_RESPIEN
|
---|
| 35 | D ^DIE
|
---|
| 36 | ;
|
---|
| 37 | ; Update the status
|
---|
| 38 | D SETSTAT^BPSOSU(IEN59,90) ; "Processing response"
|
---|
| 39 | ;
|
---|
| 40 | ; Get Position and log it
|
---|
| 41 | N POSITION S POSITION=$P(^BPST(IEN59,0),U,9)
|
---|
| 42 | I REVERSAL S POSITION=1 ; but reversals have only 1 transaction
|
---|
| 43 | ;
|
---|
| 44 | ;
|
---|
| 45 | S MSG=$T(+0)_"-Processing "
|
---|
| 46 | I REVERSAL S MSG=MSG_"Reversal "
|
---|
| 47 | S MSG=MSG_"Response #"_RESPIEN_" for Claim #"_CLAIMIEN_" and position "_POSITION
|
---|
| 48 | D LOG^BPSOSL(IEN59,MSG)
|
---|
| 49 | ;
|
---|
| 50 | ; If the Response Status is missing for the prescription, quit with error
|
---|
| 51 | I '$D(^BPSR(RESPIEN,1000,POSITION,500)) D G RESPBAD
|
---|
| 52 | . S ERROR=901,ERRTXT="Corrupted response `"_RESPIEN
|
---|
| 53 | ;
|
---|
| 54 | ; Get the Respose Status for the prescription and update the statistics
|
---|
| 55 | N RESP S RESP=$P(^BPSR(RESPIEN,1000,POSITION,500),U)
|
---|
| 56 | D INCSTAT^BPSOSUD("R",$S(RESP="R"&REVERSAL:7,RESP="R":2,RESP="P":3,RESP="D":4,RESP="C":5,RESP="A":6,1:19))
|
---|
| 57 | ;
|
---|
| 58 | ; Log Response and if Payable, Amount Paid
|
---|
| 59 | S MSG=$T(+0)_"-Response = "_RESP
|
---|
| 60 | I RESP="P" S MSG=MSG_"-$"_$$INSPAID1^BPSOS03(RESPIEN,POSITION)
|
---|
| 61 | D LOG^BPSOSL(IEN59,MSG)
|
---|
| 62 | ;
|
---|
| 63 | ; If the claims was rejected, log the reject reason
|
---|
| 64 | I RESP="R" D ; rejected, give rejection reasons
|
---|
| 65 | . N J S J=0 F S J=$O(^BPSR(RESPIEN,1000,POSITION,511,J)) Q:'J D
|
---|
| 66 | .. N R S R=$P($G(^BPSR(RESPIEN,1000,POSITION,511,J,0)),U)
|
---|
| 67 | .. N X
|
---|
| 68 | .. I R]"" D
|
---|
| 69 | ... S X=$O(^BPSF(9002313.93,"B",R,0))
|
---|
| 70 | ... I X]"" S X=$P($G(^BPSF(9002313.93,X,0)),U,2)
|
---|
| 71 | .. E S X=""
|
---|
| 72 | .. D LOG^BPSOSL(IEN59,"Reject Code: "_R_" - "_X)
|
---|
| 73 | . ;
|
---|
| 74 | . ; If there are reject codes and the claim is not a reversal, synch reject codes
|
---|
| 75 | . ; with Outpatient Pharmacy
|
---|
| 76 | . I 'REVERSAL D DURSYNC^BPSECMP2(IEN59)
|
---|
| 77 | ;
|
---|
| 78 | ; Get response messages and log them.
|
---|
| 79 | S X=$G(^BPSR(RESPIEN,504))
|
---|
| 80 | I X]"" D LOG^BPSOSL(IEN59,"Response Message: "_X)
|
---|
| 81 | S X=$G(^BPSR(RESPIEN,1000,POSITION,504))
|
---|
| 82 | I X]"" D LOG^BPSOSL(IEN59,"Response Message: "_X)
|
---|
| 83 | S X=$G(^BPSR(RESPIEN,1000,POSITION,526))
|
---|
| 84 | I X]"" D LOG^BPSOSL(IEN59,"Response Message: "_X)
|
---|
| 85 | ;
|
---|
| 86 | ; Get Payer Sheet and Payer Sheet name
|
---|
| 87 | N PAYSH,PAYSHNM
|
---|
| 88 | S PAYSH=$$PAYERSH^BPSOSQF(IEN59),PAYSHNM=$$GET1^DIQ(9002313.92,PAYSH_",",.01,"E")
|
---|
| 89 | ;
|
---|
| 90 | ; Check if the payer should go to sleep based on the reject codes
|
---|
| 91 | I $$REJSLEEP^BPSOSQ4(RESPIEN,POSITION) D ; ins. asleep: want to retry
|
---|
| 92 | . D SETSTAT^BPSOSU(IEN59,31)
|
---|
| 93 | . N RETRY
|
---|
| 94 | . S RETRY=$$INCSLEEP^BPSOSQ4(IEN59,PAYSH)
|
---|
| 95 | . D LOG^BPSOSL(IEN59,$T(+0)_"-Insurer asleep; retry scheduled for "_RETRY_" for "_$G(PAYSHNM))
|
---|
| 96 | E D ; else: a normal kind of response, so we are done
|
---|
| 97 | . D CLRSLEEP^BPSOSQ4(IEN59,PAYSH)
|
---|
| 98 | . N RESULT
|
---|
| 99 | . I REVERSAL S RESULT="Reversal "
|
---|
| 100 | . S RESULT=$G(RESULT)_$S(RESP="R":"Rejected",RESP="P":"Payable",RESP="D":"Duplicate",RESP="C":"Captured",RESP="A":"Accepted",1:"Completed")
|
---|
| 101 | . D SETRESU^BPSOSU(IEN59,0,RESULT)
|
---|
| 102 | . D SETSTAT^BPSOSU(IEN59,99) ; "Done"
|
---|
| 103 | Q
|
---|
| 104 | ;
|
---|
| 105 | RESPBAD ; corrupted response escape from RESP1 - reached by a GOTO from RESP
|
---|
| 106 | ; Log the error
|
---|
| 107 | D ERROR^BPSOSU($T(+0),IEN59,$G(ERROR),$G(ERRTXT))
|
---|
| 108 | Q
|
---|