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

ORMTIMST.m

Go to the documentation of this file.
  1. ORMTIMST ; JM/SLC-ISC - ORMTIME STATUS ROUTINES ;06/06/2006
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**253**;Dec 17, 1997
  1. ;
  1. EN ; Pre-install environment check - will ORMTIME run in the next 5 minutes?
  1. ;
  1. D ENVCHECK(5)
  1. Q
  1. ;
  1. RUNNING() ; Checks to see if ORMTIME is running
  1. L +^OR(100,"AE"):2 I $T L -^OR(100,"AE") Q 0
  1. Q 1
  1. ;
  1. NEXTRUN() ; Number of minutes before the next scheduled run of ORMTIME. - returns in format MINUTES:SECONDS
  1. ; If past scheduled time, but within the last 10 minutes, returns 0 (give TaskMan time to invoke it)
  1. ; If -1, unable to determine value
  1. N RESULT,ORY,I,SCHDT,NOWDT,DIFFDT,MAX,DELAY,SEC,MIN,PASTDUE
  1. S MAX=9999999
  1. S RESULT=MAX
  1. S DELAY=10 ; Give Taskman 10 minutes to invoke ORMTIME
  1. S NOWDT=$$NOW^XLFDT
  1. S PASTDUE=$$FMADD^XLFDT(NOWDT,0,0,-DELAY,0)
  1. D OPTSTAT^XUTMOPT("ORMTIME RUN",.ORY) ; get option schedule info IA# 1472
  1. F I=1:1:ORY D Q:(RESULT=0)
  1. . S SCHDT=$P(ORY(I),U,2) ; next scheduled ORMTIME run time
  1. . S DIFFDT=$$FMDIFF^XLFDT(SCHDT,NOWDT,2)
  1. . I DIFFDT<0 D Q
  1. . . I SCHDT>PASTDUE S RESULT=0
  1. . I RESULT>DIFFDT S RESULT=DIFFDT
  1. I RESULT=MAX S RESULT=-1
  1. I RESULT>0 D
  1. . S SEC=RESULT#60,MIN=RESULT\60
  1. . I SEC<10 S SEC="0"_SEC
  1. . S RESULT=MIN_":"_SEC
  1. Q RESULT
  1. ;
  1. ENVCHECK(MINUTES) ; Environment check to see if ORMTIME is running, or will run in the next few minutes
  1. ;
  1. I '+$G(XPDENV) Q ; Don't evaluate during the global load - just when actually installing
  1. N KIDS
  1. S KIDS=1
  1. G ENVMAIN
  1. ;
  1. ENVTEST(MINUTES) ; Run for testing purposes only
  1. N KIDS
  1. S KIDS=0
  1. ;
  1. ENVMAIN ;
  1. N I,RUNNING,MSG,CHKSOON,SOON,COUNT,NEXT,STARTMSG
  1. D BOUT("Checking ORMTIME status...")
  1. S RUNNING=$$RUNNING
  1. S CHKSOON=1
  1. S MSG="ORMTIME is "
  1. I RUNNING S MSG=MSG_"running, waiting for it to finish..."
  1. E S MSG=MSG_"not running."
  1. D BOUT(MSG)
  1. I RUNNING D
  1. . S (COUNT,CHKSOON)=0
  1. . F I=1:1:15 D Q:'RUNNING
  1. . . S RUNNING=$$RUNNING
  1. . . I RUNNING S COUNT=COUNT+1 I COUNT>2 S COUNT=0 D OUT(" ORMTIME is still running...")
  1. . I 'RUNNING D
  1. . . H 2 ; Wait 2 seconds after the lock is released, to make sure ORMTIME is finished executing
  1. . . D OUT("ORMTIME is done.")
  1. I RUNNING D ABORT("ORMTIME is taking too long to run.") Q
  1. ;
  1. I CHKSOON D Q:SOON
  1. . D BOUT("Checking ORMTIME Schedule...")
  1. . S NEXT=$$NEXTRUN
  1. . S SOON=1
  1. . I (NEXT<0)!(NEXT'<MINUTES) S SOON=0
  1. . S MSG="ORMTIME is "
  1. . I SOON D I 1
  1. . . I NEXT<1 S STARTMSG="less than a minute."
  1. . . E S STARTMSG=NEXT_" minutes."
  1. . E S MSG=MSG_"not " S STARTMSG="the next "_MINUTES_":00 minutes."
  1. . S MSG=MSG_"scheduled to run in "_STARTMSG
  1. . D BOUT(MSG)
  1. . I SOON D ABORT("Too close to ORMTIME's scheduled start time.")
  1. D BOUT("Installation conditions are acceptable, continuing installation...")
  1. Q
  1. ;
  1. ABORT(TXT) ; Send abort message
  1. D BOUT("***********************************")
  1. D OUT("***** ABORTING INSTALLATION *****")
  1. D OUT("***********************************")
  1. D OUT(TXT)
  1. D OUT("Try installation again after ORMTIME completes.")
  1. S XPDQUIT=2 ;abort installation but leave transport global in ^XTMP
  1. Q
  1. ;
  1. OUT(TEXT) ; Send output - if run from install, send to MES^XPDUTL
  1. I KIDS D MES^XPDUTL(TEXT) I 1
  1. E W TEXT,!
  1. Q
  1. BOUT(TEXT) ; Send output - if run from install, send to BMES^XPDUTL
  1. I KIDS D BMES^XPDUTL(TEXT) I 1
  1. E W !,TEXT,!
  1. Q
  1. PRETEST ; test install
  1. N KIDS
  1. S KIDS=0
  1. G PREMAIN
  1. ;
  1. PRECHECK ; Start install - make sure ORMTIME doesn't run while the installation takes place.
  1. N KIDS
  1. S KIDS=1
  1. PREMAIN ;
  1. N COUNT
  1. S COUNT=0
  1. F Q:'$$RUNNING D
  1. . I COUNT=0 D BOUT("ORMTIME is running. Install waiting for ORMTIME to finished...")
  1. . S COUNT=COUNT+1
  1. . I COUNT>4 D OUT(" ORMTIME is still running...") S COUNT=1
  1. I COUNT>0 H 2 D BOUT("ORMTIME has finished running, continuing with install...")
  1. D BOUT("Starting ORMTIME update...")
  1. Q