source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLEVMST0.m@ 923

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

initial load of WorldVistAEHR

File size: 6.8 KB
RevLine 
[613]1HLEVMST0 ;O-OIFO/LJA - Event Monitor MASTER JOB ;02/04/2004 14:42
2 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
3 ;
4UNQUEUE ; Unqueue master job...
5 N DIFF,IOINHI,IOINORM,LAST0,LASTDT,LASTIEN,NEXTH,SECNEXT
6 N SECNOW,TASKNO,ZTDTH,ZTSK
7 ;
8 S X="IOINHI;IOINORM" D ENDR^%ZISS
9 ;
10 D HDU
11 D EXU
12 ;
13 W !
14 ;
15 S LASTDT=$O(^HLEV(776.2,"B",":"),-1)
16 S LASTIEN=$O(^HLEV(776.2,"B",+LASTDT,":"),-1)
17 S LAST0=$G(^HLEV(776.2,+LASTIEN,0)) I $P(LAST0,U,4)'="Q" D QUIT ;->
18 . D TELL("The most recently queued master job is no longer active...","1^2^999")
19 ;
20 S LASTSK=$P(LAST0,U,5) I LASTSK>0 D
21 . W !,"The current master job is task# ",$P(LAST0,U,5),", queued for "
22 . W $$FMTE^XLFDT(+$P(LAST0,U,6)),"."
23 ;
24 W !
25 I '$$YN^HLCSRPT4("OK to stop master job now","No") D QUIT ;->
26 . W " no action taken..."
27 ;
28 W " Master job stopped..."
29 W !!,IOINHI,"Important!!",IOINORM," You must remember to start a new master job!!"
30 ;
31 D UNQ^HLEVUTIL(+LASTIEN,+LASTSK,"Master job stopped by "_$P($G(^VA(200,+$G(DUZ),0)),U)_".")
32 ;
33 D TELL("","0^0^999")
34 ;
35 Q
36 ;
37HDU W @IOF,$$CJ^XLFSTR("Unqueue Master Job",IOM)
38 W !,$$REPEAT^XLFSTR("=",IOM)
39 QUIT
40 ;
41EXU N I,T F I=1:1 S T=$T(EXU+I) QUIT:T'[";;" W !,$P(T,";;",2,99)
42 ;;If a master job has been queued to a future time, it can be unqueued now.
43 ;;
44 ;;Note: If you unqueue this task, no future master jobs will run until you
45 ;; manually start a new master job. (Start new master jobs with the
46 ;; '' menu option.)
47 QUIT
48 ;
49MSTNOW ; Start queued master job now!
50 N DIFF,LAST0,LASTDT,LASTIEN,NEXTH,SECNEXT,SECNOW,TASKNO,ZTDTH,ZTSK
51 ;
52 W @IOF,$$CJ^XLFSTR("Master Job ""Run Now"" Utility",IOM)
53 W !,$$REPEAT^XLFSTR("=",IOM)
54 W !
55 ;
56 S LASTDT=$O(^HLEV(776.2,"B",":"),-1) ; Last (probably queued) job time
57 S LASTIEN=$O(^HLEV(776.2,"B",+LASTDT,":"),-1)
58 S LAST0=$G(^HLEV(776.2,+LASTIEN,0)) I LAST0']"" D
59 . W !,"Couldn't find last master job entry..."
60 ;
61 S TASKNO=$P(LAST0,U,5) I '$D(^%ZTSK(+TASKNO)) D
62 . W !,"Couldn't find task",$S(TASKNO:"# "_TASKNO_"...",1:".")
63 ;
64 S TASK0=$G(^%ZTSK(+TASKNO,0)) I TASK0']"" D
65 . W !,"Couldn't find task# ",TASKNO,"'S zero node..."
66 ;
67 S NEXTH=$P(TASK0,U,6) I NEXTH'?1.N1","1.N D
68 . W !,"Invalid future queue time ($H)..."
69 ;
70 S SECNEXT=$$SEC(NEXTH)
71 S SECNOW=$$SEC($H)
72 ;
73 S DIFF=SECNEXT-SECNOW
74 I DIFF<60 D QUIT ;->
75 . I DIFF<1 W !,"Master job will start any moment!" QUIT ;->
76 . W !,"Master job will start on its own in ",DIFF," seconds..."
77 ;
78 I '$D(^%ZTSCH(SECNEXT,TASKNO)) D
79 . W !,"Couldn't find ^%ZTSK(SEC,ZTSK) node..."
80 ;
81 W !,"This utility allows you to run the master job ahead of it's currently"
82 W !,"scheduled time to run."
83 ;
84 W !!,"Master task# ",TASKNO," is queued to "
85 W $$SDT^HLEVX001($$HTFM^XLFDT(NEXTH))
86 W " and it will be started now..."
87 ;
88 W !
89 I '$$YN^HLCSRPT4("OK to start now","No") D QUIT ;->
90 . W " no action taken..."
91 ;
92 S ZTSK=TASKNO,ZTDTH=$H
93 D REQ^%ZTLOAD
94 ;
95 W !!,"Master job requeued to 'now'..."
96 ;
97 Q
98 ;
99STARTMST ; Start brand new master job now (interactively)!
100 N DIFF,IOINHI,IOINORM,LAST0,LASTDT,LASTIEN,NEXTH,SECNEXT
101 N SECNOW,TASKNO,ZTDTH,ZTSK
102 ;
103 S LASTDT=$O(^HLEV(776.2,"B",":"),-1)
104 S LASTIEN=$O(^HLEV(776.2,"B",+LASTDT,":"),-1)
105 S LAST0=$G(^HLEV(776.2,+LASTIEN,0))
106 S TASKNO=$P(LAST0,U,5)
107 ;
108 ; If this option is accessed by queued background job, just unqueue
109 ; everything to make sure, and start a new master job for NOW...
110 I $D(ZTQUEUED) D QUIT ;->
111 . D UNQ^HLEVUTIL(+LASTIEN,+TASKNO,"Reboot unqueue/requeue master job.")
112 . D STARTJOB^HLEVMST
113 ;
114 S X="IOINHI;IOINORM" D ENDR^%ZISS
115 ;
116 D HD
117 D EX
118 ;
119 W !
120 ;
121 I $P(LAST0,U,4)="Q" D QUIT ;->
122 . D TELL("It appears as if task# "_$P(LAST0,U,5)_" has already been queued.","1^2^999")
123 ;
124 I $P(LAST0,U,5)>0 D
125 . W !!,"The ",IOINHI,"last",IOINORM
126 . W " master job was task# ",$P(LAST0,U,5),", queued "
127 . W $$FMTE^XLFDT(+LAST0),"."
128 ;
129 W !
130 I '$$YN^HLCSRPT4("OK to start a "_IOINHI_"new"_IOINORM_" master task now","No") D QUIT ;->
131 . W " no action taken..."
132 ;
133 D STARTJOB^HLEVMST
134 ;
135 D TELL("Press RETURN to exit... ","0^0^999")
136 ;
137 Q
138 ;
139HD W @IOF,$$CJ^XLFSTR("Master Job Start",IOM)
140 W !,$$REPEAT^XLFSTR("=",IOM)
141 QUIT
142 ;
143EX N I,T F I=1:1 S T=$T(EX+I) QUIT:T'[";;" W !,$P(T,";;",2,99)
144 ;;This option will queue a new master job task if no master job is currently
145 ;;running and no master job is queued for the future.
146 ;;
147 ;;Note: A master job is queued every time the event monitoring software is
148 ;; installed, and every time the system is rebooted. So, normally it
149 ;; is not necessary to use this option to create a new master job.
150 ;; (The most common reason for using this option is if the queued
151 ;; master job was 'dequeued'.)
152 QUIT
153 ;
154SEC(HORO) ; Convert $H to seconds...
155 QUIT:HORO'?5.N1","1.N "" ;->
156 QUIT ((86400*+HORO)+$P(HORO,",",2))
157 ;
158SECTHORO(SEC) ; Convert seconds to $H...
159 N DAYS,SECH
160 QUIT:SEC'?1.N "" ;->
161 S DAYS=SEC\86400,SECH=SEC#86400
162 QUIT DAYS_","_SECH
163 ;
164TELL(TXTINFO,ACT,TXTBT) ; Print TXTINFO, FF to bottom, and $$BTE(TXTBT)...
165 ;
166 ; ACT = #1 ^ #2 ^ #3 ^ #4 -> Controls pre-$$BTE positioning...
167 ;
168 ; #1 => 0 = Spaces before printing TXTINFO (See #2).
169 ; 1 = Lines before printing TXTINFO (see #2). [DEFAULT]
170 ; #2 => # = # Spaces (if #1=0) or lines (if #1=1-DEFAULT)
171 ; #3 => # = # lines before printing TXTBT (see #4).
172 ; (# lines printed will never exceed IOSL unless
173 ; overridden by #4. Entering #3=999 just ensures that
174 ; line feeds will be issued until cursor is at bottom
175 ; of screen.
176 ; #4 => # = # lines that **must** be printed before TXTBT.
177 ;
178 ; Examples...
179 ;
180 ; 0^3^999^5 - Prints 3 spaces, TXTINFO and FFs to bottom. If the
181 ; screen was full when TELL was called, only one FF would
182 ; normally be issued (minimum, for spacing purposes).
183 ; However, the '5' ensures that at least 5 LFs are issued.
184 ; Then, TXTBT printed.
185 ;
186 ; 1^2^2 - Prints 2 LFs, TXTINFO, and 2 LFs, then TXTBT. (If the
187 ; screen was full when TELL called, only 1 LF would be
188 ; printed before printing TXTBT.)
189 ;
190 N I,X
191 ;
192 S ACT=$G(ACT),TXTINFO=$G(TXTINFO)
193 S TXTBT=$S($G(TXTBT)]"":TXTBT,1:"Press RETURN to exit... ")
194 ;
195 ; Default to line feeds...
196 S:$P(ACT,U)'=0&($P(ACT,U)'=1) $P(ACT,U)=1
197 ;
198 ; Default to 1 line feed or 3 spaces...
199 S:$P(ACT,U,2)'?1.N $P(ACT,U,2)=$S(+ACT=0:3,1:1)
200 ;
201 ; Default to bottom of form trailing lines...
202 S:$P(ACT,U,3)'?1.N $P(ACT,U,3)=999
203 ;
204 ; Default to minimum lines after printing TXTINFO...
205 S:$P(ACT,U,4)'?1.N $P(ACT,U,4)=1
206 ;
207 I +ACT=0 X "F I=1:1:$P(ACT,U,2) W "" """ W TXTINFO
208 I +ACT=1 X "F I=1:1:$P(ACT,U,2) W !" W TXTINFO
209 ;
210 S ACT=$P(ACT,U,3,4)
211 ;
212 ; If positive, always issue at least one line feed...
213 I ACT W ! S $P(ACT,U)=$P(ACT,U)-1
214 ;
215 F I=1:1:ACT Q:($Y+3)>IOSL&(ACT>$P(ACT,U,2)) W !
216 ;
217 S X=$$BTE^HLCSMON(TXTBT)
218 ;
219 Q
220 ;
221EOR ;HLEVMST0 - Event Monitor MASTER JOB ;5/16/03 14:42
Note: See TracBrowser for help on using the repository browser.