XTPMSTAT ;OAK/BP - PRINT PATCH STATISTICS BY REPORT GROUP; 2/7/06
;;7.3;TOOLKIT;**98,100**; Apr 25, 1995;Build 4
;
S IOP="HOME" D ^%ZIS K IOP
EN W @IOF,"Patch Monitor Statistics",!!!
W "Please select the REPORTING GROUP. You may select as many groups as you",!
W "wish for each report. Each group will be reported in a separate section.",!!!
K TMP("XTBGRP"),TMP("XTBPKG")
N DIC,DA S DIC(0)="AEQM",DIC="^XPD(9.95," D ^DIC S DA(1)=+Y
I DA(1)>0 N DIC S DIC(0)="AEQM",DIC="^XPD(9.95,DA(1),2," F D ^DIC Q:Y<0 DO
.I $D(TMP("XTBGRP",$P(Y,U,2))) W $C(7),". . . You already have that one" Q
.S TMP("XTBGRP",$P(Y,U,2))=+Y
G:X[U EXIT
G:'$D(TMP("XTBGRP")) EXIT
W !!,"Do you want a new form/screen between REPORTING GROUPS" S %=1 D YN^DICN S XTBPGF=%
;
DATE W ! S %DT="AEP"
S %DT("A")="Enter BEGINNING Compliance date: " D ^%DT G:Y<0 EXIT S XTBBDT=Y X ^DD("DD") S XTBBDT1=Y
S %DT="AE",%DT("A")=" and ENDING Compliance date: " D ^%DT G:Y<0 EXIT S XTBEDT=Y X ^DD("DD") S XTBEDT1=Y
I XTBEDT<XTBBDT W !!,$C(7),"Starting date is later than ending date.",!! H 2 G DATE
;
DEV W !! S %ZIS="AEQ" D ^%ZIS G:POP EXIT
I $D(IO("Q")) S ZTIO=ION,ZTRTN="SORT^XTPMSTAT",ZTSAVE("XTB*")="",ZTSAVE("TMP*")="",ZTDESC="Patch Monitor Statistics" D ^%ZTLOAD D HOME^%ZIS
I $D(ZTSK) W !,"Queued as task #",ZTSK H 2 G EXIT
;
; sort patches by compliance date
SORT U IO F XTBCPLDT=(XTBBDT-.0001):0 S XTBCPLDT=$O(^XPD(9.9,"D",XTBCPLDT)) Q:XTBCPLDT=""!(XTBCPLDT>XTBEDT) DO
.F XTBDA=0:0 S XTBDA=$O(^XPD(9.9,"D",XTBCPLDT,XTBDA)) Q:XTBDA="" DO
..S XTBDTA=$G(^XPD(9.9,XTBDA,0)) Q:XTBDTA=""
..S XTBPTNAM=$P(XTBDTA,U,1),XTBNMSP=$P($P(XTBDTA,U,4)," - ",1) Q:XTBNMSP="" ;parent package missing in file
..S XTBRELDT=$P(XTBDTA,U,2),XTBPRIOR=$P(XTBDTA,U,3)
..S TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM,XTBDA)=XTBRELDT_U_XTBPRIOR
PRINT ; read and print sorted groups
S Y=DT X ^DD("DD") S XTBCURDT=Y
K XTBLINE S $P(XTBLINE,"-",(IOM-2))="-"
S PG=0,XTBGRP="",XTBGRP=$O(TMP("XTBGRP",XTBGRP)) G:XTBGRP="" EXIT D HDR ; first header
S (XTBGRP,XTBNMSP,XTBPTNAM,XTBOLDNM,XTBOLGRP)="",(XTBTPTCH,XTBTLATE)=0
F S XTBGRP=$O(TMP("XTBGRP",XTBGRP)) Q:XTBGRP="" S XTBGPDA=TMP("XTBGRP",XTBGRP) DO Q:$D(XTBOUT)
.; read param file for monitored groups
.F S XTBNMSP=$O(^XPD(9.95,1,2,XTBGPDA,1,"B",XTBNMSP)) Q:XTBNMSP="" I $D(TMP("XTBPKG",XTBNMSP)) DO Q:$D(XTBOUT)
..; read sorted namespaces
..F XTBCPLDT=0:0 S XTBCPLDT=$O(TMP("XTBPKG",XTBNMSP,XTBCPLDT)) Q:XTBCPLDT="" F S XTBPTNAM=$O(TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM)) Q:XTBPTNAM="" DO Q:$D(XTBOUT)
...F XTBDA=0:0 S XTBDA=$O(TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM,XTBDA)) Q:XTBDA="" DO Q:$D(XTBOUT)
....S XTBTPTCH=XTBTPTCH+1
....S XTBDTA=TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM,XTBDA)
....S XTBRELDT=$P(XTBDTA,U),XTBPRIOR=$P(XTBDTA,U,2)
....S XTBRCVDT=$P($G(^XPD(9.9,XTBDA,0)),U,2)
....S XTBPTYPE=$P($G(^XPD(9.9,XTBDA,0)),U,10)
....I +XTBPTYPE=0 S D0=XTBDA D ^XTPMKPCF S XTBINSDT=X K D0
....I +XTBPTYPE=1 S XTBINSDT=$P($G(^XPD(9.9,XTBDA,0)),U,11)
....I XTBINSDT]"" S X1=XTBINSDT,X2=XTBCPLDT D ^%DTC S XTBDAYLT=X
....I XTBINSDT="" S X1=DT,X2=XTBCPLDT D ^%DTC S XTBDAYLT=X
....S XTBGRPHD="Report group: "_XTBGRP
....I XTBOLGRP="",PG=1 W XTBGRPHD,!!
....I XTBOLDNM'="",XTBNMSP'=XTBOLDNM W !
....I XTBOLDNM'="",XTBGRP'=XTBOLGRP,XTBPGF=1 D:IOST?1"C-".E PAUSE Q:$D(XTBOUT) D HDR W XTBGRPHD,!!
....I XTBOLDNM'="",XTBGRP'=XTBOLGRP,XTBPGF=0 W !,XTBGRPHD,!!
....I $Y>(IOSL-6),IOST?1"C-".E D PAUSE Q:$D(XTBOUT) D HDR I XTBGRP'=XTBOLGRP W XTBGRPHD,!!
....S Y=XTBINSDT X ^DD("DD") S XTBINSDT=Y
....S Y=XTBCPLDT X ^DD("DD") S XTBCPLDX=Y
....S Y=XTBRELDT X ^DD("DD") S XTBRELDT=Y
....S XTBPRIOR=$S(XTBPRIOR="m":"Mandatory",XTBPRIOR="e":"Emergency",1:"Unknown")
....W XTBCPLDX,?14,XTBPTNAM,?27,XTBRELDT,?41,XTBINSDT,?55,XTBPRIOR
....I XTBDAYLT>0 W ?67,$J(XTBDAYLT,3,0)_$S(XTBDAYLT>1:" days",1:" day") S XTBTLATE=XTBTLATE+1
....W ! S XTBOLDNM=XTBNMSP,XTBOLGRP=XTBGRP
....I $Y>(IOSL-6),IOST?1"C-".E D PAUSE Q:$D(XTBOUT)
....I $Y>(IOSL-6) D HDR I XTBGRP'=XTBOLGRP W XTBGRPHD,!!
G:$D(XTBOUT) EXIT
I $Y>(IOSL-6),IOST?1"C-".E D HDR
W !!?6,"Totals patches received for date range: ",XTBTPTCH,!
W "Total patches installed past compliance date: ",XTBTLATE,!!
S XTBDIVOK=0 I XTBTPTCH>0 S XTBDIVOK=1
W ?25,"Delinquent patch % : ",$S(XTBDIVOK=1:$J((XTBTLATE/XTBTPTCH*100),6,2),1:0)_" %",!
W ?25," Compliance % : ",$S(XTBDIVOK=1:$J(100-(XTBTLATE/XTBTPTCH*100),6,2),1:0)," %",!
I IOST?1"C-".E K XTBANS W !!,"Press ENTER to end " R XTBANS:DTIME
;
EXIT I IOST?1"C-".E W @IOF,!
D ^%ZISC
K %,%DT,%ZIS,XTBNMSP,XTBANS,XTBBDT,XTBBDT1,XTBCPLDT,XTBCPLDX,XTBDA,XTBEDT,XTBEDT1,XTBDAYLT,TMP
K XTBGRPDA,XTBGRP,XTBINSDT,XTBLINE,XTBNMSP,XTBOLDNM,XTBNMSP,XTBPTNAM,XTBPTYPE,XTBDTA,XTBGPDA
K XTBRCVDT,XTBTLATE,XTBTPTCH,D0,DIC,PG,POP,X,X1,X2,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,%T,%Y,XTBGRPHD
K TMP("XTBGRP"),TMP("XTBPKG"),XTBOUT,XTBPGF,XTBOLGRP,ZTSK,XTBRELDT,XTBPRIOR,XTBCURDT,XTBDIVOK
Q
;
HDR S PG=PG+1 I IOST?1"P-".E,PG>1 W @IOF
I IOST?1"C-".E W @IOF
W XTBCURDT S X="Patch Statistical Report for "_^DD("SITE")
W ?(IOM-$L(X)\2),X,?(IOM-12),"Page: ",PG,!
S X="Date range: "_XTBBDT1_" to "_XTBEDT1 W ?(IOM-$L(X)\2),X,!
W !,"Compliance",?14,"Patch",?27,"Release",?41,"Install",?67,"# Days",!
W "Date",?14,"Number",?27,"Date",?41,"Date",?55,"Priority",?67,"Delinquent",!,XTBLINE,!
Q
;
PAUSE Q:IOST'?1"C-".E
K XTBANS,XTBOUT W !!,"Press ENTER to continue or '^' to end " R XTBANS:DTIME
I XTBANS[U!('$T) S (XTBNMSP,XTBPTNAM,XTBCPLDT,XTBDA)="ZZZZZZ",XTBOUT=1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXTPMSTAT 5590 printed Nov 22, 2024@17:51:34 Page 2
XTPMSTAT ;OAK/BP - PRINT PATCH STATISTICS BY REPORT GROUP; 2/7/06
+1 ;;7.3;TOOLKIT;**98,100**; Apr 25, 1995;Build 4
+2 ;
+3 SET IOP="HOME"
DO ^%ZIS
KILL IOP
EN WRITE @IOF,"Patch Monitor Statistics",!!!
+1 WRITE "Please select the REPORTING GROUP. You may select as many groups as you",!
+2 WRITE "wish for each report. Each group will be reported in a separate section.",!!!
+3 KILL TMP("XTBGRP"),TMP("XTBPKG")
+4 NEW DIC,DA
SET DIC(0)="AEQM"
SET DIC="^XPD(9.95,"
DO ^DIC
SET DA(1)=+Y
+5 IF DA(1)>0
NEW DIC
SET DIC(0)="AEQM"
SET DIC="^XPD(9.95,DA(1),2,"
FOR
DO ^DIC
if Y<0
QUIT
Begin DoDot:1
+6 IF $DATA(TMP("XTBGRP",$PIECE(Y,U,2)))
WRITE $CHAR(7),". . . You already have that one"
QUIT
+7 SET TMP("XTBGRP",$PIECE(Y,U,2))=+Y
End DoDot:1
+8 if X[U
GOTO EXIT
+9 if '$DATA(TMP("XTBGRP"))
GOTO EXIT
+10 WRITE !!,"Do you want a new form/screen between REPORTING GROUPS"
SET %=1
DO YN^DICN
SET XTBPGF=%
+11 ;
DATE WRITE !
SET %DT="AEP"
+1 SET %DT("A")="Enter BEGINNING Compliance date: "
DO ^%DT
if Y<0
GOTO EXIT
SET XTBBDT=Y
XECUTE ^DD("DD")
SET XTBBDT1=Y
+2 SET %DT="AE"
SET %DT("A")=" and ENDING Compliance date: "
DO ^%DT
if Y<0
GOTO EXIT
SET XTBEDT=Y
XECUTE ^DD("DD")
SET XTBEDT1=Y
+3 IF XTBEDT<XTBBDT
WRITE !!,$CHAR(7),"Starting date is later than ending date.",!!
HANG 2
GOTO DATE
+4 ;
DEV WRITE !!
SET %ZIS="AEQ"
DO ^%ZIS
if POP
GOTO EXIT
+1 IF $DATA(IO("Q"))
SET ZTIO=ION
SET ZTRTN="SORT^XTPMSTAT"
SET ZTSAVE("XTB*")=""
SET ZTSAVE("TMP*")=""
SET ZTDESC="Patch Monitor Statistics"
DO ^%ZTLOAD
DO HOME^%ZIS
+2 IF $DATA(ZTSK)
WRITE !,"Queued as task #",ZTSK
HANG 2
GOTO EXIT
+3 ;
+4 ; sort patches by compliance date
SORT USE IO
FOR XTBCPLDT=(XTBBDT-.0001):0
SET XTBCPLDT=$ORDER(^XPD(9.9,"D",XTBCPLDT))
if XTBCPLDT=""!(XTBCPLDT>XTBEDT)
QUIT
Begin DoDot:1
+1 FOR XTBDA=0:0
SET XTBDA=$ORDER(^XPD(9.9,"D",XTBCPLDT,XTBDA))
if XTBDA=""
QUIT
Begin DoDot:2
+2 SET XTBDTA=$GET(^XPD(9.9,XTBDA,0))
if XTBDTA=""
QUIT
+3 ;parent package missing in file
SET XTBPTNAM=$PIECE(XTBDTA,U,1)
SET XTBNMSP=$PIECE($PIECE(XTBDTA,U,4)," - ",1)
if XTBNMSP=""
QUIT
+4 SET XTBRELDT=$PIECE(XTBDTA,U,2)
SET XTBPRIOR=$PIECE(XTBDTA,U,3)
+5 SET TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM,XTBDA)=XTBRELDT_U_XTBPRIOR
End DoDot:2
End DoDot:1
PRINT ; read and print sorted groups
+1 SET Y=DT
XECUTE ^DD("DD")
SET XTBCURDT=Y
+2 KILL XTBLINE
SET $PIECE(XTBLINE,"-",(IOM-2))="-"
+3 ; first header
SET PG=0
SET XTBGRP=""
SET XTBGRP=$ORDER(TMP("XTBGRP",XTBGRP))
if XTBGRP=""
GOTO EXIT
DO HDR
+4 SET (XTBGRP,XTBNMSP,XTBPTNAM,XTBOLDNM,XTBOLGRP)=""
SET (XTBTPTCH,XTBTLATE)=0
+5 FOR
SET XTBGRP=$ORDER(TMP("XTBGRP",XTBGRP))
if XTBGRP=""
QUIT
SET XTBGPDA=TMP("XTBGRP",XTBGRP)
Begin DoDot:1
+6 ; read param file for monitored groups
+7 FOR
SET XTBNMSP=$ORDER(^XPD(9.95,1,2,XTBGPDA,1,"B",XTBNMSP))
if XTBNMSP=""
QUIT
IF $DATA(TMP("XTBPKG",XTBNMSP))
Begin DoDot:2
+8 ; read sorted namespaces
+9 FOR XTBCPLDT=0:0
SET XTBCPLDT=$ORDER(TMP("XTBPKG",XTBNMSP,XTBCPLDT))
if XTBCPLDT=""
QUIT
FOR
SET XTBPTNAM=$ORDER(TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM))
if XTBPTNAM=""
QUIT
Begin DoDot:3
+10 FOR XTBDA=0:0
SET XTBDA=$ORDER(TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM,XTBDA))
if XTBDA=""
QUIT
Begin DoDot:4
+11 SET XTBTPTCH=XTBTPTCH+1
+12 SET XTBDTA=TMP("XTBPKG",XTBNMSP,XTBCPLDT,XTBPTNAM,XTBDA)
+13 SET XTBRELDT=$PIECE(XTBDTA,U)
SET XTBPRIOR=$PIECE(XTBDTA,U,2)
+14 SET XTBRCVDT=$PIECE($GET(^XPD(9.9,XTBDA,0)),U,2)
+15 SET XTBPTYPE=$PIECE($GET(^XPD(9.9,XTBDA,0)),U,10)
+16 IF +XTBPTYPE=0
SET D0=XTBDA
DO ^XTPMKPCF
SET XTBINSDT=X
KILL D0
+17 IF +XTBPTYPE=1
SET XTBINSDT=$PIECE($GET(^XPD(9.9,XTBDA,0)),U,11)
+18 IF XTBINSDT]""
SET X1=XTBINSDT
SET X2=XTBCPLDT
DO ^%DTC
SET XTBDAYLT=X
+19 IF XTBINSDT=""
SET X1=DT
SET X2=XTBCPLDT
DO ^%DTC
SET XTBDAYLT=X
+20 SET XTBGRPHD="Report group: "_XTBGRP
+21 IF XTBOLGRP=""
IF PG=1
WRITE XTBGRPHD,!!
+22 IF XTBOLDNM'=""
IF XTBNMSP'=XTBOLDNM
WRITE !
+23 IF XTBOLDNM'=""
IF XTBGRP'=XTBOLGRP
IF XTBPGF=1
if IOST?1"C-".E
DO PAUSE
if $DATA(XTBOUT)
QUIT
DO HDR
WRITE XTBGRPHD,!!
+24 IF XTBOLDNM'=""
IF XTBGRP'=XTBOLGRP
IF XTBPGF=0
WRITE !,XTBGRPHD,!!
+25 IF $Y>(IOSL-6)
IF IOST?1"C-".E
DO PAUSE
if $DATA(XTBOUT)
QUIT
DO HDR
IF XTBGRP'=XTBOLGRP
WRITE XTBGRPHD,!!
+26 SET Y=XTBINSDT
XECUTE ^DD("DD")
SET XTBINSDT=Y
+27 SET Y=XTBCPLDT
XECUTE ^DD("DD")
SET XTBCPLDX=Y
+28 SET Y=XTBRELDT
XECUTE ^DD("DD")
SET XTBRELDT=Y
+29 SET XTBPRIOR=$SELECT(XTBPRIOR="m":"Mandatory",XTBPRIOR="e":"Emergency",1:"Unknown")
+30 WRITE XTBCPLDX,?14,XTBPTNAM,?27,XTBRELDT,?41,XTBINSDT,?55,XTBPRIOR
+31 IF XTBDAYLT>0
WRITE ?67,$JUSTIFY(XTBDAYLT,3,0)_$SELECT(XTBDAYLT>1:" days",1:" day")
SET XTBTLATE=XTBTLATE+1
+32 WRITE !
SET XTBOLDNM=XTBNMSP
SET XTBOLGRP=XTBGRP
+33 IF $Y>(IOSL-6)
IF IOST?1"C-".E
DO PAUSE
if $DATA(XTBOUT)
QUIT
+34 IF $Y>(IOSL-6)
DO HDR
IF XTBGRP'=XTBOLGRP
WRITE XTBGRPHD,!!
End DoDot:4
if $DATA(XTBOUT)
QUIT
End DoDot:3
if $DATA(XTBOUT)
QUIT
End DoDot:2
if $DATA(XTBOUT)
QUIT
End DoDot:1
if $DATA(XTBOUT)
QUIT
+35 if $DATA(XTBOUT)
GOTO EXIT
+36 IF $Y>(IOSL-6)
IF IOST?1"C-".E
DO HDR
+37 WRITE !!?6,"Totals patches received for date range: ",XTBTPTCH,!
+38 WRITE "Total patches installed past compliance date: ",XTBTLATE,!!
+39 SET XTBDIVOK=0
IF XTBTPTCH>0
SET XTBDIVOK=1
+40 WRITE ?25,"Delinquent patch % : ",$SELECT(XTBDIVOK=1:$JUSTIFY((XTBTLATE/XTBTPTCH*100),6,2),1:0)_" %",!
+41 WRITE ?25," Compliance % : ",$SELECT(XTBDIVOK=1:$JUSTIFY(100-(XTBTLATE/XTBTPTCH*100),6,2),1:0)," %",!
+42 IF IOST?1"C-".E
KILL XTBANS
WRITE !!,"Press ENTER to end "
READ XTBANS:DTIME
+43 ;
EXIT IF IOST?1"C-".E
WRITE @IOF,!
+1 DO ^%ZISC
+2 KILL %,%DT,%ZIS,XTBNMSP,XTBANS,XTBBDT,XTBBDT1,XTBCPLDT,XTBCPLDX,XTBDA,XTBEDT,XTBEDT1,XTBDAYLT,TMP
+3 KILL XTBGRPDA,XTBGRP,XTBINSDT,XTBLINE,XTBNMSP,XTBOLDNM,XTBNMSP,XTBPTNAM,XTBPTYPE,XTBDTA,XTBGPDA
+4 KILL XTBRCVDT,XTBTLATE,XTBTPTCH,D0,DIC,PG,POP,X,X1,X2,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,%T,%Y,XTBGRPHD
+5 KILL TMP("XTBGRP"),TMP("XTBPKG"),XTBOUT,XTBPGF,XTBOLGRP,ZTSK,XTBRELDT,XTBPRIOR,XTBCURDT,XTBDIVOK
+6 QUIT
+7 ;
HDR SET PG=PG+1
IF IOST?1"P-".E
IF PG>1
WRITE @IOF
+1 IF IOST?1"C-".E
WRITE @IOF
+2 WRITE XTBCURDT
SET X="Patch Statistical Report for "_^DD("SITE")
+3 WRITE ?(IOM-$LENGTH(X)\2),X,?(IOM-12),"Page: ",PG,!
+4 SET X="Date range: "_XTBBDT1_" to "_XTBEDT1
WRITE ?(IOM-$LENGTH(X)\2),X,!
+5 WRITE !,"Compliance",?14,"Patch",?27,"Release",?41,"Install",?67,"# Days",!
+6 WRITE "Date",?14,"Number",?27,"Date",?41,"Date",?55,"Priority",?67,"Delinquent",!,XTBLINE,!
+7 QUIT
+8 ;
PAUSE if IOST'?1"C-".E
QUIT
+1 KILL XTBANS,XTBOUT
WRITE !!,"Press ENTER to continue or '^' to end "
READ XTBANS:DTIME
+2 IF XTBANS[U!('$TEST)
SET (XTBNMSP,XTBPTNAM,XTBCPLDT,XTBDA)="ZZZZZZ"
SET XTBOUT=1
+3 QUIT