source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLEVAPI0.m@ 701

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

initial load of WorldVistAEHR

File size: 7.4 KB
Line 
1HLEVAPI0 ;O-OIFO/LJA - Event Monitor APIs ;02/04/2004 14:42
2 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
3 ;
4ONOFFM(HLEVIENE,STATUS) ;Turn on/off event monitor...
5 D DEBUG^HLEVAPI2("ONOFFM") ; Debug data created conditionally
6 ;
7 ; Stop all event monitoring to enable on-site debugging...
8 QUIT:$G(^TMP("HLEVFLAG",$J))["STOP" ;->
9 ;
10 QUIT $$ONOFF(776.1,+HLEVIENE,STATUS)
11 ;
12ONOFFS(HLEVIEN,STATUS) ; Turn on/off system...
13 QUIT $$ONOFF(776.999,+HLEVIEN,STATUS)
14 ;
15ONOFF(FILE,HLEVIENE,STATUS) ; Turn on/off event monitor or system...
16 ; FILE can = 776.1 or 776.999
17 ; Actually, HLEVIENE can be the IEN of the monitor, or the system.
18 ; If STATUS="A", sets status to ACTIVE.
19 ; If STATUS="I", sets status to INACTIVE.
20 ; If STATUS=null or undefined (not passed), present status returned...
21 ;
22 N DA,DATA,DIE,DR,STAT,X,Y
23 ;
24 ; Find entry and IEN and zero node data...
25 S FILE=+$G(FILE) I FILE'=776.1&(FILE'=776.999) QUIT "^Invalid file number" ;->
26 S HLEVIENE=$G(HLEVIENE)
27 S:FILE=776.999 HLEVIENE=1 ; Just overwrite anything passed by user...
28 I $L($G(STATUS))>1 QUIT "^Invalid STATUS passed" ;->
29 S STATUS=$$UP^XLFSTR($E($G(STATUS)_" "))
30 I " AI"'[STATUS QUIT "^Invalid STATUS passed" ;->
31 ;
32 ; If they passed the name of the entry...
33 I HLEVIENE'=+HLEVIENE D QUIT:HLEVIENE'>0 "^Couldn't find entry" ;->
34 . I $TR(HLEVIENE," ","")']"" QUIT ;->
35 . S HLEVIENE(1)=$O(^HLEV(FILE,"B",HLEVIENE,0)) ; Must have passed in name
36 . I HLEVIENE(1)'>0 D
37 . . S HLEVIENE(1)=$O(^HLEV(FILE,"B",$$UP^XLFSTR(HLEVIENE),0))
38 . S HLEVIENE=HLEVIENE(1)
39 ;
40 ; Get zero node...
41 S DATA=$G(^HLEV(FILE,+HLEVIENE,0)) QUIT:DATA']"" "^Couldn't find entry" ;->
42 ;
43 ; Get current status...
44 S STAT=$E($P(DATA,U,2)_" ")
45 ;
46 ; If current status not yet entered in field...
47 I " AI"'[STAT D QUIT STAT ;->
48 . ; Passed-in STATUS not A or I, so just tell them value of status...
49 . I "AI"'[STATUS S STAT="^Status not entered yet" QUIT ;->
50 . ; User passed in a value to set the status to, so set it for them...
51 . S DA=+HLEVIENE,DIE=FILE,DR="2///"_STATUS
52 . D ^DIE
53 . S STAT=STATUS
54 ;
55 ; If all they want is the status...
56 I STATUS=" " QUIT STAT ;->
57 ;
58 ; Status entered in field before call...
59 ;
60 ; If passed-in status is the same as the current status in entry...
61 I STAT=STATUS QUIT STATUS ;-> Already set...
62 ;
63 ; Change status of field to passed-in value...
64 S DA=+HLEVIENE,DIE=FILE,DR="2///"_STATUS
65 D ^DIE
66 ;
67 Q STATUS
68 ;
69ONOFFEV ; Turn on/off event monitor
70 N CHG
71 ;
72 N DATA,DIC,IEN,IENR
73 D HDR^HLEVREP("Turn on/off Event Monitors")
74 ;
75S7761 KILL DATA,DIC,IEN,IENR
76 W !
77 S IEN=$$ASKIEN^HLEVREP(776.1) QUIT:IEN'>0 ;->
78 D HDR^HLEVREP("Turn on/off Event Monitors",IEN)
79 D VIEW7761(+IEN)
80 D RUNS7761^HLEVREP(+IEN)
81 I $D(^TMP($J,"HLRUNS")) D
82 . W !!,"Recent Checks of the Monitor by Master Job"
83 . W !,$$REPEAT^XLFSTR("-",IOM)
84 . W !,"Check-time",?18,"Results"
85 . W !,$$REPEAT^XLFSTR("-",IOM)
86 . S IENR=0
87 . F S IENR=$O(^TMP($J,"HLRUNS",IENR)) Q:IENR'>0 D
88 . . S DATA=$G(^TMP($J,"HLRUNS",IENR)) QUIT:DATA']"" ;->
89 . . W !,$$SDT^HLEVX001($P(DATA,U,2)),?18,$$STAT2M^HLEVX001($P(DATA,U))
90 W !
91 S CHG=$$ACTINACT(776.1,+IEN,2,"Event monitor status")
92 I CHG D
93 . D HDR^HLEVREP("Turn on/off Event Monitors",IEN)
94 . D VIEW7761(+IEN)
95 F Q:(IOSL-$Y)<4 W !
96 ;S X=$$BTE^HLCSMON("Press RETURN to continue... ")
97 G S7761 ;->
98 ;
99VIEW7761(IEN) ; Actual display code for entry...
100 N NODE,P1,P2,P3,P4,P5,P6,PAR,PCE
101 ;
102 S NODE=$G(^HLEV(776.1,+IEN,0))
103 F PCE=1:1:6 S @("P"_PCE)=$P(NODE,U,PCE)
104 ;
105 ; Store under field number...
106 F PCE=1:1:8 S PAR(PCE)=$P($G(^HLEV(776.1,+IEN,40)),U,PCE)
107 ;
108 D SH7761("Description",$S(P3]"":P3,1:"---"))
109 D SH7761("Status",$S(P2="A":"ACTIVE",1:"INACTIVE"))
110 D SH7761("Requeue minutes",$S(P4:P4_"min",P4=0:"0 [Immediate Run]",1:"---"))
111 D SH7761("Notification mail group",$S(P5:$P($G(^XMB(3.8,+P5,0)),U),1:"---"))
112 D SH7761("M startup",$S(P6]"":P6,1:"---"))
113 W !,$$CJ^XLFSTR(" Parameter ""Variable"" Descriptors ",IOM,"-")
114 F PCE=1:1:8 I PAR(PCE)]"" D
115 . W !,?25,"Parameter - "_PCE_" = ",PAR(PCE)
116 ;
117 Q
118 ;
119SH7761(TAG,VAL) ;
120 W !,?(35-$L(TAG)-2),TAG,":",?45,VAL
121 Q
122 ;
123ONOFFPAR ; Turn on/off parameters...
124 N CHG
125 ;
126 D VIEW7769^HLEVREP(0)
127 ;
128 W !
129 ;
130 S CHG=0
131 S X=$$ACTINACT(776.999,1,2,"STATUS-MASTER JOB") I X=1 S CHG=1
132 S X=$$ACTINACT(776.999,1,6,"STATUS-EVENT MONITORING") I X=1 S CHG=1
133 ;
134 I CHG D VIEW7769^HLEVREP(0)
135 ;
136 W !
137 F Q:(IOSL-$Y)<3 W !
138 S X=$$BTE^HLCSMON("Press RETURN to exit... ")
139 ;
140 Q
141 ;
142ACTINACT(FILE,IEN,FLD,TAG) ; Turn on/off status fields...
143 N DA,DIE,DR,STAT,X,Y
144 S STAT=$P($G(^HLEV(FILE,IEN,0)),U,+FLD)
145 S X=$$YN^HLCSRPT4("Change '"_TAG_"' to "_$S(STAT="A":"INACTIVE",1:"ACTIVE"),"No") I X'=1 D QUIT "" ;->
146 . W " ... nothing changed ..."
147 S DA=IEN,DIE=FILE,DR=FLD_"///"_$S(STAT="A":"I",1:"A")
148 D ^DIE
149 W " changed!"
150 Q 1
151 ;
152EVENTCHK(HLEVIENM) ; Loop thru all MONITORs...
153 ; NOEVCHK,ZTSKMST -- req
154 N HLEVIENE,HLEVNM
155 ;
156 ; Check STATUS-EVENT...
157 S NO=$O(^HLEV(776.999,":"),-1) QUIT:$P($G(^HLEV(776.999,+NO,0)),U,6)'="A" ;->
158 ;
159 S HLEVNM=0
160 F S HLEVNM=$O(^HLEV(776.1,"B",HLEVNM)) Q:HLEVNM']"" D
161 . S HLEVIENE=0
162 . F S HLEVIENE=$O(^HLEV(776.1,"B",HLEVNM,HLEVIENE)) Q:'HLEVIENE D
163 . . D EVENTONE^HLEVAPI3(HLEVIENM,HLEVNM,HLEVIENE)
164 . . S NOEVCHK=$G(NOEVCHK)+1
165 ;
166 Q
167 ;
168EVRES(HLEVIENM,HLEVIENE,RES,HLEVIENJ) ; Record result of queued task...
169 ; ZTSK -- req
170 N MIEN,NODE,STATUS
171 ;
172 ; Initial sets...
173 S STATUS=$P($G(^HLEV(776,+$G(HLEVIENJ),0)),U,4)
174 S RES=$E($$UP^XLFSTR($G(RES)))
175 ;
176 ; If any call made here, the job is running by definition...
177 I $G(^HLEV(776,+$G(HLEVIENJ),0))]"" D
178 . ; ABORT^HLEVAPI might have set status to ERROR. Don't override!
179 . S $P(^HLEV(776,+$G(HLEVIENJ),0),U,4)=$S(STATUS="E":"E",RES="X":"E",RES="F":"F",1:"R")
180 ;
181 ; If no master job, or RUNNING, quit...
182 I HLEVIENM=9999999!(RES="R") QUIT ;->
183 ;
184 ; Store results in 776.2...
185 S MIEN=$O(^HLEV(776.2,+HLEVIENM,51,"B",+HLEVIENE,0)) QUIT:MIEN'>0 ;->
186 S NODE=$G(^HLEV(776.2,+HLEVIENM,51,+MIEN,0)) QUIT:NODE']"" ;->
187 ; Various jobs will set... QUIT:$P(NODE,U,4)'=$G(ZTSK) ;->
188 S $P(NODE,U,5)=$G(RES),$P(NODE,U,6)=$$NOW^XLFDT
189 S ^HLEV(776.2,+HLEVIENM,51,+MIEN,0)=NODE
190 ;
191 Q
192 ;
193RUNEV(LASTRUN,LAPSE) ; Is LASTRUN (FM) LAPSE(min) before NOW?
194 N WHENRUN
195 QUIT:LASTRUN']"" "" ;->
196 S WHENRUN=$$FMADD^XLFDT($$NOW^XLFDT,0,0,-LAPSE)
197 Q $S(WHENRUN>LASTRUN:1,1:"")
198 ;
199OKMCODE(MREF) ; Is this a valid M subrtn^rtn reference?
200 N TXT
201 QUIT:MREF'?1.8E1"^"1.8E "" ;->
202 S TXT=$T(@MREF)
203 Q $S(TXT]"":1,1:"")
204 ;
205Q1TIME(HLEVIENE,OVERRIDE,QTIME,XTMP) ; Start a one-time run of event monitor (w/no master job)
206 N DATA,HLEVIENJ,HLEVNM,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
207 ;
208 ; Override inactive entry?
209 S OVERRIDE=$S($G(OVERRIDE):1,1:0)
210 ;
211 ; Queue to future time?
212 S QTIME=$G(QTIME)
213 ;
214 ; Is event active?
215 S DATA=$G(^HLEV(776.1,+$G(HLEVIENE),0)) QUIT:DATA']"" "^Entry not found" ;->
216 I $P(DATA,U,2)'="A",'OVERRIDE QUIT "^Event not active" ;->
217 ;
218 ; More variable sets...
219 S HLEVNM=$P(DATA,U)
220 S HLEVIENM=9999999 ; A one-time, no master job, run...
221 ;
222 ; Create a monitor stub entry...
223 S HLEVIENJ=$$NEWEVENT^HLEVAPI(HLEVIENE,QTIME)
224 I HLEVIENJ'>0 QUIT "^Entry creation failure" ;->
225 ;
226 ; Queue a new job w/stub entry's IEN...
227 S ZTIO="",ZTDTH=$S(QTIME?7N1"."1.N:$$FMTH^XLFDT(QTIME),1:$H)
228 S ZTDESC="HL Event Monitor - #"_HLEVIENE
229 S ZTRTN="QUEUEV^HLEVAPI3"
230 S ZTSAVE("HLEVIENJ")="",ZTSAVE("HLEVIENE")=""
231 S ZTSAVE("HLEVNM")="",ZTSAVE("HLEVIENM")=""
232 I $G(XTMP)]"" S ZTSAVE("XTMP")=""
233 D ^%ZTLOAD
234 ;
235 I $G(^HLEV(776,+$G(HLEVIENJ),0))]"",$G(ZTSK)>0 D
236 . N DA,DIE,DR
237 . S DA=+HLEVIENJ,DIE=776,DR="8///"_ZTSK
238 . D ^DIE
239 ;
240 Q $G(ZTSK)_U_$G(HLEVIENJ)
241 ;
242EOR ;HLEVAPI0 - Event Monitor APIs ;5/16/03 14:42
Note: See TracBrowser for help on using the repository browser.