A5PLIST ;SLC/RJS-Display Due and Overdue patches in account from imported data; 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 !!," Build Uninstalled Patch list by release date.. "
;
S D0=0 F S D0=$O(^A5PATCH("EXLIST",D0)) Q:'D0 D
.S REC=$G(^A5PATCH("EXLIST",D0))
.Q:'$L(REC)
.S PATCH=$P(REC,"^",1)
.S SEQ=$P(REC,"^",5)
.S PNAME=$P(REC,"^",8)
.S ^TMP($J,"PLIST",PNAME)=1
.S RELEASE=$P(REC,"^",2)
.S INSTALL=$O(^TMP($J,"INSTALL",PNAME,RELEASE))
.Q:INSTALL
.S ^TMP($J,"PREL",RELEASE,$P(PNAME,"*",1),+SEQ,PNAME)=REC
;
S D0=0 F S D0=$O(^XPD(9.9,D0)) Q:'D0 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)
.Q:$G(^TMP($J,"PLIST",PNAME))
.S RELEASE=$P(REC,"^",2)
.S INSTALL=$P(REC,"^",11,12)
.Q:INSTALL
.S INSTALL=$O(^TMP($J,"INSTALL",PNAME,RELEASE))
.Q:INSTALL
.S ^TMP($J,"PREL",RELEASE,$P(PNAME,"*",1),+SEQ,PNAME)=REC
;
; Print Report
;
S D0="" F S D0=$O(^TMP($J,"PREL",D0)) Q:'$L(D0) D
.W !!,$$DATE(D0),!
.S D1="" F S D1=$O(^TMP($J,"PREL",D0,D1)) Q:'$L(D1) D
..S D2="" F S D2=$O(^TMP($J,"PREL",D0,D1,D2)) Q:'$L(D2) D
...S D3="" F S D3=$O(^TMP($J,"PREL",D0,D1,D2,D3)) Q:'$L(D3) D
....S REC=$G(^TMP($J,"PREL",D0,D1,D2,D3))
....Q:'$L(REC)
....S PATCH=$P(REC,"^",1)
....S SEQ=$P(REC,"^",5)
....S DESC=$P(REC,"^",7)
....S PNAME=$P(REC,"^",8)
....S RELEASE=$P(REC,"^",2)
....S COMPLY=$P(REC,"^",9)
....S INSTALL=$P(REC,"^",11,12)
....W !,?5,PNAME,$$PAD(12-$L(PNAME))," SEQ# ",SEQ,?30,DESC
;
Q
;
EXPORT ;
;
K ^TMP($J)
S TODAY=$$DAYS(DT)
S NMSP=^%ZOSF("PROD")
;
W !,"K ^A5PATCH(""EXLIST"")"
;
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 RELEASE=$P(REC,"^",2)
.;Q:(RELEASE<3150101)
.S $P(REC,"^",4)=""
.S $P(REC,"^",11)=""
.S $P(REC,"^",12)=""
.U $I:130 W !,"S ^A5PATCH(""EXLIST"","_D0_")="""_REC_""""
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[HA5PLIST 3927 printed Dec 13, 2024@01:38:38 Page 2
A5PLIST ;SLC/RJS-Display Due and Overdue patches in account from imported data; 12/10/2015
+1 ;class3
S ;
+1 ;
+2 KILL ^TMP($JOB)
+3 SET TODAY=$$DAYS(DT)
+4 SET NMSP=^%ZOSF("PROD")
+5 ;
+6 ;
+7 ;
+8 WRITE !!," Scanning Install File for installed patches... "
+9 ;
+10 SET D0=0
FOR
SET D0=$ORDER(^XPD(9.7,D0))
if 'D0
QUIT
Begin DoDot:1
+11 SET PNAME=$PIECE($GET(^XPD(9.7,D0,0)),"^",1)
+12 if '(PNAME["*")
QUIT
+13 SET INDATE=$PIECE($GET(^XPD(9.7,D0,1)),"^",3)
+14 SET INUSER=$PIECE($GET(^XPD(9.7,D0,0)),"^",11)
+15 SET COMMENT=$GET(^XPD(9.7,D0,2))
+16 if '(COMMENT["SEQ")
QUIT
+17 SET SEQ="SEQ"_$PIECE(COMMENT,"SEQ",2)
+18 SET PNAME=$$UPCASE(PNAME)
+19 SET ^TMP($JOB,"INSTALL",PNAME,+INDATE)=INUSER
End DoDot:1
+20 ;
+21 WRITE !!," Scanning Package File for installed patches..."
+22 ;
+23 SET D0=0
FOR
SET D0=$ORDER(^DIC(9.4,D0))
if 'D0
QUIT
Begin DoDot:1
+24 SET PACK=$PIECE($GET(^DIC(9.4,D0,0)),"^",2)
if '$LENGTH(PACK)
QUIT
+25 SET D1=0
FOR
SET D1=$ORDER(^DIC(9.4,D0,22,D1))
if 'D1
QUIT
Begin DoDot:2
+26 SET VERS=$PIECE($GET(^DIC(9.4,D0,22,D1,0)),"^",1)
if '$LENGTH(VERS)
QUIT
+27 SET D2=0
FOR
SET D2=$ORDER(^DIC(9.4,D0,22,D1,"PAH",D2))
if 'D2
QUIT
Begin DoDot:3
+28 SET NODE0=$GET(^DIC(9.4,D0,22,D1,"PAH",D2,0))
+29 SET PATCH=$$UPCASE(PACK_"*"_VERS_"*"_$PIECE(NODE0,"^",1))
+30 SET PATCH=$PIECE(PATCH," ",1)
+31 if $ORDER(^TMP($JOB,"INSTALL",PATCH,0))
QUIT
+32 SET DATE=$PIECE(NODE0,"^",2)
if 'DATE
QUIT
+33 IF '(DATE[".")
SET DATE=DATE+.0001
+34 SET USER=$PIECE(NODE0,"^",3)
+35 SET ^TMP($JOB,"INSTALL",PATCH,DATE)=USER
End DoDot:3
End DoDot:2
End DoDot:1
+36 ;
+37 ;
+38 WRITE !!," Build Uninstalled Patch list by release date.. "
+39 ;
+40 SET D0=0
FOR
SET D0=$ORDER(^A5PATCH("EXLIST",D0))
if 'D0
QUIT
Begin DoDot:1
+41 SET REC=$GET(^A5PATCH("EXLIST",D0))
+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 ^TMP($JOB,"PLIST",PNAME)=1
+47 SET RELEASE=$PIECE(REC,"^",2)
+48 SET INSTALL=$ORDER(^TMP($JOB,"INSTALL",PNAME,RELEASE))
+49 if INSTALL
QUIT
+50 SET ^TMP($JOB,"PREL",RELEASE,$PIECE(PNAME,"*",1),+SEQ,PNAME)=REC
End DoDot:1
+51 ;
+52 SET D0=0
FOR
SET D0=$ORDER(^XPD(9.9,D0))
if 'D0
QUIT
Begin DoDot:1
+53 SET REC=$GET(^XPD(9.9,D0,0))
+54 if '$LENGTH(REC)
QUIT
+55 SET PATCH=$PIECE(REC,"^",1)
+56 SET SEQ=$PIECE(REC,"^",5)
+57 SET PNAME=$PIECE(REC,"^",8)
+58 if $GET(^TMP($JOB,"PLIST",PNAME))
QUIT
+59 SET RELEASE=$PIECE(REC,"^",2)
+60 SET INSTALL=$PIECE(REC,"^",11,12)
+61 if INSTALL
QUIT
+62 SET INSTALL=$ORDER(^TMP($JOB,"INSTALL",PNAME,RELEASE))
+63 if INSTALL
QUIT
+64 SET ^TMP($JOB,"PREL",RELEASE,$PIECE(PNAME,"*",1),+SEQ,PNAME)=REC
End DoDot:1
+65 ;
+66 ; Print Report
+67 ;
+68 SET D0=""
FOR
SET D0=$ORDER(^TMP($JOB,"PREL",D0))
if '$LENGTH(D0)
QUIT
Begin DoDot:1
+69 WRITE !!,$$DATE(D0),!
+70 SET D1=""
FOR
SET D1=$ORDER(^TMP($JOB,"PREL",D0,D1))
if '$LENGTH(D1)
QUIT
Begin DoDot:2
+71 SET D2=""
FOR
SET D2=$ORDER(^TMP($JOB,"PREL",D0,D1,D2))
if '$LENGTH(D2)
QUIT
Begin DoDot:3
+72 SET D3=""
FOR
SET D3=$ORDER(^TMP($JOB,"PREL",D0,D1,D2,D3))
if '$LENGTH(D3)
QUIT
Begin DoDot:4
+73 SET REC=$GET(^TMP($JOB,"PREL",D0,D1,D2,D3))
+74 if '$LENGTH(REC)
QUIT
+75 SET PATCH=$PIECE(REC,"^",1)
+76 SET SEQ=$PIECE(REC,"^",5)
+77 SET DESC=$PIECE(REC,"^",7)
+78 SET PNAME=$PIECE(REC,"^",8)
+79 SET RELEASE=$PIECE(REC,"^",2)
+80 SET COMPLY=$PIECE(REC,"^",9)
+81 SET INSTALL=$PIECE(REC,"^",11,12)
+82 WRITE !,?5,PNAME,$$PAD(12-$LENGTH(PNAME))," SEQ# ",SEQ,?30,DESC
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+83 ;
+84 QUIT
+85 ;
EXPORT ;
+1 ;
+2 KILL ^TMP($JOB)
+3 SET TODAY=$$DAYS(DT)
+4 SET NMSP=^%ZOSF("PROD")
+5 ;
+6 WRITE !,"K ^A5PATCH(""EXLIST"")"
+7 ;
+8 SET D0=0
FOR
SET D0=$ORDER(^XPD(9.9,D0))
if 'D0
QUIT
USE $IO:132
Begin DoDot:1
+9 SET REC=$GET(^XPD(9.9,D0,0))
+10 if '$LENGTH(REC)
QUIT
+11 SET RELEASE=$PIECE(REC,"^",2)
+12 ;Q:(RELEASE<3150101)
+13 SET $PIECE(REC,"^",4)=""
+14 SET $PIECE(REC,"^",11)=""
+15 SET $PIECE(REC,"^",12)=""
+16 USE $IO:130
WRITE !,"S ^A5PATCH(""EXLIST"","_D0_")="""_REC_""""
End DoDot:1
+17 QUIT
+18 ;
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 ;