KMPSUTL1 ;OAK/KAK - SAGG Utilities ;9/1/2015
;;2.0;SAGG PROJECT;**1**;Jul 02, 2007;Build 67
;
MPLTF() ;-- returns the type of M platform
;---------------------------------------------------------------------
; Returns: CVMS for Cache for OpenVMS platform
; CWINNT for Cache for Windows NT platform
;---------------------------------------------------------------------
;
N MPLTF,ZV
;
S ZV=$$OS^%ZOSV ; IA# 10097
S MPLTF=$S(ZV["VMS":"CVMS",ZV["UNIX":"CUNIX",ZV["NT":"CWINNT",1:"UNK")
Q MPLTF
;
TSKSTAT(OPT) ;-- status of scheduled task option
;---------------------------------------------------------------------
; input OPT = option name
; output RTN = status code^literal condition
; ...^scheduled date@time (day)^numeric day-of-week
; ...^expanded scheduled frequency^short form frequency
; ...^task id^queued by^user status
;
; where status code^condition:
; = 0^SCHEDULED
; = 1^NOT SCHEDULED and 'scheduled date@time' will
; be UNKNOWN and 'numeric day of week' will be -1
; = 2^NOT RESCHEDULED
; = 3^MISSING when OPT does not exist
; = 9^UNKNOWN
;
; where user status = ACTIVE or NOT ACTIVE
;---------------------------------------------------------------------
;
N ACTV,DA,DAY,DOW,FREQ,RTN,TSK,TSKINFO,USER,Y
;
S (DOW,FREQ)=-1
S RTN="9^UNKNOWN^NO DATE^-1^UNKNOWN^^^UNKNOWN^NOT ACTIVE"
;
I '$D(^DIC(19,"B",OPT)) S $P(RTN,U,1,2)="3^MISSING" Q RTN
S DA=$O(^DIC(19,"B",OPT,0)),DA=+$O(^DIC(19.2,"B",DA,0))
S TSKINFO=$G(^DIC(19.2,DA,0)),(DOW,Y)=$P(TSKINFO,U,2),FREQ=$P(TSKINFO,U,6)
S:+Y $P(TSKINFO,U,2)=$$FMTE^XLFDT(Y)
I DOW'="" S DAY=$$DOW^XLFDT(DOW),DOW=$$DOW^XLFDT(DOW,1)
S TSK=+$G(^DIC(19.2,+DA,1))
I (DOW="")!(TSK="") S $P(RTN,U,1,2)="1^NOT SCHEDULED"
E D
.S $P(RTN,U,1,2)="0^SCHEDULED"
.I FREQ="" S $P(RTN,U,1,2)="2^NOT RESCHEDULED"
.; queued to run at
.S $P(RTN,U,3,4)=$S($P(TSKINFO,U,2)="":"NO DATE",1:$P(TSKINFO,U,2))_$S($D(DAY):" ("_DAY_")",1:"")_U_DOW
; rescheduling frequency
I FREQ?1.3N1A D
.S $P(RTN,U,5,6)=+FREQ_" "_$S(FREQ["D":"day",FREQ["M":"month",1:FREQ)_$S(+FREQ>1:"s",1:"")_U_FREQ
E S $P(RTN,U,5,6)=$S(FREQ="":"UNKNOWN",1:FREQ)_U_FREQ
; task id
S $P(RTN,U,7)=TSK
; find if the user is active
I TSK D
.S TSKINFO=$G(^%ZTSK(TSK,0))
.S USER=+$P(TSKINFO,U,3)
.S ACTV=+$$ACTIVE^XUSER(USER)
.; queued by
.S $P(RTN,U,8)=$P($G(^VA(200,USER,0)),U)
I $G(ACTV) S $P(RTN,U,9)="ACTIVE"
Q RTN
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPSUTL1 2570 printed Sep 15, 2024@21:06:08 Page 2
KMPSUTL1 ;OAK/KAK - SAGG Utilities ;9/1/2015
+1 ;;2.0;SAGG PROJECT;**1**;Jul 02, 2007;Build 67
+2 ;
MPLTF() ;-- returns the type of M platform
+1 ;---------------------------------------------------------------------
+2 ; Returns: CVMS for Cache for OpenVMS platform
+3 ; CWINNT for Cache for Windows NT platform
+4 ;---------------------------------------------------------------------
+5 ;
+6 NEW MPLTF,ZV
+7 ;
+8 ; IA# 10097
SET ZV=$$OS^%ZOSV
+9 SET MPLTF=$SELECT(ZV["VMS":"CVMS",ZV["UNIX":"CUNIX",ZV["NT":"CWINNT",1:"UNK")
+10 QUIT MPLTF
+11 ;
TSKSTAT(OPT) ;-- status of scheduled task option
+1 ;---------------------------------------------------------------------
+2 ; input OPT = option name
+3 ; output RTN = status code^literal condition
+4 ; ...^scheduled date@time (day)^numeric day-of-week
+5 ; ...^expanded scheduled frequency^short form frequency
+6 ; ...^task id^queued by^user status
+7 ;
+8 ; where status code^condition:
+9 ; = 0^SCHEDULED
+10 ; = 1^NOT SCHEDULED and 'scheduled date@time' will
+11 ; be UNKNOWN and 'numeric day of week' will be -1
+12 ; = 2^NOT RESCHEDULED
+13 ; = 3^MISSING when OPT does not exist
+14 ; = 9^UNKNOWN
+15 ;
+16 ; where user status = ACTIVE or NOT ACTIVE
+17 ;---------------------------------------------------------------------
+18 ;
+19 NEW ACTV,DA,DAY,DOW,FREQ,RTN,TSK,TSKINFO,USER,Y
+20 ;
+21 SET (DOW,FREQ)=-1
+22 SET RTN="9^UNKNOWN^NO DATE^-1^UNKNOWN^^^UNKNOWN^NOT ACTIVE"
+23 ;
+24 IF '$DATA(^DIC(19,"B",OPT))
SET $PIECE(RTN,U,1,2)="3^MISSING"
QUIT RTN
+25 SET DA=$ORDER(^DIC(19,"B",OPT,0))
SET DA=+$ORDER(^DIC(19.2,"B",DA,0))
+26 SET TSKINFO=$GET(^DIC(19.2,DA,0))
SET (DOW,Y)=$PIECE(TSKINFO,U,2)
SET FREQ=$PIECE(TSKINFO,U,6)
+27 if +Y
SET $PIECE(TSKINFO,U,2)=$$FMTE^XLFDT(Y)
+28 IF DOW'=""
SET DAY=$$DOW^XLFDT(DOW)
SET DOW=$$DOW^XLFDT(DOW,1)
+29 SET TSK=+$GET(^DIC(19.2,+DA,1))
+30 IF (DOW="")!(TSK="")
SET $PIECE(RTN,U,1,2)="1^NOT SCHEDULED"
+31 IF '$TEST
Begin DoDot:1
+32 SET $PIECE(RTN,U,1,2)="0^SCHEDULED"
+33 IF FREQ=""
SET $PIECE(RTN,U,1,2)="2^NOT RESCHEDULED"
+34 ; queued to run at
+35 SET $PIECE(RTN,U,3,4)=$SELECT($PIECE(TSKINFO,U,2)="":"NO DATE",1:$PIECE(TSKINFO,U,2))_$SELECT($DATA(DAY):" ("_DAY_")",1:"")_U_DOW
End DoDot:1
+36 ; rescheduling frequency
+37 IF FREQ?1.3N1A
Begin DoDot:1
+38 SET $PIECE(RTN,U,5,6)=+FREQ_" "_$SELECT(FREQ["D":"day",FREQ["M":"month",1:FREQ)_$SELECT(+FREQ>1:"s",1:"")_U_FREQ
End DoDot:1
+39 IF '$TEST
SET $PIECE(RTN,U,5,6)=$SELECT(FREQ="":"UNKNOWN",1:FREQ)_U_FREQ
+40 ; task id
+41 SET $PIECE(RTN,U,7)=TSK
+42 ; find if the user is active
+43 IF TSK
Begin DoDot:1
+44 SET TSKINFO=$GET(^%ZTSK(TSK,0))
+45 SET USER=+$PIECE(TSKINFO,U,3)
+46 SET ACTV=+$$ACTIVE^XUSER(USER)
+47 ; queued by
+48 SET $PIECE(RTN,U,8)=$PIECE($GET(^VA(200,USER,0)),U)
End DoDot:1
+49 IF $GET(ACTV)
SET $PIECE(RTN,U,9)="ACTIVE"
+50 QUIT RTN