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

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

initial load of FOIAVistA 6/30/08 version

File size: 7.2 KB
Line 
1IBJDB11 ;ALB/CPM - BILLING LAG TIME REPORT (COMPILE) ; 27-DEC-96
2 ;;2.0;INTEGRATED BILLING;**69,100,118,165**;21-MAR-94
3 ;
4EN ; - Entry point from IBJDB1.
5 ;
6 ; -
7 I IBRPT="D" F X=2,3,4,6,7,8 S:IBSEL[X IBSEL=IBSEL_X_"I,"
8 I 'IBSORT D INIT(0) G REV
9 S X=0 F S X=$S('VAUTD:$O(VAUTD(X)),1:$O(^DG(40.8,X))) Q:'X D INIT(X)
10 ;
11REV ; - Review all claims in file #399.
12 S IBN=0 F S IBN=$O(^DGCR(399,IBN)) Q:'IBN S IBN0=$G(^(IBN,0)) D Q:IBQ
13 .I IBN#100=0 S IBQ=$$STOP^IBOUTL("Billing Lag Time Report") Q:IBQ
14 .;
15 .I $P($G(^PRCA(430,IBN,0)),U,2)'=9 Q ; Not an RI claim.
16 .I $P(IBN0,U,13)<3 Q ; Not authorized.
17 .I $P(IBN0,U,13)=7 Q ; Cancelled in IB.
18 .S X=$P($G(^PRCA(430,IBN,0)),U,8) I X=26!(X=39) Q ; Cancelled in AR.
19 .;
20 .; - Does claim meet report criteria?
21 .S IBAUTH=$$AUTH(IBN) I 'IBAUTH Q
22 .;
23 .; - Get division, if necessary.
24 .I 'IBSORT S IBDIV=0
25 .E S IBDIV=$$DIV^IBJDF2(IBN) I 'IBDIV S IBDIV=+$$PRIM^VASITE()
26 .I IBSORT,'VAUTD,'$D(VAUTD(IBDIV)) Q ; Not a selected division.
27 .;
28 .S IBTY=$S($P(IBN0,U,5)<3:"IN",1:"OP") ; Inpatient or outpatient claim?
29 .;
30 .;- Get date PTF transmitted.
31 .S IBPTF="" I IBTY="IN" S IBPTF=$$PTF($P(IBN0,U,8)) Q:'IBPTF
32 .;
33 .; - Get other claim info and build date line.
34 .S IBDAT=$P(IBAUTH,U,2,5),DFN=+$P(IBN0,U,2),IBDFN=$G(^DPT(DFN,0))
35 .S IBPOL=+$G(^DPT(DFN,.312,+$P($G(^DGCR(399,IBN,"MP")),U,2),1))
36 .;
37 .; - Get care dates; quit if there are none.
38 .K IBDR S IBNU=$G(^DGCR(399,IBN,"U")) D
39 ..I IBTY="IN" S X=+$P(IBNU,U,2) S:'X X=+IBNU S:X IBDR(X)="" Q
40 ..I '$D(^DGCR(399,IBN,"OP")) D Q
41 ...S X=+$P(IBNU,U,2) S:X IBDR(X)="" S:+IBNU&(+IBNU'=X) IBDR(+IBNU)=""
42 ..S X=0 F S X=$O(^DGCR(399,IBN,"OP",X)) Q:'X S IBDR(X)=""
43 .I '$D(IBDR) Q
44 .;
45 .; - Calculate statistics for each care date.
46 .S IBX=0 F S IBX=$O(IBDR(IBX)) Q:'IBX D
47 ..;
48 ..; - Get discharge date.
49 ..I IBTY="IN" D
50 ...S IBX1=+$G(^DGPT(+$P(IBN0,U,8),70))\1 I IBX1 Q
51 ...S IBX1=+$O(^DGPM("APTT3",DFN,(IBX-.0001)))\1 I 'IBX1 S IBX1=IBX
52 ..;
53 ..; - Get most recent check out date that has not been marked as non
54 ..; billable by Claims Tracking; quit if there isn't one.
55 ..I IBTY="OP" D K IBCL,IBCL1 Q:'IBCHK
56 ...D CL(IBN) ;GET LIST OF CLINICS FOR THIS BILL
57 ...S IBCHK=0,IBX1=IBX-.0001
58 ...F S IBX1=$O(^SCE("ADFN",DFN,IBX1)) Q:'IBX1!((IBX1\1)>IBX) D
59 ....S IBX2=0 F S IBX2=$O(^SCE("ADFN",DFN,IBX1,IBX2)) Q:'IBX2 D
60 .....;
61 .....;CHECK TO SEE IF CLINICS MATCH
62 .....S IBCL1=+$P($G(^SCE(IBX2,0)),U,4) Q:'$D(IBCL(IBCL1))
63 .....I $P($G(^IBT(356,+$O(^IBT(356,"ASCE",IBX2,0)),0)),U,19) Q
64 .....S IBX3=$P($G(^SCE(IBX2,0)),U,7)\1 I IBX3,IBX3'>$P(IBAUTH,U,2) D
65 ...... S:IBX3>IBCHK IBCHK=IBX3 Q
66 ..;
67 ..S X=$S(IBTY="IN":IBX1_U_+IBPTF,1:IBX_U_IBCHK)_U_IBDAT
68 ..S IBPOL1=$S(IBPOL>+X:1,1:0) ; Policy found after treatment.
69 ..;
70 ..; - Check date line for at least one date within the user specified
71 ..; range; quit if there isn't any.
72 ..S IBDCHK=0 F Y=2:1:6 I $$DL(0,$P(X,U,Y)) S IBDCHK=1 Q
73 ..I 'IBDCHK Q
74 ..;
75 ..K D,Y,Z S IBSEL1=""
76 ..F Y=1:1:5 S Z(1)=$P(X,U,Y),Z(2)=$P(X,U,Y+1) D
77 ...;
78 ...; - Check out date/PTF transmission date.
79 ...I Y=1 D:Z(2) Q
80 ....S D(0)=$$FMDIFF^XLFDT(Z(2),Z(1)),Z=$S(IBTY="IN":5,1:1)
81 ....I $$DL(Z,Z(2)) S IBSEL1=IBSEL1_Z_",",Y(Z)=$S(IBRPT="D":Z(1)_U_Z(2)_U_D(0),1:D(0))
82 ...;
83 ...; - Date authorized.
84 ...I Y=2 D:Z(1) Q
85 ....S D(1)=$$FMDIFF^XLFDT(Z(2),Z(1)),Z=$S(IBTY="IN":6,1:2)
86 ....I $$DL(Z,Z(2)) D
87 .....S Z1=$S(IBPOL1:Z_"I",1:Z),IBSEL1=IBSEL1_Z1_",",Y(Z1)=$S(IBRPT="D":Z(1)_U_Z(2)_U_D(1),1:D(1))
88 .....I Z1=Z D
89 ......S Z2=Z_"I",IBSEL1=IBSEL1_Z2_",",Y(Z2)=$S(IBRPT="D":Z(1)_U_Z(2)_U_D(1),1:D(1))
90 ...;
91 ...; - Date activated.
92 ...I Y=3 D:Z(2) Q
93 ....S D(2)=$$FMDIFF^XLFDT(Z(2),Z(1)) I $$DL(9,Z(2)) S IBSEL1=IBSEL1_"9,",Y(9)=$S(IBRPT="D":Z(1)_U_Z(2)_U_D(2),1:D(2))
94 ...;
95 ...; - Payment date.
96 ...I Y=4 D:Z(2) Q
97 ....S D(3)=$$FMDIFF^XLFDT(Z(2),Z(1)),D(6)=$$FMDIFF^XLFDT(Z(2),+X)
98 ....F Z=$S(IBTY="IN":7,1:3),10 I $$DL(Z,Z(2)) D
99 .....S Z1=$S(IBPOL1&(Z<10):Z_"I",1:Z),Z2=$S(Z<10:6,1:3)
100 .....S IBSEL1=IBSEL1_Z1_",",Y(Z1)=$S(IBRPT="D":$S(Z2=3:Z(1),1:+X)_U_Z(2)_U_D(Z2),1:D(Z2))
101 .....I Z1=Z,Z<10 S Z3=Z_"I",IBSEL1=IBSEL1_Z3_",",Y(Z3)=$S(IBRPT="D":$S(Z2=3:Z(1),1:+X)_U_Z(2)_U_D(Z2),1:D(Z2))
102 ...;
103 ...; - Date closed.
104 ...I Z(2) D
105 ....S D(4)=$$FMDIFF^XLFDT(Z(2),Z(1)),D(5)=$$FMDIFF^XLFDT(Z(2),+X)
106 ....F Z=$S(IBTY="IN":8,1:4),11 I $$DL(Z,Z(2)) D
107 .....S Z1=$S(IBPOL1&(Z<11):Z_"I",1:Z),Z2=$S(Z<11:5,1:4)
108 .....S IBSEL1=IBSEL1_Z1_",",Y(Z1)=$S(IBRPT="D":$S(Z2=4:Z(1),1:+X)_U_Z(2)_U_D(Z2),1:D(Z2))
109 .....I Z1=Z,Z<11 S Z3=Z_"I",IBSEL1=IBSEL1_Z3_",",Y(Z3)=$S(IBRPT="D":$S(Z2=4:Z(1),1:+X)_U_Z(2)_U_D(Z2),1:D(Z2))
110 ..;
111 ..; - Save data for detail or summary report(s).
112 ..F Y=1:1 S Z=$P(IBSEL1,",",Y) Q:'Z D
113 ...I IBRPT="D" D
114 ....S IBBN=$P(IBN0,U) S:IBPOL1 IBBN=IBBN_"*"
115 ....S Y(Z)=IBBN_U_Y(Z),Y1(Z)=$G(Y1(Z))+1
116 ....S ^TMP("IBJDB1",$J,IBDIV,IBTY,Z,$P(IBDFN,U)_"@@"_$P(IBDFN,U,9),Y1(Z))=Y(Z)
117 ...E S IBCT(IBDIV,IBTY,Z)=IBCT(IBDIV,IBTY,Z)+1,IBTL(IBDIV,IBTY,Z)=IBTL(IBDIV,IBTY,Z)+Y(Z)
118 ;
119 Q
120 ;
121INIT(X) ; - Initialize summary accumulators/detail division nodes.
122 I IBRPT="D" S ^TMP("IBJDB1",$J,X)="" Q
123 F Y=1:1:4,9,10,11,"2I","3I","4I" S (IBCT(X,"OP",Y),IBTL(X,"OP",Y))=0
124 F Y=5:1:11,"6I","7I","8I" S (IBCT(X,"IN",Y),IBTL(X,"IN",Y))=0
125 Q
126 ;
127AUTH(IBN) ; - Is this an authorized claim?
128 ; Input: IBN=Pointer to the AR in file #430
129 ; Output: VAL=1^2^3^4^5, where:
130 ; 1=1-Authorized claim
131 ; 0-Not an authorized claim
132 ; 2=Date AR was authorized
133 ; 3=Date AR was activated
134 ; 4=AR first payment date
135 ; 5=Date AR was closed
136 ;
137 N IBPAY,IBT,IBT0,IBT1,VAL,X
138 S VAL=0 I '$G(IBN) G AUTHQ
139 ;
140 ; - Get date authorized (required).
141 S X=$P($G(^DGCR(399,IBN,"S")),U,10) G:'X AUTHQ S VAL="1^"_X
142 ;
143 ; - Get date activated, if available.
144 S X=$P($G(^PRCA(430,IBN,6)),U,21) I X S $P(VAL,U,3)=X\1 G FP
145 S X=$P($G(^PRCA(430,IBN,9)),U,3) I X S $P(VAL,U,3)=X\1 G FP
146 S X=$P($G(^PRCA(430,IBN,0)),U,10) I X S $P(VAL,U,3)=X\1
147 ;
148FP ; - Get first payment date, if available.
149 I '$P($G(^PRCA(430,IBN,7)),U,7) G DC ; No payments made.
150 S (IBPAY,IBT)=0 F S IBT=$O(^PRCA(433,"C",IBN,IBT)) Q:'IBT D Q:IBPAY
151 .S IBT0=$G(^PRCA(433,IBT,0)),IBT1=$G(^(1))
152 .I $P(IBT0,U,4)'=2 Q ; Not complete.
153 .I $P(IBT1,U,2)'=2,$P(IBT1,U,2)'=34 Q ; Not a payment.
154 .S X=$S(+IBT1:+IBT1,1:$P(IBT1,U,9)\1),$P(VAL,U,4)=X,IBPAY=1
155 ;
156DC ; - Get date AR closed.
157 S X=$$CLO^PRCAFN(IBN) I X>0 S $P(VAL,U,5)=X
158 ;
159 ; - Is there a payment date AND a closed date for this claim?
160 I '$P(VAL,U,4),$P(VAL,U,5) S $P(VAL,U)=0
161 ;
162AUTHQ Q VAL
163 ;
164DL(X,X1) ; - Is line item date valid for report?
165 ; Input: X=Line item number (or 0), X1=Line item date
166 ; Output: 1=valid, 0=invalid
167 ; *Requires pre-defined variables IBBDT, IBEDT, and IBSEL
168 S X2=0 I 'X1 G DLQ
169 I 'X S:X1'<IBBDT&(X1'>IBEDT) X2=1 G DLQ
170 I IBSEL[(","_X_","),X1'<IBBDT,X1'>IBEDT S X2=1
171DLQ Q X2
172 ;
173 ;
174PTF(X) ; - Get most recent PTF transmission date.
175 ; Input: X=IEN of PTF file entry.
176 ; Output: Y=PTF date.
177 N I,K,Y
178 S Y=0 G:'$O(^DGP(45.83,"C",+X,0)) PTFQ
179 S I=0 F S I=$O(^DGP(45.83,"C",X,I)) Q:'I D
180 .S J=$P($G(^DGP(45.83,I,0)),U,2)\1 Q:J>$P(IBAUTH,U,2) S:J K(J)=""
181 S I=0 F S I=$O(K(I)) Q:'I S Y=I
182 ;
183PTFQ Q Y
184 ;
185CL(IBN) ; - Get the clinics for bill.
186 N I,J K IBCL ; IBCL=Bill clinic array.
187 S I=0 F S I=$O(^DGCR(399,IBN,"CP",I)) Q:I="" D
188 .S J=$P($G(^DGCR(399,IBN,"CP",I,0)),U,7) S:J IBCL(J)=""
189 Q
Note: See TracBrowser for help on using the repository browser.