source: WorldVistAEHR/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBNCPEV1.m@ 1306

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

initial load of WorldVistAEHR

File size: 7.9 KB
Line 
1IBNCPEV1 ;DALOI/SS - NCPDP BILLING EVENTS REPORT ;21-MAR-2006
2 ;;2.0;INTEGRATED BILLING;**342,339,363**;21-MAR-94;Build 35
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ;IA# 10155 is used to read ^DD(file,field,0) node
6 Q
7 ;
8SETVARS ;
9 ;newed in IBNCPEV
10 S (IBECME,IBPAT,IBRX,IBQ,IBSCR,IBPAGE,IBDTL,IBDIVS)=0
11 ;date
12 F D DATE^IBNCPDPE Q:IBQ Q:$$TESTDATA^IBNCPDPE
13 Q:IBQ
14 N IBMLTDV S IBMLTDV=$$MULTPHRM^BPSUTIL()
15 I +IBMLTDV=1 S IBDIVS=+$$MULTIDIV(.IBDIVS) S:IBDIVS=0 IBDIVS(0)="0^ALL" I IBDIVS=-1 S IBQ=1 Q
16 I +IBMLTDV=0 S IBDIVS=0,IBDIVS(0)="0^"_$P(IBMLTDV,U,2)
17 D MODE^IBNCPDPE Q:IBQ
18 D DEVICE^IBNCPDPE Q:IBQ
19 Q
20 ;
21 ;/**
22 ; input -
23 ; IBECMENO = ECME #
24 ; IBST = start date (FM format)
25 ; IBEND = end date (FM format)
26 ; output - returns internal entry number of file #52 for the earliest date within the date range
27GETRX(IBECMENO,IBST,IBEND) ; get ien of file 52 from #366.14
28 ; array from where the ECME BILLING EVENTS report gets its data
29 ; This subroutine is called when the user enters an ECME# as
30 ; part of the search criteria
31 N IBDATE,IBNO,IBIEN
32 S IBDATE=+$O(^IBCNR(366.14,"E",IBECMENO,IBST-1))
33 I IBDATE=0 Q 0
34 I IBDATE>IBEND Q 0
35 S IBNO=+$O(^IBCNR(366.14,"E",IBECMENO,IBDATE,0))
36 I IBNO=0 Q 0
37 S IBIEN=$O(^IBCNR(366.14,"B",IBDATE,0))
38 Q +$P($G(^IBCNR(366.14,IBIEN,1,IBNO,2)),U)
39 ;
40 ;/**
41 ;finish
42 ;input:
43 ;IBD2 - node ^IBCNR(366.14,D0,1,D1,2)
44 ;IBD3 - node ^IBCNR(366.14,D0,1,D1,3)
45 ;IBD4 - node ^IBCNR(366.14,D0,1,D1,4)
46 ;IBINS - multiple of ^IBCNR(366.14,D0,1,D1,5)
47DSTAT(IBD2,IBD3,IBD4,IBINS) ;
48 N IBX,IBT,IBSC,IB1ST,IBNXT,IBEXMPV
49 S IB1ST=1
50 D CHKP^IBNCPEV Q:IBQ
51 W !?10,"ELIGIBILITY: "
52 F IBX=2:1 S IBT=$P($T(EXEMPT+IBX^IBNCPDP1),";",3),IBSC=$P(IBT,U,2) Q:IBSC="" S IBEXMPV=$$EXMPFLDS(IBSC,IBD4) D:IBEXMPV]"" Q:IBQ!(IBEXMPV=3)
53 . I IBEXMPV=3 W "overridden by the user" Q
54 . I 'IB1ST W "," I $X>70 D CHKP^IBNCPEV Q:IBQ W !?10 S IB1ST=1
55 . W " ",IBSC,":",$S(IBEXMPV=1:"Yes",IBEXMPV=0:"No",IBEXMPV=2:"No Answer",1:"?") S IB1ST=0
56 Q:IBQ
57 I $P(IBD2,U,4) D CHKP^IBNCPEV Q:IBQ W !?10,"DRUG:",$$DRUGNAM(+$P(IBD2,U,4))
58 D CHKP^IBNCPEV Q:IBQ W !?10
59 W "NDC:",$S($P(IBD2,U,5):$P(IBD2,U,5),1:"No"),", BILLED QTY:",$S($P(IBD2,U,8):$P(IBD2,U,8),1:"No"),", COST:",$S($P(IBD3,U,4):$P(IBD3,U,4),1:"No")
60 I $P(IBD2,U,10)]"" W ", DEA:",$P(IBD2,U,10)
61 S IBX=0,IBNXT=0 F S IBX=$O(IBINS(IBX)) Q:'IBX D Q:IBQ S IBNXT=1
62 .N Y S Y=$P(IBINS(IBX,0),U,2,8) W:'Y "@@@@" Q:'Y
63 .I IBNXT D CHKP^IBNCPEV Q:IBQ W !?10,"-----------"
64 .D CHKP^IBNCPEV Q:IBQ W !?10
65 .W "PLAN:",$P($G(^IBA(355.3,+Y,0)),U,3)," "
66 .W "INSURANCE: ",$P($G(^DIC(36,+$G(^IBA(355.3,+Y,0)),0)),U)
67 .D CHKP^IBNCPEV Q:IBQ W !?10 S IB1ST=1
68 .I $P(Y,U,2)]"" W "BIN:",$P(Y,U,2) S IB1ST=0
69 .I $P(Y,U,3)]"" W:'IB1ST ", " W "PCN:",$P(Y,U,3) S IB1ST=0
70 .I $P(Y,U,4)]"" W:'IB1ST ", " W "PAYER SHEET B1:",$P(Y,U,4) S IB1ST=0
71 .D CHKP^IBNCPEV Q:IBQ W !?10 S IB1ST=1
72 .S Y=IBINS(IBX,1)
73 .I $P(Y,U,4)]"" W "PAYER SHEET B2:",$P(Y,U,4) S IB1ST=0
74 .I $P(Y,U,5)]"" W:'IB1ST ", " W "PAYER SHEET B3:",$P(Y,U,5)
75 .;S Y=$G(Z1("INS",IBX,2)) Q:Y=""
76 .S Y=IBINS(IBX,2) Q:Y=""
77 .D CHKP^IBNCPEV Q:IBQ W !?10 S IB1ST=1
78 .I $P(Y,U)]"" W "DISPENSING FEE:",$P(Y,U) S IB1ST=0
79 .I $P(Y,U,2)]"" W:'IB1ST ", " W "BASIS OF COST DETERM:",$$BOCD^IBNCPEV($P(Y,U,2)) S IB1ST=0
80 .D CHKP^IBNCPEV Q:IBQ W !?10 S IB1ST=1
81 .I $P(Y,U,3)]"" W "COST:",$J($P(Y,U,3),0,2) S IB1ST=0
82 .I $P(Y,U,4)]"" W:'IB1ST ", " W "GROSS AMT DUE:",$J($P(Y,U,4),0,2) S IB1ST=0
83 .I $P(Y,U,5)]"" W:'IB1ST ", " W "ADMIN FEE:",$J($P(Y,U,5),0,2)
84 Q:IBQ
85 ;
86 D CHKP^IBNCPEV Q:IBQ
87 W !?10,"USER:",$$USR^IBNCPEV(+$P(IBD3,U,10))
88 Q
89 ;
90 ;get Exemption status by name
91 ;IBEXMP - exemption (like "AO","EC", etc)
92 ;IBNODE - node ^IBCNR(366.14,D0,1,D1,4)
93EXMPFLDS(IBEXMP,IBNODE) ;
94 Q:IBEXMP="AO" $P(IBNODE,U,1)
95 Q:IBEXMP="CV" $P(IBNODE,U,2)
96 Q:IBEXMP="SWA" $P(IBNODE,U,3)
97 Q:IBEXMP="IR" $P(IBNODE,U,4)
98 Q:IBEXMP="MST" $P(IBNODE,U,5)
99 Q:IBEXMP="HNC" $P(IBNODE,U,6)
100 Q:IBEXMP="SC" $P(IBNODE,U,7)
101 Q:IBEXMP="SHAD" $P(IBNODE,U,8)
102 Q ""
103 ;returns DFN from file #366.14 by prescription ien of file #50
104GETDFN(IBRX) ;
105 N IB1,IB2
106 S IB1=+$O(^IBCNR(366.14,"I",IBRX,0))
107 I IB1=0 Q 0
108 S IB2=+$O(^IBCNR(366.14,"I",IBRX,IB1,0))
109 I IB2=0 Q 0
110 Q +$P($G(^IBCNR(366.14,IB1,1,IB2,0)),U,3)
111 ;
112 ;return DRUG name (#50,.01)
113 ;IBX1 - ien in file #50
114DRUGNAM(IBX1) ;
115 ;Q $P($G(^PSDRUG(IBX1,0)),U)
116 N X
117 K ^TMP($J,"IBNCPDP50")
118 D DATA^PSS50(IBX1,"","","","","IBNCPDP50")
119 S X=$G(^TMP($J,"IBNCPDP50",IBX1,.01))
120 K ^TMP($J,"IBNCPDP50")
121 Q X
122 ;
123DRUGAPI(DRUGIEN,FLDNUM) ;
124 ;return a DRUG's field value
125 ;input:
126 ; DRUGIEN - ien #50
127 ; FLDNUM - field number (like .01)
128 ;output:
129 ; returned value that contains the external value of the specified field
130 N IBARR,DIQ,DIC
131 S DIQ="IBARR",DIQ(0)="E",DIC=50
132 D EN^PSSDI(50,"IB",DIC,.FLDNUM,.DRUGIEN,.DIQ)
133 Q $G(IBARR(50,DRUGIEN,FLDNUM,"E"))
134 ;
135 ;reopen
136REOPEN ;
137 D CHKP^IBNCPEV Q:IBQ
138 D SUBHDR^IBNCPEV
139 I +$P(IBD3,U,3) D CHKP^IBNCPEV Q:IBQ W !?10,"PLAN:",$P($G(^IBA(355.3,+$P(IBD3,U,3),0)),U,3),", INSURANCE: ",$P($G(^DIC(36,+$G(^IBA(355.3,+$P(IBD3,U,3),0)),0)),U)
140 I $L($P(IBD3,U,6))>2 D CHKP^IBNCPEV Q:IBQ W !?10,"REOPEN COMMENTS:",$P(IBD3,U,6)
141 D CHKP^IBNCPEV Q:IBQ
142 D DISPUSR^IBNCPEV
143 Q
144 ;
145 ;Prompts user to select miltiple divisions (BPS PHARMACIES)
146 ; in order to filter the report by division(s) or for ALL divisions
147 ;
148 ;returns composite value:
149 ;1st piece
150 ; 1 - divisions were selected
151 ; 0 - divisions were NOT selected
152 ; -1 if upparrow entered or timeout
153 ;2nd piece
154 ; A-all or D - division(s) in the
155 ;
156 ;and by reference:
157 ;IBPSPHAR (only if the user selects "D") - a local array with iens and names
158 ; of BPS PHARMACY(is) (file #9002313.56) selected by the user
159 ; IBPSPHAR(ien of file #9002313.56) = ien of file #9002313.56 ^ name of the BPS PHARMACY
160 ;
161MULTIDIV(IBPSPHAR) ;
162 N IBDIVCNT,IBANSW,IBRETV
163 S IBRETV=$$SELPHARM^BPSUTIL(.IBPSPHAR)
164 I IBRETV="^" Q -1 ;exit
165 I IBRETV="A" Q "0^A"
166 Q "1^D"
167 ;
168 ;check if ePharmacy division in IB36614 in among those selected by the user
169 ;IBDIVS - a local array (by reference) with divisions selected by the user
170 ;returns 0 - not among selected divisions, 1 - among them
171CHECKDIV(IB36614,IBDIVS) ;
172 I $D(IBDIVS(IB36614)) Q 1
173 Q 0
174 ;
175 ;Compile the string for divisions
176 ;input:
177 ;IBDVS - division local array by reference
178 ;output:
179 ; return value with the resulting string
180DISPLDIV(IBDVS) ;
181 I ('$D(IBDVS))!($G(IBDVS)="") Q "" ;invalid parameters
182 I IBDVS=0 Q "" ;if "all" or single division
183 N IBZ,IBCNT,IBDIVSTR
184 S IBDIVSTR=""
185 S IBZ=0,IBCNT=0
186 F S IBZ=$O(IBDVS(IBZ)) Q:+IBZ=0 D
187 . I IBCNT>0 S IBDIVSTR=IBDIVSTR_", "
188 . S IBCNT=IBCNT+1
189 . S IBDIVSTR=IBDIVSTR_$P(IBDVS(IBZ),U,2)
190 I $L(IBDIVSTR)'<80 S IBDIVSTR=$E(IBDIVSTR,1,75)_"..."
191 Q $$CENTERIT(IBDIVSTR,80)
192 ;
193 ;Compile the string for title
194 ;input:
195 ;IBBDT - begin date
196 ;IBEDT - end date
197 ;IBDTL - summary/detail mode
198 ;IBDIVS - division local array by reference
199 ;output:
200 ; return value with the resulting string
201DISPTITL(IBBDT,IBEDT,IBDTL,IBDIVS) ;
202 I ('$D(IBDIVS))!($G(IBDIVS)="")!($G(IBBDT)="")!($G(IBEDT)="")!($G(IBDTL)="") Q "" ;invalid parameters
203 N IBTITL
204 S IBTITL="BILLING ECME EVENTS ON "_$$DAT^IBNCPEV(IBBDT)
205 I IBBDT'=IBEDT S IBTITL=IBTITL_" TO "_$$DAT^IBNCPEV(IBEDT)
206 S IBTITL=IBTITL_" ("_$S(IBDTL:"DETAILED",1:"SUMMARY")_") for "
207 I IBDIVS'=0 S IBTITL=IBTITL_"SELECTED DIVISIONS:"
208 I IBDIVS=0 S IBTITL=IBTITL_$P(IBDIVS(0),U,2)_" DIVISION" I $P(IBDIVS(0),U,2)="ALL" S IBTITL=IBTITL_"S"
209 Q $$CENTERIT(IBTITL,80)
210 ;
211 ;Center the string (add left pads to center the string)
212 ;input:
213 ;IBSTR - input string
214 ;IBMAXLEN - max len
215 ;output:
216 ; return value with the resulting string
217CENTERIT(IBSTR,IBMAXLEN) ;
218 I ($G(IBSTR)="")!(+$G(IBMAXLEN)=0) Q ""
219 N IBLEFT,IBSP
220 S IBSTR=$E(IBSTR,1,IBMAXLEN)
221 S IBLEFT=((IBMAXLEN-$L(IBSTR))/2)\1
222 S IBSP=""
223 S $P(IBSP," ",IBLEFT+1)=""
224 Q IBSP_IBSTR
225 ;Get list of indicators that were not answered
226GETNOANS(IBD4) ;
227 N IBX,IBT,IBSC,IBEXMPV,IBQ,IBRET
228 S IBQ=0,IBRET=""
229 F IBX=2:1 S IBT=$P($T(EXEMPT+IBX^IBNCPDP1),";",3),IBSC=$P(IBT,U,2) Q:IBSC="" S IBEXMPV=$$EXMPFLDS^IBNCPEV1(IBSC,IBD4) D:IBEXMPV]""
230 . I IBEXMPV=2 S IBRET=IBRET_","_IBSC
231 Q $S(IBRET="":"SC",1:$E(IBRET,2,99))
232 ;IBNCPEV1
Note: See TracBrowser for help on using the repository browser.