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

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

initial load of WorldVistAEHR

File size: 7.1 KB
Line 
1IBJDI6 ;ALB/CPM - SC VETS W/ NSC EPISODES OF INPT CARE ; 18-DEC-96
2 ;;2.0;INTEGRATED BILLING;**69,83,98,100**;21-MAR-94
3 ;
4EN ; - Option entry point.
5 ;
6 W !!,"This report provides a number of the NSC inpatient episodes for SC veterans"
7 W !,"which have and have not been billed.",!
8 ;
9DATE D DATE^IBOUTL I IBBDT=""!(IBEDT="") G ENQ
10 ;
11 ; - Select a detailed or summary report.
12 D DS^IBJD I IBRPT["^" G ENQ
13 ;
14 W !!,"This report only requires an 80 column printer."
15 ;
16 W !!,"Note: This report may take a while to run."
17 W !?6,"You should queue this report to run after normal business hours.",!
18 ;
19 ; - Select a device.
20 S %ZIS="QM" D ^%ZIS G:POP ENQ
21 I $D(IO("Q")) D G ENQ
22 .S ZTRTN="DQ^IBJDI6",ZTDESC="IB - SC VETS W/ NSC EPISODES"
23 .F I="IBBDT","IBEDT","IBRPT" S ZTSAVE(I)=""
24 .D ^%ZTLOAD
25 .W !!,$S($D(ZTSK):"This job has been queued. The task number is "_ZTSK_".",1:"Unable to queue this job.")
26 .K ZTSK,IO("Q") D HOME^%ZIS
27 ;
28 U IO
29 ;
30DQ ; - Tasked entry point.
31 ;
32 I $G(IBXTRACT) D E^IBJDE(6,1) ; Change extract status.
33 ;
34 K IB,^TMP("IBJDI6",$J)
35 S IBQ=0 F X="NSC","NSCB","NSCR","NSCU","SC","TOT" S IB(X)=0
36 F X=0:1:3 S IB("NSCU",X)=0
37 ;
38 ; - Find data required for the report.
39 S IBD=IBBDT-.01 F S IBD=$O(^DGPM("ATT3",IBD)) Q:'IBD!(IBD\1>IBEDT) D Q:IBQ
40 .S IBPM=0 F S IBPM=$O(^DGPM("ATT3",IBD,IBPM)) Q:'IBPM D Q:IBQ
41 ..I IBPM#100=0 S IBQ=$$STOP^IBOUTL("SC Vets w/NSC Episodes") Q:IBQ
42 ..S IBPMD=$G(^DGPM(IBPM,0)) Q:'IBPMD
43 ..S DFN=+$P(IBPMD,U,3) Q:'DFN
44 ..I $$TESTP^IBJDI1(DFN) Q ; Test patient.
45 ..S IBDIS=+IBPMD\1
46 ..;
47 ..; - Patient must be insured, and SC.
48 ..I '$$INSURED^IBCNS1(DFN,IBDIS) Q
49 ..D ELIG^VADPT Q:'VAEL(3)
50 ..;
51 ..; - Set 'totals' accumulator.
52 ..S IB("TOT")=IB("TOT")+1
53 ..;
54 ..; - See if associated PTF record has NSC movements.
55 ..S IBADMD=$G(^DGPM(+$P(IBPMD,U,14),0))
56 ..S IBPTF=+$P(IBADMD,U,16),IBSTAT=$P($G(^DGPT(IBPTF,0)),U,6)
57 ..I '$$PTF(IBPTF) S IB("SC")=IB("SC")+1 Q
58 ..S IB("NSC")=IB("NSC")+1
59 ..;
60 ..; - See if there is a claim for the NSC episode.
61 ..S IBADM=+IBADMD\1
62 ..I $$BILL(IBPTF,DFN,IBADM,IBDIS) S IB("NSCB")=IB("NSCB")+1 Q
63 ..;
64 ..; - Has episode been flagged as non-billable?
65 ..S IBCT=$O(^IBT(356,"AD",+$P(IBPMD,U,14),0))
66 ..I IBCT,$P($G(^IBT(356,IBCT,0)),U,19) S IB("NSCR")=IB("NSCR")+1 Q
67 ..;
68 ..S IB("NSCU")=IB("NSCU")+1
69 ..S IB("NSCU",IBSTAT)=IB("NSCU",IBSTAT)+1
70 ..I IBRPT="D" D
71 ...S X=$G(^DPT(DFN,0))
72 ...S ^TMP("IBJDI6",$J,$P(X,U)_"@@"_DFN)=$P(X,U,9)
73 ...S ^TMP("IBJDI6",$J,$P(X,U)_"@@"_DFN,IBADM)=$S(IBSTAT=0:"OPEN",IBSTAT=1:"CLOSED",IBSTAT=2:"RELEASED",1:"TRANSMITTED")_U_IBDIS
74 ;
75 I IBQ G ENQ
76 ;
77 I $G(IBXTRACT) D E^IBJDE(6,0) G ENQ ; Extract summary data.
78 ;
79 ; - Print the reports.
80 S (IBPAG,IBQ)=0 D NOW^%DTC S IBRUN=$$DAT2^IBOUTL(%)
81 I IBRPT="D" D DET
82 I 'IBQ D SUM
83 ;
84 I 'IBQ D PAUSE
85 ;
86ENQ K ^TMP("IBJDI6",$J)
87 I $D(ZTQUEUED) S ZTREQ="@" G ENQ1
88 ;
89 D ^%ZISC
90ENQ1 K IB,IBQ,IBBDT,IBEDT,IBRPT,IBD,IBDN,IBPAG,IBRUN,IBX,IBX1,IBX2
91 K IBADM,IBDIS,IBCT,IBH,IBPER,IBPM,IBPMD,IBPMDT,IBPTF,IBSTAT,IBADMD
92 K %,%ZIS,DFN,POP,VA,VAERR,VAEL,X,Y,ZTDESC,ZTRTN,ZTSAVE
93 Q
94 ;
95DET ; - Print the detailed report.
96 D HDET Q:IBQ
97 I '$D(^TMP("IBJDI6",$J)) D G DETQ
98 .I IB("NSC") W !!,"All NSC episodes for SC veterans in the selected date range have been billed." Q
99 .W !!,"There were no NSC episodes found in the selected date range."
100 ;
101 S IBX="" F S IBX=$O(^TMP("IBJDI6",$J,IBX)) Q:IBX="" S IBX1=^(IBX) D Q:IBQ
102 .S (IBH,IBADM)=0 F S IBADM=$O(^TMP("IBJDI6",$J,IBX,IBADM)) Q:'IBADM S IBX2=^(IBADM) D Q:IBQ
103 ..I $Y>(IOSL-2) D PAUSE Q:IBQ D HDET Q:IBQ S IBH=0
104 ..W ! I 'IBH D PAT S IBH=1
105 ..W ?46,$P(IBX2,U),?59,$$DAT1^IBOUTL(IBADM),?69,$$DAT1^IBOUTL($P(IBX2,U,2))
106 ;
107DETQ I 'IBQ D PAUSE
108 Q
109 ;
110PAT ; - Write the patient information.
111 W $P(IBX,"@@"),?32,$$SSN(IBX1)
112 Q
113 ;
114HDET ; - Write the detail report header.
115 I $E(IOST,1,2)="C-"!(IBPAG) W @IOF,*13
116 S IBPAG=IBPAG+1
117 W !,"Insured SC Vets w/ Unbilled NSC Care",?38,"Run Date: ",IBRUN,?70,"Page: ",IBPAG
118 W !,"For Patients discharged in the period "_$$DAT1^IBOUTL(IBBDT)_" to "_$$DAT1^IBOUTL(IBEDT)
119 W !,"Patient",?32,"SSN",?46,"PTF Status",?59,"Adm Date",?69,"Disc Date"
120 W !,$$DASH(80)
121 S IBQ=$$STOP^IBOUTL("SC Vets w/NSC Episodes")
122 Q
123 ;
124SUM ; - Print the summary report.
125 I $E(IOST,1,2)="C-"!(IBPAG) W @IOF,*13
126 S IBPAG=IBPAG+1
127 W !!?13,"INSURED SC VETERANS W/ UNBILLED NSC INPATIENT EPISODES"
128 W !?33,"SUMMARY REPORT"
129 W !!?16,"For Patients discharged from ",$$DAT1^IBOUTL(IBBDT)," - ",$$DAT1^IBOUTL(IBEDT)
130 W !!?24,"Run Date: ",IBRUN,!?24,$$DASH(31),!!
131 ;
132 S IBPER(1)=$S('IB("TOT"):0,1:$J(IB("SC")/IB("TOT")*100,0,2))
133 S IBPER(2)=$S('IB("NSC"):0,1:$J(IB("NSCB")/IB("NSC")*100,0,2))
134 S IBPER(3)=$S('IB("NSC"):0,1:$J(IB("NSCR")/IB("NSC")*100,0,2))
135 W ?9,"Number of Discharges of Insured SC Veterans:",?54,$J(IB("TOT"),4)
136 W !?5,"Discharges Which were totally Service-Connected:",?54,$J(IB("SC"),4),?62,"(",IBPER(1),"%)"
137 W !,"Discharges Which included Non-Service Connected Care:",?54,$J(IB("NSC"),4),?62,"(",$J($S('IB("TOT"):0,1:100-IBPER(1)),0,2),"%)"
138 W !?10,"Number of NSC Discharges Which were Billed:",?54,$J(IB("NSCB"),4),?62,"(",IBPER(2),"%)"
139 W !?4,"Number of NSC Discharges Flagged as Non-Billable:",?54,$J(IB("NSCR"),4),?62,"(",IBPER(3),"%)"
140 W !?19,"Number of Unbilled NSC Discharges:",?54,$J(IB("NSCU"),4),?62,"(",$J($S('IB("NSC"):0,1:100-IBPER(2)-IBPER(3)),0,2),"%)",!?54,"----"
141 F X=0:1:3 D
142 .I X=0 W !,"Unbilled NSC Discharges w/ PTF Status of"
143 .W ?41,$S(X=0:"Open",X=1:"Closed",X=2:"Released",1:"Transmitted"),":",?54,$J(IB("NSCU",X),4),?62,"(",$J($S('IB("NSCU",X):0,1:IB("NSCU",X)/IB("NSCU")*100),0,2),"%)",!
144 Q
145 ;
146DASH(X) ; - Return a dashed line.
147 Q $TR($J("",X)," ","=")
148 ;
149PAUSE ; - Page break.
150 I $E(IOST,1,2)'="C-" Q
151 N IBX,DIR,DIRUT,DUOUT,DTOUT,DIROUT,X,Y
152 F IBX=$Y:1:(IOSL-3) W !
153 S DIR(0)="E" D ^DIR I $D(DIRUT)!($D(DUOUT)) S IBQ=1
154 Q
155 ;
156SSN(X) ; - Format the SSN.
157 Q $S(X]"":$E(X,1,3)_"-"_$E(X,4,5)_"-"_$E(X,6,10),1:"")
158 ;
159PTF(IBPTF) ; - Does the PTF record have an NSC-related movement?
160 ; Input: IBPTF = Pointer to the PTF record in file #45
161 ; Output: IBNSC = 1 (NSC movement) or 0 (No NSC movement)
162 ;
163 N IBNSC,X,Y
164 S (IBNSC,X)=0
165 I '$G(IBPTF) G PTFQ
166 ;
167 ; - Check PTF movements for a movement not related to SC care.
168 F S X=$O(^DGPT(IBPTF,"M",X)) Q:'X S Y=$P($G(^(X,0)),U,18) I Y'=1 S IBNSC=1 Q
169 ;
170PTFQ Q IBNSC
171 ;
172BILL(IBPTF,DFN,IBADM,IBDIS) ; - Has this episode of care been billed?
173 ; Input: IBPTF = Pointer to the PTF record in file #45
174 ; DFN = Pointer to the patient in file #2
175 ; IBADM = Episode admission date
176 ; IBDIS = Episode discharge date
177 ; Output: BILL = 1 (Episode has been billed)
178 ; 0 (Episode has not been billed)
179 ;
180 N BILL,X,X1,XU,Y
181 S BILL=0
182 ;
183 ; - See if there is a claim based on the PTF record.
184 I $G(IBPTF) D G:BILL BILLQ
185 .S X=0 F S X=$O(^DGCR(399,"APTF",IBPTF,X)) Q:'X S Y=$P($G(^DGCR(399,X,0)),U,13) I Y,Y<7 S BILL=1 Q
186 ;
187 ; - Check other inpatient bills for care provided in the adm/dis period.
188 S X=0 F S X=$O(^DGCR(399,"C",+$G(DFN),X)) Q:'X D Q:BILL
189 .S X1=$G(^DGCR(399,X,0)),XU=$G(^("U")) Q:X1=""
190 .I $P(X1,U,5)>2 Q ; Outpatient care.
191 .I $P(X1,U,13)=7 Q ; Bill is cancelled.
192 .I +XU\1<IBADM!($P(XU,U,2)\1>IBEDT) Q ; Care outside of range.
193 .S BILL=1
194 ;
195BILLQ Q BILL
Note: See TracBrowser for help on using the repository browser.