source: WorldVistAEHR/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDTU10.m@ 1141

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

initial load of WorldVistAEHR

File size: 8.1 KB
RevLine 
[613]1KMPDTU10 ;OAK/RAK - CP Tools Timing Utility ;6/21/05 10:17
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;**4**;Mar 22, 2002
3 ;
4DATERNG(KMPDSS,KMPDEF,KMPDRES,KMPDDT) ; timing date range for a subscript
5 ;-----------------------------------------------------------------------
6 ; KMPDSS.... KMPTMP SUBSCRIPT
7 ; KMPDEF.... (optional) default number of days to track - if not defined
8 ; will default to seven (7)
9 ; KMPDRES(). Results of api in format:
10 ; KMPDRES(0)=piece 1 - Start Date Internal
11 ; piece 2 - End Date Internal
12 ; piece 3 - Start Date External
13 ; piece 4 - End Date External
14 ; Null ("") is returned if no results are found
15 ; KMPDRES(1)=NumberOfDays
16 ; KMPDDT.... Date only (do not ask for days)
17 ; 0 - both date & days
18 ; 1 - date only - do not ask for days
19 ;
20 ; This api determines the date range for KMPDSS (ex: ORWCV for CPRS
21 ; cover sheets). It asks the user the ending date. After the ending
22 ; date is entered, the user is prompted for the number of days to track.
23 ; Results are returned in the KMPDRES() array as described above.
24 ;-----------------------------------------------------------------------
25 K KMPDRES S KMPDRES(0)="",KMPDRES(1)=""
26 Q:$G(KMPDSS)=""
27 S:'$G(KMPDEF) KMPDEF=7
28 S KMPDDT=+$G(KMPDDT)
29 N COUNT,DATE,DAYS,END,SESS,START
30 ; start & end dates
31 S DATE=$$DATERNG1(KMPDSS,.SESS)
32 Q:'$D(SESS)
33 S START=$P(DATE,U),END=$P(DATE,U,2)
34 Q:'START!('END)
35 ; get end date
36 K DIR S DIR(0)="DO^"_START_":"_END_":E"
37 S DIR("A")="Select End Date",DIR("B")=$$FMTE^XLFDT(END)
38 W ! D ^DIR Q:'Y S END=Y
39 ; if date only
40 I KMPDDT D Q
41 .S KMPDRES(0)=END_U_END_U_$$FMTE^XLFDT(END)_U_$$FMTE^XLFDT(END)
42 ; determine number of days
43 S DATE=END+.1,START=END,DAYS=0
44 F S DATE=$O(SESS(DATE),-1) Q:'DATE S START=DATE,DAYS=DAYS+1
45 Q:'DAYS
46 ; days to go back
47 K DIR S DIR(0)="NO^1:"_DAYS_":O"
48 S DIR("A")="Select # of Days Review"
49 S DIR("B")=$S(DAYS'<KMPDEF:KMPDEF,1:DAYS)
50 D ^DIR Q:Y=""!(Y="^")
51 ; determine start date
52 S START=END
53 I Y'=1 S COUNT=1 D
54 .F S START=$O(SESS(START),-1) Q:'START S COUNT=COUNT+1 Q:COUNT'<Y
55 S KMPDRES(0)=START_U_END_U_$$FMTE^XLFDT(START)_U_$$FMTE^XLFDT(END)
56 S KMPDRES(1)=Y
57 ;
58 Q
59 ;
60DATERNG1(KMPDSS,KMPDSESS) ;-- extrinsic function
61 ;-----------------------------------------------------------------------
62 ; KMPDSS.... KMPTMP SUBSCRIPT
63 ; KMPDSESS() Array of dates:
64 ; KMPDSESS(3030801)=""
65 ; KMPDSESS(3030802)=""
66 ; ...
67 ;
68 ; Return: StartDate^EndDate - in internal fileman format
69 ; "" - no results
70 ;-----------------------------------------------------------------------
71 Q:$G(KMPDSS)="" ""
72 N DATE,END,START
73 ; determine most recent date
74 F DATE=0:0 S DATE=$O(^KMPD(8973.2,"ASVDTSS",KMPDSS,DATE)) Q:'DATE D
75 .; set array of session dates
76 .S KMPDSESS(DATE)=""
77 Q:'$D(KMPDSESS) ""
78 ; set start and end dates according to SESS() array
79 S END=$O(KMPDSESS("A"),-1),START=$O(KMPDSESS(""))
80 Q START_"^"_END
81 ;
82DTTMRNG(KMPDSS,KMPDEF,KMPDRES,KMPDEFH) ; timing date/time range for a subscript
83 ;-----------------------------------------------------------------------
84 ; KMPDSS.... KMPTMP SUBSCRIPT
85 ; KMPDEF.... (optional) default number of days to track - if not defined
86 ; will default to seven (7)
87 ; KMPDRES(). Results of api in format:
88 ; KMPDRES(0)=piece 1 - Start Date Internal
89 ; piece 2 - End Date Internal
90 ; piece 3 - Start Date External
91 ; piece 4 - End Date External
92 ; Null ("") is returned if no results are found
93 ; KMPDRES(1)=NumberOfDays
94 ; KMPDEFH.. (optional) Default hour.
95 ;
96 ; This api determines the date range for KMPDSS (ex: ORWCV for CPRS
97 ; cover sheets). It asks the user the ending date. After the ending
98 ; date is entered, the user is prompted for the number of hours to
99 ; review. Results are returned in the KMPDRES() array as described
100 ; above.
101 ;-----------------------------------------------------------------------
102 K KMPDRES S KMPDRES(0)="",KMPDRES(1)=""
103 Q:$G(KMPDSS)=""
104 S:'$G(KMPDEF) KMPDEF=7
105 S KMPDEFH=$G(KMPDEFH)
106 N COUNT,DATE,DAYS,END,SESS,START
107 ; get date
108 D DATERNG(KMPDSS,1,.KMPDRES,1)
109 Q:'$D(KMPDRES)
110 Q:$G(KMPDRES(0))=""
111 S KMPDRES(1)=""
112 ; determine number of hours
113 K DIR S DIR(0)="LO^0:23:O"
114 S DIR("A")="Select Hour(s) to Review"
115 S:KMPDEFH'="" DIR("B")=KMPDEFH
116 D ^DIR Q:Y=""!(Y="^")
117 S KMPDRES(1)=Y
118 Q
119 ;
120LISTSEL(KMPDLIST,KMPDSS,KMPDRLTM) ;-- extrinsic function - build list and select entry
121 ;-----------------------------------------------------------------------
122 ; KMPDLIST... 2 - Client Name
123 ; 3 - IP Address
124 ; KMPDSS..... Field #.07 (KMPTMP SUBSCRIPT)
125 ; KMPDRLTM... Real-Time data
126 ; 0 - not real-time
127 ; 1 - real-time
128 ;
129 ; Return: "" - no selection
130 ; Name - free text
131 ;
132 ; This function will build a list of entries from file #8973.2
133 ;(CP TIMING) and ask the user to select an entry.
134 ;-----------------------------------------------------------------------
135 S KMPDLIST=+$G(KMPDLIST)
136 Q:KMPDLIST<2!(KMPDLIST>3) ""
137 Q:$G(KMPDSS)="" ""
138 S KMPDRLTM=+$G(KMPDRLTM)
139 ;
140 N DIC,I,X,XREF,Y
141 ;
142 W " ==> building list..."
143 K ^TMP("KMPDTU10-LIST",$J)
144 D @$S('KMPDRLTM:"LISTSELH",1:"LISTSELR")
145 ; quit if no data
146 Q:'$D(^TMP("KMPDTU10-LIST",$J))
147 S DIC="^TMP(""KMPDTU10-LIST"",$J,"
148 S DIC(0)="AEQZ"
149 S DIC("A")=$S(KMPDLIST=2:"Select Client",1:"IP Address")_": "
150 D ^DIC
151 K ^TMP("KMPDTU10-LIST",$J)
152 Q $S(Y<1:"",1:$P(Y,"^",2))
153 ;
154LISTSELH ;-- historical data list
155 N I,CNT,DOT,XREF
156 ; determine xref to build list
157 S XREF=$S(KMPDLIST=2:"ASSCLDTTM",KMPDLIST=3:"ASSIPDTTM",1:"")
158 S I="",(CNT,DOT)=0
159 F S I=$O(^KMPD(8973.2,XREF,KMPDSS,I)) Q:I="" D
160 .S CNT=CNT+1,DOT=DOT+1 W:'(DOT#100) "."
161 .S ^TMP("KMPDTU10-LIST",$J,CNT,0)=I
162 .S ^TMP("KMPDTU10-LIST",$J,"B",I,CNT)=""
163 S ^TMP("KMPDTU10-LIST",$J,0)=$S(KMPDLIST=2:"Client Name",1:"IP Address")_"^1.01^"_CNT_"^"_CNT
164 Q
165 ;
166LISTSELR ;-- real-time data list
167 N I,CNT,DATA,DOT,X
168 S I="",(CNT,DOT)=0
169 F S I=$O(^KMPTMP("KMPDT",KMPDSS,I)) Q:I="" S DATA=^(I) I DATA]"" D
170 .S X=$S(KMPDLIST=2:$P(DATA,U,4),1:$P($P(I," ",2),"-"))
171 .Q:$O(^TMP("KMPDTU10-LIST",$J,"B",X,0))
172 .S CNT=CNT+1,DOT=DOT+1 W:'(DOT#100) "."
173 .S ^TMP("KMPDTU10-LIST",$J,CNT,0)=X
174 .S ^TMP("KMPDTU10-LIST",$J,"B",X,CNT)=""
175 S ^TMP("KMPDTU10-LIST",$J,0)=$S(KMPDLIST=2:"Client Name",1:"IP Address")_"^1.01^"_CNT_"^"_CNT
176 Q
177 ;
178SRCHBY(KMPDRES,KMPDSS,KMPDRLTM) ;-- api - search by criteria
179 ;-----------------------------------------------------------------------
180 ; KMPDRES().. Array (passed by reference) containing results in format:
181 ; KMPDRES = "" - no valid selection
182 ; KMPDRES = 1^User Name
183 ; KMPDRES(1) = DUZ^NewPersonName
184 ; KMPDRES = 2^Client Name
185 ; KMPDRES(1) = ClientName (free text)
186 ; KMPDRES = 3^IP Address
187 ; KMPDRES(1) = IPAddress
188 ; KMPDRES = 4^Any Occurrence
189 ; KMPDSS..... KMPTMP SUBSCIPT - field #.07 from file #8973.2 (CP TIMING)
190 ; KMPDRLTM... Real-Time data
191 ; 0 - not real-time
192 ; 1 - real-time
193 ;-----------------------------------------------------------------------
194 K KMPDRES S KMPDRES=""
195 Q:$G(KMPDSS)=""
196 S KMPDRLTM=+$G(KMPDRLTM)
197 N DIC,DIR,X,Y
198 S DIR(0)="SO^1:User Name;2:Client Name;3:IP Address;4:All of the Above"
199 S DIR("A")="Search By"
200 S DIR("B")=4
201 D ^DIR
202 Q:'Y
203 S KMPDRES=Y_"^"_Y(0)
204 ; quit if 'all of the above'
205 Q:(+KMPDRES)=4
206 ;
207 ; user name
208 I (+KMPDRES)=1 D Q
209 .S DIC=200,DIC(0)="AEMQZ",DIC("A")="Select User: "
210 .D ^DIC
211 .I Y<1 S KMPDRES="" Q
212 .S KMPDRES(1)=Y
213 ;
214 ; client name
215 I (+KMPDRES)=2 D Q
216 .S KMPDRES(1)=$$LISTSEL(+KMPDRES,KMPDSS,KMPDRLTM)
217 .S:KMPDRES(1)="" KMPDRES=""
218 ;
219 ; ip address
220 I (+KMPDRES)=3 D Q
221 .S KMPDRES(1)=$$LISTSEL(+KMPDRES,KMPDSS,KMPDRLTM)
222 .S:KMPDRES(1)="" KMPDRES=""
223 ;
224 Q
225 ;
226TTLSEC() ;-- extrinsic function - time-to-load threshold seconds
227 ;-----------------------------------------------------------------------
228 ;-----------------------------------------------------------------------
229 N DIR,X,Y
230 S DIR(0)="NAO^1"
231 S DIR("A")="Select Time-To-Load Threshold (Seconds): "
232 S DIR("B")=60
233 D ^DIR
234 Q $S(Y:Y,1:"")
Note: See TracBrowser for help on using the repository browser.