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

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

initial load of WorldVistAEHR

File size: 8.0 KB
RevLine 
[613]1IBJDI5 ;ALB/CPM - INSURANCE POLICIES NOT VERIFIED ; 18-DEC-96
2 ;;2.0;INTEGRATED BILLING;**69,98,100,118,123**;21-MAR-94
3 ;
4EN ; - Option entry point.
5 ;
6 W !!,"This report provides a number of the insurance policies which were"
7 W !,"entered into the system within a given timeframe, but were never verified.",!
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 ; - Select print/not print verified policies/totals.
15 S DIR(0)="YO"
16 S DIR("A",1)="Do you want to print a "_$S(IBRPT="D":"separate report for",1:"total number of")_" policies that were verified"
17 S DIR("A")=" over a year ago"
18 S DIR("B")="NO" D ^DIR K DIR S IBVER=Y I IBVER["^" G ENQ
19 ;
20 I IBRPT="D" W !!,"You will need a 132 column printer for this report!"
21 E W !!,"This report only requires an 80 column printer."
22 ;
23 W !!,"Note: This report may take a while to run."
24 W !?6,"You should queue this report to run after normal business hours.",!
25 ;
26 ; - Select a device.
27 S %ZIS="QM" D ^%ZIS G:POP ENQ
28 I $D(IO("Q")) D G ENQ
29 .S ZTRTN="DQ^IBJDI5",ZTDESC="IB - INSURANCE POLICIES NOT VERIFIED"
30 .F I="IBBDT","IBEDT","IBRPT","IBVER" S ZTSAVE(I)=""
31 .D ^%ZTLOAD
32 .W !!,$S($D(ZTSK):"This job has been queued. The task number is "_ZTSK_".",1:"Unable to queue this job.")
33 .K ZTSK,IO("Q") D HOME^%ZIS
34 ;
35 U IO
36 ;
37DQ ; - Tasked entry point.
38 ;
39 I $G(IBXTRACT) D E^IBJDE(5,1) ; Change extract status.
40 ;
41 N IBQUERY
42 K IB,^TMP("IBJDI51",$J),^TMP("IBJDI52",$J)
43 S (IB("NOT"),IB("TOT"),IB("VER"),IBQ)=0 S:IBVER IB("VERO")=0
44 ;
45 ; - Find inpatients treated within the user-specified date range.
46 S IBD=IBBDT-.01 F S IBD=$O(^DGPM("ATT3",IBD)) Q:'IBD!(IBD\1>IBEDT) D Q:IBQ
47 .S IBPM=0 F S IBPM=$O(^DGPM("ATT3",IBD,IBPM)) Q:'IBPM D Q:IBQ
48 ..I IBPM#100=0 S IBQ=$$STOP^IBOUTL("Insurance Policies Not Verified") Q:IBQ
49 ..S IBPMD=$G(^DGPM(IBPM,0)) Q:'IBPMD
50 ..S DFN=+$P(IBPMD,U,3) Q:'DFN
51 ..;
52 ..; - Process patient.
53 ..I '$D(^TMP("IBJDI51",$J,DFN)) D PROC(DFN,"*",IBD)
54 ;
55 I IBQ G ENQ
56 ;
57 ; - Find outpatients treated within the user-specified date range.
58 D CLOSE^IBSDU(.IBQUERY)
59 D OUTPT^IBJDI21("",IBBDT,IBEDT,"S:IBQ SDSTOP=1 I 'IBQ,$$ENCHK^IBJDI5(Y0) D ENC^IBJDI5(Y0)","Insurance Policies Not Verified",.IBQ,"IBJDI51",.IBQUERY)
60 D CLOSE^IBSDU(.IBQUERY)
61 ;
62 I IBQ G ENQ
63 ;
64 ; - Find data required for the report.
65 S IBC=0 F S IBC=$O(^TMP("IBJDI51",$J,IBC)) Q:'IBC D Q:IBQ
66 .I IBC#100=0 S IBQ=$$STOP^IBOUTL("Insurance Policies Not Verified") Q:IBQ
67 .;
68 .; - Get the patient's active insurance policies.
69 .K IBINS S IBC1=$G(^TMP("IBJDI51",$J,IBC))
70 .D ALL^IBCNS1(IBC,"IBINS",1,+IBC1) Q:'$D(IBINS)
71 .S IBC2=0 F S IBC2=$O(IBINS(IBC2)) Q:'IBC2 D
72 ..;
73 ..; - Make sure the insurance company reimburses VA.
74 ..S IBC3=$G(^DIC(36,+$G(IBINS(IBC2,0)),0))
75 ..Q:$P(IBC3,U)="" Q:$P(IBC3,U,2)="N"
76 ..;
77 ..S IBCDFND=$G(IBINS(IBC2,1))
78 ..;
79 ..S IB("TOT")=IB("TOT")+1 ; Count all.
80 ..;
81 ..; - Check if policy is verified, verified over a year, or neither.
82 ..S IBVFLG=0
83 ..I $P(IBCDFND,U,3) D Q:'IBVFLG
84 ...S IB("VER")=IB("VER")+1 Q:'IBVER
85 ...S X1=DT,X2=$P(IBCDFND,U,3) D ^%DTC
86 ...I X>365 S IB("VERO")=IB("VERO")+1,IBVFLG=1
87 ..E S IB("NOT")=IB("NOT")+1
88 ..;
89 ..; - Build line for detailed report.
90 ..I IBRPT="D" D
91 ...S IBDOD=$S(+$G(^DPT(IBC,.35)):$$DAT2^IBOUTL(+$G(^(.35))\1),1:"")
92 ...S X=$G(^DPT(IBC,0)),IBEBY=$P(IBCDFND,U,2)
93 ...S IBVDTE=$S(IBVFLG:$P(IBCDFND,U,3),1:"")
94 ...S IBVBY=$S(IBVFLG:$P(IBCDFND,U,4),1:"")
95 ...S ^TMP("IBJDI52",$J,IBVFLG,$P(X,U)_$P(IBC1,U,2)_"@@"_$P(X,U,9)_"@@"_IBDOD_"@@"_IBC,IBC2)=$P(IBC3,U)_U_IBEBY_U_$S(+IBCDFND>0:+IBCDFND\1,1:"")_U_IBVBY_U_$S(+IBVDTE>0:IBVDTE\1,1:"")
96 ;
97 I IBQ G ENQ
98 ;
99 I $G(IBXTRACT) D E^IBJDE(5,0) G ENQ ; Extract summary data.
100 ;
101 ; - Print the reports.
102 S (IBPAG,IBQ)=0 D NOW^%DTC S IBRUN=$$DAT2^IBOUTL(%)
103 I IBRPT="D" D DET
104 I 'IBQ D SUM
105 ;
106 I 'IBQ D PAUSE
107 ;
108ENQ K ^TMP("IBJDI51",$J),^TMP("IBJDI52",$J)
109 I $D(ZTQUEUED) S ZTREQ="@" G ENQ1
110 ;
111 D ^%ZISC
112ENQ1 K IB,IBQ,IBBDT,IBEDT,IBRPT,IBD,IBDN,IBPH,IBPM,IBINS,IBPMD,IBPAG,IBRUN,%
113 K IBEBY,IBVBY,IBVDTE,IBDOD,IBPER,IBC,IBC1,IBC2,IBC3,IBCDFN,IBVER,IBVFLG
114 K IBCDFND,IBX,IBX1,IBX2,IBX3,DFN,POP,X,X1,X2,Y,ZTDESC,ZTRTN,ZTSAVE,%ZIS
115 Q
116 ;
117ENC(IBOED) ; - Encounter extract for outpatient loop.
118 ; Input: IBOED = Outpatient encounter in file #409.68
119 ;
120 D PROC(+$P(IBOED,U,2),"",+IBOED) ; Process patient.
121 Q
122 ;
123PROC(DFN,IBIPC,IBDTE) ; - Process each specific patient.
124 ; Input: DFN = Pointer to the patient in file #2
125 ; IBIPC = Inpatient treatment marker
126 ; ("*"=Had inpat. treatment, null=No inpat. treatment)
127 ; IBDTE = Patient's checkout or discharge date
128 ;
129 I $$TESTP^IBJDI1(DFN) Q ; Test patient.
130 D ELIG^VADPT I 'VAEL(4) G PRCQ ; Patient is not a vet.
131 ;
132 ; - Set patient index.
133 S ^TMP("IBJDI51",$J,DFN)=IBDTE\1_U_IBIPC
134 ;
135PRCQ K VA,VAERR,VAEL
136 Q
137 ;
138ENCHK(IBOED) ; - Check outpatient's encounter record.
139 ; Input: IBOED = Outpatient encounter in file #409.68
140 ; Output: 1 = OK for processing
141 ; 0 = Not OK for processing
142 ;
143 N X,X1 S Y=0 I '$G(IBOED) G ENCKQ
144 ;
145 ; - Check if encounter was a registration/cancellation without exam.
146 S X=+$P(IBOED,U,2)
147 S X1=+$P($G(^DPT(X,"DIS",+$O(^DPT("ADIS",+IBOED,X,0)),0)),U,7)
148 I $D(^DIC(37,"B","CANCEL WITHOUT EXAM",X1)) G ENCKQ
149 I $D(^DIC(37,"B","NO CARE OR TREATMENT REQUIRED",X1)) G ENCKQ
150 ;
151 I "^1^4^7^"[("^"_+$P(IBOED,U,10)_"^") G ENCKQ ; C&P/collat/emply visit.
152 I $P(IBOED,U,12)'=2 G ENCKQ ; Not checked out.
153 ;
154 S Y=1
155ENCKQ Q Y
156 ;
157DET ; - Print the detailed report.
158 I '$D(^TMP("IBJDI52",$J,0)) S IBX=0 D HDET W !,"All policies within the selected date range have been verified." D PAUSE
159 S IBX="" F S IBX=$O(^TMP("IBJDI52",$J,IBX)) Q:IBX="" D Q:IBQ
160 .D HDET Q:IBQ
161 .S IBX1="" F S IBX1=$O(^TMP("IBJDI52",$J,IBX,IBX1)) Q:IBX1="" D Q:IBQ
162 ..I $Y>(IOSL-4) D PAUSE Q:IBQ D HDET Q:IBQ
163 ..W $P(IBX1,"@@"),?33,$$SSN($P(IBX1,"@@",2)),?47,$P(IBX1,"@@",3)
164 ..S IBX2=0 F S IBX2=$O(^TMP("IBJDI52",$J,IBX,IBX1,IBX2)) Q:'IBX2 S IBX3=^(IBX2) D
165 ...I $Y>(IOSL-4) D PAUSE Q:IBQ D HDET Q:IBQ
166 ...W ?62,$P(IBX3,U),?94,$E($P($G(^VA(200,+$P(IBX3,U,2),0)),U),1,24)
167 ...W ?120,$$DAT2^IBOUTL($P(IBX3,U,3)),!
168 ...I IBX W ?94,$E($P($G(^VA(200,+$P(IBX3,U,4),0)),U),1,24),?120,$$DAT2^IBOUTL($P(IBX3,U,5)),!
169 .;
170 .I 'IBQ D PAUSE
171 ;
172 I '$D(^TMP("IBJDI52",$J,1)),IBVER S IBX=1 D HDET W !,"All policies within the selected date range have been verified less than a year ago." D PAUSE
173 Q
174 ;
175HDET ; - Write the detail report header.
176 I $E(IOST,1,2)="C-"!(IBPAG) W @IOF,*13
177 S IBPAG=IBPAG+1
178 W !,"Insurance Policies ",$S(IBX:"Verified Over a Year Ago",1:"Not Verified"),?80,"Run Date: ",IBRUN,?123,"Page: ",IBPAG
179 W !,"For Patients treated for the period "_$$DAT1^IBOUTL(IBBDT)_" to "_$$DAT1^IBOUTL(IBEDT)_" ('*' = Had inpatient care)"
180 I IBX W !?94,"Policy Entered By Date Entered"
181 W !,"Patient",?33,"SSN",?47,"Date of Death"
182 W ?62,"Insurance Company",?94,"Policy ",$S(IBX:"Verified",1:"Entered")," By",?120,"Date ",$S(IBX:"Verif'd",1:"Entered")
183 W !,$$DASH(132),!!
184 S IBQ=$$STOP^IBOUTL("Insurance Policies Not Verified")
185 Q
186 ;
187SUM ; - Print the summary report.
188 I $E(IOST,1,2)="C-"!(IBPAG) W @IOF,*13
189 S IBPAG=IBPAG+1
190 W !!?$S(IBVER:14,1:24),"INSURANCE POLICIES NOT VERIFIED",$S(IBVER:"/VERIFIED OVER 1 YEAR",1:"")
191 W !?32,"SUMMARY REPORT",!!?17,"For Patients treated from ",$$DAT1^IBOUTL(IBBDT)," - ",$$DAT1^IBOUTL(IBEDT)
192 W !!?24,"Run Date: ",IBRUN,!?24,$$DASH(31),!!
193 ;
194 S IBPER=$S('IB("TOT"):0,1:$J(IB("VER")/IB("TOT")*100,0,2))
195 W ?24,"Number of Patients Treated:",?53,$J(IB("TOT"),5)
196 W !?23,"Number of Policies Verified:",?53,$J(IB("VER"),5),?62,"(",IBPER,"%)"
197 I IBVER W !?7,"Number of Policies Verified Over a Year Ago:",?53,$J(IB("VERO"),5),?62,"(",$S('IB("VERO"):0,1:$J(IB("VERO")/IB("TOT")*100,0,2)),"%)"
198 W !?19,"Number of Policies Not Verified:",?53,$J(IB("NOT"),5),?62,"(",$S('IB("TOT"):0,1:$J(100-IBPER,0,2)),"%)"
199 Q
200 ;
201DASH(X) ; - Return a dashed line.
202 Q $TR($J("",X)," ","=")
203 ;
204PAUSE ; - Page break.
205 I $E(IOST,1,2)'="C-" Q
206 N IBX,DIR,DIRUT,DUOUT,DTOUT,DIROUT,X,Y
207 F IBX=$Y:1:(IOSL-3) W !
208 S DIR(0)="E" D ^DIR I $D(DIRUT)!($D(DUOUT)) S IBQ=1
209 Q
210 ;
211SSN(X) ; - Format the SSN.
212 Q $S(X]"":$E(X,1,3)_"-"_$E(X,4,5)_"-"_$E(X,6,10),1:"")
Note: See TracBrowser for help on using the repository browser.