1 | ECXAADM ;ALB/JAP - ADM Extract Audit Report ;Oct 08, 1997
|
---|
2 | ;;3.0;DSS EXTRACTS;**8,33**;Dec 22, 1997
|
---|
3 | EN ;entry point for ADM extract audit report
|
---|
4 | N %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR,DIRUT,DTOUT,DUOUT
|
---|
5 | S ECXERR=0
|
---|
6 | ;ecxaud=0 for 'extract' audit
|
---|
7 | S ECXHEAD="ADM",ECXAUD=0
|
---|
8 | W !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
|
---|
9 | ;select extract
|
---|
10 | D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
|
---|
11 | Q:ECXERR
|
---|
12 | ;determine if facility is multidivisional
|
---|
13 | S DIC="^DG(43,",DA=1,DR="11;",DIQ="ECX",DIQ(0)="I" D EN^DIQ1
|
---|
14 | I +ECX(43,1,11,"I")=0 S ECXALL=1
|
---|
15 | I +ECX(43,1,11,"I")=1 D
|
---|
16 | .W !!
|
---|
17 | .S DIR(0)="Y",DIR("A")="Do you want the "_ECXHEAD_" extract audit report for all divisions"
|
---|
18 | .S DIR("B")="NO" D ^DIR K DIR
|
---|
19 | .I $G(DIRUT) S ECXERR=1 Q
|
---|
20 | .;if y=0 i.e., 'no', then ecxall=0 i.e., 'selected'
|
---|
21 | .S ECXALL=Y
|
---|
22 | I ECXERR=1 D Q
|
---|
23 | .W !!,?5,"Try again later... exiting.",!
|
---|
24 | .D AUDIT^ECXKILL
|
---|
25 | ;select divisions/sites; all divisions if ecxall=1
|
---|
26 | S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
|
---|
27 | W !
|
---|
28 | D ADM^ECXDVSN(.ECXDIV,ECXALL,ECXSTART,ECXEND,.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 | S ECXPGM="PROCESS^ECXAADM",ECXDESC="ADM Extract Audit Report"
|
---|
34 | S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXALL")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
|
---|
35 | W !
|
---|
36 | D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
|
---|
37 | I ECXSAVE("POP")=1 D Q
|
---|
38 | .W !!,?5,"Try again later... exiting.",!
|
---|
39 | .D AUDIT^ECXKILL
|
---|
40 | I ECXSAVE("ZTSK")=0 D
|
---|
41 | .K ECXSAVE,ECXPGM,ECXDESC
|
---|
42 | .D PROCESS^ECXAADM
|
---|
43 | I IO'=IO(0) D ^%ZISC
|
---|
44 | D HOME^%ZIS
|
---|
45 | D AUDIT^ECXKILL
|
---|
46 | Q
|
---|
47 | ;
|
---|
48 | PROCESS ;process data in file #727.802
|
---|
49 | N X,Y,W,DATE,DIV,IEN,TL,ORDER,SORD,GTOT,STOT,WARD,QQFLG,CNT
|
---|
50 | K ^TMP($J,"ECXWARD"),^TMP($J,"ECXORDER")
|
---|
51 | S (CNT,QQFLG)=0
|
---|
52 | S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
|
---|
53 | S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
|
---|
54 | ;get run date in external format
|
---|
55 | D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
|
---|
56 | ;get ward info in ^tmp($j,"ecxward" and ^tmp($j,"ecxorder"
|
---|
57 | D WARDS^ECXUTLA(ECXALL,.ECXDIV)
|
---|
58 | S W="" F S W=$O(^TMP($J,"ECXWARD",W)) Q:W="" D
|
---|
59 | .S DIV=$P(^TMP($J,"ECXWARD",W),U,3),GTOT(DIV)=0,TL(W)=0,ORDER="" D
|
---|
60 | ..F S ORDER=$O(^TMP($J,"ECXORDER",DIV,ORDER)) Q:ORDER="" I $D(^(ORDER,1)) S STOT(DIV,ORDER)=0
|
---|
61 | ;get records in date range and ward set
|
---|
62 | S IEN="" F S IEN=$O(^ECX(727.802,"AC",ECXEXT,IEN)) Q:IEN="" D Q:QQFLG
|
---|
63 | .S DATE=$P(^ECX(727.802,IEN,0),U,9),WARD=$P(^(0),U,28)
|
---|
64 | .;convert free text date to fm internal format date
|
---|
65 | .S $E(DATE,1,2)=$E(DATE,1,2)-17
|
---|
66 | .Q:$L(DATE)<7 Q:(DATE<ECXSTART) Q:(DATE>ECXEND)
|
---|
67 | .;track missing wards
|
---|
68 | .I WARD="" D Q
|
---|
69 | ..S ^TMP($J,"MISWRD")=$G(^TMP($J,"MISWRD"))+1,^("MISWRD",IEN)=""
|
---|
70 | .;if ward is among those selected, then tally admission data
|
---|
71 | .I $D(TL(WARD)) S TL(WARD)=TL(WARD)+1,CNT=CNT+1
|
---|
72 | .I $D(ZTQUEUED),(CNT>499),'(CNT#500),$$S^%ZTLOAD S QQFLG=1,ZTSTOP=1 K ZTREQ
|
---|
73 | ;after all the extract records are processed, set totals into ^tmp($j,"ecxorder"
|
---|
74 | I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
|
---|
75 | S W="" F S W=$O(TL(W)) Q:W="" D
|
---|
76 | .S ORDER=$P(^TMP($J,"ECXWARD",W),U,1),DIV=$P(^(W),U,3)
|
---|
77 | .S $P(^TMP($J,"ECXORDER",DIV,ORDER),U,3)=TL(W)
|
---|
78 | ;determine ward group subtotal and division grandtotal
|
---|
79 | I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
|
---|
80 | S DIV="" F S DIV=$O(^TMP($J,"ECXORDER",DIV)) Q:DIV="" S GTOT(DIV)=0 D
|
---|
81 | .S ORDER="",STOT=0 F S ORDER=$O(^TMP($J,"ECXORDER",DIV,ORDER)) Q:ORDER="" D
|
---|
82 | ..S TOT=$P(^TMP($J,"ECXORDER",DIV,ORDER),U,3),STOT=STOT+TOT,GTOT(DIV)=GTOT(DIV)+TOT
|
---|
83 | ..I $D(^TMP($J,"ECXORDER",DIV,ORDER,1)) S $P(^(1),U,3)=STOT,STOT=0
|
---|
84 | D PRINT
|
---|
85 | D AUDIT^ECXKILL
|
---|
86 | Q
|
---|
87 | ;
|
---|
88 | PRINT ;print the admission data by division and ward order
|
---|
89 | N JJ,SS,LN,PG,QFLG,WRDNM,WRDTOT,GRPNM,GRPTOT,DATA,DATA1,DIC,DA,DR,DIR
|
---|
90 | N DIRUT,DTOUT,DUOUT,IEN,FAC,ADMDT
|
---|
91 | U IO
|
---|
92 | I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
|
---|
93 | S (QFLG,PG)=0,$P(LN,"-",80)="",DIV=""
|
---|
94 | F S DIV=$O(GTOT(DIV)) Q:DIV="" D Q:QFLG
|
---|
95 | .D HEADER Q:QFLG
|
---|
96 | .I GTOT(DIV)=0 D Q
|
---|
97 | ..W !!,?5,"No admission data extracted for this medical center division.",!
|
---|
98 | .S ORDER="" F S ORDER=$O(^TMP($J,"ECXORDER",DIV,ORDER)) Q:ORDER="" D Q:QFLG
|
---|
99 | ..S DATA=^TMP($J,"ECXORDER",DIV,ORDER) K DATA1 I $D(^(ORDER,1)) S DATA1=^(1)
|
---|
100 | ..S WRDNM=$P(DATA,U,2),WRDTOT=+$P(DATA,U,3)
|
---|
101 | ..;don't display inactive wards unless there is admission data
|
---|
102 | ..;don't attempt to group inactive/unordered wards
|
---|
103 | ..I ORDER>999990 K DATA1 I WRDTOT=0 Q
|
---|
104 | ..D:($Y+3>IOSL) HEADER Q:QFLG
|
---|
105 | ..W !,?5,WRDNM,?45,$$RJ^XLFSTR(WRDTOT,5," ")
|
---|
106 | ..;if data1 exists, then this is the end of a ward group so print group total
|
---|
107 | ..I $G(DATA1) D Q:QFLG
|
---|
108 | ...S GRPNM=$P(DATA1,U,2),GRPTOT=$P(DATA1,U,3)
|
---|
109 | ...D:($Y+3>IOSL) HEADER Q:QFLG
|
---|
110 | ...W !,?40,"----------"
|
---|
111 | ...W !,"Ward group "_GRPNM_" subtotal:",?45,$$RJ^XLFSTR(GRPTOT,5," ")
|
---|
112 | ...D:($Y+3>IOSL) HEADER Q:QFLG
|
---|
113 | ...W !!
|
---|
114 | .D:($Y+3>IOSL) HEADER Q:QFLG
|
---|
115 | .W !!,"Division "_$P(ECXDIV(DIV),U,2)_" Grand Total:",?45,$$RJ^XLFSTR(GTOT(DIV),5," ")
|
---|
116 | ;print patients with missing wards
|
---|
117 | I $D(^TMP($J,"MISWRD")) D
|
---|
118 | .S DIV="MISWRD",ECXDIV(DIV)="^^^^^*** MISSING WARDS ***^" D HEADER
|
---|
119 | .S WRDTOT=$G(^TMP($J,"MISWRD"))
|
---|
120 | .W !,?5,"MISSING WARD",?45,$$RJ^XLFSTR(WRDTOT,5," "),!!
|
---|
121 | .D HEAD
|
---|
122 | .S IEN="" F S IEN=$O(^TMP($J,"MISWRD",IEN)) Q:'IEN D I QFLG Q
|
---|
123 | ..S DATA=$G(^ECX(727.802,IEN,0)),ADMDT=$P(DATA,U,9) Q:DATA=""
|
---|
124 | ..S FAC=$P(DATA,U,4) S:FAC'="" FAC=$$GET1^DIQ(40.8,FAC,.01,"E")
|
---|
125 | ..W !?2,$P(DATA,U,7),?8,$P(DATA,U,5),?25,$E(FAC,1,14),?45
|
---|
126 | ..W $E(ADMDT,5,6)_"/"_$E(ADMDT,7,8)_"/"_$E(ADMDT,1,4)," "
|
---|
127 | ..W $E($P(DATA,U,34),1,2)_":"_$E($P(DATA,U,34),3,4)
|
---|
128 | ..D:($Y+3>IOSL) HEADER,HEAD Q:QFLG
|
---|
129 | I $E(IOST)'="C" D
|
---|
130 | .W @IOF S PG=PG+1
|
---|
131 | .W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
|
---|
132 | .W !,"DSS Extract Log #: "_ECXEXT
|
---|
133 | .W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
|
---|
134 | .W !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
|
---|
135 | .W !!,LN,!!
|
---|
136 | .S DIC="^ECX(727.1,",DA=ECXARRAY("DEF"),DR="1" D EN^DIQ
|
---|
137 | .W @IOF
|
---|
138 | I $E(IOST)="C",'QFLG D
|
---|
139 | .S SS=22-$Y F JJ=1:1:SS W !
|
---|
140 | .S DIR(0)="E" W ! D ^DIR K DIR
|
---|
141 | Q
|
---|
142 | ;
|
---|
143 | HEAD ;header for missing wards
|
---|
144 | W !,?2,"NAME",?8,"PATIENT DFN",?25,"FACILITY",?45,"ADMISSION DATE"
|
---|
145 | W !,?2,"====",?8,"===========",?25,"========",?45,"=============="
|
---|
146 | Q
|
---|
147 | ;
|
---|
148 | HEADER ;header and page control
|
---|
149 | N JJ,SS,DIR,DIRUT,DTOUT,DUOUT,DSSID
|
---|
150 | I $E(IOST)="C" D
|
---|
151 | .S SS=22-$Y F JJ=1:1:SS W !
|
---|
152 | .I PG>0 S DIR(0)="E" W ! D ^DIR K DIR S:'Y QFLG=1
|
---|
153 | Q:QFLG
|
---|
154 | S DSSID=$P(ECXDIV(DIV),U,6)
|
---|
155 | W:$Y!($E(IOST)="C") @IOF S PG=PG+1
|
---|
156 | W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
|
---|
157 | W !,"DSS Extract Log #: "_ECXEXT
|
---|
158 | W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
|
---|
159 | W !,"Report Run Date/Time: "_ECXRUN
|
---|
160 | I DSSID="" W !,"Medical Center Division: "_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")",?68,"Page: "_PG
|
---|
161 | I DSSID]"" W !,"Medical Center Division: "_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")"_" <"_DSSID_">",?68,"Page: "_PG
|
---|
162 | W !!,?5,"Ward <DSS Dept.>",?40,"# of Admissions"
|
---|
163 | W !,LN,!
|
---|
164 | Q
|
---|