Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLEVMST0

HLEVMST0.m

Go to the documentation of this file.
  1. HLEVMST0 ;O-OIFO/LJA - Event Monitor MASTER JOB ;02/04/2004 14:42
  1. ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13, 1995
  1. ;
  1. UNQUEUE ; Unqueue master job...
  1. N DIFF,IOINHI,IOINORM,LAST0,LASTDT,LASTIEN,NEXTH,SECNEXT
  1. N SECNOW,TASKNO,ZTDTH,ZTSK
  1. ;
  1. S X="IOINHI;IOINORM" D ENDR^%ZISS
  1. ;
  1. D HDU
  1. D EXU
  1. ;
  1. W !
  1. ;
  1. S LASTDT=$O(^HLEV(776.2,"B",":"),-1)
  1. S LASTIEN=$O(^HLEV(776.2,"B",+LASTDT,":"),-1)
  1. S LAST0=$G(^HLEV(776.2,+LASTIEN,0)) I $P(LAST0,U,4)'="Q" D QUIT ;->
  1. . D TELL("The most recently queued master job is no longer active...","1^2^999")
  1. ;
  1. S LASTSK=$P(LAST0,U,5) I LASTSK>0 D
  1. . W !,"The current master job is task# ",$P(LAST0,U,5),", queued for "
  1. . W $$FMTE^XLFDT(+$P(LAST0,U,6)),"."
  1. ;
  1. W !
  1. I '$$YN^HLCSRPT4("OK to stop master job now","No") D QUIT ;->
  1. . W " no action taken..."
  1. ;
  1. W " Master job stopped..."
  1. W !!,IOINHI,"Important!!",IOINORM," You must remember to start a new master job!!"
  1. ;
  1. D UNQ^HLEVUTIL(+LASTIEN,+LASTSK,"Master job stopped by "_$P($G(^VA(200,+$G(DUZ),0)),U)_".")
  1. ;
  1. D TELL("","0^0^999")
  1. ;
  1. Q
  1. ;
  1. HDU W @IOF,$$CJ^XLFSTR("Unqueue Master Job",IOM)
  1. W !,$$REPEAT^XLFSTR("=",IOM)
  1. QUIT
  1. ;
  1. EXU N I,T F I=1:1 S T=$T(EXU+I) QUIT:T'[";;" W !,$P(T,";;",2,99)
  1. ;;If a master job has been queued to a future time, it can be unqueued now.
  1. ;;
  1. ;;Note: If you unqueue this task, no future master jobs will run until you
  1. ;; manually start a new master job. (Start new master jobs with the
  1. ;; '' menu option.)
  1. QUIT
  1. ;
  1. MSTNOW ; Start queued master job now!
  1. N DIFF,LAST0,LASTDT,LASTIEN,NEXTH,SECNEXT,SECNOW,TASKNO,ZTDTH,ZTSK
  1. ;
  1. W @IOF,$$CJ^XLFSTR("Master Job ""Run Now"" Utility",IOM)
  1. W !,$$REPEAT^XLFSTR("=",IOM)
  1. W !
  1. ;
  1. S LASTDT=$O(^HLEV(776.2,"B",":"),-1) ; Last (probably queued) job time
  1. S LASTIEN=$O(^HLEV(776.2,"B",+LASTDT,":"),-1)
  1. S LAST0=$G(^HLEV(776.2,+LASTIEN,0)) I LAST0']"" D
  1. . W !,"Couldn't find last master job entry..."
  1. ;
  1. S TASKNO=$P(LAST0,U,5) I '$D(^%ZTSK(+TASKNO)) D
  1. . W !,"Couldn't find task",$S(TASKNO:"# "_TASKNO_"...",1:".")
  1. ;
  1. S TASK0=$G(^%ZTSK(+TASKNO,0)) I TASK0']"" D
  1. . W !,"Couldn't find task# ",TASKNO,"'S zero node..."
  1. ;
  1. S NEXTH=$P(TASK0,U,6) I NEXTH'?1.N1","1.N D
  1. . W !,"Invalid future queue time ($H)..."
  1. ;
  1. S SECNEXT=$$SEC(NEXTH)
  1. S SECNOW=$$SEC($H)
  1. ;
  1. S DIFF=SECNEXT-SECNOW
  1. I DIFF<60 D QUIT ;->
  1. . I DIFF<1 W !,"Master job will start any moment!" QUIT ;->
  1. . W !,"Master job will start on its own in ",DIFF," seconds..."
  1. ;
  1. I '$D(^%ZTSCH(SECNEXT,TASKNO)) D
  1. . W !,"Couldn't find ^%ZTSK(SEC,ZTSK) node..."
  1. ;
  1. W !,"This utility allows you to run the master job ahead of it's currently"
  1. W !,"scheduled time to run."
  1. ;
  1. W !!,"Master task# ",TASKNO," is queued to "
  1. W $$SDT^HLEVX001($$HTFM^XLFDT(NEXTH))
  1. W " and it will be started now..."
  1. ;
  1. W !
  1. I '$$YN^HLCSRPT4("OK to start now","No") D QUIT ;->
  1. . W " no action taken..."
  1. ;
  1. S ZTSK=TASKNO,ZTDTH=$H
  1. D REQ^%ZTLOAD
  1. ;
  1. W !!,"Master job requeued to 'now'..."
  1. ;
  1. Q
  1. ;
  1. STARTMST ; Start brand new master job now (interactively)!
  1. N DIFF,IOINHI,IOINORM,LAST0,LASTDT,LASTIEN,NEXTH,SECNEXT
  1. N SECNOW,TASKNO,ZTDTH,ZTSK
  1. ;
  1. S LASTDT=$O(^HLEV(776.2,"B",":"),-1)
  1. S LASTIEN=$O(^HLEV(776.2,"B",+LASTDT,":"),-1)
  1. S LAST0=$G(^HLEV(776.2,+LASTIEN,0))
  1. S TASKNO=$P(LAST0,U,5)
  1. ;
  1. ; If this option is accessed by queued background job, just unqueue
  1. ; everything to make sure, and start a new master job for NOW...
  1. I $D(ZTQUEUED) D QUIT ;->
  1. . D UNQ^HLEVUTIL(+LASTIEN,+TASKNO,"Reboot unqueue/requeue master job.")
  1. . D STARTJOB^HLEVMST
  1. ;
  1. S X="IOINHI;IOINORM" D ENDR^%ZISS
  1. ;
  1. D HD
  1. D EX
  1. ;
  1. W !
  1. ;
  1. I $P(LAST0,U,4)="Q" D QUIT ;->
  1. . D TELL("It appears as if task# "_$P(LAST0,U,5)_" has already been queued.","1^2^999")
  1. ;
  1. I $P(LAST0,U,5)>0 D
  1. . W !!,"The ",IOINHI,"last",IOINORM
  1. . W " master job was task# ",$P(LAST0,U,5),", queued "
  1. . W $$FMTE^XLFDT(+LAST0),"."
  1. ;
  1. W !
  1. I '$$YN^HLCSRPT4("OK to start a "_IOINHI_"new"_IOINORM_" master task now","No") D QUIT ;->
  1. . W " no action taken..."
  1. ;
  1. D STARTJOB^HLEVMST
  1. ;
  1. D TELL("Press RETURN to exit... ","0^0^999")
  1. ;
  1. Q
  1. ;
  1. HD W @IOF,$$CJ^XLFSTR("Master Job Start",IOM)
  1. W !,$$REPEAT^XLFSTR("=",IOM)
  1. QUIT
  1. ;
  1. EX N I,T F I=1:1 S T=$T(EX+I) QUIT:T'[";;" W !,$P(T,";;",2,99)
  1. ;;This option will queue a new master job task if no master job is currently
  1. ;;running and no master job is queued for the future.
  1. ;;
  1. ;;Note: A master job is queued every time the event monitoring software is
  1. ;; installed, and every time the system is rebooted. So, normally it
  1. ;; is not necessary to use this option to create a new master job.
  1. ;; (The most common reason for using this option is if the queued
  1. ;; master job was 'dequeued'.)
  1. QUIT
  1. ;
  1. SEC(HORO) ; Convert $H to seconds...
  1. QUIT:HORO'?5.N1","1.N "" ;->
  1. QUIT ((86400*+HORO)+$P(HORO,",",2))
  1. ;
  1. SECTHORO(SEC) ; Convert seconds to $H...
  1. N DAYS,SECH
  1. QUIT:SEC'?1.N "" ;->
  1. S DAYS=SEC\86400,SECH=SEC#86400
  1. QUIT DAYS_","_SECH
  1. ;
  1. TELL(TXTINFO,ACT,TXTBT) ; Print TXTINFO, FF to bottom, and $$BTE(TXTBT)...
  1. ;
  1. ; ACT = #1 ^ #2 ^ #3 ^ #4 -> Controls pre-$$BTE positioning...
  1. ;
  1. ; #1 => 0 = Spaces before printing TXTINFO (See #2).
  1. ; 1 = Lines before printing TXTINFO (see #2). [DEFAULT]
  1. ; #2 => # = # Spaces (if #1=0) or lines (if #1=1-DEFAULT)
  1. ; #3 => # = # lines before printing TXTBT (see #4).
  1. ; (# lines printed will never exceed IOSL unless
  1. ; overridden by #4. Entering #3=999 just ensures that
  1. ; line feeds will be issued until cursor is at bottom
  1. ; of screen.
  1. ; #4 => # = # lines that **must** be printed before TXTBT.
  1. ;
  1. ; Examples...
  1. ;
  1. ; 0^3^999^5 - Prints 3 spaces, TXTINFO and FFs to bottom. If the
  1. ; screen was full when TELL was called, only one FF would
  1. ; normally be issued (minimum, for spacing purposes).
  1. ; However, the '5' ensures that at least 5 LFs are issued.
  1. ; Then, TXTBT printed.
  1. ;
  1. ; 1^2^2 - Prints 2 LFs, TXTINFO, and 2 LFs, then TXTBT. (If the
  1. ; screen was full when TELL called, only 1 LF would be
  1. ; printed before printing TXTBT.)
  1. ;
  1. N I,X
  1. ;
  1. S ACT=$G(ACT),TXTINFO=$G(TXTINFO)
  1. S TXTBT=$S($G(TXTBT)]"":TXTBT,1:"Press RETURN to exit... ")
  1. ;
  1. ; Default to line feeds...
  1. S:$P(ACT,U)'=0&($P(ACT,U)'=1) $P(ACT,U)=1
  1. ;
  1. ; Default to 1 line feed or 3 spaces...
  1. S:$P(ACT,U,2)'?1.N $P(ACT,U,2)=$S(+ACT=0:3,1:1)
  1. ;
  1. ; Default to bottom of form trailing lines...
  1. S:$P(ACT,U,3)'?1.N $P(ACT,U,3)=999
  1. ;
  1. ; Default to minimum lines after printing TXTINFO...
  1. S:$P(ACT,U,4)'?1.N $P(ACT,U,4)=1
  1. ;
  1. I +ACT=0 X "F I=1:1:$P(ACT,U,2) W "" """ W TXTINFO
  1. I +ACT=1 X "F I=1:1:$P(ACT,U,2) W !" W TXTINFO
  1. ;
  1. S ACT=$P(ACT,U,3,4)
  1. ;
  1. ; If positive, always issue at least one line feed...
  1. I ACT W ! S $P(ACT,U)=$P(ACT,U)-1
  1. ;
  1. F I=1:1:ACT Q:($Y+3)>IOSL&(ACT>$P(ACT,U,2)) W !
  1. ;
  1. S X=$$BTE^HLCSMON(TXTBT)
  1. ;
  1. Q
  1. ;
  1. EOR ;HLEVMST0 - Event Monitor MASTER JOB ;5/16/03 14:42