source: WorldVistAEHR/trunk/r/FEE_BASIS-FB/FBSHRAD.m@ 1042

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

initial load of WorldVistAEHR

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