source: FOIAVistA/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSRPT6.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 8.5 KB
Line 
1BPSRPT6 ;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 ;Get the Insurance Company pointer and name
8 ;
9 ; Returned Value -> ptr^Insurance Company Name
10 ;
11INSNAM(BP59) N BPIN,BPDOS,BPDFN,BPSZZ,BP36,BPX
12 ;
13 ;Reset Insurance
14 S BP36=""
15 ;
16 ;First Pull From BPS Transactions
17 S BPIN=+$P($G(^BPST(BP59,9)),U)
18 I +BPIN S BP36=$P($G(^BPST(BP59,10,BPIN,0)),U,7) S:BP36]"" BP36="1^"_BP36
19 ;
20 ;If Not Found, look up using API
21 I BP36="" D
22 .S BPDOS=+$P($G(^BPST(BP59,12)),U,2)\1
23 .I BPDOS=0 S BPDOS=+$P($G(^BPST(BP59,0)),U,8)\1
24 .S BPDFN=+$P($G(^BPST(BP59,0)),U,6)
25 .S BPX=$$INSUR^IBBAPI(BPDFN,BPDOS,,.BPSZZ,"1")
26 .S BP36=$G(BPSZZ("IBBAPI","INSUR",1,1))
27 ;
28 ;If Not Found, put in MISSING INSURANCE
29 I $TR(BP36,U)="" S BP36=" ^**MISSING INSURANCE**"
30 ;
31 Q BP36
32 ;
33 ;Select an Insurance Company file entry (Fileman Lookup)
34 ;
35 ; Returned value -> Insurance Company Name
36 ;
37SELINS() N INS
38 S INS=$$SELINSUR^IBNCPDPI("Select Insurance","")
39 I $P(INS,U)=-1 S INS="^"
40 E S INS=$P(INS,U,2)
41 Q INS
42 ;
43 ;Get the drug name for display
44 ;
45 ; Input variable -> BP50 - Lookup to DRUG (#50)
46 ; BPLEN - Length of the display field
47 ; Returned value -> Name of the drug
48 ;
49DRGNAM(BP50,BPLEN) Q $E($$DRUGDIE^BPSUTIL1(+BP50,.01,"E"),1,BPLEN)
50 ;
51 ;Select a DRUG file entry (Fileman Lookup)
52 ;
53 ; Returned Variable -> Y
54 ;
55SELDRG N DIC S DIC(0)="QEAM",DIC=50,DIC("A")="Select Drug: "
56 D DRUGDIC^BPSUTIL1(.DIC)
57 Q
58 ;
59 ;Get the drug class for display
60 ;
61 ; Input variable -> BP50605 - Lookup to VA DRUG CLASS (#50.605)
62 ; BPLEN - Length of the display field
63 ; Returned value -> Name of the drug class
64 ;
65DRGCLNAM(BP50605,BPLEN) N IEN,Y
66 K ^TMP($J,"BPSRPT6")
67 S Y=""
68 I BP50605]"" D
69 .D C^PSN50P65(BP50605,"","BPSRPT6")
70 .S IEN=$O(^TMP($J,"BPSRPT6",0))
71 .I IEN]"" S Y=$E($G(^TMP($J,"BPSRPT6",IEN,1)),1,BPLEN)
72 K ^TMP($J,"BPSRPT6")
73 Q Y
74 ;
75 ;Select a VA DRUG CLASS file entry (Fileman Lookup)
76 ;
77SELDRGC N DIR,DIRUT,DTOUT,DUOUT,IEN,TOT,X
78 K ^TMP($J,"BPSRPT6")
79 ;
80 F D Q:Y]""
81 .K ^TMP($J,"BPSRPT6"),^TMP($J,"BPSRPT6X")
82 .S DIR(0)="FO^1:35"
83 .S DIR("A")="Select Drug Class"
84 .S DIR("?")="Answer with VA DRUG CLASS CODE, or CLASSIFICATION. TYPE '??' FOR A LIST"
85 .S DIR("??")="^D DCLIST^BPSRPT6"
86 .D ^DIR
87 .I ($G(DUOUT)=1)!($G(DTOUT)=1)!($G(Y)="") S Y="^" Q
88 .;
89 .;Get list based on original user input
90 .D C^PSN50P65("",Y,"BPSRPT6X")
91 .;
92 .;Get list based on uppercase input
93 .S Y=$$UP^XLFSTR(Y)
94 .D C^PSN50P65("",Y,"BPSRPT6")
95 .;
96 .;Merge lists together
97 .M ^TMP($J,"BPSRPT6")=^TMP($J,"BPSRPT6X")
98 .K ^TMP($J,"BPSRPT6X")
99 .;
100 .; Reset 0 node based on combined lists
101 .S Y=0 F TOT=0:1 S Y=$O(^TMP($J,"BPSRPT6",Y)) Q:'+Y
102 .S ^TMP($J,"BPSRPT6",0)=TOT
103 .;
104 .;Check for no entries found
105 .I TOT<1 W " ??" S Y="" Q
106 .;
107 .;Check for Unique Entry
108 .I TOT=1 D Q
109 ..S Y="",IEN=$O(^TMP($J,"BPSRPT6",0))
110 ..I IEN]"" S Y=$G(^TMP($J,"BPSRPT6",IEN,1)) W $C(13),"Select Drug Class: ",Y
111 .;
112 .;Check for multiple entries - allow user to pick
113 .I TOT>1 S Y=$$DCSEL(TOT)
114 .I Y="^^" S Y=""
115 .;
116 Q
117 ;
118 ;List Entries in VA DRUG CLASS
119 ;
120DCLIST N CL,DTOUT,IEN,Y
121 K ^TMP($J,"BPSRPT6")
122 D C^PSN50P65("","??","BPSRPT6")
123 ;
124 ;First create new index - sorted by CLASSIFICATION
125 S IEN=0 F S IEN=$O(^TMP($J,"BPSRPT6",IEN)) Q:'IEN D
126 .S CL=$G(^TMP($J,"BPSRPT6",IEN,1)) Q:CL=""
127 .S ^TMP($J,"BPSRPT6","B",CL,IEN)=$G(^TMP($J,"BPSRPT6",IEN,".01"))
128 ;
129 ;Now loop through and display entries
130 S $X=0,$Y=0 W !,?3,"Choose from: ",!
131 S (Y,CL)="" F S CL=$O(^TMP($J,"BPSRPT6","B",CL)) Q:CL="" D Q:Y]""
132 .S IEN="" F S IEN=$O(^TMP($J,"BPSRPT6","B",CL,IEN)) Q:IEN="" D Q:Y]""
133 ..W ?3,$G(^TMP($J,"BPSRPT6","B",CL,IEN)),!,?3,CL,!
134 ..I $Y>19!'$Y D
135 ...W ?3 R "'^' TO STOP: ",Y:$G(DTIME,300)
136 ...E S DTOUT=1
137 ...W $C(13),$J("",17),$C(13)
138 ...I ($G(DTOUT)=1)!($G(Y)="^") S Y="^" Q
139 ...S $X=0,$Y=0
140 ;
141 K ^TMP($J,"BPSRPT6")
142 Q
143 ;
144 ;Allow user to pick VA DRUG CLASS entry based on initial input
145 ;
146 ; Input variable - TOT -> Total entries placed in ^TMP($J,"BPSRPT6")
147 ; Returned value - VA DRUG CLASSIFICATION
148 ;
149DCSEL(TOT) N CL,DTOUT,I,IEN,IX,Y
150 ;
151 ;First create new index
152 F IX="B","N" K ^TMP($J,"BPSRPT6",IX)
153 S Y="",IEN=0 F S IEN=$O(^TMP($J,"BPSRPT6",IEN)) Q:'IEN D
154 .S CL=$G(^TMP($J,"BPSRPT6",IEN,1)) Q:CL=""
155 .S ^TMP($J,"BPSRPT6","B",CL,IEN)=$G(^TMP($J,"BPSRPT6",IEN,".01"))
156 ;
157 ;Now loop through and allow one to be picked
158 S (Y,CL)="" F S CL=$O(^TMP($J,"BPSRPT6","B",CL)) Q:CL="" D Q:Y]""
159 .S IEN="" F S IEN=$O(^TMP($J,"BPSRPT6","B",CL,IEN)) Q:IEN="" D Q:Y]""
160 ..S I=$G(I)+1 W !,?5,I,?9,$G(^TMP($J,"BPSRPT6","B",CL,IEN)),!,?3,CL
161 ..S ^TMP($J,"BPSRPT6","N",I)=CL
162 ..;
163 ..;Stop after every 5 entries
164 ..I I#5=0 I TOT>I D Q:$G(Y)="^"!($G(Y)="^^")
165 ...W !,"Press <RETURN> to see more, '^' to exit this list, OR"
166 ...W !,"CHOOSE 1 - "_I R ": ",Y:DTIME S:'$T DTOUT=1
167 ...I ($G(DTOUT)=1)!(Y="^") S Y="^^"
168 ..;
169 ..;Stop after last entry
170 ..I I=TOT D
171 ...W !,"CHOOSE 1 - "_I R ": ",Y:DTIME S:'$T DTOUT=1
172 ..I ($G(DTOUT)=1)!(Y="^") S Y="^^"
173 ..;
174 ..;Check for valid entry
175 ..I Y="^^" S Y=""
176 ..I Y]"",'$D(^TMP($J,"BPSRPT6","N",Y)) W " ??" S Y=""
177 ..I Y]"",$D(^TMP($J,"BPSRPT6","N",Y)) S Y=$G(^TMP($J,"BPSRPT6","N",Y))
178 ;
179 Q Y
180 ;
181 ;Get DRUG file pointer
182 ;
183 ; Return Value -> n = ptr to DRUG (#50)
184 ; 0 = Unknown
185 ;
186GETDRUG(BPRX) Q +$$RXAPI1^BPSUTIL1(BPRX,6,"I")
187 ;
188 ;Get VA DRUG CLASS pointer
189 ;
190 ; Input Variables: BP50 - ptr to DRUG (#50)
191 ;
192 ; Return Value -> n = ptr to VA DRUG CLASS (#50.605)
193 ; 0 = Unknown
194 ;
195GETDRGCL(BP50) Q $$DRUGDIE^BPSUTIL1(BP50,25)
196 ;
197 ;Determine whether claim was Mail, Window, or CMOP
198 ;
199 ; Input Variables: BPREF - refill # (0-No Refills,1-1st Refill, 2-2nd, ...)
200 ;
201 ; Return Value -> M = Mail
202 ; W = Window
203 ; C = CMOP
204 ;
205MWC(BPRX,BPREF) Q $$MWC^PSOBPSU2(BPRX,BPREF)
206 ;
207 ;Get Patient Name
208 ;
209 ; Input variable -> BPDFN - ptr to PATIENT (#2)
210 ; Returned value -> Patient Name (shortened)
211 ;
212PATNAME(BPDFN) Q $E($P($G(^DPT(BPDFN,0)),U),1,25)
213 ;
214 ;Get Last 4 of SSN
215 ;
216 ; Input variable -> BPDFN - ptr to PATIENT (#2)
217 ; Returned value -> Last 4 digits of patient's SSN
218 ;
219SSN4(BPDFN) N X
220 S X=$P($G(^DPT(BPDFN,0)),U,9)
221 Q $E(X,$L(X)-3,$L(X))
222 ;
223 ;Get RX#
224 ;
225 ; Returned value -> RX#
226 ;
227RXNUM(BPRX) Q $$RXAPI1^BPSUTIL1(+BPRX,.01,"I")
228 ;
229 ;Determine $Collected
230 ;
231 ; Returned Value -> $Collected
232 ;
233COLLECTD(BPRX,BPREF) N COL,RET
234 S RET=$$BILLINFO^IBNCPDPI(BPRX,BPREF)
235 S COL=$P(RET,U,5) I COL="0",($P(RET,U,3)=16)!($P(RET,U,3)=27) S COL=""
236 I $P(RET,U,7)=1 S COL="N/A"
237 Q COL
238 ;
239 ;Determine Bill #
240 ;
241 ; Returned Value -> Bill Number
242 ;
243BILL(BPRX,BPREF) N BILL
244 S BILL=$P($$BILLINFO^IBNCPDPI(BPRX,BPREF),U)
245 Q BILL
246 ;
247 ;Get the Closed Claim Reason
248 ;
249 ; Input variable -> 0 for All Closed Claim Reasons or
250 ; lookup to CLAIMS TRACKING NON-BILLABLE REASONS (#356.8)
251 ; Returned value -> ALL or the selected Closed Claim Reason
252 ;
253GETCLR(RSN) ;
254 I RSN="0" S RSN="ALL"
255 E S RSN=$P($G(^IBE(356.8,+RSN,0)),U)
256 Q RSN
257 ;
258 ;Get the Closed By Person
259 ;
260 ; Returned Value -> Closed By Name
261 ;
262CLSBY(BP59) N BP02,CBY,Y
263 S BP02=+$P($G(^BPST(BP59,0)),U,4)
264 S CBY=+$P($G(^BPSC(BP02,900)),U,3)
265 S Y=$$GET1^DIQ(200,CBY_",",".01")
266 Q Y
267 ;
268 ;Get the Claim Status
269 ;
270 ; Input Variables: BPREF - refill # (0-No Refills,1-1st Refill, 2-2nd, ...)
271 ;
272STATUS(BPRX,BPREF) Q $$STATUS^BPSOSRX(BPRX,BPREF,0)
273 ;
274 ;Elapsed Time
275 ;
276 ; Returned Value -> TIME - Elapsed Processing Time
277 ;
278ELAPSE(BP59) Q $$TIMEDIFI^BPSOSUD($P($G(^BPST(BP59,0)),U,11),$P($G(^BPST(BP59,0)),U,8))
279 ;
280 ;Get RX issue date
281 ;
282RXISSDT(BPRX) Q +$$RXAPI1^BPSUTIL1(BPRX,1,"I")
283 ;
284 ;
285 ;Get RX's fill date
286RXFILDT(BPRX) Q +$$RXAPI1^BPSUTIL1(BPRX,22,"I")
287 ;
288 ;Get Refill's issue date
289 ;
290REFISSDT(BPRX,BPREF) Q $$REFDISDT(BPRX,BPREF)
291 ;
292 ;Get Refill's dispense date
293 ;
294REFDISDT(BPRX,BPREF) Q +$$RXSUBF1^BPSUTIL1(BPRX,52,52.1,+BPREF,10.1,"I")
295 ;
296 ;Get Refill's refill date
297 ;
298REFFILDT(BPRX,BPREF) Q +$$RXSUBF1^BPSUTIL1(BPRX,52,52.1,+BPREF,.01,"I")
299 ;
300 ;Get RX's release date
301 ;
302RXRELDT(BPRX) Q +$$RXAPI1^BPSUTIL1(BPRX,31,"I")
303 ;
304 ;Get Refill's release date
305 ;
306REFRELDT(BPRX,BPREF) Q +$$RXSUBF1^BPSUTIL1(BPRX,52,52.1,+BPREF,17,"I")
307 ;
308 ;See if refill exists
309 ;
310IFREFILL(BPRX,BPREF) Q $S(+$$RXSUBF1^BPSUTIL1(BPRX,52,52.1,+BPREF,.01,"I"):1,1:0)
311 ;
312 ;Get RX status
313 ;
314 ; Input Variables -> BP59 = ptr to BPS TRANSACTIONS
315 ;
316RXSTATUS(BP59) Q $$RXST^BPSSCRU2(BP59)
317 ;
318 ;Return RX Quantity (From BPS TRANSACTION)
319 ;
320QTY(BP59) Q +$P($G(^BPST(BP59,5)),U,1)
321 ;
322 ;Return NDC Number
323GETNDC(BPRX,BPREF) Q $$GETNDC^PSONDCUT(BPRX,BPREF)
324 ;
325 ;Return Copay Status ($)
326COPAY(BPRX) Q $S(+$$RXAPI1^BPSUTIL1(BPRX,105,"I"):"$",1:"")
Note: See TracBrowser for help on using the repository browser.