source: FOIAVistA/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSOSQ4.m@ 1635

Last change on this file since 1635 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.1 KB
Line 
1BPSOSQ4 ;BHAM ISC/FCS/DRS/DLF - 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 ; This routine has two components
6 ; Procedures to report Response info
7 ; Procedures to handle insurer asleep functions
8 Q
9 ;
10 ; The following are separate little utilities called from elsewhere.
11 ;
12PAID(IEN59) ;quick query to see if it's paid
13 N TMP D RESPINFO(IEN59,.TMP) Q:'$D(TMP("RSP")) 0
14 N X S X=TMP("RSP")
15 I X="Payable" Q 1
16 Q 0
17RESPINFO(RXI,DST) ;EP - BPSOS6M
18 ; quick way to get all the response info for a given RXI
19 ; IMPORTANT!! Do not change spelling, case, wording, or spacing!!!
20 ; If a reversal was attempted, it complicates things.
21 ; fills DST array as follows:
22 ; DST("HDR")=Response Status (header)
23 ; DST("RSP")=Response Status (prescription)
24 ; This could be: "Payable" "Rejected" "Captured" "Duplicate"
25 ; or "Accepted reversal" or "Rejected reversal"
26 ; or "null" or "null reversal" (no response or corrupt response
27 ; or maybe someone without insurance, so no request was sent)
28 ; DST("REJ",0)=count of reject codes
29 ; DST("REJ",n)=each reject code
30 ; DST("MSG")=message with the response
31 ; All of these are defined, even if originals were '$D.
32 ; The external forms are returned.
33 N REVERSAL S REVERSAL=$G(^BPST(RXI,4))>0
34 N RESP
35 I 'REVERSAL S RESP=$P(^BPST(RXI,0),U,5)
36 E S RESP=$P(^BPST(RXI,4),U,2)
37 I 'RESP Q
38 N ECME S POS=$P(^BPST(RXI,0),U,9) Q:'POS
39 N FMT S FMT="E"
40 S DST("HDR")=$$RESP500(RESP,FMT)
41 S DST("RSP")=$$RESP1000(RESP,POS,FMT)
42 S DST("REJ",0)=$$REJCOUNT(RESP,POS,FMT)
43 I DST("REJ",0) D
44 . N I F I=1:1:DST("REJ",0) S DST("REJ",I)=$$REJCODE(RESP,POS,I,FMT)
45 S DST("MSG")=$$RESPMSG(RESP,POS,FMT)
46 ; Dealing with oddities of PCS (and others'?) response to reversals
47 I REVERSAL,DST("RSP")["null" D
48 . I DST("RSP")["null" S DST("RSP")=DST("HDR")_" reversal"
49 Q
50 ; In the following quickies:
51 ; RESP = RESPIEN, pointer to 9002313.03
52 ; FMT = "I" for internal, "E" for external, defaults to internal
53RESP500(RESP,FMT) ;EP - BPSOS57,BPSOSUC
54 ; returns the response header status
55 N X S X=$P($G(^BPSR(RESP,500)),U)
56 I $G(FMT)'="E" Q X
57 I X="" S X="null"
58 S X=$S(X="A":"Accepted",X="R":"Rejected",1:"?"_X)
59 Q X
60RESP1000(RESP,POS,FMT) ;EP - BPSOSUC
61 ; returns the prescription response status
62 ; Note! Could be DP or DC for duplicates
63 N X S X=$P($G(^BPSR(RESP,1000,POS,500)),U)
64 I $G(FMT)'="E" Q X
65 I X="" S X="null"
66 ;
67 ;IHS/SD/lwj 10/07/02 NCPDP 5.1 changes - they will send an "A" back
68 ; now on the transaction level to indicate that it has been accepted
69 ; Next code line remarked out - following added
70 ;
71 S X=$S(X="A":"Accepted",X="P":"Payable",X="R":"Rejected",X="C":"Captured",X="D"!(X="DP")!(X="DC"):"Duplicate",1:"?"_X)
72 Q X
73 ;
74REJCOUNT(RESP,POS,FMT) ; returns rejection count
75 Q +$P($G(^BPSR(RESP,1000,POS,511,0)),U,3)
76 ;
77REJCODE(RESP,POS,N,FMT) ; returns Nth rejection code
78 ; if FMT="E", returns code:text
79 N CODE S CODE=$P($G(^BPSR(RESP,1000,POS,511,N,0)),U)
80 I CODE="" S CODE="null"
81 I FMT'="E" Q CODE
82 N X S X=$O(^BPSF(9002313.93,"B",CODE,0))
83 I X]"" S CODE=CODE_":"_$P($G(^BPSF(9002313.93,X,0)),U,2)
84 E S CODE="?"_CODE
85 Q CODE
86 ;
87 ; NCPDP 5.1 changes - message may not come back in 504. They may
88 ; come back in 526 instead
89RESPMSG(RESP,POS,FMT) ; response message - additional text from insurer
90 ;
91 N MSG
92 S MSG=""
93 S MSG=$G(^BPSR(RESP,504))
94 S:MSG="" MSG=$G(^BPSR(RESP,1000,POS,504))
95 S:MSG="" MSG=$G(^BPSR(RESP,1000,POS,526))
96 Q MSG
97 ;
98 ;
99NOW() N %,%H,%I,X D NOW^%DTC Q %
100 ;
101 ; The xxxSLEEP functions are called from BPSOSQL
102 ;
103 ; REJSLEEP - Check if the insurer should be asleep
104 ; based on the reject codes
105 ; Input
106 ; RESP - BPS Response IEN
107 ; POS - Multiple IEN
108 ; Return
109 ; 1 if the insurer is asleep
110 ; 0 if the insurer is not asleep
111REJSLEEP(RESP,POS) ;EP - BPSOSQL
112 ;
113 ; DMB - Asleep functionality is disabled for VA until an analysis of reject
114 ; codes can be done and asleep code needs to handle a stranded prober.
115 Q 0
116 ;
117 ; Validate parameters
118 I '$G(RESP) Q 0
119 I '$G(POS) Q 0
120 ;
121 ; This is basically old IHS logic
122 I $G(^BPSR(RESP,1000,POS,504))?1"EV16-".E Q 1
123 I $G(^BPSR(RESP,1000,POS,504))?1"EV38-".E Q 1
124 I $G(^BPSR(RESP,1000,POS,504))?1"EV32-".E Q 1
125 I $G(^BPSR(RESP,1000,POS,504))?1"EV25-".E Q 1 ; BPS*1.0T7*4
126 ;
127 ; NDC's, and theoretically, Envoy too, though they seem to do EV- msgs
128 I $O(^BPSR(RESP,1000,POS,511,"B",90))="" Q 0 ; cheap check
129 ;
130 ; But for a PCS case we see, Code 99 + some code < 90 ; BPS*1.0T7*2
131 ; isn't "asleep" - 99 is something PCS threw in ; BPS*1.0T7*2
132 ; so require 99 to be accompanied by something <99 too ; BPS*1.0T7*2
133 ;
134 N RET S RET=0 N I F I=92,93,99 D Q:RET
135 . I $D(^BPSR(RESP,1000,POS,511,"B",I)) S RET=1
136 . Q:I'=99 Q:'RET ; BPS*1.0T7*2
137 . I I=99,$O(^BPSR(RESP,1000,POS,511,"B",0))<90 S RET=0 ; BPS*1.0T7*2
138 Q RET
139 ;
140 ; INCSLEEP - Increment sleep time for this insurer, if necessary.
141 ; Input
142 ; IEN59 - BPS Transaction IEN
143 ; PAYSH - Payer Sheet IEN
144 ; Return the scheduled retry time
145INCSLEEP(IEN59,PAYSH) ;EP - BPSOSQL
146 ;
147 ; Set retry time to be 10 minutes in the future
148 N X,RETRY
149 S X=600,RETRY=$$TADDNOWS^BPSOSUD(X)
150 ;
151 ; Set retry time to be 10 minutes
152 S $P(^BPSF(9002313.92,PAYSH,1),U,12)=RETRY
153 S $P(^BPST(IEN59,8),U,1)=RETRY
154 S $P(^BPST(IEN59,8),U,3)=PAYSH
155 ;
156 ; Fire up a packet process 10 seconds after the RETRY time so that the
157 ; claims can be processed as soon as the retry time expires
158 D TASKAT^BPSOSQA($$TADDNOWS^BPSOSUD(X+10))
159 ;
160 ; And run packeter right now, too, to stamp new times on the others in status 31
161 D TASK^BPSOSQA
162 Q RETRY
163 ;
164 ; Clear insurer sleeping condition
165CLRSLEEP(IEN59,PAYSH) ;EP - BPSOSQL
166 N RETRY
167 ;
168 ; Reset Retry Time and Prober Flga
169 I $D(^BPST(IEN59,8)) S $P(^BPST(IEN59,8),U,1)="",$P(^BPST(IEN59,8),U,3)=""
170 ;
171 ; Get retry time from the payer sheet and quit if does not exist
172 S RETRY=$P($G(^BPSF(9002313.92,PAYSH,1)),U,12)
173 ;
174 ; Reset Retry Time and Prober
175 S $P(^BPSF(9002313.92,PAYSH,1),U,11)=""
176 S $P(^BPSF(9002313.92,PAYSH,1),U,12)=""
177 ;
178 ; If this insurer was asleep and there are other asleep transactions, fire off
179 ; the Packeter task to see if they should be done
180 I RETRY,$D(^BPST("AD",31)) D TASK^BPSOSQA
181 Q
Note: See TracBrowser for help on using the repository browser.