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

BLRTASKS.m

Go to the documentation of this file.
BLRTASKS ;IHS/OIT/MKK - IHS LAB TASKS REPORT ; 17-Dec-2015 15:37 ; MKK
 ;;5.2;LR;**1030,1033,1034,1038**;NOV 01, 1997;Build 6
 ;
 ; Report to examine the TaskMan globals to determine IF all the
 ; REQUIRED Lab Tasks are tasked, or, if not, try to determine when
 ; they last run.
 ;
EEP ; Ersatz EP
 D EEP^BLRGMENU
 Q
 ;
EP ; EP - Main Entry Point
 NEW CNT,IEN,LABTASKS,NXTRUNDT,OPTION,ROOT,TASK,TASKDESC
 NEW HEADER,HD1,LINES,MAXLINES,QFLG
 NEW CHKOPT,NOWDATE,NOWTIME,SCHDDATE,SCHDTASK,SCHDTIME,TODAY
 NEW MESSAGE,MSGLINE,ALERTMSG,ALRTLINE
 ;
 D INITVARS
 ;
 F  S OPTION=$O(LABTASKS(OPTION))  Q:OPTION=""  D
 . K ROOT     ; IHS/MSC/MKK - LR*5.2*1038
 . S CHKOPT=OPTION
 . D OPTSTAT^XUTMOPT(CHKOPT,.ROOT)
 . S TASK=$P($G(ROOT(1)),"^")
 . S SCHDDATE=$P($G(ROOT(1)),"^",2)
 . S HOWOFTEN=$P($G(ROOT(1)),"^",3)
 . ;
 . ; If DEBUG set, then report no matter what
 . I +$G(DEBUG) D MAKEMESG(OPTION,SCHDDATE,.MESSAGE,.MSGLINE)  Q
 . ;
 . ; If No date or if scheduled in the PAST, it means it's not Running.  Report it.
 . I +$P(SCHDDATE,"@")<TODAY D MAKEMESG(OPTION,SCHDDATE,.MESSAGE,.MSGLINE)
 . ;
 ;
 W:+$G(DEBUG) !,"DEBUG SET.  $D(MESSAGE)=",$D(MESSAGE),!
 ;
 D:$D(MESSAGE) SENDMAIL("Daily LAB Option(s) Not Scheduled.",.MESSAGE)
 ;
 D CHEKSNAP   ; IHS/MSC/MKK - LR*5.2*1033
 ;
 Q
 ;
