source: WorldVistAEHR/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSRPT8.m@ 1504

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

initial load of WorldVistAEHR

File size: 8.6 KB
Line 
1BPSRPT8 ;BHAM ISC/BEE - ECME REPORTS ;14-FEB-05
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q
6 ;
7 ;Routine to Display the Reports in Excel
8 ;
9 ;Print Report Line 1
10 ;
11 ; Input Variable -> BPRTYPE,BPDIV,BPGRPLAN,BPDFN,BPRX,BPREF,BPX,BPSRTDT
12 ; BPBIL,BPINS,BPCOLL
13 ;
14WRLINE1(BPRTYPE,BPREC,BPDIV,BPGRPLAN,BPDFN,BPRX,BPREF,BPX,BPSRTDT,BPBIL,BPINS,BPCOLL) ;
15 ;
16 ;Division
17 S BPREC=$S(BPDIV=0:"BLANK",$$DIVNAME^BPSSCRDS(BPDIV)]"":$$DIVNAME^BPSSCRDS(BPDIV),1:BPDIV)_U
18 ;Insurance
19 I BPRTYPE'=5,BPRTYPE'=6 S BPREC=BPREC_$E(BPGRPLAN,1,90)_U
20 S BPREC=BPREC_$$PATNAME^BPSRPT6(BPDFN)_U ;Patient Name
21 S BPREC=BPREC_"("_$$SSN4^BPSRPT6(BPDFN)_")"_U ;L4SSN
22 S BPREC=BPREC_$$RXNUM^BPSRPT6(BPRX)_$$COPAY^BPSRPT6(BPRX)_U ;RX Number
23 S BPREC=BPREC_BPREF_"/"_$$ECMENUM^BPSRPT1($P(BPX,U,3))_U ;Refill/ECME Number
24 ;
25 I (BPRTYPE=1)!(BPRTYPE=4) D Q
26 . S BPREC=BPREC_$$DATTIM^BPSRPT1(BPSRTDT)_U ;Date
27 . S BPREC=BPREC_$TR($J(BPBIL,10,2)," ")_U ;$Billed
28 . S BPREC=BPREC_$TR($J(BPINS,10,2)," ")_U ;$Ins. Paid
29 . S BPREC=BPREC_$S(BPCOLL]"":$TR($J(BPCOLL,10,2)," "),1:"")_U ;$Collected
30 ;
31 I BPRTYPE=2 D Q
32 . S BPREC=BPREC_$$DATTIM^BPSRPT1(BPSRTDT)_U ;Date
33 . S BPREC=BPREC_$$DATTIM^BPSRPT1(+BPX)_U ;Released On
34 . ;RX INFO
35 . S BPREC=BPREC_$$MWC^BPSRPT6(BPRX,BPREF)_U ;Fill Location
36 . S BPREC=BPREC_$$RTBCKNAM^BPSRPT1($$RTBCK^BPSRPT1($P(BPX,U,3)))_U ;Fill Type
37 . S BPREC=BPREC_$$RXSTATUS^BPSRPT6($P(BPX,U,3)) ;Status
38 . S BPREC=BPREC_$S($P(BPX,U):"/RL",1:"/NR")_U ;RL/NR
39 ;
40 I BPRTYPE=3 D Q
41 . S BPREC=BPREC_$$DATTIM^BPSRPT1(BPSRTDT)_U ;Date
42 . S BPREC=BPREC_$TR($J(BPBIL,10,2)," ")_U ;$Billed
43 . S BPREC=BPREC_$TR($J(BPINS,10,2)," ")_U ;Insurance Response
44 ;
45 I BPRTYPE=5 D Q
46 . S BPREC=BPREC_$$DATTIM^BPSRPT1($$TRANDT^BPSRPT2($P(BPX,U,3),1))_U ;Completed
47 . S BPREC=BPREC_$$TTYPE^BPSRPT7($P(BPX,U,4),$P(BPX,U,5))_U ;Trans Type
48 . S BPREC=BPREC_$$RESPONSE^BPSRPT7($P(BPX,U,4),$P(BPX,U,5))_U ;Payer Response
49 ;
50 I BPRTYPE=7 D Q
51 . ;RX INFO
52 . S BPREC=BPREC_$$MWC^BPSRPT6(BPRX,BPREF)_U ;Fill Location
53 . S BPREC=BPREC_$$RTBCKNAM^BPSRPT1($$RTBCK^BPSRPT1($P(BPX,U,3)))_U ;Fill Type
54 . S BPREC=BPREC_$$RXSTATUS^BPSRPT6($P(BPX,U,3)) ;Status
55 . S BPREC=BPREC_$S($P(BPX,U):"/RL",1:"/NR")_U ;RL/NR
56 . S BPREC=BPREC_$S($P(BPX,U,13):"REJ",1:"")_U
57 . S BPREC=BPREC_$$DRGNAM^BPSRPT6($P(BPX,U,14),32)_U ;Drug
58 . S BPREC=BPREC_$TR($$GETNDC^BPSRPT6(BPRX,BPREF),"-")_U
59 Q
60 ;
61 ;Print Report Line 2
62 ;
63 ; Input Variable -> BPRTYPE,BPX,BPRX,BPREF,BPBIL,BPGRPLAN
64 ;
65WRLINE2(BPRTYPE,BPREC,BPX,BPRX,BPREF,BPBIL,BPGRPLAN) ;
66 I (BPRTYPE=1)!(BPRTYPE=4) D Q
67 . ;Drug, Released On
68 . S BPREC=BPREC_$$DRGNAM^BPSRPT6($P(BPX,U,14),32)_U_$TR($$GETNDC^BPSRPT6(BPRX,BPREF),"-")_U
69 . S BPREC=BPREC_$$DATTIM^BPSRPT1(+BPX)_U
70 . ;RX INFO
71 . S BPREC=BPREC_$$MWC^BPSRPT6(BPRX,BPREF)_U ;Fill Location
72 . S BPREC=BPREC_$$RTBCKNAM^BPSRPT1($$RTBCK^BPSRPT1($P(BPX,U,3)))_U ;Fill Type
73 . S BPREC=BPREC_$$RXSTATUS^BPSRPT6($P(BPX,U,3)) ;Status
74 . S BPREC=BPREC_$S($P(BPX,U):"/RL",1:"/NR")_U ;RL/NR
75 . S BPREC=BPREC_$S($P(BPX,U,13):"REJ",1:"")
76 . I BPRTYPE=1 S BPREC=BPREC_U_$$BILL^BPSRPT6(BPRX,BPREF) ;Bill #
77 ;
78 I BPRTYPE=2 D Q
79 . S BPREC=BPREC_$E($$CRDHLDID^BPSRPT2(+$P(BPX,U,3)),3,23)_U ;Cardholder ID
80 . S BPREC=BPREC_$E($$GRPID^BPSRPT2(+$P(BPX,U,3)),3,10)_U ;Group ID
81 . S BPREC=BPREC_$TR($J(BPBIL,10,2)," ")_U ;$Billed
82 . S BPREC=BPREC_$$QTY^BPSRPT6($P(BPX,U,3))_U ;Qty
83 . S BPREC=BPREC_$$GETNDC^BPSRPT6(BPRX,BPREF)_U ;NDC#
84 . S BPREC=BPREC_$$DRGNAM^BPSRPT6($P(BPX,U,14),32)_U ;Drug
85 ;
86 I BPRTYPE=3 D Q
87 . S BPREC=BPREC_$$DRGNAM^BPSRPT6($P(BPX,U,14),32)_U ;Drug
88 . S BPREC=BPREC_$TR($$GETNDC^BPSRPT6(BPRX,BPREF),"-")_U
89 . ;RX INFO
90 . S BPREC=BPREC_$$MWC^BPSRPT6(BPRX,BPREF)_U ;Fill Location
91 . S BPREC=BPREC_$$RTBCKNAM^BPSRPT1($$RTBCK^BPSRPT1($P(BPX,U,3)))_U ;Fill Type
92 . S BPREC=BPREC_$$RXSTATUS^BPSRPT6($P(BPX,U,3)) ;Status
93 . S BPREC=BPREC_$S($P(BPX,U):"/RL",1:"/NR")_U ;RL/NR
94 . S BPREC=BPREC_$S($P(BPX,U,13):"REJ",1:"")
95 ;
96 I BPRTYPE=5 D Q
97 . S BPREC=BPREC_$$DRGNAM^BPSRPT6($P(BPX,U,14),32)_U ;Drug
98 . S BPREC=BPREC_$TR($$GETNDC^BPSRPT6(BPRX,BPREF),"-")_U
99 . ;RX INFO
100 . S BPREC=BPREC_$$MWC^BPSRPT6(BPRX,BPREF)_U ;Fill Location
101 . S BPREC=BPREC_$$RTBCKNAM^BPSRPT1($$RTBCK^BPSRPT1($P(BPX,U,3)))_U ;Fill Type
102 . S BPREC=BPREC_$$RXSTATUS^BPSRPT6($P(BPX,U,3)) ;Status
103 . S BPREC=BPREC_$S($P(BPX,U):"/RL",1:"/NR")_U ;RL/NR
104 . S BPREC=BPREC_$S($P(BPX,U,13):"REJ",1:"")_U
105 . I $P(BPGRPLAN,U,2)]"" S BPREC=BPREC_$E($P(BPGRPLAN,U,2),1,30) ;Insurance
106 . S BPREC=BPREC_U_$$ELAPSE^BPSRPT6($P(BPX,U,3)) ;Elapsed Time
107 ;
108 I BPRTYPE=7 D Q
109 . S BPREC=BPREC_$E($$CRDHLDID^BPSRPT2(+$P(BPX,U,3)),3,23)_U ;Cardholder ID
110 . S BPREC=BPREC_$E($$GRPID^BPSRPT2(+$P(BPX,U,3)),3,10)_U ;Group ID
111 . S BPREC=BPREC_$$DATTIM^BPSRPT1(+$$CLOSEDT^BPSRPT2(+$P(BPX,U,3)))_U ;Close Dt/Time
112 . S BPREC=BPREC_$E($$CLSBY^BPSRPT6(+$P(BPX,U,3)),1,25)_U ;Close By
113 . S BPREC=BPREC_$E($P($$CLRSN^BPSRPT7(+$P(BPX,U,3)),U,2),1,30)_U ;Close Reason
114 Q
115 ;
116 ;Print Report Line 3
117 ;
118 ; Input Variable -> BPRTYPE,BPX
119 ;
120WRLINE3(BPRTYPE,BPREC,BPX) N BP59,BPSARR,BPRJCNT,BPZZ
121 S BP59=+$P(BPX,U,3)
122 ;
123 I (",2,7,")[BPRTYPE D Q
124 .S BPREC=BPREC_$$CLAIMID^BPSRPT2(BP59)_U ;Claim ID
125 .S BPRJCNT=$$REJTEXT^BPSRPT2(BP59,.BPSARR)
126 .F BPZZ=1:1:BPRJCNT S:BPZZ'=1 BPREC=BPREC_"," S BPREC=BPREC_$P(BPSARR(BPZZ),":")
127 .;
128 .;Write one record per reject/close code
129 .S:+BPRJCNT=0 BPRJCNT=1
130 .F BPZZ=1:1:BPRJCNT W !,$G(BPREC),U,$P($G(BPSARR(BPZZ)),":"),U,$P($G(BPSARR(BPZZ)),":",2)
131 ;
132 I BPRTYPE=4 D
133 . ;Method
134 . I $$AUTOREV^BPSRPT1(BP59) S BPREC=BPREC_U_"AUTO"_U
135 . E S BPREC=BPREC_U_"REGULAR"_U
136 . ;Return Status
137 . I $P(BPX,U,15)["ACCEPTED" S BPREC=BPREC_"ACCEPTED"_U
138 . E S BPREC=BPREC_"REJECTED"_U
139 . ;Reason
140 . S BPREC=BPREC_$$RVSRSN^BPSRPT7(+$P(BPX,U,3))
141 ;
142 ;Write the record
143 W !,$G(BPREC)
144 Q
145 ;
146 ;Print Excel Header
147 ;
148HDR(BPRTYPE) ;
149 ;
150 ;Check if header already printed
151 I $G(BPSDATA) Q
152 S BPSDATA=1
153 ;
154 ;Division
155 W !,"DIVISION",U
156 ;
157 I BPRTYPE'=5,BPRTYPE'=6 W "INSURANCE",U
158 ;
159 I (",1,2,3,4,5,7,")[BPRTYPE W "PATIENT NAME",U,"Pt.ID",U,"RX#",U,"REF/ECME#",U
160 ;
161 I (BPRTYPE=1)!(BPRTYPE=4) D Q
162 . W "DATE",U
163 . W "$BILLED",U
164 . W "$INS RESPONSE",U
165 . W "$COLLECT",U
166 . W "DRUG",U
167 . W "NDC",U
168 . W "RELEASED ON",U
169 . W "FILL LOCATION",U
170 . W "FILL TYPE",U
171 . W "STATUS",U
172 . W "REJECTED"
173 . I BPRTYPE=1 W U,"BILL#"
174 . I BPRTYPE=4 W U,"REVERSAL METHOD",U,"RETURN STATUS",U,"REASON"
175 ;
176 I BPRTYPE=2 D Q
177 . W "DATE",U
178 . W "RELEASED ON",U
179 . W "FILL LOCATION",U
180 . W "FILL TYPE",U
181 . W "STATUS",U
182 . W "CARDHOLD.ID",U
183 . W "GROUP ID",U
184 . W "$BILLED",U
185 . W "QTY",U
186 . W "NDC#",U
187 . W "DRUG",U
188 . W "CLAIM ID",U
189 . W "REJECT CODE(S)",U
190 . W "REJECT CODE",U
191 . W "REJECT EXPLANATION"
192 ;
193 I BPRTYPE=3 D Q
194 . W "DATE",U
195 . W "$BILLED",U
196 . W "$INS RESPONSE",U
197 . W "DRUG",U
198 . W "NDC",U
199 . W "FILL LOCATION",U
200 . W "FILL TYPE",U
201 . W "STATUS",U
202 . W "REJECTED"
203 ;
204 I BPRTYPE=5 D Q
205 . W "COMPLETED",U
206 . W "TRANS TYPE",U
207 . W "PAYER RESPONSE",U
208 . W "DRUG",U
209 . W "NDC",U
210 . W "FILL LOCATION",U
211 . W "FILL TYPE",U
212 . W "STATUS",U
213 . W "REJECTED",U
214 . W "INSURANCE",U
215 . W "ELAP TIME IN SECONDS"
216 ;
217 I BPRTYPE=6 D Q
218 .W "DATE",U
219 .W "#CLAIMS",U
220 .W "AMOUNT SUBMITTED",U
221 .W "RETURNED REJECTED",U
222 .W "RETURNED PAYABLE",U
223 .W "AMOUNT TO RECEIVE",U
224 .W "DIFFERENCE"
225 ;
226 I BPRTYPE=7 D Q
227 . W "FILL LOCATION",U
228 . W "FILL TYPE",U
229 . W "STATUS",U
230 . W "REJECTED",U
231 . W "DRUG",U
232 . W "NDC",U
233 . W "CARDHOLD.ID",U
234 . W "GROUP ID",U
235 . W "CLOSE DATE/TIME",U
236 . W "CLOSED BY",U
237 . W "CLOSE REASON",U
238 . W "CLAIM ID",U
239 . W "REJECT CODE(S)",U
240 . W "REJECT CODE",U
241 . W "REJECT EXPLANATION"
242 Q
243 ;
244 ;Print Report Insurance Subtotals
245 ;
246ITOT(BPRTYPE,BPDIV,BPGRPLAN,BPTBIL,BPTINS,BPTCOLL,BPCNT) N BPNP
247 I (BPRTYPE=1)!(BPRTYPE=4) D Q
248 .W !!,?78,"----------",?100,"----------",?122,"----------"
249 .W !,"SUBTOTALS for INS:",$E(BPGRPLAN,1,50),?78,$J(BPTBIL,10,2),?100,$J(BPTINS,10,2),?122,$J(BPTCOLL,10,2)
250 .W !,"COUNT",?78,$J(BPCNT,10),?100,$J(BPCNT,10),?122,$J(BPCNT,10)
251 .W:BPCNT !,"MEAN",?78,$J(BPTBIL/BPCNT,10,2),?100,$J(BPTINS/BPCNT,10,2),?122,$J(BPTCOLL/BPCNT,10,2)
252 I BPRTYPE=3 D Q
253 .W !!,?100,"----------",?122,"----------"
254 .W !,"SUBTOTALS for INS:",$E(BPGRPLAN,1,50),?100,$J(BPTBIL,10,2),?122,$J(BPTINS,10,2)
255 .W !,"COUNT",?100,$J(BPCNT,10),?122,$J(BPCNT,10)
256 .W:BPCNT !,"MEAN",?100,$J(BPTBIL/BPCNT,10,2),?122,$J(BPTINS/BPCNT,10,2)
257 I BPRTYPE=2 D Q
258 .W !!,?41,"----------"
259 .W !,"SUBTOTALS for INS:",$E(BPGRPLAN,1,22),?41,$J(BPTBIL,10,2)
260 .W !,"COUNT",?41,$J(BPCNT,10)
261 .W:BPCNT !,"MEAN",?41,$J(BPTBIL/BPCNT,10,2)
262 I (BPRTYPE=7) D Q
263 .W !!,"SUBTOTALS for INS:",$E(BPGRPLAN,1,50)
264 .N BPBILR
265 .S BPBILR="" F S BPBILR=$O(BPCNT(BPBILR)) Q:BPBILR="" D Q:BPQ
266 ..S BPNP=$$CHKP^BPSRPT5(1) Q:BPQ
267 ..W !,?3,BPBILR,?65,$J($G(BPCNT(BPBILR)),5)
268 .Q:$G(BPQ)
269 .W !,?65,"-----"
270 .W !,"CLOSED CLAIMS SUBTOTAL",?65,$J(BPCNT,5)
271 ;
272 Q
Note: See TracBrowser for help on using the repository browser.