source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBJDB21.m@ 812

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

initial load of FOIAVistA 6/30/08 version

File size: 7.6 KB
Line 
1IBJDB21 ;ALB/RB - REASONS NOT BILLABLE REPORT (COMPILE) ;19-JUN-00
2 ;;2.0;INTEGRATED BILLING;**123,159,185**;21-MAR-94
3 ;
4EN ; - Entry point from IBJDB2.
5 K ^TMP("IBJDB2",$J),IB,IBE
6 I '$G(IBXTRACT) D
7 . F X=1:1:4 I IBSEL[X S IBE(X)=IBEPS(X) ; Set episodes for report.
8 ;
9 ; - Print the header line for the Excel spreadsheet
10 I $G(IBEXCEL) D PHDL
11 ;
12 ; - Compile reason not billable (RNB) data for episode.
13 S IBRNB=0 F S IBRNB=$S(IBSRNB'="A":$O(IBSRNB(IBRNB)),1:$O(^IBE(356.8,IBRNB))) Q:'IBRNB D
14 .S IB0=0 F S IB0=$O(^IBT(356,"AR",IBRNB,IB0)) Q:'IB0 D
15 ..S IBN0=$G(^IBT(356,IB0,0)),IBN1=$G(^IBT(356,IB0,1)) Q:'IBN0!('IBN1)
16 ..S IBEP=+$P(IBN0,U,18) I IBSEL'[IBEP Q ; Get episode.
17 ..S (IBRNB1,IBSORT1)=$P($G(^IBE(356.8,IBRNB,0)),U)
18 ..;
19 ..; - Get valid date entered/episode date and amount for report.
20 ..S IBEPD=+$P(IBN0,U,6)\1,IBDEN=+IBN1\1
21 ..S IBDT=$S($E(IBD)="D":IBDEN,1:IBEPD)
22 ..Q:IBDT<IBBDT!(IBDT>IBEDT)
23 ..S IBAMT=$$AMOUNT(IBEP,IB0)
24 ..;
25 ..; - Get division, if necessary.
26 ..I IBSD D Q:'VAUTD&('$D(VAUTD(IBDIV)))
27 ...S IBDIV=$$DIV^IBJD1(IB0)
28 ..E S IBDIV=$S($G(IBEXCEL):+$$PRIM^VASITE(),1:0)
29 ..;
30 ..; - Provider & Specialty
31 ..S (IBPRV,IBSPC)="",IBQT=0
32 ..I IBEP=1!(IBEP=2) D I IBQT Q
33 ...S IBPRSP=$$PRVSPC(IBEP,IB0)
34 ...I IBSPRV'="A",'$D(IBSPRV(+IBPRSP)) S IBQT=1 Q
35 ...I IBEP=1,IBSISP'="A",'$D(IBSISP(+$P(IBPRSP,U,3))) S IBQT=1 Q
36 ...I IBEP=2,IBSOSP'="A",'$D(IBSOSP(+$P(IBPRSP,U,3))) S IBQT=1 Q
37 ...S IBPRV=$S($P(IBPRSP,U,2)'="":$P(IBPRSP,U,2),1:"** UNKNOWN **")
38 ...S IBSPC=$S($P(IBPRSP,U,4)'="":$P(IBPRSP,U,4),1:"** UNKNOWN **")
39 ..;
40 ..; - Get remaining data for detailed report.
41 ..S DFN=+$P(IBN0,U,2)
42 ..D DEM^VADPT S IBPT=$E(VADM(1),1,25),IBSSN=$P(VADM(2),U)
43 ..S DIC="^VA(200,",DA=+$P(IBN1,U,4),DR=".01",DIQ="IBCLK" D EN^DIQ1
44 ..S IBCLK=$E($G(IBCLK(200,DA,.01)),1,20)
45 ..;
46 ..; - Get totals for summary.
47 ..I '$D(IB(IBDIV,IBEP,IBRNB)) S IB(IBDIV,IBEP,IBRNB)="0^0"
48 ..S $P(IB(IBDIV,IBEP,IBRNB),U)=$P(IB(IBDIV,IBEP,IBRNB),U)+1
49 ..S $P(IB(IBDIV,IBEP,IBRNB),U,2)=$P(IB(IBDIV,IBEP,IBRNB),U,2)+IBAMT
50 ..I IBRPT="S" Q
51 ..;
52 ..S IBSORT1=$S(IBSORT="P":IBPRV,IBSORT="S":IBSPC,1:IBSORT1)
53 ..S:IBSORT1="" IBSORT1=" "
54 ..;
55 ..I $G(IBEXCEL) D Q
56 ...W !,$E($P($G(^DG(40.8,IBDIV,0)),U),1,25),U
57 ...W $S(IBEP<4:$E(IBE(IBEP)),1:"H"),U,IBPT,U,IBSSN,U
58 ...W $$DT^IBJD(IBEPD,1),U,$$DT^IBJD(IBDEN,1),U
59 ...W $$DT^IBJD($P(IBN1,U,3),1),U,IBCLK,U,$E(IBRNB1,1,25),U
60 ...W $E(IBPRV,1,25),U,$E(IBSPC,1,25),U,IBAMT,U,$P(IBN1,U,8)
61 ..;
62 ..S X=IBEPD_U_IBDEN_U_$P(IBN1,U,3)_U_IBCLK_U_IBRNB1
63 ..S X=X_U_IBPRV_U_IBSPC_U_IBAMT_U_$E($P(IBN1,U,8),1,70)
64 ..S ^TMP("IBJDB2",$J,IBDIV,IBEP,IBSORT1,IBPT_"@@"_$E(IBSSN,6,10))=$$INS^IBJD1(+$P(IBN0,U,2),IBEPD)
65 ..S ^TMP("IBJDB2",$J,IBDIV,IBEP,IBSORT1,IBPT_"@@"_$E(IBSSN,6,10),+IBN0)=X
66 ;
67 I '$G(IBEXCEL) D EN^IBJDB22 ; Print report(s).
68 ;
69ENQ K ^TMP("IBJDB2")
70 K DA,DIC,DIQ,DR,IB,IB0,IBAMT,IBCLK,IBDEN,IBDIV,IBDT,IBE,IBEP,IBEPD,IBI
71 K IBN0,IBN1,IBN2,IBPRSP,IBPRV,IBPT,IBQT,IBRNB,IBRNB1,IBSORT1,IBSPC
72 K IBSSN,VADM,X1,X2
73 Q
74 ;
75AMOUNT(EPS,CLM) ; Return the Amount not billed
76 ; Input: EPS - Episode(1=Inpatient,2=Outpatient,3=Prosthet.,4=Prescr.)
77 ; CLM - Pointer to Claim Tracking File (#356)
78 ;Output: AMOUNT not billed
79 ;
80 N ADM,ADMDT,AMOUNT,BLBS,BLDT,CPT,CPTLST,DA,DR,DCHD,DFN,DIC,DIQ,DIV,DRG
81 N ENC,ENCDT,EPDT,PFT,PRST,PTF,RIMB,VCPT,TTCST,X
82 ;
83 S AMOUNT=0,X=$G(^IBT(356,CLM,0))
84 S ENC=+$P(X,U,4) ; Encounter (Pointer to #409.68)
85 S ADM=+$P(X,U,5) ; Admission (Pointer to #405)
86 S PRST=+$P(X,U,9) ; Prothetics (Pointer to #660)
87 S EPDT=$P(X,U,6) ; Episode Date (FM format)
88 ;
89 ; - Assumes REIMBURSABLE INS. as the RATE TYPE
90 S RIMB=$O(^DGCR(399.3,"B","REIMBURSABLE INS.",0)) I 'RIMB S RIMB=8
91 ;
92 G @("AMT"_EPS)
93 ;
94AMT1 ; - Inpatient Charges
95 I 'ADM G QAMT
96 S X=$G(^DGPM(ADM,0)) G QAMT:X="" S PTF=$P(X,U,16) G QAMT:'PTF
97 S ADMDT=$P(X,U)\1,DFN=+$P(X,U,3)
98 I $P(X,U,17) S DCHD=$P($G(^DGPM(+$P(X,U,17),0)),U)\1
99 I '$G(DCHD) S DCHD=$$DT^XLFDT()
100 ;
101 K ^TMP($J,"IBCRC-PTF"),^TMP($J,"IBCRC-DIV"),^TMP($J,"IBCRC-INDT")
102 D PTF^IBCRBG(PTF) G QAMT:'$D(^TMP($J,"IBCRC-PTF"))
103 D PTFDV^IBCRBG(PTF) G QAMT:'$D(^TMP($J,"IBCRC-DIV"))
104 D BSLOS^IBCRBG(ADMDT,DCHD,1,ADM,0) G QAMT:'$D(^TMP($J,"IBCRC-INDT"))
105 ;
106 S BLDT=""
107 F S BLDT=$O(^TMP($J,"IBCRC-INDT",BLDT)) Q:BLDT="" D
108 .S X=^TMP($J,"IBCRC-INDT",BLDT)
109 .S BLBS=$P(X,U,2),DRG=$P(X,U,4),DIV=$P(X,U,5)
110 .;
111 .; - Tort Liable Charge (prior to 09/01/99)
112 .I BLDT<2990901 D Q
113 ..S AMOUNT=AMOUNT+$$BICOST^IBCRCI(RIMB,1,BLDT,"INPATIENT BEDSECTION STAY",BLBS)
114 .;
115 .; - Reasonable Charges (on 09/01/99 or later)
116 .S AMOUNT=AMOUNT+$$BICOST^IBCRCI(RIMB,1,BLDT,"INPATIENT DRG",DRG,"",DIV,"",1)
117 ;
118 ; - Add the Professional Average Amount per Episode (Reason.Chg only)
119 I EPDT'<2990901 S AMOUNT=AMOUNT+$$AVG(EPDT)
120 ;
121 ; - Subtract the amount billed for this Episode
122 S AMOUNT=AMOUNT-$$CLAMT(DFN,EPDT,1)
123 ;
124 K ^TMP($J,"IBCRC-PTF"),^TMP($J,"IBCRC-DIV"),^TMP($J,"IBCRC-INDT")
125 ;
126 G QAMT
127 ;
128AMT2 ; - Outpatient Charges
129 S X=$$GETOE^SDOE(ENC),ENCDT=+$P(X,U),DFN=+$P(X,U,2),DIV=$P(X,U,11)
130 ;
131 ; - Tort Liable Charge (prior to 09/01/99)
132 I ENCDT<2990901 D G QAMT
133 . S AMOUNT=+$$BICOST^IBCRCI(RIMB,3,ENCDT,"OUTPATIENT VISIT DATE")
134 ;
135 D GETCPT^SDOE(ENC,"CPTLST") S VCPT=0
136 F S VCPT=$O(CPTLST(VCPT)) Q:VCPT="" D
137 .S CPT=+CPTLST(VCPT)
138 .S AMOUNT=AMOUNT+$$BICOST^IBCRCI(RIMB,3,ENCDT,"PROCEDURE",CPT,"",DIV,"")
139 ;
140 ; - Subtract the amount billed for this Episode
141 S AMOUNT=AMOUNT-$$CLAMT(DFN,EPDT,0)
142 G QAMT
143 ;
144AMT3 ; Prosthetic Charges
145 S DIC="^RMPR(660,",DA=PRST,DR="14",DIQ="TTCST" D EN^DIQ1
146 S AMOUNT=+$G(TTCST(660,DA,14))
147 G QAMT
148 ;
149AMT4 ; - Prescription Charges
150 ; - Tort Liable Charge & Reasonable Charge (same source)
151 S AMOUNT=+$$BICOST^IBCRCI(RIMB,3,EPDT,"PRESCRIPTION FILL")
152 ;
153QAMT I AMOUNT<0 S AMOUNT=0
154 Q AMOUNT
155 ;
156CLAMT(DFN,EPDT,PT) ; Returns the Total Amount of Claims for Patient/Episode
157 ;
158 ; Input: DFN - Pointer to the Patient File #2
159 ; EPDT - Episode Date
160 ; PT - 0=Outpatient, 1=Inpatient
161 ;
162 N CLAMT,CLM,DAY,IBD,X
163 S CLAMT=0,DAY=EPDT-1,CLM=""
164 F S CLM=$O(^DGCR(399,"C",DFN,CLM)) Q:'CLM D
165 .S X=$G(^DGCR(399,CLM,0))
166 .I $P($P(X,U,3),".")=$P(EPDT,".") D
167 ..S IBD=$$CKBIL^IBTUBOU(CLM,PT) Q:IBD=""
168 ..I '$P(IBD,U,3) Q ; Not authorized
169 ..S CLAMT=CLAMT+$G(^DGCR(399,CLM,"U1"))
170 ;
171QCLAMT Q CLAMT
172 ;
173AVG(EPDT) ; Returns the Average Amount of Inpatient Professional per
174 ; Number of Episodes for the previous 12 months
175 N AVG,M,Z
176 S AVG=0,M=EPDT\100*100
177 I '$D(^IBE(356.19,M,1)) S M=$O(^IBE(356.19,M),-1) I 'M G QAVG
178 S Z=$G(^IBE(356.19,M,1)) I $P(Z,U,12) S AVG=$P(Z,U,11)/$P(Z,U,12)
179QAVG Q $J(AVG,0,2)
180 ;
181PRVSPC(EPS,CLM) ; Return the Provider and the Specialty
182 ; Input: EPS - Episode(1 = Inpatient OR 2 = Outpatient)
183 ; CLM - Pointer to Claim Tracking File (#356)
184 ; Output: Provider Code (Pointer to #200) ^ Provider Name ^
185 ; Specialty Code (Pointer to #40.7 or #45.7) ^ Specialty Name
186 ;
187 N ADM,DFN,ENC,PRI,PRS,PRV,PRVLST,SPC,STP,X,VAIN,VAINDT
188 ;
189 S X=$G(^IBT(356,CLM,0))
190 S DFN=$P(X,U,2),ENC=$P(X,U,4),ADM=$P(X,U,5),PRS=$P(X,U,8)
191 ;
192 S (PRV,SPC)="^"
193 I EPS=1,ADM D G QPS ; Inpatient
194 .S X=$G(^DGPM(ADM,0)),VAINDT=$P(X,U)\1 I 'VAINDT Q
195 .D INP^VADPT S PRV=$G(VAIN(11)),SPC=$G(VAIN(3))
196 .S:PRV="" PRV="^" S:SPC="" SPC="^"
197 ;
198 I EPS=2,ENC D G QPS ; Outpatient
199 .D GETPRV^SDOE(ENC,"PRVLST")
200 .S (X,PRI)=""
201 .F S X=$O(PRVLST(X),-1) Q:X=""!PRI D
202 ..N IBX S PRV=+PRVLST(X)
203 ..I $P(PRVLST(X),U,4)="P" S PRI=1 ; Primary provider
204 ..I PRV S PRV=PRV_U_$P($G(^VA(200,+PRV,0)),U)
205 ..S IBX=$$GETOE^SDOE(ENC),STP=$P(IBX,U,3)
206 ..I STP'="" S SPC=STP_U_$P($G(^DIC(40.7,STP,0)),U)
207 ;
208QPS Q (PRV_U_SPC)
209 ;
210PHDL ; - Print the header line for the Excel spreadsheet
211 N X
212 S X="Division^Svc^Patient^SSN^Episode Dt^Dt Entered^Dt Lst Edit^"
213 S X=X_"Lst Edited By^RNB Cat^Provider^Specialty^Entry Amt^Comments"
214 W !,X
215 Q
Note: See TracBrowser for help on using the repository browser.