INITVARS ; EP
 NEW FIRSTINS,HED,INSTALLN,INSTLLDT,LABPATCH,PTR,STATUS,WOTPATCH
 ;
 S LABTASKS("LRTASK ROLLOVER")=""
 S LABTASKS("BLRTASK LAB LOG CLEANUP")=""
 S LABTASKS("LRTASK NIGHTY")=""
 S LABTASKS("LA7TASK NIGHTY")=""
 ;
 S OPTION=""
 ;
 S TODAY=$$DT^XLFDT
 ;
 S STATUS=0,WOTPATCH="LR*5.2*1099"
 F  S WOTPATCH=$O(^XPD(9.7,"B",WOTPATCH),-1)  Q:WOTPATCH=""!($E(WOTPATCH,1,2)'="LR")!(STATUS=3)  D
 . S PTR="AAA"
 . F  S PTR=$O(^XPD(9.7,"B",WOTPATCH,PTR),-1)  Q:PTR=""!(STATUS=3)  D
 .. S STATUS=$P($G(^XPD(9.7,PTR,0)),"^",9)
 .. I STATUS=3 S LABPATCH=WOTPATCH,INSTALLN=PTR
 ;
 S INSTLLDT=$P($G(^XPD(9.7,INSTALLN,0)),"^",3)
 S INSTLLDT=$TR($$FMTE^XLFDT(INSTLLDT,"2MZ"),"@"," ")
 S HEADER(1)=$$CJ^XLFSTR("Latest IHS Lab Patch: "_LABPATCH,IOM)
 S HEADER(2)=$$CJ^XLFSTR("Latest IHS Lab Patch Install Date: "_INSTLLDT,IOM)
 S HED=2
 ;
 ; Find out about First-Time Install of Latest Lab Patch
 S PTR=$O(^XPD(9.7,"B",LABPATCH,0))
 S FIRSTINS=$P($G(^XPD(9.7,PTR,0)),"^",3)
 S FIRSTINS=$TR($$FMTE^XLFDT(FIRSTINS,"2MZ"),"@"," ")
 S:FIRSTINS'=INSTLLDT HED=HED+1,HEADER(HED)=$$CJ^XLFSTR("First Install Date for "_LABPATCH_": "_FIRSTINS,IOM)
 ;
 S HED=HED+1 S HEADER(HED)=$$CJ^XLFSTR("LABORATORY TASKS",IOM)
 ;
 I '$$TM^%ZTLOAD S HED=HED+1 S HEADER(HED)=$$CJ^XLFSTR("*** TaskMan is NOT Running ***",IOM)  ; IHS/MSC/MKK - LR*5.2*1034
 ;
 S MAXLINES=22
 S LINES=MAXLINES+10,PG=0,(HD1,QFLG)="NO"
 ;
 S (MSGLINE,ALRTLINE)=0
 S CNT=0                ; IHS/MSC/MKK - LR*5.2*1033
 Q
 ;
CTMFUTDT ; EP - Check TaskMan FUTure DaTe
 K ZTSK
 S ZTSK=TASK
 D ISQED^%ZTLOAD       ; Return Task Status
 S SCHDTASK=$G(ZTSK("D"))
 ;
 S SCHDDATE=$P(SCHDTASK,",")
 S SCHDTIME=$P(SCHDTASK,",",2)
 ;
 Q:SCHDDATE<NOWDATE
 Q:SCHDDATE=NOWDATE&(SCHDTIME<NOWTIME)
 ;
 S STATUS=$P($G(^%ZTSK(TASK,.1)),"^",1)
 S STATUS=$S($G(STATUS)'="":$P($G(STATUS(STATUS)),"^"),1:"***")
 Q
 ;
 ; Create/Add to MESSAGE array
MAKEMESG(OPTION,SCHDDATE,MESSAGE,MSGLINE) ; EP
 NEW STR
 ;
 I MSGLINE>0 D
 . S MSGLINE=MSGLINE+1
 . S MESSAGE(MSGLINE)=" "
 ;
 S STR="Option >>> "_OPTION_" <<< Not Scheduled in TaskMan."
 ;
 S MSGLINE=MSGLINE+1
 S MESSAGE(MSGLINE)=STR
 ;
 I +$G(SCHDDATE)>0 D
 . S STR=$J("",10)_"Scheduled Date:"_$$UP^XLFSTR($$FMTE^XLFDT(SCHDDATE,"5MPZ"))
 . S MSGLINE=MSGLINE+1
 . S MESSAGE(MSGLINE)=STR
 ;
 Q
 ;
SENDALRT(ALERTMSG) ; EP - Send alert to LMI group AND Installer
 N XQA,XQAMSG
 ;
 S XQAMSG=ALERTMSG_"   MailMan Message Sent."
 S XQA("G.LMI")=""
 ;
 ; If installer not part of LMI Mail Group, send them alert also
 S:$$NINLMI(DUZ) XQA(DUZ)=""
 ;
 D SETUP^XQALERT
 ;
 Q
 ;
NINLMI(CHKDUZ) ; EP -- Check to see if DUZ is NOT part of LMI Mail Group
 NEW MGRPIEN,XMDUZ
 ;
 Q:CHKDUZ=.5 0                      ; IHS/MSC/MKK - LR*5.2*1033 - Do NOT send anything to POSTMASTER (DUZ=.5)
 ;
 ; Get IEN of LMI MaiL Group
 D CHKGROUP^XMBGRP("LMI",.MGRPIEN)  ; VA DBIA 1146
 Q:+(MGRPIEN)<1 1                   ; If no Mail Group, return TRUE
 ;
 ; XMDUZ = DUZ of the user
 ; Y     = IEN of the mail group
 S XMDUZ=DUZ
 S Y=MGRPIEN
 D CHK^XMA21                        ; VA DBIA 10067
 ;
 Q $S($T=1:0,1:1)
 ;
SENDMAIL(MAILMSG,MESSAGE) ; EP -- Send MailMan E-mail to LMI group AND User
 NEW DIFROM
 ;
 K XMY
 S XMY("G.LMI")=""
 ;
 ; If user not part of LMI Mail Group, send them e-mail also
 S:$$NINLMI(DUZ) XMY(DUZ)=""
 ;
 S LRBLNOW=$E($$NOW^XLFDT,1,12)
 ;
 S XMSUB=MAILMSG
 S XMTEXT="MESSAGE("
 S XMDUZ="BLRTASKS"
 S XMZ="NOT OKAY"
 D ^XMD
 ;
 I $G(XMMG)'=""!(XMZ="NOT OKAY") D
 . D BMES^XPDUTL($J("",5)_"MAILMAN ERROR.")
 . D BMES^XPDUTL($J("",10)_"XMZ:"_XMZ)
 . D BMES^XPDUTL($J("",10)_"XMMG:"_XMMG)
 ;
 K X,XMDUZ,XMSUB,XMTEXT,XMY,XMZ,Y   ; Cleanup
 ;
 D SENDALRT(MAILMSG)
 Q
 ;
DEBUG ; EP
 NEW DEBUG
 ;
 S DEBUG=1
 D EP
 Q
 ;
DEBUGRPT ; EP
 W ?4,OPTION
 W ?34,$$UP^XLFSTR($$FMTE^XLFDT(SCHDDATE,"5MPZ"))
 W ?64,HOWOFTEN
 W !
 Q
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.1*1033
CHEKSNAP ; EP - Make certain the TAKE SNAPSHOTS field in the BLR MASTER CONTROL file is set to NO.
 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
 ;
 S SITE=.9999999
 F  S SITE=$O(^BLRSITE(SITE))  Q:SITE<1  D
 . Q:+$$GET1^DIQ(9009029,SITE,"TAKE SNAPSHOTS","I")<1      ; Skip if NO or NULL.
 . ;
 . D ^XBFMK
 . K FDA,ERRS
 . S FDA(9009029,SITE_",",1)=0
 . D FILE^DIE("K","FDA","ERRS")
 . ;
 . S ^TMP("BLRTASKS",$J,SITE)=$$GET1^DIQ(4,SITE,"NAME")
 . S ^TMP("BLRTASKS",$J,SITE,$H)=$$HTE^XLFDT($H,"5MZ")
 . S ^TMP("BLRTASKS",$J,SITE,$H,"TAKE SNAPSHOTS")=$$GET1^DIQ(9009029,SITE,"TAKE SNAPSHOTS")
 . M:$D(ERRS) ^TMP("BLRTASKS",$J,SITE,$H,"TAKE SNAPSHOTS","ERRS")=ERRS
 Q
 ;
SCRNREPT ; EP - DEBUG -- Print Report to the screen
 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
 ;
 D INITVARS
 ;
 D SCRNINIT
 ;
 F  S OPTION=$O(LABTASKS(OPTION))  Q:OPTION=""  D SCRNLINE
 D HLZTCPCK   ; IHS/MSC/MKK - LR*5.2*1038
 ;
 D PRESSKEY^BLRGMENU(9)
 Q
 ;
SCRNINIT ; EP - DEBUG -- Initialization of variables
 D OTHRINIT  Q     ; IHS/MSC/MKK - LR*5.2*1034
 ;
 S HEADER(4)=$$CJ^XLFSTR("TODAY:"_TODAY_"   ["_$$FMTE^XLFDT(TODAY,"5DZ")_"]",IOM)
 S HEADER(5)=" "
 S HEADER(6)="OPTION"
 S $E(HEADER(6),26)="TASK"
 S $E(HEADER(6),36)="SCHDDATE"
 S $E(HEADER(6),49)="$$FMTE SCHDDATE"
 S $E(HEADER(6),74)="Sched"
 S BLRVERN=$TR($P($T(+1),";")," ")
 S BLRVERN2="SCRNREPT"
 Q
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1034
OTHRINIT ; EP Different version of SCRINIT above
 NEW HED
 ;
 S HED=$O(HEADER("A"),-1)
 ; S HED=HED+1,HEADER(HED)=$$CJ^XLFSTR("TODAY:"_TODAY_"   ["_$$FMTE^XLFDT(TODAY,"5DZ")_"]",IOM)
 S HED=HED+1,HEADER(HED)=$$CJ^XLFSTR("TODAY:"_$$FMTE^XLFDT(TODAY,"5DZ")_"   ["_TODAY_"]",IOM) ; IHS/MSC/MKK - LR*5.2*1038
 S HED=HED+1,HEADER(HED)=" "
 S HED=HED+1,HEADER(HED)="OPTION"
 ; S $E(HEADER(HED),26)="TASK"
 S $E(HEADER(6),26)="TASK #"                ; IHS/MSC/MKK - LR*5.2*1038
 S $E(HEADER(HED),36)="SCHDDATE"
 ; S $E(HEADER(HED),49)="$$FMTE SCHDDATE"
 S $E(HEADER(HED),50)="$$FMTE SCHDDATE"     ; IHS/MSC/MKK - LR*5.2*1038
 S $E(HEADER(HED),74)="Sched"
 S BLRVERN=$TR($P($T(+1),";")," ")
 S BLRVERN2="SCRNREPT"
 Q
 ; ----- END IHS/MSC/MKK - LR*5.2*1034
 ;
SCRNLINE ; EP - DEBUG -- Print line of data
 D SCRNBRKO
 ;
 I CNT<1 D HEADERDT^BLRGMENU
 W OPTION,?25,TASK,?35,SCHDDATE,?49,EXTSCHDT,?74,HOWOFTEN
 W !
 S CNT=CNT+1
 Q
 ;
SCRNBRKO ; EP - DEBUG -- "Break out" Variables
 S CHKOPT=OPTION
 K ROOT  ; IHS/MSC/MKK - LR*5.2*1038
 D OPTSTAT^XUTMOPT(CHKOPT,.ROOT)
 S TASK=$P($G(ROOT(1)),"^")
 S SCHDDATE=+$P($P($G(ROOT(1)),"^",2),"@")
 S EXTSCHDT=$$UP^XLFSTR($$FMTE^XLFDT(SCHDDATE,"5MPZ"))
 S HOWOFTEN=$P($G(ROOT(1)),"^",3)
 Q
 ; ----- END IHS/MSC/MKK - LR*5.1*1033
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.1*1038
HLZTCPCK ; EP - Check to see if HLZTCP interface routine is running
 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
 ;
 ; Setup SYSTEM call
 S SYSCALL="##class(%SYS.ProcessQuery).%OpenId(PID)."
 ;
 ; Setup Cache Objects to retrieve PIDs of jobs
 S RSET=##class(%ResultSet).%New("%SYS.ProcessQuery:ListPids")
 D RSET.Execute()
 ;
 S (HLZTCP,RTNCNT)=0
 ;
 ; Loop through PIDs
 F  Q:'RSET.Next()!(HLZTCP)  D
 . S PID=RSET.GetData(1)
 . Q:PID<1
 . ;
 . ; Only analyze routines running on the current UCI.
 . Q:$$GETSYS("NameSpace")'=$NAMESPACE
 . ;
 . S RTN=$$GETSYS("Routine")
 . S:RTN'["NOJOBRTN" RTNCNT=RTNCNT+1
 . ;
 . S:RTN["HLZTCP" HLZTCP=PID
 ;
 ; W:HLZTCP<1 !,$$CJ^XLFSTR(RTNCNT_" Routines analyzed.",IOM)
 W !,$$CJ^XLFSTR("HLZTCP is"_$S(HLZTCP:"",1:" >> NOT <<")_" running.",IOM)
 Q
 ;
GETSYS(WOTDETAIL) ; EP -- Get System Information
 	S GETWOT=SYSCALL_WOTDETAIL_"Get()"
 Q @GETWOT
 ;
 ;
TESTGPID ; EP - Test the 'Get PID' code by looking at LAB routines ONLY
 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
 ;
 S HEADER(1)="%SYS.ProcessQuery:ListPids"
 S HEADER(2)="Testing RSET.Next() Looping"
 D HEADERDT^BLRGMENU
 ;
 S HEADER(3)=$$CJ^XLFSTR("LAB Routines ONLY",IOM)
 S HEADER(4)=" "
 S $E(HEADER(5),15)="PID"
 S $E(HEADER(5),25)="UCI"
 S $E(HEADER(5),35)="Routine"
 ;
 ; Setup SYSTEM call
 S SYSCALL="##class(%SYS.ProcessQuery).%OpenId(PID)."
 ;
 S RSET=##class(%ResultSet).%New("%SYS.ProcessQuery:ListPids")
 D RSET.Execute()
 S (HLZTCP,LABCNT,RTNCNT)=0
 ;
 F  Q:'RSET.Next()!(HLZTCP)  D
 . S PID=RSET.GetData(1)
 . Q:PID<1
 . ;
 . S UCI=$$GETSYS("NameSpace")
 . ;
 . S RTN=$$GETSYS("Routine")
 . S RTNCNT=RTNCNT+1
 . Q:$E(RTN,1,3)'="BLR"&($E(RTN,1,2)'="LA")&($E(RTN,1,2)'="LR")
 . ;
 . S LABCNT=LABCNT+1
 . D:LABCNT=1 HEADERDT^BLRGMENU
 . W ?4,$J(LABCNT,3),")",?14,PID,?24,UCI,?34,RTN,!
 ;
 I LABCNT<1 D
 . F X=3:1:5 K HEADER(X)
 . D HEADERDT^BLRGMENU
 ;
 W !,?4,RTNCNT," Routines analyzed."
 W !!,?9,$S(LABCNT:LABCNT,1:"No")," LAB routine",$S(LABCNT=1:"",1:"s")," running."
 D PRESSKEY^BLRGMENU(4)
 Q
 ; ----- END IHS/MSC/MKK - LR*5.1*1038