HLEVAPI1 ;O-OIFO/LJA - Event Monitor APIs ;02/04/2004 14:42
;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
;
SYSETUP ; Called by option's entry action...
N DATA,LAST,NEXT,STAT
;
; Make sure master job is current...
D CHECKMST^HLEVMST
;
S DATA=$G(^HLEV(776.999,1,0)),LAST=$$LAST7762,NEXT=$$NEXT7762
;
S STAT=$P(DATA,U,2)
S STAT="-------- Master job status is "_$S(STAT="A":"ACTIVE",STAT="I":"INACTIVE",1:"NOT SET YET")_" --------"
W !!!,$$CJ^XLFSTR(STAT,IOM)
S X=$$LAST7762 I X]"" W !,$$CJ^XLFSTR(X,IOM)
S X=$$NEXT7762 I X]"" W !,$$CJ^XLFSTR(X,IOM)
;
S STAT=$P(DATA,U,6)
W !,$$CJ^XLFSTR("-------- Event monitoring status is "_$S(STAT="A":"ACTIVE",STAT="I":"INACTIVE",1:"NOT SET YET")_" --------",IOM)
;
Q
;
LAST7762() ; Return d/h/m/s since last master job run...
N DATA,FIEN,IEN,LASTDT
;
S LASTDT=":",FIEN=0
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
. . S DATA=$G(^HLEV(776.2,+IEN,0)) QUIT:$P(DATA,U,4)'="F" ;->
. . S FIEN=IEN
;
QUIT:'FIEN "Unknown last master job run time..." ;->
;
QUIT $$DT7762(FIEN,0)
;
NEXT7762() ; Return d/h/m/s till next master job run...
N DATA,FIEN,IEN,LASTDT
;
S LASTDT=":",FIEN=0
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
. . S DATA=$G(^HLEV(776.2,+IEN,0)) QUIT:$P(DATA,U,4)'="Q" ;->
. . S FIEN=IEN
;
QUIT:'FIEN "Unknown next master job run time..." ;->
;
Q $$DT7762(+FIEN,1)
;
DT7762(FIEN,NXT) ; Called by $$LAST7762 & NEXT7762...
N DATA,DATE
S DATA=$G(^HLEV(776.2,+FIEN,0))
S DATE=$P(DATA,U,$S('NXT:2,1:6)) QUIT:DATE'?7N1"."1.N "" ;->
S DATE=$$DHMSFM^HLEVUTIL(DATE,$$NOW^XLFDT,1)
I 'NXT D QUIT DATE ;-> Last...
. I DATE["[" S DATE="Unknown last master job run..." QUIT ;->
. S DATE="Last master job run was "_DATE_" ago..."
I NXT D QUIT DATE ;-> Next...
. I DATE'["[" S DATE="Unknown next master job run..." QUIT ;->
. S DATE="Next run "_$S($P(DATA,U,5):"[task# "_$P(DATA,U,5)_"] ",1:"")_"is "_$P($P(DATE,"[",2),"]")_" in the future..."
Q ""
;
LOADALL(HLEVIENJ,SVSUB) ; Load all sections into global for mailing...
N NO,TXT
S SVSUB=$S($G(SVSUB)]"":SVSUB,1:"HLMAILMSG") ; Save Subscript...
D LOADDESC(HLEVIENJ,SVSUB) ; Short description of monitor.
D LOADCOMP(HLEVIENJ,SVSUB) ; Completed line...
D LOADBODY^HLEVAPI2(HLEVIENJ,SVSUB) ; Start/end/Status/Status-Appl...
S NO=0
F S NO=$O(HLEVTXT(NO)) Q:NO'>0 D
. S TXT=$G(HLEVTXT(NO)) QUIT:TXT']"" ;->
. S TXT=$$UP^XLFSTR($TR(TXT," ",""))
. I TXT="RUNDIARY" D LOADDGBL^HLEVAPI2(HLEVIENJ,50,SVSUB) QUIT ;->
. I TXT="MESSAGETEXT" D LOADDGBL^HLEVAPI2(HLEVIENJ,51,SVSUB) QUIT ;->
. I TXT="VARIABLEVALUE" D LOADVAR(HLEVIENJ,SVSUB) QUIT ;->
. KILL X S X="W "_TXT D ^DIM Q:'$D(X) ;->
. D LOADUSER(TXT,SVSUB)
Q
;
LOADUSER(GBL,SVSUB) ; Load user data into Mailman message...
N NO,TXT
;
QUIT:$O(@GBL@(0))'>0 ;->
;
S NO=0
F S NO=$O(@GBL@(NO)) Q:NO'>0 D
. S TXT=$G(@GBL@(NO))
. F D Q:TXT']""
. . D ADD($E(TXT,1,74))
. . S TXT=$E(TXT,75,999) QUIT:TXT']"" ;->
. . S TXT=" "_TXT
;
Q
;
LOADDESC(HLEVIENJ,SVSUB) ; Load description if it exists...
N DESC,HLEVIENE
S SVSUB=$S($G(SVSUB)]"":SVSUB,1:"HLMAILMSG")
S HLEVIENE=$P($G(^HLEV(776,+HLEVIENJ,0)),U,3)
S DESC=$P($G(^HLEV(776,+$G(HLEVIENE),0)),U,3) QUIT:DESC']"" ;->
; First line...
D ADD("Monitor description: "_DESC)
D ADD("")
Q
;
LOADCOMP(HLEVIENJ,SVSUB) ; Load generic event monitor info into XMTEXT...
N HLEVIENE,HLEVNM
S SVSUB=$S($G(SVSUB)]"":SVSUB,1:"HLMAILMSG")
S HLEVIENE=$P($G(^HLEV(776,+HLEVIENJ,0)),U,3)
S HLEVNM=$P($G(^HLEV(776.1,+HLEVIENE,0)),U)
; First line...
D ADD("The '"_HLEVNM_"' event monitor has completed.")
D ADD("")
Q
;
LOADVAR(HLEVIENJ,SVSUB) ; Load variable names...
N CUT,MIEN,TXT,VAR
;
QUIT:$O(^HLEV(776,+HLEVIENJ,52,0))'>0 ;->
;
D ADD(""),ADD("Variable List"),ADD("-------------")
;
S VAR=""
F S VAR=$O(^HLEV(776,+HLEVIENJ,52,"B",VAR)) Q:VAR']"" D
. S MIEN=0
. F S MIEN=$O(^HLEV(776,+HLEVIENJ,52,"B",VAR,MIEN)) Q:MIEN'>0 D
. . S TXT=$G(^HLEV(776,+HLEVIENJ,52,+MIEN,0)) QUIT:TXT']"" ;->
. . S TXT=$P(TXT,U)_$S($P(TXT,U,2)]"":"["_$P(TXT,U,2)_"]",1:"")_"="
. . S TXT(1)=$G(^HLEV(776,+HLEVIENJ,52,+MIEN,52))
. . I ($L(TXT)+$L(TXT(1)))<240 S TXT=TXT_TXT(1),TXT(1)=""
. . I TXT(1)]"" D
. . . S CUT(1)=$L(TXT),CUT(2)=$L(TXT(1)),CUT=240-CUT(1)
. . . S TXT=TXT_$E(TXT(1),1,CUT),TXT(1)=$E(TXT(1),CUT+1,999)
. . F D QUIT:TXT']""
. . . D ADD($E(TXT,1,74))
. . . S TXT=$E(TXT,75,999) QUIT:TXT']"" ;->
. . . S TXT=" "_TXT
. . . QUIT:TXT(1)']"" ;->
. . .
;
Q
;
ADD(TXT) ; Add TXT to global to be mailed out...
; SVSUB -- req
N NO
S NO=$O(^TMP($J,SVSUB,":"),-1)+1
S ^TMP($J,SVSUB,+NO)=TXT
Q
;
CURR(IEN776) ; Is job running and current?
N DATA,DIFF,STAT,TSTAMP
S DATA=$G(^HLEV(776,+IEN776,0))
S STAT=$P(DATA,U,4) QUIT:STAT'="R" "" ;->
S TSTAMP=$P(DATA,U,6) QUIT:TSTAMP'?7N1"."1.N "" ;->
S TSTAMP=$$FMTH^XLFDT(TSTAMP)
S DIFF=$$DIFFDH^HLCSFMN1(TSTAMP,$H) ; Difference...
I DIFF'?1.N1"^"2N1":"2N1":"2N QUIT "" ;-> DD^HH:MM:SS
I +DIFF>0 QUIT "" ;-> 1 or more days difference!
S DIFF=$P(DIFF,U,2) ; HH:MM:SS now...
; If 1 or more hrs, or >15 minutes old...
I +DIFF!(+$P(DIFF,":",2)>15) QUIT "" ;->
Q 1
;
APPSTAT(STATUS) ; Fill in application status...
; HLEVIENJ -- req
N DA,DIE,DR
;
D DEBUG^HLEVAPI2("VARIABLE") ; Debug data created conditionally
;
; Stop all event monitoring to enable on-site debugging...
QUIT:$G(^TMP("HLEVFLAG",$J))["STOP" ;->
;
QUIT:$G(STATUS)']"" ;->
QUIT:$G(^HLEV(776,+$G(HLEVIENJ),0))']"" ;->
S DA=+HLEVIENJ,DIE=776,DR="5///"_$E(STATUS,1,10)
D ^DIE
Q
;
RUNDIARY(GBL) ; Move GBL data into RUN DIARY...
; HLEVIENJ -- req
;
D DEBUG^HLEVAPI2("VARIABLE") ; Debug data created conditionally
;
; Stop all event monitoring to enable on-site debugging...
QUIT:$G(^TMP("HLEVFLAG",$J))["STOP" ;->
;
D GBLMOVE(+$G(HLEVIENJ),50,$G(GBL))
Q
;
MSGTEXT(GBL) ; Mark event job entry to NOTIFY MAIL GROUP...
; HLEVIENJ -- req
;
D DEBUG^HLEVAPI2("VARIABLE") ; Debug data created conditionally
;
; Stop all event monitoring to enable on-site debugging...
QUIT:$G(^TMP("HLEVFLAG",$J))["STOP" ;->
;
D GBLMOVE(+$G(HLEVIENJ),51,$G(GBL))
Q
;
GBLMOVE(HLEVIENJ,SUB,GBL) ; Move GBL data into entry's WP text...
N CT,NO,NODE
;
S SUB=$G(SUB) QUIT:SUB'=51&(SUB'=52) ;->
QUIT:$G(^HLEV(776,+HLEVIENJ,0))']"" ;->
;
; Add event text...
S NODE="^776.002",NO=0
F S NO=$O(@GBL@(NO)) Q:NO'>0 D
. S CT=$O(^HLEV(776,+HLEVIENJ,SUB,":"),-1)+1
. S ^HLEV(776,+HLEVIENJ,SUB,CT,0)=$G(@GBL@(+NO))
S CT=$O(^HLEV(776,+HLEVIENJ,SUB,":"),-1) QUIT:CT'>0 ;->
S $P(NODE,U,3)=CT,$P(NODE,U,4)=CT
S ^HLEV(776,+HLEVIENJ,SUB,0)=NODE
;
Q
;
ONETIME ;Start a one-time run of event monitor (w/no master job)
N HLEVIENE,QTASK
W @IOF,$$CJ^XLFSTR("One-time Queueing of Event Monitor",IOM)
W !,$$REPEAT^XLFSTR("=",IOM)
W !,"Normally, the master job evaluates every event monitor and queues a background"
W !,"job for those events ready for a new ""run."" This option allows the running"
W !,"of an event monitor between ""normal"" runs."
W !!,"Do you want to start a new ""in-between"" run of a monitor? If so, select"
W !,"it now. If not, press RETURN to exit..."
W !
;
S HLEVIENE=$$ASKIEN^HLEVREP(776.1) I HLEVIENE'>0 D QUIT ;->
. W " exiting..."
;
W !
D ASKRUN(HLEVIENE)
;
Q
;
ASKRUN(HLEVIENE) ; Ask if want to run a one-time...
N DATA,QTASK,QTIME
;
I $P($G(^HLEV(776.1,+$G(HLEVIENE),0)),U,2)'="A" D QUIT ;->
. QUIT:$G(^HLEV(776.1,+$G(HLEVIENE),0))']"" ;->
. D TELL^HLEVMST0("Event monitor is INACTIVE!!","1,2,999")
;
I $$YN^HLCSRPT4("Run monitor now","No") D QUIT ;->
. D QIT($$NOW^XLFDT) W " exiting..."
;
W !!,"You may queue this monitor to run ""one-time"" in the future. If so, enter a"
W !,"future date/time now..."
W !
;
F S QTIME=$$ASKDATE^HLEVAPI2("Enter future run time") D QUIT:QTIME?7N1"."1.N!(QTIME']"")
. QUIT:QTIME'?7N1"."1.N ;->
. I QTIME>$$NOW^XLFDT D QIT(QTIME) QUIT ;->
. S QTIME="REASK"
. W " enter a future time..."
;
Q
;
QIT(QTIME) ; Queue it...
N QTASK
S QTASK=$$Q1TIME^HLEVAPI0(+HLEVIENE,0,QTIME)
I +QTASK>0 W !!," Queued task# ",+QTASK," [#",$P(QTASK,U,2),"]..."
I +QTASK'>0 W !!," Error occurred. No monitor ""run"" started..."
W !
F Q:($Y+3)>IOSL W !
S X=$$BTE^HLCSMON("Press RETURN to exit... ")
Q
;
EOR ;HLEVAPI1 - Event Monitor APIs ;5/16/03 14:42
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLEVAPI1 8813 printed Dec 13, 2024@01:57:42 Page 2
HLEVAPI1 ;O-OIFO/LJA - Event Monitor APIs ;02/04/2004 14:42
+1 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
+2 ;
SYSETUP ; Called by option's entry action...
+1 NEW DATA,LAST,NEXT,STAT
+2 ;
+3 ; Make sure master job is current...
+4 DO CHECKMST^HLEVMST
+5 ;
+6 SET DATA=$GET(^HLEV(776.999,1,0))
SET LAST=$$LAST7762
SET NEXT=$$NEXT7762
+7 ;
+8 SET STAT=$PIECE(DATA,U,2)
+9 SET STAT="-------- Master job status is "_$SELECT(STAT="A":"ACTIVE",STAT="I":"INACTIVE",1:"NOT SET YET")_" --------"
+10 WRITE !!!,$$CJ^XLFSTR(STAT,IOM)
+11 SET X=$$LAST7762
IF X]""
WRITE !,$$CJ^XLFSTR(X,IOM)
+12 SET X=$$NEXT7762
IF X]""
WRITE !,$$CJ^XLFSTR(X,IOM)
+13 ;
+14 SET STAT=$PIECE(DATA,U,6)
+15 WRITE !,$$CJ^XLFSTR("-------- Event monitoring status is "_$SELECT(STAT="A":"ACTIVE",STAT="I":"INACTIVE",1:"NOT SET YET")_" --------",IOM)
+16 ;
+17 QUIT
+18 ;
LAST7762() ; Return d/h/m/s since last master job run...
+1 NEW DATA,FIEN,IEN,LASTDT
+2 ;
+3 SET LASTDT=":"
SET FIEN=0
+4 FOR
SET LASTDT=$ORDER(^HLEV(776.2,"B",LASTDT),-1)
if 'LASTDT!(FIEN)
QUIT
Begin DoDot:1
+5 SET IEN=":"
+6 FOR
SET IEN=$ORDER(^HLEV(776.2,"B",+LASTDT,IEN),-1)
if 'IEN!(FIEN)
QUIT
Begin DoDot:2
+7 ;->
SET DATA=$GET(^HLEV(776.2,+IEN,0))
if $PIECE(DATA,U,4)'="F"
QUIT
+8 SET FIEN=IEN
End DoDot:2
End DoDot:1
+9 ;
+10 ;->
if 'FIEN
QUIT "Unknown last master job run time..."
+11 ;
+12 QUIT $$DT7762(FIEN,0)
+13 ;
NEXT7762() ; Return d/h/m/s till next master job run...
+1 NEW DATA,FIEN,IEN,LASTDT
+2 ;
+3 SET LASTDT=":"
SET FIEN=0
+4 FOR
SET LASTDT=$ORDER(^HLEV(776.2,"B",LASTDT),-1)
if 'LASTDT!(FIEN)
QUIT
Begin DoDot:1
+5 SET IEN=":"
+6 FOR
SET IEN=$ORDER(^HLEV(776.2,"B",+LASTDT,IEN),-1)
if 'IEN!(FIEN)
QUIT
Begin DoDot:2
+7 ;->
SET DATA=$GET(^HLEV(776.2,+IEN,0))
if $PIECE(DATA,U,4)'="Q"
QUIT
+8 SET FIEN=IEN
End DoDot:2
End DoDot:1
+9 ;
+10 ;->
if 'FIEN
QUIT "Unknown next master job run time..."
+11 ;
+12 QUIT $$DT7762(+FIEN,1)
+13 ;
DT7762(FIEN,NXT) ; Called by $$LAST7762 & NEXT7762...
+1 NEW DATA,DATE
+2 SET DATA=$GET(^HLEV(776.2,+FIEN,0))
+3 ;->
SET DATE=$PIECE(DATA,U,$SELECT('NXT:2,1:6))
if DATE'?7N1"."1.N
QUIT ""
+4 SET DATE=$$DHMSFM^HLEVUTIL(DATE,$$NOW^XLFDT,1)
+5 ;-> Last...
IF 'NXT
Begin DoDot:1
+6 ;->
IF DATE["["
SET DATE="Unknown last master job run..."
QUIT
+7 SET DATE="Last master job run was "_DATE_" ago..."
End DoDot:1
QUIT DATE
+8 ;-> Next...
IF NXT
Begin DoDot:1
+9 ;->
IF DATE'["["
SET DATE="Unknown next master job run..."
QUIT
+10 SET DATE="Next run "_$SELECT($PIECE(DATA,U,5):"[task# "_$PIECE(DATA,U,5)_"] ",1:"")_"is "_$PIECE($PIECE(DATE,"[",2),"]")_" in the future..."
End DoDot:1
QUIT DATE
+11 QUIT ""
+12 ;
LOADALL(HLEVIENJ,SVSUB) ; Load all sections into global for mailing...
+1 NEW NO,TXT
+2 ; Save Subscript...
SET SVSUB=$SELECT($GET(SVSUB)]"":SVSUB,1:"HLMAILMSG")
+3 ; Short description of monitor.
DO LOADDESC(HLEVIENJ,SVSUB)
+4 ; Completed line...
DO LOADCOMP(HLEVIENJ,SVSUB)
+5 ; Start/end/Status/Status-Appl...
DO LOADBODY^HLEVAPI2(HLEVIENJ,SVSUB)
+6 SET NO=0
+7 FOR
SET NO=$ORDER(HLEVTXT(NO))
if NO'>0
QUIT
Begin DoDot:1
+8 ;->
SET TXT=$GET(HLEVTXT(NO))
if TXT']""
QUIT
+9 SET TXT=$$UP^XLFSTR($TRANSLATE(TXT," ",""))
+10 ;->
IF TXT="RUNDIARY"
DO LOADDGBL^HLEVAPI2(HLEVIENJ,50,SVSUB)
QUIT
+11 ;->
IF TXT="MESSAGETEXT"
DO LOADDGBL^HLEVAPI2(HLEVIENJ,51,SVSUB)
QUIT
+12 ;->
IF TXT="VARIABLEVALUE"
DO LOADVAR(HLEVIENJ,SVSUB)
QUIT
+13 ;->
KILL X
SET X="W "_TXT
DO ^DIM
if '$DATA(X)
QUIT
+14 DO LOADUSER(TXT,SVSUB)
End DoDot:1
+15 QUIT
+16 ;
LOADUSER(GBL,SVSUB) ; Load user data into Mailman message...
+1 NEW NO,TXT
+2 ;
+3 ;->
if $ORDER(@GBL@(0))'>0
QUIT
+4 ;
+5 SET NO=0
+6 FOR
SET NO=$ORDER(@GBL@(NO))
if NO'>0
QUIT
Begin DoDot:1
+7 SET TXT=$GET(@GBL@(NO))
+8 FOR
Begin DoDot:2
+9 DO ADD($EXTRACT(TXT,1,74))
+10 ;->
SET TXT=$EXTRACT(TXT,75,999)
if TXT']""
QUIT
+11 SET TXT=" "_TXT
End DoDot:2
if TXT']""
QUIT
End DoDot:1
+12 ;
+13 QUIT
+14 ;
LOADDESC(HLEVIENJ,SVSUB) ; Load description if it exists...
+1 NEW DESC,HLEVIENE
+2 SET SVSUB=$SELECT($GET(SVSUB)]"":SVSUB,1:"HLMAILMSG")
+3 SET HLEVIENE=$PIECE($GET(^HLEV(776,+HLEVIENJ,0)),U,3)
+4 ;->
SET DESC=$PIECE($GET(^HLEV(776,+$GET(HLEVIENE),0)),U,3)
if DESC']""
QUIT
+5 ; First line...
+6 DO ADD("Monitor description: "_DESC)
+7 DO ADD("")
+8 QUIT
+9 ;
LOADCOMP(HLEVIENJ,SVSUB) ; Load generic event monitor info into XMTEXT...
+1 NEW HLEVIENE,HLEVNM
+2 SET SVSUB=$SELECT($GET(SVSUB)]"":SVSUB,1:"HLMAILMSG")
+3 SET HLEVIENE=$PIECE($GET(^HLEV(776,+HLEVIENJ,0)),U,3)
+4 SET HLEVNM=$PIECE($GET(^HLEV(776.1,+HLEVIENE,0)),U)
+5 ; First line...
+6 DO ADD("The '"_HLEVNM_"' event monitor has completed.")
+7 DO ADD("")
+8 QUIT
+9 ;
LOADVAR(HLEVIENJ,SVSUB) ; Load variable names...
+1 NEW CUT,MIEN,TXT,VAR
+2 ;
+3 ;->
if $ORDER(^HLEV(776,+HLEVIENJ,52,0))'>0
QUIT
+4 ;
+5 DO ADD("")
DO ADD("Variable List")
DO ADD("-------------")
+6 ;
+7 SET VAR=""
+8 FOR
SET VAR=$ORDER(^HLEV(776,+HLEVIENJ,52,"B",VAR))
if VAR']""
QUIT
Begin DoDot:1
+9 SET MIEN=0
+10 FOR
SET MIEN=$ORDER(^HLEV(776,+HLEVIENJ,52,"B",VAR,MIEN))
if MIEN'>0
QUIT
Begin DoDot:2
+11 ;->
SET TXT=$GET(^HLEV(776,+HLEVIENJ,52,+MIEN,0))
if TXT']""
QUIT
+12 SET TXT=$PIECE(TXT,U)_$SELECT($PIECE(TXT,U,2)]"":"["_$PIECE(TXT,U,2)_"]",1:"")_"="
+13 SET TXT(1)=$GET(^HLEV(776,+HLEVIENJ,52,+MIEN,52))
+14 IF ($LENGTH(TXT)+$LENGTH(TXT(1)))<240
SET TXT=TXT_TXT(1)
SET TXT(1)=""
+15 IF TXT(1)]""
Begin DoDot:3
+16 SET CUT(1)=$LENGTH(TXT)
SET CUT(2)=$LENGTH(TXT(1))
SET CUT=240-CUT(1)
+17 SET TXT=TXT_$EXTRACT(TXT(1),1,CUT)
SET TXT(1)=$EXTRACT(TXT(1),CUT+1,999)
End DoDot:3
+18 FOR
Begin DoDot:3
+19 DO ADD($EXTRACT(TXT,1,74))
+20 ;->
SET TXT=$EXTRACT(TXT,75,999)
if TXT']""
QUIT
+21 SET TXT=" "_TXT
+22 ;->
if TXT(1)']""
QUIT
+23 End DoDot:3
if TXT']""
QUIT
End DoDot:2
End DoDot:1
+24 ;
+25 QUIT
+26 ;
ADD(TXT) ; Add TXT to global to be mailed out...
+1 ; SVSUB -- req
+2 NEW NO
+3 SET NO=$ORDER(^TMP($JOB,SVSUB,":"),-1)+1
+4 SET ^TMP($JOB,SVSUB,+NO)=TXT
+5 QUIT
+6 ;
CURR(IEN776) ; Is job running and current?
+1 NEW DATA,DIFF,STAT,TSTAMP
+2 SET DATA=$GET(^HLEV(776,+IEN776,0))
+3 ;->
SET STAT=$PIECE(DATA,U,4)
if STAT'="R"
QUIT ""
+4 ;->
SET TSTAMP=$PIECE(DATA,U,6)
if TSTAMP'?7N1"."1.N
QUIT ""
+5 SET TSTAMP=$$FMTH^XLFDT(TSTAMP)
+6 ; Difference...
SET DIFF=$$DIFFDH^HLCSFMN1(TSTAMP,$HOROLOG)
+7 ;-> DD^HH:MM:SS
IF DIFF'?1.N1"^"2N1":"2N1":"2N
QUIT ""
+8 ;-> 1 or more days difference!
IF +DIFF>0
QUIT ""
+9 ; HH:MM:SS now...
SET DIFF=$PIECE(DIFF,U,2)
+10 ; If 1 or more hrs, or >15 minutes old...
+11 ;->
IF +DIFF!(+$PIECE(DIFF,":",2)>15)
QUIT ""
+12 QUIT 1
+13 ;
APPSTAT(STATUS) ; Fill in application status...
+1 ; HLEVIENJ -- req
+2 NEW DA,DIE,DR
+3 ;
+4 ; Debug data created conditionally
DO DEBUG^HLEVAPI2("VARIABLE")
+5 ;
+6 ; Stop all event monitoring to enable on-site debugging...
+7 ;->
if $GET(^TMP("HLEVFLAG",$JOB))["STOP"
QUIT
+8 ;
+9 ;->
if $GET(STATUS)']""
QUIT
+10 ;->
if $GET(^HLEV(776,+$GET(HLEVIENJ),0))']""
QUIT
+11 SET DA=+HLEVIENJ
SET DIE=776
SET DR="5///"_$EXTRACT(STATUS,1,10)
+12 DO ^DIE
+13 QUIT
+14 ;
RUNDIARY(GBL) ; Move GBL data into RUN DIARY...
+1 ; HLEVIENJ -- req
+2 ;
+3 ; Debug data created conditionally
DO DEBUG^HLEVAPI2("VARIABLE")
+4 ;
+5 ; Stop all event monitoring to enable on-site debugging...
+6 ;->
if $GET(^TMP("HLEVFLAG",$JOB))["STOP"
QUIT
+7 ;
+8 DO GBLMOVE(+$GET(HLEVIENJ),50,$GET(GBL))
+9 QUIT
+10 ;
MSGTEXT(GBL) ; Mark event job entry to NOTIFY MAIL GROUP...
+1 ; HLEVIENJ -- req
+2 ;
+3 ; Debug data created conditionally
DO DEBUG^HLEVAPI2("VARIABLE")
+4 ;
+5 ; Stop all event monitoring to enable on-site debugging...
+6 ;->
if $GET(^TMP("HLEVFLAG",$JOB))["STOP"
QUIT
+7 ;
+8 DO GBLMOVE(+$GET(HLEVIENJ),51,$GET(GBL))
+9 QUIT
+10 ;
GBLMOVE(HLEVIENJ,SUB,GBL) ; Move GBL data into entry's WP text...
+1 NEW CT,NO,NODE
+2 ;
+3 ;->
SET SUB=$GET(SUB)
if SUB'=51&(SUB'=52)
QUIT
+4 ;->
if $GET(^HLEV(776,+HLEVIENJ,0))']""
QUIT
+5 ;
+6 ; Add event text...
+7 SET NODE="^776.002"
SET NO=0
+8 FOR
SET NO=$ORDER(@GBL@(NO))
if NO'>0
QUIT
Begin DoDot:1
+9 SET CT=$ORDER(^HLEV(776,+HLEVIENJ,SUB,":"),-1)+1
+10 SET ^HLEV(776,+HLEVIENJ,SUB,CT,0)=$GET(@GBL@(+NO))
End DoDot:1
+11 ;->
SET CT=$ORDER(^HLEV(776,+HLEVIENJ,SUB,":"),-1)
if CT'>0
QUIT
+12 SET $PIECE(NODE,U,3)=CT
SET $PIECE(NODE,U,4)=CT
+13 SET ^HLEV(776,+HLEVIENJ,SUB,0)=NODE
+14 ;
+15 QUIT
+16 ;
ONETIME ;Start a one-time run of event monitor (w/no master job)
+1 NEW HLEVIENE,QTASK
+2 WRITE @IOF,$$CJ^XLFSTR("One-time Queueing of Event Monitor",IOM)
+3 WRITE !,$$REPEAT^XLFSTR("=",IOM)
+4 WRITE !,"Normally, the master job evaluates every event monitor and queues a background"
+5 WRITE !,"job for those events ready for a new ""run."" This option allows the running"
+6 WRITE !,"of an event monitor between ""normal"" runs."
+7 WRITE !!,"Do you want to start a new ""in-between"" run of a monitor? If so, select"
+8 WRITE !,"it now. If not, press RETURN to exit..."
+9 WRITE !
+10 ;
+11 ;->
SET HLEVIENE=$$ASKIEN^HLEVREP(776.1)
IF HLEVIENE'>0
Begin DoDot:1
+12 WRITE " exiting..."
End DoDot:1
QUIT
+13 ;
+14 WRITE !
+15 DO ASKRUN(HLEVIENE)
+16 ;
+17 QUIT
+18 ;
ASKRUN(HLEVIENE) ; Ask if want to run a one-time...
+1 NEW DATA,QTASK,QTIME
+2 ;
+3 ;->
IF $PIECE($GET(^HLEV(776.1,+$GET(HLEVIENE),0)),U,2)'="A"
Begin DoDot:1
+4 ;->
if $GET(^HLEV(776.1,+$GET(HLEVIENE),0))']""
QUIT
+5 DO TELL^HLEVMST0("Event monitor is INACTIVE!!","1,2,999")
End DoDot:1
QUIT
+6 ;
+7 ;->
IF $$YN^HLCSRPT4("Run monitor now","No")
Begin DoDot:1
+8 DO QIT($$NOW^XLFDT)
WRITE " exiting..."
End DoDot:1
QUIT
+9 ;
+10 WRITE !!,"You may queue this monitor to run ""one-time"" in the future. If so, enter a"
+11 WRITE !,"future date/time now..."
+12 WRITE !
+13 ;
+14 FOR
SET QTIME=$$ASKDATE^HLEVAPI2("Enter future run time")
Begin DoDot:1
+15 ;->
if QTIME'?7N1"."1.N
QUIT
+16 ;->
IF QTIME>$$NOW^XLFDT
DO QIT(QTIME)
QUIT
+17 SET QTIME="REASK"
+18 WRITE " enter a future time..."
End DoDot:1
if QTIME?7N1"."1.N!(QTIME']"")
QUIT
+19 ;
+20 QUIT
+21 ;
QIT(QTIME) ; Queue it...
+1 NEW QTASK
+2 SET QTASK=$$Q1TIME^HLEVAPI0(+HLEVIENE,0,QTIME)
+3 IF +QTASK>0
WRITE !!," Queued task# ",+QTASK," [#",$PIECE(QTASK,U,2),"]..."
+4 IF +QTASK'>0
WRITE !!," Error occurred. No monitor ""run"" started..."
+5 WRITE !
+6 FOR
if ($Y+3)>IOSL
QUIT
WRITE !
+7 SET X=$$BTE^HLCSMON("Press RETURN to exit... ")
+8 QUIT
+9 ;
EOR ;HLEVAPI1 - Event Monitor APIs ;5/16/03 14:42