source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORMTIMST.m@ 794

Last change on this file since 794 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.7 KB
Line 
1ORMTIMST ; JM/SLC-ISC - ORMTIME STATUS ROUTINES ;06/06/2006
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**253**;Dec 17, 1997
3 ;
4EN ; Pre-install environment check - will ORMTIME run in the next 5 minutes?
5 ;
6 D ENVCHECK(5)
7 Q
8 ;
9RUNNING() ; Checks to see if ORMTIME is running
10 L +^OR(100,"AE"):2 I $T L -^OR(100,"AE") Q 0
11 Q 1
12 ;
13NEXTRUN() ; Number of minutes before the next scheduled run of ORMTIME. - returns in format MINUTES:SECONDS
14 ; If past scheduled time, but within the last 10 minutes, returns 0 (give TaskMan time to invoke it)
15 ; If -1, unable to determine value
16 N RESULT,ORY,I,SCHDT,NOWDT,DIFFDT,MAX,DELAY,SEC,MIN,PASTDUE
17 S MAX=9999999
18 S RESULT=MAX
19 S DELAY=10 ; Give Taskman 10 minutes to invoke ORMTIME
20 S NOWDT=$$NOW^XLFDT
21 S PASTDUE=$$FMADD^XLFDT(NOWDT,0,0,-DELAY,0)
22 D OPTSTAT^XUTMOPT("ORMTIME RUN",.ORY) ; get option schedule info IA# 1472
23 F I=1:1:ORY D Q:(RESULT=0)
24 . S SCHDT=$P(ORY(I),U,2) ; next scheduled ORMTIME run time
25 . S DIFFDT=$$FMDIFF^XLFDT(SCHDT,NOWDT,2)
26 . I DIFFDT<0 D Q
27 . . I SCHDT>PASTDUE S RESULT=0
28 . I RESULT>DIFFDT S RESULT=DIFFDT
29 I RESULT=MAX S RESULT=-1
30 I RESULT>0 D
31 . S SEC=RESULT#60,MIN=RESULT\60
32 . I SEC<10 S SEC="0"_SEC
33 . S RESULT=MIN_":"_SEC
34 Q RESULT
35 ;
36ENVCHECK(MINUTES) ; Environment check to see if ORMTIME is running, or will run in the next few minutes
37 ;
38 I '+$G(XPDENV) Q ; Don't evaluate during the global load - just when actually installing
39 N KIDS
40 S KIDS=1
41 G ENVMAIN
42 ;
43ENVTEST(MINUTES) ; Run for testing purposes only
44 N KIDS
45 S KIDS=0
46 ;
47ENVMAIN ;
48 N I,RUNNING,MSG,CHKSOON,SOON,COUNT,NEXT,STARTMSG
49 D BOUT("Checking ORMTIME status...")
50 S RUNNING=$$RUNNING
51 S CHKSOON=1
52 S MSG="ORMTIME is "
53 I RUNNING S MSG=MSG_"running, waiting for it to finish..."
54 E S MSG=MSG_"not running."
55 D BOUT(MSG)
56 I RUNNING D
57 . S (COUNT,CHKSOON)=0
58 . F I=1:1:15 D Q:'RUNNING
59 . . S RUNNING=$$RUNNING
60 . . I RUNNING S COUNT=COUNT+1 I COUNT>2 S COUNT=0 D OUT(" ORMTIME is still running...")
61 . I 'RUNNING D
62 . . H 2 ; Wait 2 seconds after the lock is released, to make sure ORMTIME is finished executing
63 . . D OUT("ORMTIME is done.")
64 I RUNNING D ABORT("ORMTIME is taking too long to run.") Q
65 ;
66 I CHKSOON D Q:SOON
67 . D BOUT("Checking ORMTIME Schedule...")
68 . S NEXT=$$NEXTRUN
69 . S SOON=1
70 . I (NEXT<0)!(NEXT'<MINUTES) S SOON=0
71 . S MSG="ORMTIME is "
72 . I SOON D I 1
73 . . I NEXT<1 S STARTMSG="less than a minute."
74 . . E S STARTMSG=NEXT_" minutes."
75 . E S MSG=MSG_"not " S STARTMSG="the next "_MINUTES_":00 minutes."
76 . S MSG=MSG_"scheduled to run in "_STARTMSG
77 . D BOUT(MSG)
78 . I SOON D ABORT("Too close to ORMTIME's scheduled start time.")
79 D BOUT("Installation conditions are acceptable, continuing installation...")
80 Q
81 ;
82ABORT(TXT) ; Send abort message
83 D BOUT("***********************************")
84 D OUT("***** ABORTING INSTALLATION *****")
85 D OUT("***********************************")
86 D OUT(TXT)
87 D OUT("Try installation again after ORMTIME completes.")
88 S XPDQUIT=2 ;abort installation but leave transport global in ^XTMP
89 Q
90 ;
91OUT(TEXT) ; Send output - if run from install, send to MES^XPDUTL
92 I KIDS D MES^XPDUTL(TEXT) I 1
93 E W TEXT,!
94 Q
95BOUT(TEXT) ; Send output - if run from install, send to BMES^XPDUTL
96 I KIDS D BMES^XPDUTL(TEXT) I 1
97 E W !,TEXT,!
98 Q
99PRETEST ; test install
100 N KIDS
101 S KIDS=0
102 G PREMAIN
103 ;
104PRECHECK ; Start install - make sure ORMTIME doesn't run while the installation takes place.
105 N KIDS
106 S KIDS=1
107PREMAIN ;
108 N COUNT
109 S COUNT=0
110 F Q:'$$RUNNING D
111 . I COUNT=0 D BOUT("ORMTIME is running. Install waiting for ORMTIME to finished...")
112 . S COUNT=COUNT+1
113 . I COUNT>4 D OUT(" ORMTIME is still running...") S COUNT=1
114 I COUNT>0 H 2 D BOUT("ORMTIME has finished running, continuing with install...")
115 D BOUT("Starting ORMTIME update...")
116 Q
Note: See TracBrowser for help on using the repository browser.