source: WorldVistAEHR/trunk/r/FEE_BASIS-FB/FBLTCAR2.m@ 1524

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

initial load of WorldVistAEHR

File size: 7.4 KB
Line 
1FBLTCAR2 ;WOIFO/SS-LTC AUTHORIZATIONS REPORTS ;11/20/02
2 ;;3.5;FEE BASIS;**49**;JAN 30, 1995
3 ;
4EN ;ask program
5 N FBLTCAR
6 S DIC("B")=$S(FBLTCPR="CONTRACT NURSING HOME":FBLTCPR,1:"OUTPATIENT")
7 S DIC="^FBAA(161.8,",DIC(0)="AQEM",DIC("S")="S FBLTCAR=$P(^(0),U,1) I FBLTCAR=""OUTPATIENT""!(FBLTCAR=""CONTRACT NURSING HOME"")"
8 D ^DIC K DIC I Y'>0 G EXIT
9 S FBPROG=+Y
10 ;
11 ; ask purpose of visit(s)
12 S DIR(0)="Y",DIR("A")="For ALL LTC Purpose of Visits? Y/N",DIR("B")="YES"
13 D ^DIR K DIR G:$D(DIRUT) EXIT
14 S FBPOV=Y
15 I 'FBPOV D G:'$D(FBPOV) EXIT S FBPOV=0
16 . K FBPOV
17 . W !,"Select one or more LTC Purpose of Visits"
18 . S DIC="^FBAA(161.82,",DIC(0)="AQEM",DIC("S")="I $P(^(0),U,2)=FBPROG&(+$P(^(0),U,4)>0)"
19 . F D Q:Y'>0
20 . . D ^DIC I Y>0 S FBPOV(+Y)=$P(Y,U,2)
21 . K DIC
22 ;
23 ; ask dates
24 S DIR(0)="D^::EX",DIR("A")="From Date"
25 ; default from date is first day of previous month
26 S DIR("B")=$$FMTE^XLFDT($E($$FMADD^XLFDT($E(DT,1,5)_"01",-1),1,5)_"01")
27 D ^DIR K DIR G:$D(DIRUT) EXIT
28 S FBDT1=Y
29 S DIR(0)="DA^"_FBDT1_"::EX",DIR("A")="To Date: "
30 ; default to date is last day of specified month
31 S X=FBDT1 D DAYS^FBAAUTL1
32 S DIR("B")=$$FMTE^XLFDT($E(FBDT1,1,5)_X)
33 D ^DIR K DIR G:$D(DIRUT) EXIT
34 S FBDT2=Y
35 ;
36 ; ask if remarks should be printed
37 S DIR(0)="Y",DIR("A")="Print authorization remarks",DIR("B")="NO"
38 D ^DIR K DIR G:$D(DIRUT) EXIT
39 S FBAR=Y
40 ;
41 ; ask device
42 S %ZIS="QM" D ^%ZIS G:POP EXIT
43 I $D(IO("Q")) D G EXIT
44 . S ZTRTN="QEN^FBLTCAR2",ZTDESC="LTC Authorizations Report"
45 . F FBX="FBLTCRT","FBPROG","FBPOV*","FBDT*","FBAR" S ZTSAVE(FBX)=""
46 . D ^%ZTLOAD,HOME^%ZIS K ZTSK,ZTDESC,ZTREQ,ZTRTN,ZTSAVE,ZTSTOP,ZTQUEUED
47 ;
48QEN ; queued entry
49 U IO
50 ;
51GATHER ; collect and sort data
52 N FBVN
53 K ^TMP($J)
54 ; loop thru Fee Basis Patients
55 S FBDFN=0 F S FBDFN=$O(^FBAAA(FBDFN)) Q:'FBDFN D
56 . S FBPNAME=$$GET1^DIQ(161,FBDFN,.01)
57 . S:FBPNAME="" FBPNAME="UNKNOWN"
58 . ; loop thru authorizations
59 . S FBAU=0 F S FBAU=$O(^FBAAA(FBDFN,1,FBAU)) Q:'FBAU D
60 . . S FBA=$G(^FBAAA(FBDFN,1,FBAU,0))
61 . . Q:$P(FBA,U,3)'=FBPROG ; not program
62 . . Q:$P($G(^FBAAA(FBDFN,1,FBAU,"ADEL")),U) ; austin deleted
63 . . Q:$P(FBA,U,7)="" ; blank purpose of visit
64 . . I 'FBPOV Q:'$D(FBPOV($P(FBA,U,7))) ; not selected POV
65 . . Q:+$P($G(^FBAA(161.82,+$P(FBA,U,7),0)),U,4)=0 ;non-LTC
66 . . ; ensure authorization is not outside the period of interest
67 . . I +$G(FBLTCRT)=0 Q ;FBLTCRT should be defined
68 . . I +$G(FBLTCRT)>0 Q:$$LTCRPT^FBLTCAR($P(FBA,U),$P(FBA,U,2),FBDT1,FBDT2,+$G(FBLTCRT)) ;for LTC reports FBLTCRT is difined in ^FBLTCAR
69 . . ; passed all criteria
70 . . S FBVN=$S($P(FBA,U,4):$P($G(^FBAAV($P(FBA,U,4),0)),U),1:"")
71 . . I FBVN="" S FBVN="not specified"
72 . . ; sort by purpose of visit,vendor,name^dfn,auth from date^auth ien
73 . . S ^TMP($J,$P(FBA,U,7),FBVN,FBPNAME_U_FBDFN,$P(FBA,U)_U_FBAU)=FBA
74 ;
75PRINT ; report data
76 N FBVN,FBD
77 S (FBQUIT,FBPG)=0 D NOW^%DTC S Y=% D DD^%DT S FBDTR=Y
78 K FBDL S FBDL="",$P(FBDL,"-",IOM)=""
79 ;
80 ; build page header text for selection criteria
81 K FBHDT
82 S FBHDT(1)=" FROM "_$$FMTE^XLFDT(FBDT1)_" TO "_$$FMTE^XLFDT(FBDT2)
83 S FBHDT(1)=FBHDT(1)_" FOR THE "_$$GET1^DIQ(161.8,FBPROG,.01)_" PROGRAM"
84 S FBHDT(2)=" FOR "_$S(FBPOV:"ALL ",1:"")_"PURPOSE OF VISIT(S)"
85 I 'FBPOV D
86 . S FBL=2,FBHDT(FBL)=FBHDT(FBL)_": "
87 . S (FBC,FBI)=0 F S FBI=$O(FBPOV(FBI)) Q:'FBI D
88 . . I $L(FBHDT(FBL))+2+$L(FBPOV(FBI))>75 D
89 . . . I FBC S FBHDT(FBL)=FBHDT(FBL)_","
90 . . . S FBL=FBL+1
91 . . . S FBC=0,FBHDT(FBL)=" "
92 . . S FBHDT(FBL)=FBHDT(FBL)_$S(FBC:", ",1:"")_FBPOV(FBI)
93 . . S FBC=FBC+1 ; count of POVs on current line (FBL)
94 ;
95 ; determine if DAYS column should be displayed (true/false)
96 S FBDD=$$GET1^DIQ(161.8,FBPROG,.01)="STATE HOME"
97 ;
98 D HD
99 I '$D(^TMP($J)) W !,"No authorizations found during period."
100 S FBC("TOT")=0 ; initialize count of authorizations on report
101 ; loop thru purpose of visit
102 S FBPOV=0 F S FBPOV=$O(^TMP($J,FBPOV)) Q:'FBPOV D Q:FBQUIT
103 . S FBPOV("E")=$$GET1^DIQ(161.82,FBPOV,.01)
104 . I $Y+9>IOSL D HD Q:FBQUIT
105 . W !!,"POV: ",FBPOV("E")
106 . S FBC("POV")=0 ; initialize count of authorizations for POV
107 . S:FBDD FBD("POV")=0 ; initialize count of days for POV
108 . ; loop thru vendors
109 . S FBVN="" F S FBVN=$O(^TMP($J,FBPOV,FBVN)) Q:FBVN="" D Q:FBQUIT
110 . . I $Y+7>IOSL D HD Q:FBQUIT D HDPOV
111 . . W !!," Vendor: ",FBVN,!
112 . . S FBC("VEN")=0 ; initialize count of auth for vendor (in POV)
113 . . S:FBDD FBD("VEN")=0 ; initialize count of days for vendor (in POV)
114 . . ; loop thru veterans
115 . . S FBPAT=""
116 . . F S FBPAT=$O(^TMP($J,FBPOV,FBVN,FBPAT)) Q:FBPAT="" D Q:FBQUIT
117 . . . S FBPNAME=$P(FBPAT,U)
118 . . . S FBDFN=$P(FBPAT,U,2)
119 . . . D
120 . . . . N DFN S DFN=FBDFN D DEM^VADPT ; obtain patient demographics
121 . . . ; loop thru authorizations
122 . . . S FBAUT=""
123 . . . F S FBAUT=$O(^TMP($J,FBPOV,FBVN,FBPAT,FBAUT)) Q:FBAUT="" D Q:FBQUIT
124 . . . . S FBDTF=$P(FBAUT,U)
125 . . . . S FBAU=$P(FBAUT,U,2)
126 . . . . S FBA=^TMP($J,FBPOV,FBVN,FBPAT,FBAUT)
127 . . . . S:FBDD FBDAYS=$$DOC^FBSHUTL($P(FBA,U),$P(FBA,U,2),FBDT1,FBDT2)
128 . . . . S FBC("VEN")=FBC("VEN")+1
129 . . . . S:FBDD FBD("VEN")=FBD("VEN")+FBDAYS
130 . . . . I $Y+6>IOSL D HD Q:FBQUIT D HDPOV,HDVEN
131 . . . . W !,?4,FBPNAME,?35,$P(VADM(2),U,2)
132 . . . . W:FBDD ?48,$J(FBDAYS,3)
133 . . . . W ?53,$$FMTE^XLFDT($P(FBA,U)),?67,$$FMTE^XLFDT($P(FBA,U,2))
134 . . . . W !,?6,"DOB: ",$P(VADM(3),U,2)
135 . . . . I +VADM(6) W ?25,"*** Patient Died on ",$P(VADM(6),U,2)
136 . . . . ; print remarks (optional)
137 . . . . I $G(FBAR),$O(^FBAAA(FBDFN,1,FBAU,2,0)) D
138 . . . . . N DIWL,DIWR,DIWF,FBRR
139 . . . . . K ^UTILITY($J,"W") S DIWL=7,DIWR=(IOM-5),DIWF="W"
140 . . . . . S X="REMARKS: ",FBRR=0
141 . . . . . F S FBRR=$O(^FBAAA(FBDFN,1,FBAU,2,FBRR)) Q:'FBRR S X=X_^(FBRR,0) D ^DIWP S X="" I $Y+6>IOSL D HD Q:FBQUIT D HDPOV,HDVEN,HDPAT
142 . . . . . D:'FBQUIT ^DIWW
143 . . . . ; print additional information for LTC reports
144 . . . . I +$G(FBLTCRT)>0 D PRNVIS^FBLTCAR(+FBDFN,+FBAU,FBVN,+FBDT1,+FBDT2,+$P(FBA,U),+$P(FBA,U,2))
145 . . . D KVA^VADPT ; clean up patient demographics
146 . . Q:FBQUIT
147 . . S FBC("POV")=FBC("POV")+FBC("VEN")
148 . . S:FBDD FBD("POV")=FBD("POV")+FBD("VEN")
149 . . I $Y+5>IOSL D HD Q:FBQUIT D HDPOV,HDVEN
150 . . W !,?32,"----"
151 . . W:FBDD ?47,"----"
152 . . W !," Vendor Subtotal:",?25,"Count: ",$J(FBC("VEN"),4)
153 . . W:FBDD ?41,"Days: ",$J(FBD("VEN"),4)
154 . Q:FBQUIT
155 . S FBC("TOT")=FBC("TOT")+FBC("POV")
156 . I $Y+5>IOSL D HD Q:FBQUIT D HDPOV
157 . W !,?32,"===="
158 . W:FBDD ?47,"===="
159 . W !,"POV Subtotal: ",?25,"Count: ",$J(FBC("POV"),4)
160 . W:FBDD ?41,"Days: ",$J(FBD("POV"),4)
161 ;
162 I FBQUIT W !!,"REPORT STOPPED AT USER REQUEST"
163 E W !!,FBC("TOT")," Authorization",$S(FBC("TOT")=1:"",1:"s")," on report"
164 I 'FBQUIT,$E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR
165 D ^%ZISC
166 ;
167EXIT ;
168 I $D(ZTQUEUED) S ZTREQ="@"
169 K ^TMP($J)
170 K FBA,FBAR,FBAU,FBAUT,FBC,FBDAYS,FBDD,FBDFN,FBDL,FBDT1,FBDT2,FBDTF
171 K FBDTR,FBHDT,FBI,FBL,FBPAT,FBPG,FBPNAME,FBPOV,FBPROG,FBSSN,FBQUIT,FBX
172 K DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y,POP,VADM
173 Q
174HD ; page header
175 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1,FBQUIT=1 Q
176 I $E(IOST,1,2)="C-",FBPG S DIR(0)="E" D ^DIR K DIR I 'Y S FBQUIT=1 Q
177 I $E(IOST,1,2)="C-"!FBPG W @IOF
178 S FBPG=FBPG+1
179 W !,$S(FBLTCRT=1:"ENDING ",1:"ACTIVE "),"AUTHORIZATIONS by POV, Vendor, Patient"
180 W ?49,FBDTR,?72,"page ",FBPG
181 S FBI=0 F S FBI=$O(FBHDT(FBI)) Q:'FBI W !,FBHDT(FBI)
182 W !!,?4,"VETERAN",?35,"Pt. ID"
183 W:FBDD ?47,"DAYS"
184 W ?56,"AUTHORIZATION"
185 W !,?53,"FROM DATE",?67,"TO DATE"
186 W !,FBDL
187 Q
188HDPOV ; page header for continued POV
189 W !,"POV:",FBPOV("E")," (continued)"
190 Q
191HDVEN ; page header for continued Vendor
192 W !," Vendor: ",FBVN," (continued)"
193 Q
194HDPAT ; page header for continued Patient
195 W !," Patient: ",FBPNAME," (continued)"
196 Q
197 ;
198 ;FBLTCAR2
Note: See TracBrowser for help on using the repository browser.