source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXAECS.m@ 1608

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

initial load of FOIAVistA 6/30/08 version

File size: 6.0 KB
Line 
1ECXAECS ;ALB/JAP - ECS Extract Audit Report ;Oct 15, 1997
2 ;;3.0;DSS EXTRACTS;**8,33**;Dec 22, 1997
3 ;
4EN ;entry point for ECS extract audit report
5 N %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR,CNT
6 S ECXERR=0
7 ;ecxaud=0 for 'extract' audit
8 S ECXHEAD="ECS",ECXAUD=0
9 W !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
10 ;select extract
11 D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
12 Q:ECXERR
13 ;determine if facility is multidivisional for event capture
14 S CNT=0,ECXD="" F S ECXD=$O(^DIC(4,"LOC",ECXD)) Q:ECXD="" S CNT=CNT+1
15 S ECXALL=1
16 I CNT>1 D
17 .W !!
18 .S DIR(0)="Y",DIR("A")="Do you want the "_ECXHEAD_" extract audit report for all Locations"
19 .S DIR("B")="NO" D ^DIR K DIR
20 .I $G(DIRUT) S ECXERR=1 Q
21 .;if y=0 i.e., 'no', then ecxall=0 i.e., 'selected'
22 .S ECXALL=Y
23 I ECXERR=1 D Q
24 .W !!,?5,"Try again later... exiting.",!
25 .D AUDIT^ECXKILL
26 ;select divisions/sites; all ec locations if ecxall=1
27 S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
28 D ECS^ECXDVSN(.ECXDIV,ECXALL,.ECXERR)
29 I ECXERR=1 D Q
30 .W !!,?5,"Try again later... exiting.",!
31 .D AUDIT^ECXKILL
32 ;determine output device and queue if requested
33 W !
34 S ECXPGM="PROCESS^ECXAECS",ECXDESC="ECS Extract Audit Report"
35 S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXALL")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
36 W !
37 D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
38 I ECXSAVE("POP")=1 D Q
39 .W !!,?5,"Try again later... exiting.",!
40 .D AUDIT^ECXKILL
41 I ECXSAVE("ZTSK")=0 D
42 .K ECXSAVE,ECXPGM,ECXDESC
43 .D PROCESS^ECXAECS
44 I IO'=IO(0) D ^%ZISC
45 D HOME^%ZIS
46 D AUDIT^ECXKILL
47 Q
48 ;
49PROCESS ;process data in file #727.815
50 N X,Y,W,DATA,DATE,DIV,IEN,UNIT,UNITN,CAT,CATN,VOL,PROC,PROCN,PIEN,PRI,PRXF,PRSYN,QQFLG,CNT
51 K ^TMP($J,"ECXAUD")
52 S (CNT,QQFLG)=0
53 S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
54 S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
55 ;get run date in external format
56 D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
57 ;get records in date range
58 S IEN="" F S IEN=$O(^ECX(727.815,"AC",ECXEXT,IEN)) Q:IEN="" D Q:QQFLG
59 .S DATA=^ECX(727.815,IEN,0),DATE=$P(DATA,U,9),DIV=$P(DATA,U,4)
60 .;convert free text date to fm internal format date
61 .S $E(DATE,1,2)=$E(DATE,1,2)-17
62 .Q:$L(DATE)<7 Q:(DATE<ECXSTART) Q:(DATE>ECXEND)
63 .;if location is among those selected, then tally event capture data
64 .I $D(ECXDIV(DIV)) D Q:QQFLG
65 ..S UNIT=$P(DATA,U,10),UNITN=$P($G(^ECD(UNIT,0)),U,1),UNIT(UNITN)=UNIT
66 ..;if no category, then cat=0
67 ..S CAT=+$P(DATA,U,11),CATN="" S:+CAT CATN=$P($G(^EC(726,CAT,0)),U,1) S:CATN="" CATN="Unknown"
68 ..S VOL=$P(DATA,U,13) S:VOL="" VOL=1 S PROC=$E($P(DATA,U,12),1,5)
69 ..I '$D(^TMP($J,"ECXAUD",DIV,UNITN,CATN,PROC)) S ^TMP($J,"ECXAUD",DIV,UNITN,CATN,PROC)=0
70 ..S ^(PROC)=^TMP($J,"ECXAUD",DIV,UNITN,CATN,PROC)+VOL,CNT=CNT+1
71 ..I $D(ZTQUEUED),(CNT>499),'(CNT#500),$$S^%ZTLOAD S QQFLG=1,ZTSTOP=1 K ZTREQ Q
72 ..;get the procedure name and setup in global array
73 ..S PIEN=0,PROCN="" S:PROC'?5N PIEN=$O(^EC(725,"E",PROC,""))
74 ..;procedures from file #725
75 ..I +PIEN>0 D
76 ...S PROCN=$P($G(^EC(725,PIEN,0)),U,1)
77 ...S PRXF=PIEN_";EC(725,"
78 ...S PRI=+$O(^ECJ("AP",DIV,UNIT,CAT,PRXF,0)),PRSYN=$P($G(^ECJ(PRI,"PRO")),U,2)
79 ...I PRSYN]"" S PROCN=PRSYN
80 ..;procedures from file #81
81 ..I PIEN=0,PROCN="" D
82 ...S PIEN=$O(^ICPT("B",PROC,"")) I +PIEN>0 S PROCN=$P($G(^ICPT(PIEN,0)),U,2)
83 ...S PRXF=PIEN_";ICPT("
84 ...S PRI=+$O(^ECJ("AP",DIV,UNIT,CAT,PRXF,0)),PRSYN=$P($G(^ECJ(PRI,"PRO")),U,2)
85 ...I PRSYN]"" S PROCN=PRSYN
86 ..S:PROCN="" PROCN="Unknown"
87 ..S ^TMP($J,"ECXPROC",PROC)=PROCN
88 ;print the report
89 D PRINT
90 D AUDIT^ECXKILL
91 Q
92 ;
93PRINT ;print event capture data by location/division and dss unit order
94 N JJ,SS,P,PN,LN,NM,DIV,DIVNM,PG,QFLG,GTOT,PROC,STOT,TOT,DIR,DIRUT,DTOUT,DUOUT
95 U IO
96 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
97 S (QFLG,PG)=0,$P(LN,"-",80)="",DIV=""
98 F S DIV=$O(ECXDIV(DIV)) Q:DIV="" D Q:QFLG
99 .S DIVNM=$P(ECXDIV(DIV),U,2)_" ("_DIV_")",GTOT=0 D HEADER
100 .I '$D(^TMP($J,"ECXAUD",DIV)) D Q
101 ..W !!,?5,"No data available for this Event Capture Location.",!!
102 .I $D(^TMP($J,"ECXAUD",DIV)) S UNITN="" F S UNITN=$O(^TMP($J,"ECXAUD",DIV,UNITN)) Q:UNITN="" D Q:QFLG
103 ..S STOT=0,UNIT=UNIT(UNITN),CATN=""
104 ..;write the unit name
105 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,UNITN_" ("_UNIT_")",!
106 ..;initialize the proc array and set totals in array
107 ..F S CATN=$O(^TMP($J,"ECXAUD",DIV,UNITN,CATN)) Q:CATN="" K PROC S PROC="" D Q:QFLG
108 ...;write the category name
109 ...D:($Y+3>IOSL) HEADER Q:QFLG W !,?5,$E(CATN,1,25)
110 ...F S PROC=$O(^TMP($J,"ECXAUD",DIV,UNITN,CATN,PROC)) Q:PROC="" S TOT=^(PROC) D
111 ....S STOT=STOT+TOT,GTOT=GTOT+TOT,PROCN=""
112 ....I $D(^TMP($J,"ECXPROC",PROC)) S PROCN=^(PROC)
113 ....S PROC($$LJ^XLFSTR(PROC,6," ")_" "_PROCN)=TOT
114 ...S PN="" F S PN=$O(PROC(PN)) Q:PN="" S TOT=PROC(PN) D Q:QFLG
115 ....;write procedure and total
116 ....W ?35,$E(PN,1,30),?68,$$RJ^XLFSTR(TOT,5," "),!
117 ..;write the unit subtotal
118 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,?5,$E(LN,1,74)
119 ..W !,"Total Volume for Unit "_UNITN_" ("_UNIT_"):",?68,$$RJ^XLFSTR(STOT,5," "),!
120 .;write the division grandtotal
121 .D:($Y+3>IOSL) HEADER Q:QFLG W !!,"Grand Total for Location "_DIVNM_":",?68,$$RJ^XLFSTR(GTOT,5," ")
122 ;print the audit descriptive narrative
123 I $E(IOST)'="C" D
124 .W @IOF S PG=PG+1
125 .W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
126 .W !,"DSS Extract Log #: "_ECXEXT
127 .W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
128 .W !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
129 .W !!,LN,!!
130 .S DIC="^ECX(727.1,",DA=ECXARRAY("DEF"),DR="1" D EN^DIQ
131 I $E(IOST)="C",'QFLG D
132 .S SS=22-$Y F JJ=1:1:SS W !
133 .S DIR(0)="E" W ! D ^DIR K DIR
134 Q
135 ;
136HEADER ;header and page control
137 N JJ,SS
138 I $E(IOST)="C" D
139 .S SS=22-$Y F JJ=1:1:SS W !
140 .I PG>0 S DIR(0)="E" W ! D ^DIR K DIR S:'Y QFLG=1
141 Q:QFLG
142 W:$Y!($E(IOST)="C") @IOF S PG=PG+1
143 W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
144 W !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
145 W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
146 W !,"Report Run Date/Time: "_ECXRUN
147 W !,"Event Capture Location: "_$P(ECXDIV(DIV),U,2)_" ("_DIV_")",?68,"Page: "_PG
148 W !!,"DSS Unit",!,?5,"Category",?35,"Procedure",?68,"Volume"
149 W !,LN,!
150 Q
Note: See TracBrowser for help on using the repository browser.