ORB3ENV ; slc/CLA - OE/RR 3 Notifications/Order Check Environment Check Routine ;9/19/01  14:29
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**105**;Dec 17, 1997
EN ; main entry point
 D ORMTIME
 Q
ORMTIME ; determine if ORMTIME is running
 N I,J,STATUS,JOB,OK,LASTDT,NOWDT,DIFFDT,SCHDT,ORY,MSG
 S OK=0
 D BMES^XPDUTL("Checking to see if ORMTIME is running...")
 ;
 ;for loop that runs for 12 iterations (60 secs.) - quits if no lock
 F I=1:1:12 Q:OK=1  D
 .L +^OR(100,"AE"):5 I $T S OK=1 Q
 .I I=1 D BMES^XPDUTL("Pausing because ORMTIME is running...")
 .E  D MES^XPDUTL(".")
 ;
 I OK=1 LOCK  ;^OR(100,"AE"):0
 ;
 ;if ORMTIME is not currently running see if scheduled in near future:
 I OK=1 D
 .S LASTDT=$$GET^XPAR("SYS","ORM ORMTIME LAST RUN",1,"I")
 .;
 .D OPTSTAT^XUTMOPT("ORMTIME RUN",.ORY)  ;get option sch info IA# 1472
 .F J=1:1:ORY Q:OK=2  D
 ..S SCHDT=$P(ORY(J),U,2)  ;next scheduled ORMTIME run time
 ..S NOWDT=$$NOW^XLFDT
 ..S DIFFDT=$$FMDIFF^XLFDT(SCHDT,NOWDT,2)
 ..I DIFFDT>0,DIFFDT<300 S OK=2  ;if sched to run in less than 5 minutes
 ;
 I OK=1 D  ;ORMTIME not running
 .D BMES^XPDUTL("ORMTIME not running nor scheduled within 5 minutes. Okay to install.")
 ;
 I OK=0 D  ;ORMTIME still running
 .D BMES^XPDUTL("ORMTIME is still running...")
 .S JOB="",JOB=$O(^TMP("OCXORMTIME",JOB),-1)
 .I +$G(JOB)>0,$D(^TMP("OCXORMTIME",JOB,"STATUS")) D
 ..S STATUS=^TMP("OCXORMTIME",JOB,"STATUS")
 ..D MES^XPDUTL(STATUS)
 .D BMES^XPDUTL("*** ABORTING INSTALLATION *** - due to potential conflict with ORMTIME.")
 .D MES^XPDUTL("Try installation again after ORMTIME run completes.")
 .D MES^XPDUTL("(ORMTIME usually requires less than 10 mintues to run to completion.)")
 .S XPDQUIT=2  ;abort installation but leave transport global in ^XTMP
 ;
 I OK=2 D  ;ORMTIME scheduled to run before patch install completes
 .S MSG=$$FMTE^XLFDT(SCHDT)
 .S MSG="ORMTIME scheduled at: "_MSG_" and may impact patch installation."
 .D BMES^XPDUTL(MSG)
 .D BMES^XPDUTL("*** ABORTING INSTALLATION *** - due to potential conflict with ORMTIME.")
 .D MES^XPDUTL("Try installation again after ORMTIME run completes.")
 .D MES^XPDUTL("(ORMTIME usually requires less than 10 mintues to run to completion.)")
 .S XPDQUIT=2  ;abort installation but leave transport global in ^XTMP
 ;
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORB3ENV   2309     printed  Sep 23, 2025@20:03:37                                                                                                                                                                                                     Page 2
ORB3ENV   ; slc/CLA - OE/RR 3 Notifications/Order Check Environment Check Routine ;9/19/01  14:29
 +1       ;;3.0;ORDER ENTRY/RESULTS REPORTING;**105**;Dec 17, 1997
EN        ; main entry point
 +1        DO ORMTIME
 +2        QUIT 
