source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLEVX001.m@ 1476

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

initial load of WorldVistAEHR

File size: 5.7 KB
Line 
1HLEVX001 ;O-OIFO/LJA - Event Monitor "Mother" ;02/04/2004 14:42
2 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
3 ;
4MOTHER ; The "Mother of All" monitors! (Monitors the Event Monitor)
5 ;HLEVIENE,HLEVIENJ,HLEVIENM -- req
6 D START^HLEVAPI()
7 D MASTER
8 D MONITOR
9 D CHECKOUT^HLEVAPI
10 Q
11 ;
12MASTER ; Collect master job information...
13 D LASTNEXT
14 D MSTRUNS
15 Q
16 ;
17MSTRUNS ; Show master runs and status counts...
18 N CT,CTM,STAT,STATM
19 KILL ^TMP($J,"SV")
20 D RUNS("SV")
21 D ADD50("")
22 D ADD50("# job runs last 24 hours",$G(^TMP($J,"SV")))
23 D ADD50(" "_$$REPEAT^XLFSTR("-",40))
24 S STAT=""
25 F S STAT=$O(^TMP($J,"SV",STAT)) Q:STAT']"" D
26 . S CT=^TMP($J,"SV",STAT)
27 . D ADD50("#"_$$STAT2(STAT),CT)
28 Q
29 ;
30STAT2(STAT) ; Return status for 776.2 0;4...
31 Q $S(STAT="E":"ERROR",STAT="F":"FINISHED",STAT="Q":"QUEUED",STAT="R":"RUNNING",STAT="P":"PARM STOP",STAT="S":"STOP REQUESTED",STAT="A":"JOB ABORTED",1:STAT)
32 ;
33STAT2M(STAT) ; REturn status for 776.2051 0;2 & 0;6...
34 Q $S(STAT="E":"TOO EARLY",STAT="I":"INACTIVE",STAT="M":"M-CHK-FAIL",STAT="Q":"QUEUED",STAT="R":"RUNNING",STAT="XM":"M CODE",$E(STAT)="X":"ERROR",1:STAT)
35 ;
36LASTNEXT ; Show last completed run and next queued run...
37 N IENLAST,IENNEXT
38 S IENLAST=+$$IEN7762("F"),NODE(+IENLAST)=$G(^HLEV(776.2,+IENLAST,0))
39 S IENNEXT=+$$IEN7762("Q"),NODE(+IENNEXT)=$G(^HLEV(776.2,+IENNEXT,0))
40 D ADD50("Last master job run",$$FMTE^XLFDT(+NODE(+IENLAST)))
41 D ADD50("Next master job at",$$FMTE^XLFDT(+NODE(+IENNEXT))_" Task#: "_$P(NODE(+IENNEXT),U,5))
42 Q
43 ;
44RUNS(SUB) ; Find number runs and results...
45 N ABORT,CUT,DATA,IEN,IENM,LASTDT,RES,STAT,STATM,STATM5
46 S CUT=$$FMADD^XLFDT($$NOW^XLFDT,-1),ABORT=0
47 S LASTDT=":"
48 F S LASTDT=$O(^HLEV(776.2,"B",LASTDT),-1) Q:'LASTDT!(LASTDT<CUT)!(ABORT) D
49 . S IEN=":"
50 . F S IEN=$O(^HLEV(776.2,"B",LASTDT,IEN),-1) Q:'IEN!(ABORT) D
51 . . S DATA=$G(^HLEV(776.2,+IEN,0))
52 . . S STAT=$P(DATA,U,4),STAT=$S(STAT]"":STAT,1:"?")
53 . . S ^TMP($J,SUB)=$G(^TMP($J,SUB))+1
54 . . S ^TMP($J,SUB,STAT)=$G(^TMP($J,SUB,STAT))+1
55 . . S IENM=0
56 . . F S IENM=$O(^HLEV(776.2,+IEN,51,IENM)) Q:IENM'>0 D
57 . . . S DATA=^HLEV(776.2,+IEN,51,+IENM,0)
58 . . . S STATM=$P(DATA,U,2),STATM=$S(STATM]"":STATM,1:"?")
59 . . . S STATM5=$P(DATA,U,5),STATM=$$STATM5(STATM,STATM5)
60 . . . S ^TMP($J,SUB,STAT,STATM)=$G(^TMP($J,SUB,STAT,STATM))+1
61 Q
62 ;
63STATM5(STATM,STATM5) ; Return sorting subscript RESULTS
64 QUIT:$E(STATM5)="X" STATM5
65 Q STATM
66 ;
67ADD50(TAG,TXT) ; Add to ^HLEV(776,+HLEVIENJ,50)...
68 ; HLEVIENJ -- req
69 N POSX
70 ;
71 S TAG=$G(TAG),TXT=$G(TXT)
72 ;
73 ; If TXT passed & TAG not passed...
74 I TXT]"",TAG']"" D QUIT ;->
75 . D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,TXT)
76 ;
77 ; If TXT not passed...
78 I TXT']"" D ;-> Blank line...
79 . ; If TAG not passed...
80 . I TAG']"" D QUIT ;-> Blank line...
81 . . D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,"")
82 . ; If TAG passed...
83 . I TAG]"" D QUIT ;-> Separator line or something
84 . . D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,TAG)
85 ;
86 S TAG=$E($$REPEAT^XLFSTR(" ",40),1,30-$L(TAG))_TAG_": "
87 S POSX=$L(TAG),TXT=TAG_TXT
88 ;
89 F QUIT:TXT']"" D
90 . D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,$E(TXT,1,74))
91 . S TXT=$E(TXT,75,999) QUIT:TXT']"" ;->
92 . S TXT=$$REPEAT^XLFSTR(" ",POSX)_TXT
93 ;
94 Q
95 ;
96IEN7762(STAT) ;
97 N FIEN,IEN,LASTDT
98 S LASTDT=":",FIEN=""
99 F S LASTDT=$O(^HLEV(776.2,"B",LASTDT),-1) Q:'LASTDT!(FIEN) D
100 . S IEN=":"
101 . F S IEN=$O(^HLEV(776.2,"B",+LASTDT,IEN),-1) Q:'IEN!(FIEN) D
102 . . QUIT:$P($G(^HLEV(776.2,+IEN,0)),U,4)'=STAT ;->
103 . . S FIEN=IEN
104 Q FIEN
105 ;
106MONITOR ; Collect monitor information...
107 ; HLEVIENJ -- req
108 N DATA,DATE,EVIEN,EVNM,IEN,IENJ,IOINHI,IOINORM,LASTDT,MIEN
109 N NO,RUNNING,STAT,X
110 ;
111 KILL ^TMP($J,"HLRUN")
112 ;
113 ; Find latest 776.2 master run...
114 S LASTDT=":",NO=0
115 F S LASTDT=$O(^HLEV(776.2,"B",LASTDT),-1) Q:'LASTDT!(NO>3) D
116 . S IEN=""
117 . F S IEN=$O(^HLEV(776.2,"B",+LASTDT,IEN),-1) Q:'IEN!(NO>3) D
118 . . S DATA(776.2)=$G(^HLEV(776.2,+IEN,0)) QUIT:DATA(776.2)']"" ;->
119 . . S STAT=$P(DATA(776.2),U,4),STAT=$S(STAT]"":STAT,1:" ")
120 . . S NO=NO+1
121 . . ; Add events monitored...
122 . . S MIEN=0
123 . . F S MIEN=$O(^HLEV(776.2,+IEN,51,MIEN)) Q:MIEN'>0 D
124 . . . S DATA(51)=$G(^HLEV(776.2,+IEN,51,+MIEN,0)) Q:DATA(51)']"" ;->
125 . . . S EVIEN=+DATA(51)
126 . . . S EVNM=$P($G(^HLEV(776.1,+EVIEN,0)),U) QUIT:EVNM']"" ;->
127 . . . S IENJ=$P(DATA(51),U,8) QUIT:IENJ'>0 ;->
128 . . . S DATA(776)=$G(^HLEV(776,+IENJ,0)) QUIT:DATA(776)']"" ;->
129 . . . S ^TMP($J,"HLRUN","NO",IEN)=DATA(776.2)
130 . . . S ^TMP($J,"HLRUN","NO",IEN,EVNM)=DATA(51)
131 . . . S ^TMP($J,"HLRUN","NO",IEN,EVNM,IENJ)=DATA(776)
132 . . . S ^TMP($J,"HLRUN","NM",EVNM,IEN)="" ; xref...
133 ;
134 QUIT:'$D(^TMP($J,"HLRUN")) ;->
135 ;
136 D ADD50("","Recent Event Runs")
137 D ADD50("",$$REPEAT^XLFSTR("-",74))
138 D ADD50("","Event-Name Run#1 Run#2 Run#3")
139 D ADD50("",$$REPEAT^XLFSTR("-",74))
140 S EVNM="",RUNNING=0
141 F S EVNM=$O(^TMP($J,"HLRUN","NM",EVNM)) Q:EVNM']"" D
142 . S TXT=$E(EVNM_$$REPEAT^XLFSTR(" ",30),1,30)_" "
143 . S EVIEN=0
144 . F S EVIEN=$O(^TMP($J,"HLRUN","NM",EVNM,EVIEN)) Q:EVIEN'>0 D
145 . . S IENJ=0
146 . . F S IENJ=$O(^TMP($J,"HLRUN","NO",+EVIEN,EVNM,IENJ)) Q:'IENJ D
147 . . . S DATA=$G(^TMP($J,"HLRUN","NO",+EVIEN,EVNM,+IENJ)) QUIT:DATA']"" ;->
148 . . . S STAT=$P(DATA,U,5),STAT=$S(STAT="F":1,1:0)
149 . . . S RUNNING=RUNNING+STAT
150 . . . S DATE=+DATA QUIT:DATE'?7N1"."1.N ;->
151 . . . S DATE=$E("[",STAT)_$$SDT(DATE)_$E("]",STAT)
152 . . . S TXT=TXT_$E(DATE_" ",1,15)
153 . D ADD50("",TXT)
154 ;
155 I RUNNING D ADD50(""),ADD50(" (Dates in [brackets] are still running.)")
156 ;
157 KILL ^TMP($J,"HLRUN")
158 ;
159 Q
160 ;
161SDT(DATE) ; Return shortened form of date...
162 I DATE?7N QUIT $E(DATE,4,5)_"/"_$E(DATE,6,7) ;->
163 I DATE?7N1"."1.N QUIT $E(DATE,4,5)_"/"_$E(DATE,6,7)_"@"_$E($P($$FMTE^XLFDT(DATE),"@",2),1,5)
164 QUIT ""
165 ;
166EOR ;HLEVX001 - Event Monitor "Mother" ;5/16/03 14:42
Note: See TracBrowser for help on using the repository browser.