source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOSTAT.m@ 1169

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

initial load of FOIAVistA 6/30/08 version

File size: 7.5 KB
Line 
1HLOSTAT ;ALB/CJM- HLO STATISTICS- 10/4/94 1pm ;01/05/2007
2 ;;1.6;HEALTH LEVEL SEVEN;**130,131,134**;Oct 13, 1995;Build 30
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ;
6COUNT(HLCSTATE,RAP,SAP,TYPE) ;
7 S:RAP="" RAP="UNKNOWN"
8 S:SAP="" SAP="UNKNOWN"
9 S:$L(TYPE)<2 TYPE="UNKNOWN"
10 S HLCSTATE("COUNTS")=$G(HLCSTATE("COUNTS"))+1,HLCSTATE("COUNTS",SAP,RAP,TYPE)=1+$G(HLCSTATE("COUNTS",SAP,RAP,TYPE))
11 Q
12SAVECNTS(HLCSTATE) ;
13 N TIME,DIR,RAP,SAP,TYPE,COUNT
14 Q:'$G(HLCSTATE("COUNTS"))
15 S TIME=$E($$NOW^XLFDT,1,10)
16 S DIR=$S(+$G(HLCSTATE("SERVER")):"IN",1:"OUT")
17 I $G(HLCSTATE("COUNTS","ACKS")) D
18 .I $$INC^HLOSITE($NA(^HLSTATS($S(DIR="IN":"OUT",1:"IN"),"HOURLY",+TIME,"ACCEPT ACK")),HLCSTATE("COUNTS","ACKS"))
19 S SAP=""
20 F S SAP=$O(HLCSTATE("COUNTS",SAP)) Q:SAP="" D
21 .S RAP=""
22 .F S RAP=$O(HLCSTATE("COUNTS",SAP,RAP)) Q:RAP="" D
23 ..S TYPE=""
24 ..F S TYPE=$O(HLCSTATE("COUNTS",SAP,RAP,TYPE)) Q:TYPE="" D
25 ...S COUNT=HLCSTATE("COUNTS",SAP,RAP,TYPE)
26 ...I $$INC^HLOSITE($NA(^HLSTATS(DIR,"HOURLY",+TIME,SAP,RAP,TYPE)),COUNT)
27 K HLCSTATE("COUNTS") S HLCSTATE("COUNTS")=0
28 Q
29 ;
30TOTAL(WORK) ;totals hours into days and days into months
31 ;
32 N RAP,SAP,TIME,LIMIT,DIR,COUNT,MONTH,START,END
33 ;
34 ;start totaling the next day after last date totaled
35 S START=$G(^HLSTATS("END DATE"))
36 S:START START=$$FMADD^XLFDT(START,1)
37 ;
38 ;end totaling in the last hour of yesterday and save it so that the next run knows where to start
39 S END=$$FMADD^XLFDT($$DT^XLFDT,-1)
40 S ^HLSTATS("END DATE")=END
41 S END=END+.24
42 ;
43 ;total hours into days
44 S LIMIT=$$FMADD^XLFDT($$DT^XLFDT,,-48) ;save ~48 hours of hourly data
45 F DIR="IN","OUT","EIN","EOUT" D
46 .S TIME=0
47 .F S TIME=$O(^HLSTATS(DIR,"HOURLY",TIME)) Q:'TIME Q:(TIME>END) D
48 ..D:'(TIME<START)
49 ...S:(DIR="IN")!(DIR="OUT") ^HLSTATS(DIR,"DAILY",$P(TIME,"."),"ACCEPT ACK")=$G(^HLSTATS(DIR,"DAILY",$P(TIME,"."),"ACCEPT ACK"))+$G(^HLSTATS(DIR,"HOURLY",TIME,"ACCEPT ACK"))
50 ...S SAP=""
51 ...F S SAP=$O(^HLSTATS(DIR,"HOURLY",TIME,SAP)) Q:SAP="" D
52 ....S RAP=""
53 ....F S RAP=$O(^HLSTATS(DIR,"HOURLY",TIME,SAP,RAP)) Q:RAP="" D
54 .....S TYPE=""
55 .....F S TYPE=$O(^HLSTATS(DIR,"HOURLY",TIME,SAP,RAP,TYPE)) Q:TYPE="" D
56 ......S COUNT=$G(^HLSTATS(DIR,"HOURLY",TIME,SAP,RAP,TYPE))
57 ......S ^HLSTATS(DIR,"DAILY",$P(TIME,"."),SAP,RAP,TYPE)=$G(^HLSTATS(DIR,"DAILY",$P(TIME,"."),SAP,RAP,TYPE))+COUNT
58 ..;get rid of old hourly stats
59 ..K:(TIME<LIMIT) ^HLSTATS(DIR,"HOURLY",TIME)
60 ;
61 ;total days into months
62 S LIMIT=$$FMADD^XLFDT($$DT^XLFDT,-30) ;save ~30 days of daily data
63 F DIR="IN","OUT","EIN","EOUT" D
64 .S TIME=0
65 .F S TIME=$O(^HLSTATS(DIR,"DAILY",TIME)) Q:'TIME Q:(TIME>END) D
66 ..D:'(TIME<START)
67 ...S MONTH=$E(TIME,1,5)
68 ...S:(DIR="IN")!(DIR="OUT") ^HLSTATS(DIR,"MONTHLY",MONTH,"ACCEPT ACK")=$G(^HLSTATS(DIR,"MONTHLY",MONTH,"ACCEPT ACK"))+$G(^HLSTATS(DIR,"DAILY",TIME,"ACCEPT ACK"))
69 ...S SAP=""
70 ...F S SAP=$O(^HLSTATS(DIR,"DAILY",TIME,SAP)) Q:SAP="" D
71 ....S RAP=""
72 ....F S RAP=$O(^HLSTATS(DIR,"DAILY",TIME,SAP,RAP)) Q:RAP="" D
73 .....S TYPE=""
74 .....F S TYPE=$O(^HLSTATS(DIR,"DAILY",TIME,SAP,RAP,TYPE)) Q:TYPE="" D
75 ......S COUNT=$G(^HLSTATS(DIR,"DAILY",TIME,SAP,RAP,TYPE))
76 ......S ^HLSTATS(DIR,"MONTHLY",MONTH,SAP,RAP,TYPE)=$G(^HLSTATS(DIR,"MONTHLY",MONTH,SAP,RAP,TYPE))+COUNT
77 ..K:(TIME<LIMIT) ^HLSTATS(DIR,"DAILY",TIME)
78 Q
79REPORT ;Interactive option for printing the message statistics report
80 N DIR,TYPE,START,END
81 W !,"Hourly, daily, and monthly statistics are maintained."
82 W !,"Hourly statistics are available for approximately the last 24 hours."
83 W !,"Daily statistics are available for approximately the last 30 days."
84 W !,"Monthly statistics are kept indefinitely"
85 S DIR(0)="S^h:HOURLY;d:DAILY;m:MONTHLY"
86 S DIR("A")="Which type of statistics should be reported"
87 S DIR("B")="MONTHLY"
88 D ^DIR
89 Q:$D(DIRUT)
90 I Y'="h",Y'="d",Y'="m" Q
91 S TYPE=$S(Y="h":"HOURLY",Y="d":"DAILY",1:"MONTHLY")
92 S START=$S(TYPE="HOURLY":$E($$FMADD^XLFDT($$NOW^XLFDT,,-24),1,10),TYPE="DAILY":$$FMADD^XLFDT(DT,-7),1:$E($$FMADD^XLFDT(DT,-30),1,5)_"01")
93 S START=$$ASKBEGIN^HLOUSR2(START)
94 Q:'START
95 S END=$$ASKEND^HLOUSR2(START)
96 Q:'END
97 S:TYPE="MONTHLY" START=$E(START,1,5)_"00"
98 S:TYPE="DAILY" START=$E(START,1,7)
99 S:TYPE="HOURLY" START=$E(START,1,10)
100 D:$$DEVICE() PRINT(TYPE,START,END)
101 Q
102 ;
103QUE ;entry point for queuing the message statistics report
104 D PRINT($G(HLOPARMS("STATISTICS TYPE")),$G(HLOPARMS("START DT/TM")),$G(HLOPARMS("END DT/TM")))
105 Q
106 ;
107PRINT(STATTYPE,START,END) ;
108 ;
109 N RAP,SAP,TIME,DIR,COUNT,PAGE,CRT,QUIT
110 S QUIT=0
111 S CRT=$S($E(IOST,1,2)="C-":1,1:0)
112 ;
113 U IO
114 W:CRT @IOF
115 W "HLO MESSAGING STATISTICS REPORT ",$$FMTE^XLFDT($$NOW^XLFDT),?70,"Page 1"
116 D LINE($$LJ("Type:",15)_STATTYPE)
117 D LINE($$LJ("Beginning:",15)_$S(STATTYPE="MONTHLY":$$FMTE^XLFDT(START),1:$$FMTE^XLFDT(START)))
118 D LINE($$LJ("Ending:",15)_$$FMTE^XLFDT(END))
119 S PAGE=1
120 ;
121 ;
122 F DIR="IN","OUT" D Q:QUIT
123 .N TOTAL
124 .S TOTAL=0
125 .D LINE(" ")
126 .S TIME=START
127 .S:STATTYPE="MONTHLY" TIME=$E(TIME,1,5)
128 .S TIME=TIME-.0001
129 .D LINE($S(DIR="IN":"Incoming Messages:",1:"Outgoing Messages:"))
130 .Q:QUIT
131 .F S TIME=$O(^HLSTATS(DIR,STATTYPE,TIME)) Q:((TIME>$G(END))&$G(END)) Q:'TIME D Q:QUIT
132 ..N SUBTOTAL
133 ..S SUBTOTAL=0
134 ..D LINE(" ")
135 ..Q:QUIT
136 ..D LINE(" Time Period: "_$S(STATTYPE="MONTHLY":$$FMTE^XLFDT(TIME_"00"),1:$$FMTE^XLFDT(TIME)))
137 ..Q:QUIT
138 ..S COUNT=$G(^HLSTATS(DIR,STATTYPE,TIME,"ACCEPT ACK"))
139 ..I COUNT D Q:QUIT
140 ...D LINE(" ")
141 ...Q:QUIT
142 ...D LINE(" Accept Acknowledgments by All Applications Count:"_$$RJ(COUNT,10))
143 ...Q:QUIT
144 ...D LINE(" ")
145 ..S SAP=""
146 ..F S SAP=$O(^HLSTATS(DIR,STATTYPE,TIME,SAP)) Q:SAP="" D Q:QUIT
147 ...Q:SAP="ACCEPT ACK"
148 ...D LINE(" Sending Application: "_SAP)
149 ...Q:QUIT
150 ...S RAP=""
151 ...F S RAP=$O(^HLSTATS(DIR,STATTYPE,TIME,SAP,RAP)) Q:RAP="" D Q:QUIT
152 ....D LINE(" Receiving Application: "_RAP)
153 ....Q:QUIT
154 ....S TYPE=""
155 ....F S TYPE=$O(^HLSTATS(DIR,STATTYPE,TIME,SAP,RAP,TYPE)) Q:TYPE="" D Q:QUIT
156 .....S COUNT=$G(^HLSTATS(DIR,STATTYPE,TIME,SAP,RAP,TYPE))
157 .....S SUBTOTAL=SUBTOTAL+COUNT
158 .....D LINE(" Message Type: "_$$LJ(TYPE,25)_" Count:"_$$RJ(COUNT,10))
159 .....Q:QUIT
160 ..I 'QUIT D
161 ...S TOTAL=TOTAL+SUBTOTAL
162 ...D LINE(" "),LINE($$RJ("**"_STATTYPE_" SUBTOTAL ** (excluding commit acks):",68)_$$RJ(SUBTOTAL,10))
163 .D:'QUIT LINE(" "),LINE($$RJ("** TOTAL "_$S(DIR="IN":"INCOMING",1:"OUTGOING")_" MESSAGES ** (excluding commit acks):",68)_$$RJ(TOTAL,10))
164 I CRT,'QUIT D PAUSE2
165 I $D(ZTQUEUED) S ZTREQ="@"
166 D ^%ZISC
167 Q
168 ;
169DEVICE() ;
170 ;Description: allows the user to select a device.
171 ;Input: none
172 ;
173 ;Output:
174 ; Function Value - Returns 0 if the user decides not to print or to
175 ; queue the report, 1 otherwise.
176 ;
177 N OK,HLOPARMS
178 S OK=1
179 S %ZIS="MQ"
180 D ^%ZIS
181 S:POP OK=0
182 D:OK&$D(IO("Q"))
183 .S HLOPARMS("STATISTICS TYPE")=TYPE,HLOPARMS("START DT/TM")=START,HLOPARMS("END DT/TM")=END
184 .S ZTRTN="QUE^HLOSTAT",ZTDESC="HLO MESSAGE STATISTICS REPORT",ZTSAVE("HLOPARMS(")=""
185 .D ^%ZTLOAD
186 .W !,$S($D(ZTSK):"REQUEST QUEUED TASK="_ZTSK,1:"REQUEST CANCELLED")
187 .D HOME^%ZIS
188 .S OK=0
189 Q OK
190 ;
191PAUSE ;
192 ;First scrolls to the bottome of the page, then does a screen pause. Sets QUIT=1 if user decides to quit.
193 ;
194 N DIR,X,Y
195 F Q:$Y>(IOSL-3) W !
196 S DIR(0)="E"
197 D ^DIR
198 I ('(+Y))!$D(DIRUT) S QUIT=1
199 Q
200PAUSE2 ;
201 ;Screen pause without scrolling. Sets QUIT=1 if user decides to quit.
202 ;
203 N DIR,X,Y
204 S DIR(0)="E"
205 D ^DIR
206 I ('(+Y))!$D(DIRUT) S QUIT=1
207 Q
208 ;
209LINE(LINE) ;Prints a line.
210 ;
211 I CRT,($Y>(IOSL-4)) D
212 .D PAUSE
213 .Q:QUIT
214 .W @IOF
215 .W LINE
216 ;
217 E I ('CRT),($Y>(IOSL-2)) D
218 .W @IOF
219 .W ?70,"Page: ",PAGE
220 .S PAGE=PAGE+1
221 .W LINE
222 ;
223 E W !,LINE
224 Q
225 ;
226LJ(STRING,LEN) ;
227 Q $$LJ^XLFSTR($E(STRING,1,LEN),LEN)
228RJ(STRING,LEN) ;
229 Q $$RJ^XLFSTR($E(STRING,1,LEN),LEN)
Note: See TracBrowser for help on using the repository browser.