ORMTIME   ; determine if ORMTIME is running
 +1        NEW I,J,STATUS,JOB,OK,LASTDT,NOWDT,DIFFDT,SCHDT,ORY,MSG
 +2        SET OK=0
 +3        DO BMES^XPDUTL("Checking to see if ORMTIME is running...")
 +4       ;
 +5       ;for loop that runs for 12 iterations (60 secs.) - quits if no lock
 +6        FOR I=1:1:12
               if OK=1
                   QUIT 
               Begin DoDot:1
 +7                LOCK +^OR(100,"AE"):5
                   IF $TEST
                       SET OK=1
                       QUIT 
 +8                IF I=1
                       DO BMES^XPDUTL("Pausing because ORMTIME is running...")
 +9               IF '$TEST
                       DO MES^XPDUTL(".")
               End DoDot:1
 +10      ;
 +11      ;^OR(100,"AE"):0
           IF OK=1
               LOCK 
 +12      ;
 +13      ;if ORMTIME is not currently running see if scheduled in near future:
 +14       IF OK=1
               Begin DoDot:1
 +15               SET LASTDT=$$GET^XPAR("SYS","ORM ORMTIME LAST RUN",1,"I")
 +16      ;
 +17      ;get option sch info IA# 1472
                   DO OPTSTAT^XUTMOPT("ORMTIME RUN",.ORY)
 +18               FOR J=1:1:ORY
                       if OK=2
                           QUIT 
                       Begin DoDot:2
 +19      ;next scheduled ORMTIME run time
                           SET SCHDT=$PIECE(ORY(J),U,2)
 +20                       SET NOWDT=$$NOW^XLFDT
 +21                       SET DIFFDT=$$FMDIFF^XLFDT(SCHDT,NOWDT,2)
 +22      ;if sched to run in less than 5 minutes
                           IF DIFFDT>0
                               IF DIFFDT<300
                                   SET OK=2
                       End DoDot:2
               End DoDot:1
 +23      ;
 +24      ;ORMTIME not running
           IF OK=1
               Begin DoDot:1
 +25               DO BMES^XPDUTL("ORMTIME not running nor scheduled within 5 minutes. Okay to install.")
               End DoDot:1
 +26      ;
 +27      ;ORMTIME still running
           IF OK=0
               Begin DoDot:1
 +28               DO BMES^XPDUTL("ORMTIME is still running...")
 +29               SET JOB=""
                   SET JOB=$ORDER(^TMP("OCXORMTIME",JOB),-1)
 +30               IF +$GET(JOB)>0
                       IF $DATA(^TMP("OCXORMTIME",JOB,"STATUS"))
                           Begin DoDot:2
 +31                           SET STATUS=^TMP("OCXORMTIME",JOB,"STATUS")
 +32                           DO MES^XPDUTL(STATUS)
                           End DoDot:2
 +33               DO BMES^XPDUTL("*** ABORTING INSTALLATION *** - due to potential conflict with ORMTIME.")
 +34               DO MES^XPDUTL("Try installation again after ORMTIME run completes.")
 +35               DO MES^XPDUTL("(ORMTIME usually requires less than 10 mintues to run to completion.)")
 +36      ;abort installation but leave transport global in ^XTMP
                   SET XPDQUIT=2
               End DoDot:1
 +37      ;
 +38      ;ORMTIME scheduled to run before patch install completes
           IF OK=2
               Begin DoDot:1
 +39               SET MSG=$$FMTE^XLFDT(SCHDT)
 +40               SET MSG="ORMTIME scheduled at: "_MSG_" and may impact patch installation."
 +41               DO BMES^XPDUTL(MSG)
 +42               DO BMES^XPDUTL("*** ABORTING INSTALLATION *** - due to potential conflict with ORMTIME.")
 +43               DO MES^XPDUTL("Try installation again after ORMTIME run completes.")
 +44               DO MES^XPDUTL("(ORMTIME usually requires less than 10 mintues to run to completion.)")
 +45      ;abort installation but leave transport global in ^XTMP
                   SET XPDQUIT=2
               End DoDot:1
 +46      ;
 +47       QUIT