HLEVAPI0 ;O-OIFO/LJA - Event Monitor APIs ;02/04/2004 14:42
;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
;
ONOFFM(HLEVIENE,STATUS) ;Turn on/off event monitor...
D DEBUG^HLEVAPI2("ONOFFM") ; Debug data created conditionally
;
; Stop all event monitoring to enable on-site debugging...
QUIT:$G(^TMP("HLEVFLAG",$J))["STOP" ;->
;
QUIT $$ONOFF(776.1,+HLEVIENE,STATUS)
;
ONOFFS(HLEVIEN,STATUS) ; Turn on/off system...
QUIT $$ONOFF(776.999,+HLEVIEN,STATUS)
;
ONOFF(FILE,HLEVIENE,STATUS) ; Turn on/off event monitor or system...
; FILE can = 776.1 or 776.999
; Actually, HLEVIENE can be the IEN of the monitor, or the system.
; If STATUS="A", sets status to ACTIVE.
; If STATUS="I", sets status to INACTIVE.
; If STATUS=null or undefined (not passed), present status returned...
;
N DA,DATA,DIE,DR,STAT,X,Y
;
; Find entry and IEN and zero node data...
S FILE=+$G(FILE) I FILE'=776.1&(FILE'=776.999) QUIT "^Invalid file number" ;->
S HLEVIENE=$G(HLEVIENE)
S:FILE=776.999 HLEVIENE=1 ; Just overwrite anything passed by user...
I $L($G(STATUS))>1 QUIT "^Invalid STATUS passed" ;->
S STATUS=$$UP^XLFSTR($E($G(STATUS)_" "))
I " AI"'[STATUS QUIT "^Invalid STATUS passed" ;->
;
; If they passed the name of the entry...
I HLEVIENE'=+HLEVIENE D QUIT:HLEVIENE'>0 "^Couldn't find entry" ;->
. I $TR(HLEVIENE," ","")']"" QUIT ;->
. S HLEVIENE(1)=$O(^HLEV(FILE,"B",HLEVIENE,0)) ; Must have passed in name
. I HLEVIENE(1)'>0 D
. . S HLEVIENE(1)=$O(^HLEV(FILE,"B",$$UP^XLFSTR(HLEVIENE),0))
. S HLEVIENE=HLEVIENE(1)
;
; Get zero node...
S DATA=$G(^HLEV(FILE,+HLEVIENE,0)) QUIT:DATA']"" "^Couldn't find entry" ;->
;
; Get current status...
S STAT=$E($P(DATA,U,2)_" ")
;
; If current status not yet entered in field...
I " AI"'[STAT D QUIT STAT ;->
. ; Passed-in STATUS not A or I, so just tell them value of status...
. I "AI"'[STATUS S STAT="^Status not entered yet" QUIT ;->
. ; User passed in a value to set the status to, so set it for them...
. S DA=+HLEVIENE,DIE=FILE,DR="2///"_STATUS
. D ^DIE
. S STAT=STATUS
;
; If all they want is the status...
I STATUS=" " QUIT STAT ;->
;
; Status entered in field before call...
;
; If passed-in status is the same as the current status in entry...
I STAT=STATUS QUIT STATUS ;-> Already set...
;
; Change status of field to passed-in value...
S DA=+HLEVIENE,DIE=FILE,DR="2///"_STATUS
D ^DIE
;
Q STATUS
;
ONOFFEV ; Turn on/off event monitor
N CHG
;
N DATA,DIC,IEN,IENR
D HDR^HLEVREP("Turn on/off Event Monitors")
;
S7761 KILL DATA,DIC,IEN,IENR
W !
S IEN=$$ASKIEN^HLEVREP(776.1) QUIT:IEN'>0 ;->
D HDR^HLEVREP("Turn on/off Event Monitors",IEN)
D VIEW7761(+IEN)
D RUNS7761^HLEVREP(+IEN)
I $D(^TMP($J,"HLRUNS")) D
. W !!,"Recent Checks of the Monitor by Master Job"
. W !,$$REPEAT^XLFSTR("-",IOM)
. W !,"Check-time",?18,"Results"
. W !,$$REPEAT^XLFSTR("-",IOM)
. S IENR=0
. F S IENR=$O(^TMP($J,"HLRUNS",IENR)) Q:IENR'>0 D
. . S DATA=$G(^TMP($J,"HLRUNS",IENR)) QUIT:DATA']"" ;->
. . W !,$$SDT^HLEVX001($P(DATA,U,2)),?18,$$STAT2M^HLEVX001($P(DATA,U))
W !
S CHG=$$ACTINACT(776.1,+IEN,2,"Event monitor status")
I CHG D
. D HDR^HLEVREP("Turn on/off Event Monitors",IEN)
. D VIEW7761(+IEN)
F Q:(IOSL-$Y)<4 W !
;S X=$$BTE^HLCSMON("Press RETURN to continue... ")
G S7761 ;->
;
VIEW7761(IEN) ; Actual display code for entry...
N NODE,P1,P2,P3,P4,P5,P6,PAR,PCE
;
S NODE=$G(^HLEV(776.1,+IEN,0))
F PCE=1:1:6 S @("P"_PCE)=$P(NODE,U,PCE)
;
; Store under field number...
F PCE=1:1:8 S PAR(PCE)=$P($G(^HLEV(776.1,+IEN,40)),U,PCE)
;
D SH7761("Description",$S(P3]"":P3,1:"---"))
D SH7761("Status",$S(P2="A":"ACTIVE",1:"INACTIVE"))
D SH7761("Requeue minutes",$S(P4:P4_"min",P4=0:"0 [Immediate Run]",1:"---"))
D SH7761("Notification mail group",$S(P5:$P($G(^XMB(3.8,+P5,0)),U),1:"---"))
D SH7761("M startup",$S(P6]"":P6,1:"---"))
W !,$$CJ^XLFSTR(" Parameter ""Variable"" Descriptors ",IOM,"-")
F PCE=1:1:8 I PAR(PCE)]"" D
. W !,?25,"Parameter - "_PCE_" = ",PAR(PCE)
;
Q
;
SH7761(TAG,VAL) ;
W !,?(35-$L(TAG)-2),TAG,":",?45,VAL
Q
;
ONOFFPAR ; Turn on/off parameters...
N CHG
;
D VIEW7769^HLEVREP(0)
;
W !
;
S CHG=0
S X=$$ACTINACT(776.999,1,2,"STATUS-MASTER JOB") I X=1 S CHG=1
S X=$$ACTINACT(776.999,1,6,"STATUS-EVENT MONITORING") I X=1 S CHG=1
;
I CHG D VIEW7769^HLEVREP(0)
;
W !
F Q:(IOSL-$Y)<3 W !
S X=$$BTE^HLCSMON("Press RETURN to exit... ")
;
Q
;
ACTINACT(FILE,IEN,FLD,TAG) ; Turn on/off status fields...
N DA,DIE,DR,STAT,X,Y
S STAT=$P($G(^HLEV(FILE,IEN,0)),U,+FLD)
S X=$$YN^HLCSRPT4("Change '"_TAG_"' to "_$S(STAT="A":"INACTIVE",1:"ACTIVE"),"No") I X'=1 D QUIT "" ;->
. W " ... nothing changed ..."
S DA=IEN,DIE=FILE,DR=FLD_"///"_$S(STAT="A":"I",1:"A")
D ^DIE
W " changed!"
Q 1
;
EVENTCHK(HLEVIENM) ; Loop thru all MONITORs...
; NOEVCHK,ZTSKMST -- req
N HLEVIENE,HLEVNM
;
; Check STATUS-EVENT...
S NO=$O(^HLEV(776.999,":"),-1) QUIT:$P($G(^HLEV(776.999,+NO,0)),U,6)'="A" ;->
;
S HLEVNM=0
F S HLEVNM=$O(^HLEV(776.1,"B",HLEVNM)) Q:HLEVNM']"" D
. S HLEVIENE=0
. F S HLEVIENE=$O(^HLEV(776.1,"B",HLEVNM,HLEVIENE)) Q:'HLEVIENE D
. . D EVENTONE^HLEVAPI3(HLEVIENM,HLEVNM,HLEVIENE)
. . S NOEVCHK=$G(NOEVCHK)+1
;
Q
;
EVRES(HLEVIENM,HLEVIENE,RES,HLEVIENJ) ; Record result of queued task...
; ZTSK -- req
N MIEN,NODE,STATUS
;
; Initial sets...
S STATUS=$P($G(^HLEV(776,+$G(HLEVIENJ),0)),U,4)
S RES=$E($$UP^XLFSTR($G(RES)))
;
; If any call made here, the job is running by definition...
I $G(^HLEV(776,+$G(HLEVIENJ),0))]"" D
. ; ABORT^HLEVAPI might have set status to ERROR. Don't override!
. S $P(^HLEV(776,+$G(HLEVIENJ),0),U,4)=$S(STATUS="E":"E",RES="X":"E",RES="F":"F",1:"R")
;
; If no master job, or RUNNING, quit...
I HLEVIENM=9999999!(RES="R") QUIT ;->
;
; Store results in 776.2...
S MIEN=$O(^HLEV(776.2,+HLEVIENM,51,"B",+HLEVIENE,0)) QUIT:MIEN'>0 ;->
S NODE=$G(^HLEV(776.2,+HLEVIENM,51,+MIEN,0)) QUIT:NODE']"" ;->
; Various jobs will set... QUIT:$P(NODE,U,4)'=$G(ZTSK) ;->
S $P(NODE,U,5)=$G(RES),$P(NODE,U,6)=$$NOW^XLFDT
S ^HLEV(776.2,+HLEVIENM,51,+MIEN,0)=NODE
;
Q
;
RUNEV(LASTRUN,LAPSE) ; Is LASTRUN (FM) LAPSE(min) before NOW?
N WHENRUN
QUIT:LASTRUN']"" "" ;->
S WHENRUN=$$FMADD^XLFDT($$NOW^XLFDT,0,0,-LAPSE)
Q $S(WHENRUN>LASTRUN:1,1:"")
;
OKMCODE(MREF) ; Is this a valid M subrtn^rtn reference?
N TXT
QUIT:MREF'?1.8E1"^"1.8E "" ;->
S TXT=$T(@MREF)
Q $S(TXT]"":1,1:"")
;
Q1TIME(HLEVIENE,OVERRIDE,QTIME,XTMP) ; Start a one-time run of event monitor (w/no master job)
N DATA,HLEVIENJ,HLEVNM,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
;
; Override inactive entry?
S OVERRIDE=$S($G(OVERRIDE):1,1:0)
;
; Queue to future time?
S QTIME=$G(QTIME)
;
; Is event active?
S DATA=$G(^HLEV(776.1,+$G(HLEVIENE),0)) QUIT:DATA']"" "^Entry not found" ;->
I $P(DATA,U,2)'="A",'OVERRIDE QUIT "^Event not active" ;->
;
; More variable sets...
S HLEVNM=$P(DATA,U)
S HLEVIENM=9999999 ; A one-time, no master job, run...
;
; Create a monitor stub entry...
S HLEVIENJ=$$NEWEVENT^HLEVAPI(HLEVIENE,QTIME)
I HLEVIENJ'>0 QUIT "^Entry creation failure" ;->
;
; Queue a new job w/stub entry's IEN...
S ZTIO="",ZTDTH=$S(QTIME?7N1"."1.N:$$FMTH^XLFDT(QTIME),1:$H)
S ZTDESC="HL Event Monitor - #"_HLEVIENE
S ZTRTN="QUEUEV^HLEVAPI3"
S ZTSAVE("HLEVIENJ")="",ZTSAVE("HLEVIENE")=""
S ZTSAVE("HLEVNM")="",ZTSAVE("HLEVIENM")=""
I $G(XTMP)]"" S ZTSAVE("XTMP")=""
D ^%ZTLOAD
;
I $G(^HLEV(776,+$G(HLEVIENJ),0))]"",$G(ZTSK)>0 D
. N DA,DIE,DR
. S DA=+HLEVIENJ,DIE=776,DR="8///"_ZTSK
. D ^DIE
;
Q $G(ZTSK)_U_$G(HLEVIENJ)
;
EOR ;HLEVAPI0 - Event Monitor APIs ;5/16/03 14:42
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLEVAPI0 7852 printed Dec 13, 2024@01:57:41 Page 2
HLEVAPI0 ;O-OIFO/LJA - Event Monitor APIs ;02/04/2004 14:42
+1 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
+2 ;
ONOFFM(HLEVIENE,STATUS) ;Turn on/off event monitor...
+1 ; Debug data created conditionally
DO DEBUG^HLEVAPI2("ONOFFM")
+2 ;
+3 ; Stop all event monitoring to enable on-site debugging...
+4 ;->
if $GET(^TMP("HLEVFLAG",$JOB))["STOP"
QUIT
+5 ;
+6 QUIT $$ONOFF(776.1,+HLEVIENE,STATUS)
+7 ;
ONOFFS(HLEVIEN,STATUS) ; Turn on/off system...
+1 QUIT $$ONOFF(776.999,+HLEVIEN,STATUS)
+2 ;
ONOFF(FILE,HLEVIENE,STATUS) ; Turn on/off event monitor or system...
+1 ; FILE can = 776.1 or 776.999
+2 ; Actually, HLEVIENE can be the IEN of the monitor, or the system.
+3 ; If STATUS="A", sets status to ACTIVE.
+4 ; If STATUS="I", sets status to INACTIVE.
+5 ; If STATUS=null or undefined (not passed), present status returned...
+6 ;
+7 NEW DA,DATA,DIE,DR,STAT,X,Y
+8 ;
+9 ; Find entry and IEN and zero node data...
+10 ;->
SET FILE=+$GET(FILE)
IF FILE'=776.1&(FILE'=776.999)
QUIT "^Invalid file number"
+11 SET HLEVIENE=$GET(HLEVIENE)
+12 ; Just overwrite anything passed by user...
if FILE=776.999
SET HLEVIENE=1
+13 ;->
IF $LENGTH($GET(STATUS))>1
QUIT "^Invalid STATUS passed"
+14 SET STATUS=$$UP^XLFSTR($EXTRACT($GET(STATUS)_" "))
+15 ;->
IF " AI"'[STATUS
QUIT "^Invalid STATUS passed"
+16 ;
+17 ; If they passed the name of the entry...
+18 ;->
IF HLEVIENE'=+HLEVIENE
Begin DoDot:1
+19 ;->
IF $TRANSLATE(HLEVIENE," ","")']""
QUIT
+20 ; Must have passed in name
SET HLEVIENE(1)=$ORDER(^HLEV(FILE,"B",HLEVIENE,0))
+21 IF HLEVIENE(1)'>0
Begin DoDot:2
+22 SET HLEVIENE(1)=$ORDER(^HLEV(FILE,"B",$$UP^XLFSTR(HLEVIENE),0))
End DoDot:2
+23 SET HLEVIENE=HLEVIENE(1)
End DoDot:1
if HLEVIENE'>0
QUIT "^Couldn't find entry"
+24 ;
+25 ; Get zero node...
+26 ;->
SET DATA=$GET(^HLEV(FILE,+HLEVIENE,0))
if DATA']""
QUIT "^Couldn't find entry"
+27 ;
+28 ; Get current status...
+29 SET STAT=$EXTRACT($PIECE(DATA,U,2)_" ")
+30 ;
+31 ; If current status not yet entered in field...
+32 ;->
IF " AI"'[STAT
Begin DoDot:1
+33 ; Passed-in STATUS not A or I, so just tell them value of status...
+34 ;->
IF "AI"'[STATUS
SET STAT="^Status not entered yet"
QUIT
+35 ; User passed in a value to set the status to, so set it for them...
+36 SET DA=+HLEVIENE
SET DIE=FILE
SET DR="2///"_STATUS
+37 DO ^DIE
+38 SET STAT=STATUS
End DoDot:1
QUIT STAT
+39 ;
+40 ; If all they want is the status...
+41 ;->
IF STATUS=" "
QUIT STAT
+42 ;
+43 ; Status entered in field before call...
+44 ;
+45 ; If passed-in status is the same as the current status in entry...
+46 ;-> Already set...
IF STAT=STATUS
QUIT STATUS
+47 ;
+48 ; Change status of field to passed-in value...
+49 SET DA=+HLEVIENE
SET DIE=FILE
SET DR="2///"_STATUS
+50 DO ^DIE
+51 ;
+52 QUIT STATUS
+53 ;
ONOFFEV ; Turn on/off event monitor
+1 NEW CHG
+2 ;
+3 NEW DATA,DIC,IEN,IENR
+4 DO HDR^HLEVREP("Turn on/off Event Monitors")
+5 ;
S7761 KILL DATA,DIC,IEN,IENR
+1 WRITE !
+2 ;->
SET IEN=$$ASKIEN^HLEVREP(776.1)
if IEN'>0
QUIT
+3 DO HDR^HLEVREP("Turn on/off Event Monitors",IEN)
+4 DO VIEW7761(+IEN)
+5 DO RUNS7761^HLEVREP(+IEN)
+6 IF $DATA(^TMP($JOB,"HLRUNS"))
Begin DoDot:1
+7 WRITE !!,"Recent Checks of the Monitor by Master Job"
+8 WRITE !,$$REPEAT^XLFSTR("-",IOM)
+9 WRITE !,"Check-time",?18,"Results"
+10 WRITE !,$$REPEAT^XLFSTR("-",IOM)
+11 SET IENR=0
+12 FOR
SET IENR=$ORDER(^TMP($JOB,"HLRUNS",IENR))
if IENR'>0
QUIT
Begin DoDot:2
+13 ;->
SET DATA=$GET(^TMP($JOB,"HLRUNS",IENR))
if DATA']""
QUIT
+14 WRITE !,$$SDT^HLEVX001($PIECE(DATA,U,2)),?18,$$STAT2M^HLEVX001($PIECE(DATA,U))
End DoDot:2
End DoDot:1
+15 WRITE !
+16 SET CHG=$$ACTINACT(776.1,+IEN,2,"Event monitor status")
+17 IF CHG
Begin DoDot:1
+18 DO HDR^HLEVREP("Turn on/off Event Monitors",IEN)
+19 DO VIEW7761(+IEN)
End DoDot:1
+20 FOR
if (IOSL-$Y)<4
QUIT
WRITE !
+21 ;S X=$$BTE^HLCSMON("Press RETURN to continue... ")
+22 ;->
GOTO S7761
+23 ;
VIEW7761(IEN) ; Actual display code for entry...
+1 NEW NODE,P1,P2,P3,P4,P5,P6,PAR,PCE
+2 ;
+3 SET NODE=$GET(^HLEV(776.1,+IEN,0))
+4 FOR PCE=1:1:6
SET @("P"_PCE)=$PIECE(NODE,U,PCE)
+5 ;
+6 ; Store under field number...
+7 FOR PCE=1:1:8
SET PAR(PCE)=$PIECE($GET(^HLEV(776.1,+IEN,40)),U,PCE)
+8 ;
+9 DO SH7761("Description",$SELECT(P3]"":P3,1:"---"))
+10 DO SH7761("Status",$SELECT(P2="A":"ACTIVE",1:"INACTIVE"))
+11 DO SH7761("Requeue minutes",$SELECT(P4:P4_"min",P4=0:"0 [Immediate Run]",1:"---"))
+12 DO SH7761("Notification mail group",$SELECT(P5:$PIECE($GET(^XMB(3.8,+P5,0)),U),1:"---"))
+13 DO SH7761("M startup",$SELECT(P6]"":P6,1:"---"))
+14 WRITE !,$$CJ^XLFSTR(" Parameter ""Variable"" Descriptors ",IOM,"-")
+15 FOR PCE=1:1:8
IF PAR(PCE)]""
Begin DoDot:1
+16 WRITE !,?25,"Parameter - "_PCE_" = ",PAR(PCE)
End DoDot:1
+17 ;
+18 QUIT
+19 ;
SH7761(TAG,VAL) ;
+1 WRITE !,?(35-$LENGTH(TAG)-2),TAG,":",?45,VAL
+2 QUIT
+3 ;
ONOFFPAR ; Turn on/off parameters...
+1 NEW CHG
+2 ;
+3 DO VIEW7769^HLEVREP(0)
+4 ;
+5 WRITE !
+6 ;
+7 SET CHG=0
+8 SET X=$$ACTINACT(776.999,1,2,"STATUS-MASTER JOB")
IF X=1
SET CHG=1
+9 SET X=$$ACTINACT(776.999,1,6,"STATUS-EVENT MONITORING")
IF X=1
SET CHG=1
+10 ;
+11 IF CHG
DO VIEW7769^HLEVREP(0)
+12 ;
+13 WRITE !
+14 FOR
if (IOSL-$Y)<3
QUIT
WRITE !
+15 SET X=$$BTE^HLCSMON("Press RETURN to exit... ")
+16 ;
+17 QUIT
+18 ;
ACTINACT(FILE,IEN,FLD,TAG) ; Turn on/off status fields...
+1 NEW DA,DIE,DR,STAT,X,Y
+2 SET STAT=$PIECE($GET(^HLEV(FILE,IEN,0)),U,+FLD)
+3 ;->
SET X=$$YN^HLCSRPT4("Change '"_TAG_"' to "_$SELECT(STAT="A":"INACTIVE",1:"ACTIVE"),"No")
IF X'=1
Begin DoDot:1
+4 WRITE " ... nothing changed ..."
End DoDot:1
QUIT ""
+5 SET DA=IEN
SET DIE=FILE
SET DR=FLD_"///"_$SELECT(STAT="A":"I",1:"A")
+6 DO ^DIE
+7 WRITE " changed!"
+8 QUIT 1
+9 ;
EVENTCHK(HLEVIENM) ; Loop thru all MONITORs...
+1 ; NOEVCHK,ZTSKMST -- req
+2 NEW HLEVIENE,HLEVNM
+3 ;
+4 ; Check STATUS-EVENT...
+5 ;->
SET NO=$ORDER(^HLEV(776.999,":"),-1)
if $PIECE($GET(^HLEV(776.999,+NO,0)),U,6)'="A"
QUIT
+6 ;
+7 SET HLEVNM=0
+8 FOR
SET HLEVNM=$ORDER(^HLEV(776.1,"B",HLEVNM))
if HLEVNM']""
QUIT
Begin DoDot:1
+9 SET HLEVIENE=0
+10 FOR
SET HLEVIENE=$ORDER(^HLEV(776.1,"B",HLEVNM,HLEVIENE))
if 'HLEVIENE
QUIT
Begin DoDot:2
+11 DO EVENTONE^HLEVAPI3(HLEVIENM,HLEVNM,HLEVIENE)
+12 SET NOEVCHK=$GET(NOEVCHK)+1
End DoDot:2
End DoDot:1
+13 ;
+14 QUIT
+15 ;
EVRES(HLEVIENM,HLEVIENE,RES,HLEVIENJ) ; Record result of queued task...
+1 ; ZTSK -- req
+2 NEW MIEN,NODE,STATUS
+3 ;
+4 ; Initial sets...
+5 SET STATUS=$PIECE($GET(^HLEV(776,+$GET(HLEVIENJ),0)),U,4)
+6 SET RES=$EXTRACT($$UP^XLFSTR($GET(RES)))
+7 ;
+8 ; If any call made here, the job is running by definition...
+9 IF $GET(^HLEV(776,+$GET(HLEVIENJ),0))]""
Begin DoDot:1
+10 ; ABORT^HLEVAPI might have set status to ERROR. Don't override!
+11 SET $PIECE(^HLEV(776,+$GET(HLEVIENJ),0),U,4)=$SELECT(STATUS="E":"E",RES="X":"E",RES="F":"F",1:"R")
End DoDot:1
+12 ;
+13 ; If no master job, or RUNNING, quit...
+14 ;->
IF HLEVIENM=9999999!(RES="R")
QUIT
+15 ;
+16 ; Store results in 776.2...
+17 ;->
SET MIEN=$ORDER(^HLEV(776.2,+HLEVIENM,51,"B",+HLEVIENE,0))
if MIEN'>0
QUIT
+18 ;->
SET NODE=$GET(^HLEV(776.2,+HLEVIENM,51,+MIEN,0))
if NODE']""
QUIT
+19 ; Various jobs will set... QUIT:$P(NODE,U,4)'=$G(ZTSK) ;->
+20 SET $PIECE(NODE,U,5)=$GET(RES)
SET $PIECE(NODE,U,6)=$$NOW^XLFDT
+21 SET ^HLEV(776.2,+HLEVIENM,51,+MIEN,0)=NODE
+22 ;
+23 QUIT
+24 ;
RUNEV(LASTRUN,LAPSE) ; Is LASTRUN (FM) LAPSE(min) before NOW?
+1 NEW WHENRUN
+2 ;->
if LASTRUN']""
QUIT ""
+3 SET WHENRUN=$$FMADD^XLFDT($$NOW^XLFDT,0,0,-LAPSE)
+4 QUIT $SELECT(WHENRUN>LASTRUN:1,1:"")
+5 ;
OKMCODE(MREF) ; Is this a valid M subrtn^rtn reference?
+1 NEW TXT
+2 ;->
if MREF'?1.8E1"^"1.8E
QUIT ""
+3 SET TXT=$TEXT(@MREF)
+4 QUIT $SELECT(TXT]"":1,1:"")
+5 ;
Q1TIME(HLEVIENE,OVERRIDE,QTIME,XTMP) ; Start a one-time run of event monitor (w/no master job)
+1 NEW DATA,HLEVIENJ,HLEVNM,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+2 ;
+3 ; Override inactive entry?
+4 SET OVERRIDE=$SELECT($GET(OVERRIDE):1,1:0)
+5 ;
+6 ; Queue to future time?
+7 SET QTIME=$GET(QTIME)
+8 ;
+9 ; Is event active?
+10 ;->
SET DATA=$GET(^HLEV(776.1,+$GET(HLEVIENE),0))
if DATA']""
QUIT "^Entry not found"
+11 ;->
IF $PIECE(DATA,U,2)'="A"
IF 'OVERRIDE
QUIT "^Event not active"
+12 ;
+13 ; More variable sets...
+14 SET HLEVNM=$PIECE(DATA,U)
+15 ; A one-time, no master job, run...
SET HLEVIENM=9999999
+16 ;
+17 ; Create a monitor stub entry...
+18 SET HLEVIENJ=$$NEWEVENT^HLEVAPI(HLEVIENE,QTIME)
+19 ;->
IF HLEVIENJ'>0
QUIT "^Entry creation failure"
+20 ;
+21 ; Queue a new job w/stub entry's IEN...
+22 SET ZTIO=""
SET ZTDTH=$SELECT(QTIME?7N1"."1.N:$$FMTH^XLFDT(QTIME),1:$HOROLOG)
+23 SET ZTDESC="HL Event Monitor - #"_HLEVIENE
+24 SET ZTRTN="QUEUEV^HLEVAPI3"
+25 SET ZTSAVE("HLEVIENJ")=""
SET ZTSAVE("HLEVIENE")=""
+26 SET ZTSAVE("HLEVNM")=""
SET ZTSAVE("HLEVIENM")=""
+27 IF $GET(XTMP)]""
SET ZTSAVE("XTMP")=""
+28 DO ^%ZTLOAD
+29 ;
+30 IF $GET(^HLEV(776,+$GET(HLEVIENJ),0))]""
IF $GET(ZTSK)>0
Begin DoDot:1
+31 NEW DA,DIE,DR
+32 SET DA=+HLEVIENJ
SET DIE=776
SET DR="8///"_ZTSK
+33 DO ^DIE
End DoDot:1
+34 ;
+35 QUIT $GET(ZTSK)_U_$GET(HLEVIENJ)
+36 ;
EOR ;HLEVAPI0 - Event Monitor APIs ;5/16/03 14:42