A5PREP ;SLC/RJS-Display Due and Overdue patches in account ; 12/10/2015
;class3
S ;
K ^TMP($J)
S TODAY=$$DAYS(DT)
S NMSP=^%ZOSF("PROD")
;
;
;
W !!," Scanning Install File for installed patches... "
;
S D0=0 F S D0=$O(^XPD(9.7,D0)) Q:'D0 D
.S PNAME=$P($G(^XPD(9.7,D0,0)),"^",1)
.Q:'(PNAME["*")
.S INDATE=$P($G(^XPD(9.7,D0,1)),"^",3)
.S INUSER=$P($G(^XPD(9.7,D0,0)),"^",11)
.S COMMENT=$G(^XPD(9.7,D0,2))
.Q:'(COMMENT["SEQ")
.S SEQ="SEQ"_$P(COMMENT,"SEQ",2)
.S PNAME=$$UPCASE(PNAME)
.S ^TMP($J,"INSTALL",PNAME,+INDATE)=INUSER
;
W !!," Scanning Package File for installed patches..."
;
S D0=0 F S D0=$O(^DIC(9.4,D0)) Q:'D0 D
.S PACK=$P($G(^DIC(9.4,D0,0)),"^",2) Q:'$L(PACK)
.S D1=0 F S D1=$O(^DIC(9.4,D0,22,D1)) Q:'D1 D
..S VERS=$P($G(^DIC(9.4,D0,22,D1,0)),"^",1) Q:'$L(VERS)
..S D2=0 F S D2=$O(^DIC(9.4,D0,22,D1,"PAH",D2)) Q:'D2 D
...S NODE0=$G(^DIC(9.4,D0,22,D1,"PAH",D2,0))
...S PATCH=$$UPCASE(PACK_"*"_VERS_"*"_$P(NODE0,"^",1))
...S PATCH=$P(PATCH," ",1)
...Q:$O(^TMP($J,"INSTALL",PATCH,0))
...S DATE=$P(NODE0,"^",2) Q:'DATE
...I '(DATE[".") S DATE=DATE+.0001
...S USER=$P(NODE0,"^",3)
...S ^TMP($J,"INSTALL",PATCH,DATE)=USER
;
;
W !!," Scanning Patch Monitor File... "
;
;
S D0=0 F S D0=$O(^XPD(9.9,D0)) Q:'D0 U $I:132 D
.S REC=$G(^XPD(9.9,D0,0))
.Q:'$L(REC)
.S PATCH=$P(REC,"^",1)
.S SEQ=$P(REC,"^",5)
.S PNAME=$P(REC,"^",8)
.S RELEASE=$P(REC,"^",2)
.S COMPLY=$P(REC,"^",9)
.S INSTALL=$P(REC,"^",11,12)
.I 'INSTALL S INSTALL=$O(^TMP($J,"INSTALL",PNAME,RELEASE)) I INSTALL S INSTALL=INSTALL_"^"_^TMP($J,"INSTALL",PNAME,INSTALL)
.S FLAG=0
.I ((TODAY-$$DAYS(RELEASE))<60) S FLAG=1
.I 'INSTALL S FLAG=1
.I '(NMSP="SCG"),((TODAY-$$DAYS(RELEASE))>90) S FLAG=0
.I (NMSP="SCG"),((TODAY-$$DAYS(COMPLY))>90) S FLAG=0
.Q:'FLAG
.S WARNING=" "
.I '(NMSP="SCG") S OVER=(TODAY-$$DAYS(RELEASE)) I 'INSTALL,(OVER>(-1)) S WARNING=" Due "
.I '(NMSP="SCG") S OVER=(TODAY-$$DAYS(RELEASE)) I 'INSTALL,(OVER>3) S WARNING="Overdue "
.I (NMSP="SCG") S OVER=(TODAY-$$DAYS(COMPLY)) I 'INSTALL,(OVER>(-1)) S WARNING=" Due "
.I (NMSP="SCG") S OVER=(TODAY-$$DAYS(COMPLY)) I 'INSTALL,(OVER>3) S WARNING="Overdue "
.S OUT=""
.s OUT=OUT_WARNING
.S OUT=OUT_" "
.S OUT=OUT_PNAME_" SEQ #"_SEQ
.S OUT=OUT_" "
.S OUT=OUT_$$PAD(40-$L(OUT))
.S OUT=OUT_$J($$DATE(RELEASE),10)
.S OUT=OUT_" "
.S OUT=OUT_$J($$DATE(COMPLY),10)
.S OUT=OUT_" "
.S OUT=OUT_$$INSTALL(INSTALL)
.S ^TMP($J,"REPORT",$P(PNAME,"*",1,2)_"*"_SEQ)=OUT
;
W !!,"Namespace: ",NMSP
W !!," Patch Released Compliance Install User"
;
S PID="" F S PPID=PID,PID=$O(^TMP($J,"REPORT",PID)) Q:'$L(PID) D
.S TEXT=^TMP($J,"REPORT",PID)
.I '($P(PID,"*",1)=$P(PPID,"*",1)) W !
.W !,TEXT
;
W !!!
Q
;
PAD(X) ;
N Y,Z
S Y=""
F Z=1:1:X S Y=Y_" "
Q Y
;
INSTALL(X) ;
;
N INSTALL,TIME,USER
S INSTALL=""
I X D
.S TIME=$$DATE($P(X,"^",1))
.S USER=$$USER(+$P(X,"^",2))
.S INSTALL=$J(TIME,10)_" "_USER
Q INSTALL
;
USER(X) ;
;
N USER
S USER=$P($G(^VA(200,X,0)),"^",1)
S:'$L(USER) USER=" Unknown"
;
Q USER
;
DAYS(X) Q ($E(X,1,3)*365)+($E(X,4,5)*30)+($E(X,6,7))
;
DATE(X) ;
N DAY,TIME
Q:'X ""
S DAY=$P(X,".",1)
S DAY=$E(DAY,4,5)_"/"_$E(DAY,6,7)_"/"_($E(DAY,1,3)+1700)
S TIME=$P(X,".",2)
I TIME S TIME=$E(TIME_"000000",1,6),TIME=$E(TIME,1,2)_":"_$E(TIME,3,4)_"."_$E(TIME,5,6)
Q DAY
;
UPCASE(X) Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
;
ZP ;
;
W !!
S TEXT="" F LINE=1:1:9999 D Q:'$L(TEXT)
.S TEXT=$T(+LINE)
.W !,$P(TEXT," ",1)_$C(126)_$P(TEXT," ",2,$L(TEXT," "))
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HA5PREP 3722 printed Dec 13, 2024@01:38:39 Page 2
A5PREP ;SLC/RJS-Display Due and Overdue patches in account ; 12/10/2015
+1 ;class3
S ;
+1 KILL ^TMP($JOB)
+2 SET TODAY=$$DAYS(DT)
+3 SET NMSP=^%ZOSF("PROD")
+4 ;
+5 ;
+6 ;
+7 WRITE !!," Scanning Install File for installed patches... "
+8 ;
+9 SET D0=0
FOR
SET D0=$ORDER(^XPD(9.7,D0))
if 'D0
QUIT
Begin DoDot:1
+10 SET PNAME=$PIECE($GET(^XPD(9.7,D0,0)),"^",1)
+11 if '(PNAME["*")
QUIT
+12 SET INDATE=$PIECE($GET(^XPD(9.7,D0,1)),"^",3)
+13 SET INUSER=$PIECE($GET(^XPD(9.7,D0,0)),"^",11)
+14 SET COMMENT=$GET(^XPD(9.7,D0,2))
+15 if '(COMMENT["SEQ")
QUIT
+16 SET SEQ="SEQ"_$PIECE(COMMENT,"SEQ",2)
+17 SET PNAME=$$UPCASE(PNAME)
+18 SET ^TMP($JOB,"INSTALL",PNAME,+INDATE)=INUSER
End DoDot:1
+19 ;
+20 WRITE !!," Scanning Package File for installed patches..."
+21 ;
+22 SET D0=0
FOR
SET D0=$ORDER(^DIC(9.4,D0))
if 'D0
QUIT
Begin DoDot:1
+23 SET PACK=$PIECE($GET(^DIC(9.4,D0,0)),"^",2)
if '$LENGTH(PACK)
QUIT
+24 SET D1=0
FOR
SET D1=$ORDER(^DIC(9.4,D0,22,D1))
if 'D1
QUIT
Begin DoDot:2
+25 SET VERS=$PIECE($GET(^DIC(9.4,D0,22,D1,0)),"^",1)
if '$LENGTH(VERS)
QUIT
+26 SET D2=0
FOR
SET D2=$ORDER(^DIC(9.4,D0,22,D1,"PAH",D2))
if 'D2
QUIT
Begin DoDot:3
+27 SET NODE0=$GET(^DIC(9.4,D0,22,D1,"PAH",D2,0))
+28 SET PATCH=$$UPCASE(PACK_"*"_VERS_"*"_$PIECE(NODE0,"^",1))
+29 SET PATCH=$PIECE(PATCH," ",1)
+30 if $ORDER(^TMP($JOB,"INSTALL",PATCH,0))
QUIT
+31 SET DATE=$PIECE(NODE0,"^",2)
if 'DATE
QUIT
+32 IF '(DATE[".")
SET DATE=DATE+.0001
+33 SET USER=$PIECE(NODE0,"^",3)
+34 SET ^TMP($JOB,"INSTALL",PATCH,DATE)=USER
End DoDot:3
End DoDot:2
End DoDot:1
+35 ;
+36 ;
+37 WRITE !!," Scanning Patch Monitor File... "
+38 ;
+39 ;
+40 SET D0=0
FOR
SET D0=$ORDER(^XPD(9.9,D0))
if 'D0
QUIT
USE $IO:132
Begin DoDot:1
+41 SET REC=$GET(^XPD(9.9,D0,0))
+42 if '$LENGTH(REC)
QUIT
+43 SET PATCH=$PIECE(REC,"^",1)
+44 SET SEQ=$PIECE(REC,"^",5)
+45 SET PNAME=$PIECE(REC,"^",8)
+46 SET RELEASE=$PIECE(REC,"^",2)
+47 SET COMPLY=$PIECE(REC,"^",9)
+48 SET INSTALL=$PIECE(REC,"^",11,12)
+49 IF 'INSTALL
SET INSTALL=$ORDER(^TMP($JOB,"INSTALL",PNAME,RELEASE))
IF INSTALL
SET INSTALL=INSTALL_"^"_^TMP($JOB,"INSTALL",PNAME,INSTALL)
+50 SET FLAG=0
+51 IF ((TODAY-$$DAYS(RELEASE))<60)
SET FLAG=1
+52 IF 'INSTALL
SET FLAG=1
+53 IF '(NMSP="SCG")
IF ((TODAY-$$DAYS(RELEASE))>90)
SET FLAG=0
+54 IF (NMSP="SCG")
IF ((TODAY-$$DAYS(COMPLY))>90)
SET FLAG=0
+55 if 'FLAG
QUIT
+56 SET WARNING=" "
+57 IF '(NMSP="SCG")
SET OVER=(TODAY-$$DAYS(RELEASE))
IF 'INSTALL
IF (OVER>(-1))
SET WARNING=" Due "
+58 IF '(NMSP="SCG")
SET OVER=(TODAY-$$DAYS(RELEASE))
IF 'INSTALL
IF (OVER>3)
SET WARNING="Overdue "
+59 IF (NMSP="SCG")
SET OVER=(TODAY-$$DAYS(COMPLY))
IF 'INSTALL
IF (OVER>(-1))
SET WARNING=" Due "
+60 IF (NMSP="SCG")
SET OVER=(TODAY-$$DAYS(COMPLY))
IF 'INSTALL
IF (OVER>3)
SET WARNING="Overdue "
+61 SET OUT=""
+62 SET OUT=OUT_WARNING
+63 SET OUT=OUT_" "
+64 SET OUT=OUT_PNAME_" SEQ #"_SEQ
+65 SET OUT=OUT_" "
+66 SET OUT=OUT_$$PAD(40-$LENGTH(OUT))
+67 SET OUT=OUT_$JUSTIFY($$DATE(RELEASE),10)
+68 SET OUT=OUT_" "
+69 SET OUT=OUT_$JUSTIFY($$DATE(COMPLY),10)
+70 SET OUT=OUT_" "
+71 SET OUT=OUT_$$INSTALL(INSTALL)
+72 SET ^TMP($JOB,"REPORT",$PIECE(PNAME,"*",1,2)_"*"_SEQ)=OUT
End DoDot:1
+73 ;
+74 WRITE !!,"Namespace: ",NMSP
+75 WRITE !!," Patch Released Compliance Install User"
+76 ;
+77 SET PID=""
FOR
SET PPID=PID
SET PID=$ORDER(^TMP($JOB,"REPORT",PID))
if '$LENGTH(PID)
QUIT
Begin DoDot:1
+78 SET TEXT=^TMP($JOB,"REPORT",PID)
+79 IF '($PIECE(PID,"*",1)=$PIECE(PPID,"*",1))
WRITE !
+80 WRITE !,TEXT
End DoDot:1
+81 ;
+82 WRITE !!!
+83 QUIT
+84 ;
PAD(X) ;
+1 NEW Y,Z
+2 SET Y=""
+3 FOR Z=1:1:X
SET Y=Y_" "
+4 QUIT Y
+5 ;
INSTALL(X) ;
+1 ;
+2 NEW INSTALL,TIME,USER
+3 SET INSTALL=""
+4 IF X
Begin DoDot:1
+5 SET TIME=$$DATE($PIECE(X,"^",1))
+6 SET USER=$$USER(+$PIECE(X,"^",2))
+7 SET INSTALL=$JUSTIFY(TIME,10)_" "_USER
End DoDot:1
+8 QUIT INSTALL
+9 ;
USER(X) ;
+1 ;
+2 NEW USER
+3 SET USER=$PIECE($GET(^VA(200,X,0)),"^",1)
+4 if '$LENGTH(USER)
SET USER=" Unknown"
+5 ;
+6 QUIT USER
+7 ;
DAYS(X) QUIT ($EXTRACT(X,1,3)*365)+($EXTRACT(X,4,5)*30)+($EXTRACT(X,6,7))
+1 ;
DATE(X) ;
+1 NEW DAY,TIME
+2 if 'X
QUIT ""
+3 SET DAY=$PIECE(X,".",1)
+4 SET DAY=$EXTRACT(DAY,4,5)_"/"_$EXTRACT(DAY,6,7)_"/"_($EXTRACT(DAY,1,3)+1700)
+5 SET TIME=$PIECE(X,".",2)
+6 IF TIME
SET TIME=$EXTRACT(TIME_"000000",1,6)
SET TIME=$EXTRACT(TIME,1,2)_":"_$EXTRACT(TIME,3,4)_"."_$EXTRACT(TIME,5,6)
+7 QUIT DAY
+8 ;
UPCASE(X) QUIT $TRANSLATE(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+1 ;
ZP ;
+1 ;
+2 WRITE !!
+3 SET TEXT=""
FOR LINE=1:1:9999
Begin DoDot:1
+4 SET TEXT=$TEXT(+LINE)
+5 WRITE !,$PIECE(TEXT," ",1)_$CHAR(126)_$PIECE(TEXT," ",2,$LENGTH(TEXT," "))
End DoDot:1
if '$LENGTH(TEXT)
QUIT
+6 QUIT
+7 ;