HLEVX001 ;O-OIFO/LJA - Event Monitor "Mother" ;02/04/2004 14:42
;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
;
MOTHER ; The "Mother of All" monitors! (Monitors the Event Monitor)
;HLEVIENE,HLEVIENJ,HLEVIENM -- req
D START^HLEVAPI()
D MASTER
D MONITOR
D CHECKOUT^HLEVAPI
Q
;
MASTER ; Collect master job information...
D LASTNEXT
D MSTRUNS
Q
;
MSTRUNS ; Show master runs and status counts...
N CT,CTM,STAT,STATM
KILL ^TMP($J,"SV")
D RUNS("SV")
D ADD50("")
D ADD50("# job runs last 24 hours",$G(^TMP($J,"SV")))
D ADD50(" "_$$REPEAT^XLFSTR("-",40))
S STAT=""
F S STAT=$O(^TMP($J,"SV",STAT)) Q:STAT']"" D
. S CT=^TMP($J,"SV",STAT)
. D ADD50("#"_$$STAT2(STAT),CT)
Q
;
STAT2(STAT) ; Return status for 776.2 0;4...
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)
;
STAT2M(STAT) ; REturn status for 776.2051 0;2 & 0;6...
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)
;
LASTNEXT ; Show last completed run and next queued run...
N IENLAST,IENNEXT
S IENLAST=+$$IEN7762("F"),NODE(+IENLAST)=$G(^HLEV(776.2,+IENLAST,0))
S IENNEXT=+$$IEN7762("Q"),NODE(+IENNEXT)=$G(^HLEV(776.2,+IENNEXT,0))
D ADD50("Last master job run",$$FMTE^XLFDT(+NODE(+IENLAST)))
D ADD50("Next master job at",$$FMTE^XLFDT(+NODE(+IENNEXT))_" Task#: "_$P(NODE(+IENNEXT),U,5))
Q
;
RUNS(SUB) ; Find number runs and results...
N ABORT,CUT,DATA,IEN,IENM,LASTDT,RES,STAT,STATM,STATM5
S CUT=$$FMADD^XLFDT($$NOW^XLFDT,-1),ABORT=0
S LASTDT=":"
F S LASTDT=$O(^HLEV(776.2,"B",LASTDT),-1) Q:'LASTDT!(LASTDT<CUT)!(ABORT) D
. S IEN=":"
. F S IEN=$O(^HLEV(776.2,"B",LASTDT,IEN),-1) Q:'IEN!(ABORT) D
. . S DATA=$G(^HLEV(776.2,+IEN,0))
. . S STAT=$P(DATA,U,4),STAT=$S(STAT]"":STAT,1:"?")
. . S ^TMP($J,SUB)=$G(^TMP($J,SUB))+1
. . S ^TMP($J,SUB,STAT)=$G(^TMP($J,SUB,STAT))+1
. . S IENM=0
. . F S IENM=$O(^HLEV(776.2,+IEN,51,IENM)) Q:IENM'>0 D
. . . S DATA=^HLEV(776.2,+IEN,51,+IENM,0)
. . . S STATM=$P(DATA,U,2),STATM=$S(STATM]"":STATM,1:"?")
. . . S STATM5=$P(DATA,U,5),STATM=$$STATM5(STATM,STATM5)
. . . S ^TMP($J,SUB,STAT,STATM)=$G(^TMP($J,SUB,STAT,STATM))+1
Q
;
STATM5(STATM,STATM5) ; Return sorting subscript RESULTS
QUIT:$E(STATM5)="X" STATM5
Q STATM
;
ADD50(TAG,TXT) ; Add to ^HLEV(776,+HLEVIENJ,50)...
; HLEVIENJ -- req
N POSX
;
S TAG=$G(TAG),TXT=$G(TXT)
;
; If TXT passed & TAG not passed...
I TXT]"",TAG']"" D QUIT ;->
. D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,TXT)
;
; If TXT not passed...
I TXT']"" D ;-> Blank line...
. ; If TAG not passed...
. I TAG']"" D QUIT ;-> Blank line...
. . D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,"")
. ; If TAG passed...
. I TAG]"" D QUIT ;-> Separator line or something
. . D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,TAG)
;
S TAG=$E($$REPEAT^XLFSTR(" ",40),1,30-$L(TAG))_TAG_": "
S POSX=$L(TAG),TXT=TAG_TXT
;
F QUIT:TXT']"" D
. D WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,$E(TXT,1,74))
. S TXT=$E(TXT,75,999) QUIT:TXT']"" ;->
. S TXT=$$REPEAT^XLFSTR(" ",POSX)_TXT
;
Q
;
IEN7762(STAT) ;
N FIEN,IEN,LASTDT
S LASTDT=":",FIEN=""
F S LASTDT=$O(^HLEV(776.2,"B",LASTDT),-1) Q:'LASTDT!(FIEN) D
. S IEN=":"
. F S IEN=$O(^HLEV(776.2,"B",+LASTDT,IEN),-1) Q:'IEN!(FIEN) D
. . QUIT:$P($G(^HLEV(776.2,+IEN,0)),U,4)'=STAT ;->
. . S FIEN=IEN
Q FIEN
;
MONITOR ; Collect monitor information...
; HLEVIENJ -- req
N DATA,DATE,EVIEN,EVNM,IEN,IENJ,IOINHI,IOINORM,LASTDT,MIEN
N NO,RUNNING,STAT,X
;
KILL ^TMP($J,"HLRUN")
;
; Find latest 776.2 master run...
S LASTDT=":",NO=0
F S LASTDT=$O(^HLEV(776.2,"B",LASTDT),-1) Q:'LASTDT!(NO>3) D
. S IEN=""
. F S IEN=$O(^HLEV(776.2,"B",+LASTDT,IEN),-1) Q:'IEN!(NO>3) D
. . S DATA(776.2)=$G(^HLEV(776.2,+IEN,0)) QUIT:DATA(776.2)']"" ;->
. . S STAT=$P(DATA(776.2),U,4),STAT=$S(STAT]"":STAT,1:" ")
. . S NO=NO+1
. . ; Add events monitored...
. . S MIEN=0
. . F S MIEN=$O(^HLEV(776.2,+IEN,51,MIEN)) Q:MIEN'>0 D
. . . S DATA(51)=$G(^HLEV(776.2,+IEN,51,+MIEN,0)) Q:DATA(51)']"" ;->
. . . S EVIEN=+DATA(51)
. . . S EVNM=$P($G(^HLEV(776.1,+EVIEN,0)),U) QUIT:EVNM']"" ;->
. . . S IENJ=$P(DATA(51),U,8) QUIT:IENJ'>0 ;->
. . . S DATA(776)=$G(^HLEV(776,+IENJ,0)) QUIT:DATA(776)']"" ;->
. . . S ^TMP($J,"HLRUN","NO",IEN)=DATA(776.2)
. . . S ^TMP($J,"HLRUN","NO",IEN,EVNM)=DATA(51)
. . . S ^TMP($J,"HLRUN","NO",IEN,EVNM,IENJ)=DATA(776)
. . . S ^TMP($J,"HLRUN","NM",EVNM,IEN)="" ; xref...
;
QUIT:'$D(^TMP($J,"HLRUN")) ;->
;
D ADD50("","Recent Event Runs")
D ADD50("",$$REPEAT^XLFSTR("-",74))
D ADD50("","Event-Name Run#1 Run#2 Run#3")
D ADD50("",$$REPEAT^XLFSTR("-",74))
S EVNM="",RUNNING=0
F S EVNM=$O(^TMP($J,"HLRUN","NM",EVNM)) Q:EVNM']"" D
. S TXT=$E(EVNM_$$REPEAT^XLFSTR(" ",30),1,30)_" "
. S EVIEN=0
. F S EVIEN=$O(^TMP($J,"HLRUN","NM",EVNM,EVIEN)) Q:EVIEN'>0 D
. . S IENJ=0
. . F S IENJ=$O(^TMP($J,"HLRUN","NO",+EVIEN,EVNM,IENJ)) Q:'IENJ D
. . . S DATA=$G(^TMP($J,"HLRUN","NO",+EVIEN,EVNM,+IENJ)) QUIT:DATA']"" ;->
. . . S STAT=$P(DATA,U,5),STAT=$S(STAT="F":1,1:0)
. . . S RUNNING=RUNNING+STAT
. . . S DATE=+DATA QUIT:DATE'?7N1"."1.N ;->
. . . S DATE=$E("[",STAT)_$$SDT(DATE)_$E("]",STAT)
. . . S TXT=TXT_$E(DATE_" ",1,15)
. D ADD50("",TXT)
;
I RUNNING D ADD50(""),ADD50(" (Dates in [brackets] are still running.)")
;
KILL ^TMP($J,"HLRUN")
;
Q
;
SDT(DATE) ; Return shortened form of date...
I DATE?7N QUIT $E(DATE,4,5)_"/"_$E(DATE,6,7) ;->
I DATE?7N1"."1.N QUIT $E(DATE,4,5)_"/"_$E(DATE,6,7)_"@"_$E($P($$FMTE^XLFDT(DATE),"@",2),1,5)
QUIT ""
;
EOR ;HLEVX001 - Event Monitor "Mother" ;5/16/03 14:42
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLEVX001 6035 printed Dec 13, 2024@01:58:06 Page 2
HLEVX001 ;O-OIFO/LJA - Event Monitor "Mother" ;02/04/2004 14:42
+1 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
+2 ;
MOTHER ; The "Mother of All" monitors! (Monitors the Event Monitor)
+1 ;HLEVIENE,HLEVIENJ,HLEVIENM -- req
+2 DO START^HLEVAPI()
+3 DO MASTER
+4 DO MONITOR
+5 DO CHECKOUT^HLEVAPI
+6 QUIT
+7 ;
MASTER ; Collect master job information...
+1 DO LASTNEXT
+2 DO MSTRUNS
+3 QUIT
+4 ;
MSTRUNS ; Show master runs and status counts...
+1 NEW CT,CTM,STAT,STATM
+2 KILL ^TMP($JOB,"SV")
+3 DO RUNS("SV")
+4 DO ADD50("")
+5 DO ADD50("# job runs last 24 hours",$GET(^TMP($JOB,"SV")))
+6 DO ADD50(" "_$$REPEAT^XLFSTR("-",40))
+7 SET STAT=""
+8 FOR
SET STAT=$ORDER(^TMP($JOB,"SV",STAT))
if STAT']""
QUIT
Begin DoDot:1
+9 SET CT=^TMP($JOB,"SV",STAT)
+10 DO ADD50("#"_$$STAT2(STAT),CT)
End DoDot:1
+11 QUIT
+12 ;
STAT2(STAT) ; Return status for 776.2 0;4...
+1 QUIT $SELECT(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)
+2 ;
STAT2M(STAT) ; REturn status for 776.2051 0;2 & 0;6...
+1 QUIT $SELECT(STAT="E":"TOO EARLY",STAT="I":"INACTIVE",STAT="M":"M-CHK-FAIL",STAT="Q":"QUEUED",STAT="R":"RUNNING",STAT="XM":"M CODE",$EXTRACT(STAT)="X":"ERROR",1:STAT)
+2 ;
LASTNEXT ; Show last completed run and next queued run...
+1 NEW IENLAST,IENNEXT
+2 SET IENLAST=+$$IEN7762("F")
SET NODE(+IENLAST)=$GET(^HLEV(776.2,+IENLAST,0))
+3 SET IENNEXT=+$$IEN7762("Q")
SET NODE(+IENNEXT)=$GET(^HLEV(776.2,+IENNEXT,0))
+4 DO ADD50("Last master job run",$$FMTE^XLFDT(+NODE(+IENLAST)))
+5 DO ADD50("Next master job at",$$FMTE^XLFDT(+NODE(+IENNEXT))_" Task#: "_$PIECE(NODE(+IENNEXT),U,5))
+6 QUIT
+7 ;
RUNS(SUB) ; Find number runs and results...
+1 NEW ABORT,CUT,DATA,IEN,IENM,LASTDT,RES,STAT,STATM,STATM5
+2 SET CUT=$$FMADD^XLFDT($$NOW^XLFDT,-1)
SET ABORT=0
+3 SET LASTDT=":"
+4 FOR
SET LASTDT=$ORDER(^HLEV(776.2,"B",LASTDT),-1)
if 'LASTDT!(LASTDT<CUT)!(ABORT)
QUIT
Begin DoDot:1
+5 SET IEN=":"
+6 FOR
SET IEN=$ORDER(^HLEV(776.2,"B",LASTDT,IEN),-1)
if 'IEN!(ABORT)
QUIT
Begin DoDot:2
+7 SET DATA=$GET(^HLEV(776.2,+IEN,0))
+8 SET STAT=$PIECE(DATA,U,4)
SET STAT=$SELECT(STAT]"":STAT,1:"?")
+9 SET ^TMP($JOB,SUB)=$GET(^TMP($JOB,SUB))+1
+10 SET ^TMP($JOB,SUB,STAT)=$GET(^TMP($JOB,SUB,STAT))+1
+11 SET IENM=0
+12 FOR
SET IENM=$ORDER(^HLEV(776.2,+IEN,51,IENM))
if IENM'>0
QUIT
Begin DoDot:3
+13 SET DATA=^HLEV(776.2,+IEN,51,+IENM,0)
+14 SET STATM=$PIECE(DATA,U,2)
SET STATM=$SELECT(STATM]"":STATM,1:"?")
+15 SET STATM5=$PIECE(DATA,U,5)
SET STATM=$$STATM5(STATM,STATM5)
+16 SET ^TMP($JOB,SUB,STAT,STATM)=$GET(^TMP($JOB,SUB,STAT,STATM))+1
End DoDot:3
End DoDot:2
End DoDot:1
+17 QUIT
+18 ;
STATM5(STATM,STATM5) ; Return sorting subscript RESULTS
+1 if $EXTRACT(STATM5)="X"
QUIT STATM5
+2 QUIT STATM
+3 ;
ADD50(TAG,TXT) ; Add to ^HLEV(776,+HLEVIENJ,50)...
+1 ; HLEVIENJ -- req
+2 NEW POSX
+3 ;
+4 SET TAG=$GET(TAG)
SET TXT=$GET(TXT)
+5 ;
+6 ; If TXT passed & TAG not passed...
+7 ;->
IF TXT]""
IF TAG']""
Begin DoDot:1
+8 DO WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,TXT)
End DoDot:1
QUIT
+9 ;
+10 ; If TXT not passed...
+11 ;-> Blank line...
IF TXT']""
Begin DoDot:1
+12 ; If TAG not passed...
+13 ;-> Blank line...
IF TAG']""
Begin DoDot:2
+14 DO WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,"")
End DoDot:2
QUIT
+15 ; If TAG passed...
+16 ;-> Separator line or something
IF TAG]""
Begin DoDot:2
+17 DO WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,TAG)
End DoDot:2
QUIT
End DoDot:1
+18 ;
+19 SET TAG=$EXTRACT($$REPEAT^XLFSTR(" ",40),1,30-$LENGTH(TAG))_TAG_": "
+20 SET POSX=$LENGTH(TAG)
SET TXT=TAG_TXT
+21 ;
+22 FOR
if TXT']""
QUIT
Begin DoDot:1
+23 DO WPTXT^HLEVUTIL(776,+HLEVIENJ,50,776.002,$EXTRACT(TXT,1,74))
+24 ;->
SET TXT=$EXTRACT(TXT,75,999)
if TXT']""
QUIT
+25 SET TXT=$$REPEAT^XLFSTR(" ",POSX)_TXT
End DoDot:1
+26 ;
+27 QUIT
+28 ;
IEN7762(STAT) ;
+1 NEW FIEN,IEN,LASTDT
+2 SET LASTDT=":"
SET FIEN=""
+3 FOR
SET LASTDT=$ORDER(^HLEV(776.2,"B",LASTDT),-1)
if 'LASTDT!(FIEN)
QUIT
Begin DoDot:1
+4 SET IEN=":"
+5 FOR
SET IEN=$ORDER(^HLEV(776.2,"B",+LASTDT,IEN),-1)
if 'IEN!(FIEN)
QUIT
Begin DoDot:2
+6 ;->
if $PIECE($GET(^HLEV(776.2,+IEN,0)),U,4)'=STAT
QUIT
+7 SET FIEN=IEN
End DoDot:2
End DoDot:1
+8 QUIT FIEN
+9 ;
MONITOR ; Collect monitor information...
+1 ; HLEVIENJ -- req
+2 NEW DATA,DATE,EVIEN,EVNM,IEN,IENJ,IOINHI,IOINORM,LASTDT,MIEN
+3 NEW NO,RUNNING,STAT,X
+4 ;
+5 KILL ^TMP($JOB,"HLRUN")
+6 ;
+7 ; Find latest 776.2 master run...
+8 SET LASTDT=":"
SET NO=0
+9 FOR
SET LASTDT=$ORDER(^HLEV(776.2,"B",LASTDT),-1)
if 'LASTDT!(NO>3)
QUIT
Begin DoDot:1
+10 SET IEN=""
+11 FOR
SET IEN=$ORDER(^HLEV(776.2,"B",+LASTDT,IEN),-1)
if 'IEN!(NO>3)
QUIT
Begin DoDot:2
+12 ;->
SET DATA(776.2)=$GET(^HLEV(776.2,+IEN,0))
if DATA(776.2)']""
QUIT
+13 SET STAT=$PIECE(DATA(776.2),U,4)
SET STAT=$SELECT(STAT]"":STAT,1:" ")
+14 SET NO=NO+1
+15 ; Add events monitored...
+16 SET MIEN=0
+17 FOR
SET MIEN=$ORDER(^HLEV(776.2,+IEN,51,MIEN))
if MIEN'>0
QUIT
Begin DoDot:3
+18 ;->
SET DATA(51)=$GET(^HLEV(776.2,+IEN,51,+MIEN,0))
if DATA(51)']""
QUIT
+19 SET EVIEN=+DATA(51)
+20 ;->
SET EVNM=$PIECE($GET(^HLEV(776.1,+EVIEN,0)),U)
if EVNM']""
QUIT
+21 ;->
SET IENJ=$PIECE(DATA(51),U,8)
if IENJ'>0
QUIT
+22 ;->
SET DATA(776)=$GET(^HLEV(776,+IENJ,0))
if DATA(776)']""
QUIT
+23 SET ^TMP($JOB,"HLRUN","NO",IEN)=DATA(776.2)
+24 SET ^TMP($JOB,"HLRUN","NO",IEN,EVNM)=DATA(51)
+25 SET ^TMP($JOB,"HLRUN","NO",IEN,EVNM,IENJ)=DATA(776)
+26 ; xref...
SET ^TMP($JOB,"HLRUN","NM",EVNM,IEN)=""
End DoDot:3
End DoDot:2
End DoDot:1
+27 ;
+28 ;->
if '$DATA(^TMP($JOB,"HLRUN"))
QUIT
+29 ;
+30 DO ADD50("","Recent Event Runs")
+31 DO ADD50("",$$REPEAT^XLFSTR("-",74))
+32 DO ADD50("","Event-Name Run#1 Run#2 Run#3")
+33 DO ADD50("",$$REPEAT^XLFSTR("-",74))
+34 SET EVNM=""
SET RUNNING=0
+35 FOR
SET EVNM=$ORDER(^TMP($JOB,"HLRUN","NM",EVNM))
if EVNM']""
QUIT
Begin DoDot:1
+36 SET TXT=$EXTRACT(EVNM_$$REPEAT^XLFSTR(" ",30),1,30)_" "
+37 SET EVIEN=0
+38 FOR
SET EVIEN=$ORDER(^TMP($JOB,"HLRUN","NM",EVNM,EVIEN))
if EVIEN'>0
QUIT
Begin DoDot:2
+39 SET IENJ=0
+40 FOR
SET IENJ=$ORDER(^TMP($JOB,"HLRUN","NO",+EVIEN,EVNM,IENJ))
if 'IENJ
QUIT
Begin DoDot:3
+41 ;->
SET DATA=$GET(^TMP($JOB,"HLRUN","NO",+EVIEN,EVNM,+IENJ))
if DATA']""
QUIT
+42 SET STAT=$PIECE(DATA,U,5)
SET STAT=$SELECT(STAT="F":1,1:0)
+43 SET RUNNING=RUNNING+STAT
+44 ;->
SET DATE=+DATA
if DATE'?7N1"."1.N
QUIT
+45 SET DATE=$EXTRACT("[",STAT)_$$SDT(DATE)_$EXTRACT("]",STAT)
+46 SET TXT=TXT_$EXTRACT(DATE_" ",1,15)
End DoDot:3
End DoDot:2
+47 DO ADD50("",TXT)
End DoDot:1
+48 ;
+49 IF RUNNING
DO ADD50("")
DO ADD50(" (Dates in [brackets] are still running.)")
+50 ;
+51 KILL ^TMP($JOB,"HLRUN")
+52 ;
+53 QUIT
+54 ;
SDT(DATE) ; Return shortened form of date...
+1 ;->
IF DATE?7N
QUIT $EXTRACT(DATE,4,5)_"/"_$EXTRACT(DATE,6,7)
+2 IF DATE?7N1"."1.N
QUIT $EXTRACT(DATE,4,5)_"/"_$EXTRACT(DATE,6,7)_"@"_$EXTRACT($PIECE($$FMTE^XLFDT(DATE),"@",2),1,5)
+3 QUIT ""
+4 ;
EOR ;HLEVX001 - Event Monitor "Mother" ;5/16/03 14:42