KMPDTP5 ;OAK/RAK/JML - CP Timing Threshold Alert ;9/1/2015
;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
;
EN ;-- entry point
;
N I,KMPDATE,KMPDSRCH,KMPDTSEC,KMPDTTL,POP,X,Y
N ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
N KMPDLBG,KMPDLFG,KMPDDTSS
;
S KMPDTTL=" Coversheet Time-to-Load (TTL) Alert Report "
D HDR^KMPDUTL4(KMPDTTL)
W !
W !?7,"This alerting report shows the particular coversheet loads"
W !?7,"that had excessive time-to-load values. This report will"
W !?7,"search for a particular person, a particular client name or"
W !?7,"IP address."
W !?7,"Foreground and background times are combined."
W !
;
; if no data
I '$O(^KMPD(8973.2,0)) D Q
.W !!?7,"*** There is currently no data in file #8973.2 (CP TIMING) ***"
;
; date & hour(s) - first determine which subscript to use in API due to addition of foreground processing
S KMPDLFG=$O(^KMPD(8973.2,"ASSDTTM","ORWCV-FT","A"),-1)
S KMPDLBG=$O(^KMPD(8973.2,"ASSDTTM","ORWCV","A"),-1)
S KMPDDTSS=$S(KMPDLFG=KMPDLBG:"ORWCV-FT",KMPDLFG>KMPDLBG:"ORWCV-FT",KMPDLFG<KMPDLBG:"ORWCV",1:"UNKNOWN")
D DTTMRNG^KMPDTU10(KMPDDTSS,1,.KMPDATE,8)
Q:$G(KMPDATE(0))=""
Q:$G(KMPDATE(1))=""
;
; time-to-load threshold seconds
S KMPDTSEC=$$TTLSEC^KMPDTU10
Q:'KMPDTSEC
;
; search by
D SRCHBY^KMPDTU10(.KMPDSRCH,"ORWCV")
Q:'KMPDSRCH
;
; select output device.
S %ZIS="Q",%ZIS("A")="Device: ",%ZIS("B")="HOME"
W ! D ^%ZIS I POP W !,"No action taken." Q
; if queued.
I $D(IO("Q")) K IO("Q") D Q
.S ZTDESC=KMPDTTL
.S ZTRTN="EN1^KMPDTP5"
.F I="KMPDATE(","KMPDSRCH(","KMPDTSEC","KMPDTTL" S ZTSAVE(I)=""
.D ^%ZTLOAD W:$G(ZTSK) !,"Task #",ZTSK
.D EXIT
;
; if output to terminal display message.
W:$E(IOST,1,2)="C-" !,"Compiling timing stats..."
D EN1
;
Q
;
EN1 ;-- entry point from taskman
I '$D(KMPDATE) D EXIT Q
I '$D(KMPDSRCH) D EXIT Q
I '$G(KMPDTSEC) D EXIT Q
I $G(KMPDTTL)="" D EXIT Q
;
K ^TMP($J)
U IO
D DATA,PRINT,EXIT
K ^TMP($J)
Q
;
DATA ;-- compile data
;
Q:'$D(KMPDATE)
Q:'$G(KMPDSRCH)
Q:'$G(KMPDTSEC)
;
N DATA,DATE,DATE1,DELTA,DOT,END,GBL,GBLREF,HOUR,HR,I,IEN,QUEUED,TIME,XREF
N KMPDBIDX,KMPDTOT,KMPDSS,KMPDLUSS
;
S GBLREF=$$GLOBAL(.KMPDSRCH) Q:GBLREF=""
S XREF=$P(GBLREF,U),KMPDLUSS=$P(GBLREF,U,2)
;
S DOT=1,QUEUED=$D(ZTQUEUED)
; set up HOUR() array
F I=1:1:24 S:$P(KMPDATE(1),",",I)'="" HOUR(+$P(KMPDATE(1),",",I))=""
Q:'$D(HOUR)
S DATE=$P(KMPDATE(0),U)-.1,END=$P(KMPDATE(0),U,2)+.9
Q:'DATE!('END)
;
K ^TMP($J)
F KMPDSS="ORWCV","ORWCV-FT" D
.; reset date and end for each pass
.S DATE=$P(KMPDATE(0),U)-.1,END=$P(KMPDATE(0),U,2)+.9
.S KMPDTOT(KMPDSS)=0
.I KMPDLUSS="" S GBL=$NA(^KMPD(8973.2,XREF,KMPDSS))
.I KMPDLUSS'="" S GBL=$NA(^KMPD(8973.2,XREF,KMPDSS,KMPDLUSS))
.F S DATE=$O(@GBL@(DATE)) Q:'DATE!(DATE>END) D
..; determine hour
..S HR=+$E($P(DATE,".",2),1,2)
..S HR=$S(HR="":0,HR=24:0,1:HR)
..; quit if not in HOUR() array
..Q:'$D(HOUR(HR))
..; hour & second
..S TIME=$E($P(DATE,".",2),1,6) Q:'TIME
..; insert colon (:) between hour & second
..S TIME=$E(TIME,1,2)_":"_$E(TIME,3,4)_":"_$E(TIME,5,6)
..; date without time
..S DATE1=$P(DATE,".")
..S IEN=0
..F S IEN=$O(@GBL@(DATE,IEN)) Q:'IEN D
...Q:'$D(^KMPD(8973.2,IEN,0)) S DATA=^(0) Q:DATA=""
...S DOT=DOT+1 W:'QUEUED&('(DOT#1000)) "."
...S KMPDBIDX=$P(DATA,U)
...S ^TMP($J,"DATA",DATE,TIME,KMPDBIDX,KMPDSS)=DATA
...S $P(^TMP($J,"DATA",DATE,TIME,KMPDBIDX,KMPDSS),U,5)=$P($G(^VA(200,+$P(DATA,U,5),0)),U)
...S KMPDTOT(KMPDSS)=KMPDTOT(KMPDSS)+1
;
Q
;
PRINT ;-- print data
;
U IO
N KMPDCNAM,KMPDUNAM,KMPDIP,KMPDSET,KMPDPDT,KMPDTOTD
D HDR
Q:'$D(^TMP($J))
N CONT,DATE,I,TOTAL
S DATE="",CONT=1,TOTAL=0
F S DATE=$O(^TMP($J,"DATA",DATE)) Q:'DATE D Q:'CONT
.S HR=""
.F S HR=$O(^TMP($J,"DATA",DATE,HR)) Q:HR="" D Q:'CONT
..I $Y>(IOSL-4) D Q:'CONT
...D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT
...D HDR ;W !,$$FMTE^XLFDT(DATE,2)
..S KMPDBIDX=""
..F S KMPDBIDX=$O(^TMP($J,"DATA",DATE,HR,KMPDBIDX)) Q:KMPDBIDX="" D
...S KMPDSS="",KMPDSET=1,KMPDTOTD=0
...F S KMPDSS=$O(^TMP($J,"DATA",DATE,HR,KMPDBIDX,KMPDSS)) Q:KMPDSS="" D
....S DATA=$G(^TMP($J,"DATA",DATE,HR,KMPDBIDX,KMPDSS))
....I KMPDSET D
.....S KMPDUNAM=$S($P(DATA,U,5)]"":$E($P(DATA,U,5),1,23),1:"N/A")
.....S KMPDCNAM=$S($P(DATA,U,6)]"":$E($P(DATA,U,6),1,23),1:"N/A")
.....S KMPDIP=$S($P(DATA,U,9)]"":$P(DATA,U,9),1:"N/A")
.....S KMPDSET=0
....S KMPDTOTD=KMPDTOTD+$P(DATA,U,4)
...; W COMBINED DATA
...Q:KMPDTOTD<KMPDTSEC
...S TOTAL=TOTAL+1
...S KMPDPDT=$$FMTE^XLFDT(DATE,2)
...W !,$P(KMPDPDT,"@",2),?10,KMPDUNAM,?35,KMPDCNAM,?60,KMPDIP,?76,KMPDTOTD
K ^TMP($J)
;
I TOTAL W !!?3,"Total Count: ",$J($FN(TOTAL,",",0),$L(TOTAL)+1)
;
; pause if output to terminal
I CONT D CONTINUE^KMPDUTL4("Press RETURN to continue",1)
;
Q
;
HDR ;-- print header
W @IOF
N HRS
S X=$G(KMPDTTL)
W !?(80-$L(X)\2),X
S HRS=$E(KMPDATE(1),1,$L(KMPDATE(1))-1)
S X=$G(KMPDATE(0)),X=$P(X,U,3)_" - Hours: "_HRS
W !?(80-$L(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
I +KMPDSRCH<4 D
.S X=$P($G(KMPDSRCH),U,2)_": "
.S X=X_$P($G(KMPDSRCH(1)),U,$S((+$G(KMPDSRCH))=1:2,1:1))
.W !?(80-$L(X)\2),X
S X="Threshold: "_$G(KMPDTSEC)_" seconds"
W !?(80-$L(X)\2),X
W !
W !,"Time",?10,"User Name",?35,"Client Name",?60,"IP Address",?76,"TTL"
W !,$$REPEAT^XLFSTR("-",IOM)
;
Q
;
EXIT ;-- cleanup on exit
S:$D(ZTQUEUED) ZTREQ="@"
D ^%ZISC
K KMPDATE,KMPDSRCH,KMPDTSEC,KMPDTTL
Q
;
GLOBAL(KMPDSRCH) ;-- extrinsic function
;-----------------------------------------------------------------------
; KMPDSRCH... see above
;-----------------------------------------------------------------------
Q:'$G(KMPDSRCH) ""
N RETURN,TYPE
S RETURN=""
S TYPE=+$G(KMPDSRCH),KMPDSRCH(1)=$G(KMPDSRCH(1))
Q:'TYPE ""
I TYPE<4 Q:KMPDSRCH(1)="" ""
; any occurrence
I TYPE=4 S RETURN="ASSDTTM^"
; username
I TYPE=1 S RETURN="ASSNPDTTM^"_+$P(KMPDSRCH(1),U)
; client name
I TYPE=2 S RETURN="ASSCLDTTM^"_KMPDSRCH(1)
; ip address
I TYPE=3 S RETURN="ASSIPDTTM^"_KMPDSRCH(1)
Q RETURN
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTP5 6156 printed Oct 16, 2024@17:41:40 Page 2
KMPDTP5 ;OAK/RAK/JML - CP Timing Threshold Alert ;9/1/2015
+1 ;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
+2 ;
EN ;-- entry point
+1 ;
+2 NEW I,KMPDATE,KMPDSRCH,KMPDTSEC,KMPDTTL,POP,X,Y
+3 NEW ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
+4 NEW KMPDLBG,KMPDLFG,KMPDDTSS
+5 ;
+6 SET KMPDTTL=" Coversheet Time-to-Load (TTL) Alert Report "
+7 DO HDR^KMPDUTL4(KMPDTTL)
+8 WRITE !
+9 WRITE !?7,"This alerting report shows the particular coversheet loads"
+10 WRITE !?7,"that had excessive time-to-load values. This report will"
+11 WRITE !?7,"search for a particular person, a particular client name or"
+12 WRITE !?7,"IP address."
+13 WRITE !?7,"Foreground and background times are combined."
+14 WRITE !
+15 ;
+16 ; if no data
+17 IF '$ORDER(^KMPD(8973.2,0))
Begin DoDot:1
+18 WRITE !!?7,"*** There is currently no data in file #8973.2 (CP TIMING) ***"
End DoDot:1
QUIT
+19 ;
+20 ; date & hour(s) - first determine which subscript to use in API due to addition of foreground processing
+21 SET KMPDLFG=$ORDER(^KMPD(8973.2,"ASSDTTM","ORWCV-FT","A"),-1)
+22 SET KMPDLBG=$ORDER(^KMPD(8973.2,"ASSDTTM","ORWCV","A"),-1)
+23 SET KMPDDTSS=$SELECT(KMPDLFG=KMPDLBG:"ORWCV-FT",KMPDLFG>KMPDLBG:"ORWCV-FT",KMPDLFG<KMPDLBG:"ORWCV",1:"UNKNOWN")
+24 DO DTTMRNG^KMPDTU10(KMPDDTSS,1,.KMPDATE,8)
+25 if $GET(KMPDATE(0))=""
QUIT
+26 if $GET(KMPDATE(1))=""
QUIT
+27 ;
+28 ; time-to-load threshold seconds
+29 SET KMPDTSEC=$$TTLSEC^KMPDTU10
+30 if 'KMPDTSEC
QUIT
+31 ;
+32 ; search by
+33 DO SRCHBY^KMPDTU10(.KMPDSRCH,"ORWCV")
+34 if 'KMPDSRCH
QUIT
+35 ;
+36 ; select output device.
+37 SET %ZIS="Q"
SET %ZIS("A")="Device: "
SET %ZIS("B")="HOME"
+38 WRITE !
DO ^%ZIS
IF POP
WRITE !,"No action taken."
QUIT
+39 ; if queued.
+40 IF $DATA(IO("Q"))
KILL IO("Q")
Begin DoDot:1
+41 SET ZTDESC=KMPDTTL
+42 SET ZTRTN="EN1^KMPDTP5"
+43 FOR I="KMPDATE(","KMPDSRCH(","KMPDTSEC","KMPDTTL"
SET ZTSAVE(I)=""
+44 DO ^%ZTLOAD
if $GET(ZTSK)
WRITE !,"Task #",ZTSK
+45 DO EXIT
End DoDot:1
QUIT
+46 ;
+47 ; if output to terminal display message.
+48 if $EXTRACT(IOST,1,2)="C-"
WRITE !,"Compiling timing stats..."
+49 DO EN1
+50 ;
+51 QUIT
+52 ;
EN1 ;-- entry point from taskman
+1 IF '$DATA(KMPDATE)
DO EXIT
QUIT
+2 IF '$DATA(KMPDSRCH)
DO EXIT
QUIT
+3 IF '$GET(KMPDTSEC)
DO EXIT
QUIT
+4 IF $GET(KMPDTTL)=""
DO EXIT
QUIT
+5 ;
+6 KILL ^TMP($JOB)
+7 USE IO
+8 DO DATA
DO PRINT
DO EXIT
+9 KILL ^TMP($JOB)
+10 QUIT
+11 ;
DATA ;-- compile data
+1 ;
+2 if '$DATA(KMPDATE)
QUIT
+3 if '$GET(KMPDSRCH)
QUIT
+4 if '$GET(KMPDTSEC)
QUIT
+5 ;
+6 NEW DATA,DATE,DATE1,DELTA,DOT,END,GBL,GBLREF,HOUR,HR,I,IEN,QUEUED,TIME,XREF
+7 NEW KMPDBIDX,KMPDTOT,KMPDSS,KMPDLUSS
+8 ;
+9 SET GBLREF=$$GLOBAL(.KMPDSRCH)
if GBLREF=""
QUIT
+10 SET XREF=$PIECE(GBLREF,U)
SET KMPDLUSS=$PIECE(GBLREF,U,2)
+11 ;
+12 SET DOT=1
SET QUEUED=$DATA(ZTQUEUED)
+13 ; set up HOUR() array
+14 FOR I=1:1:24
if $PIECE(KMPDATE(1),",",I)'=""
SET HOUR(+$PIECE(KMPDATE(1),",",I))=""
+15 if '$DATA(HOUR)
QUIT
+16 SET DATE=$PIECE(KMPDATE(0),U)-.1
SET END=$PIECE(KMPDATE(0),U,2)+.9
+17 if 'DATE!('END)
QUIT
+18 ;
+19 KILL ^TMP($JOB)
+20 FOR KMPDSS="ORWCV","ORWCV-FT"
Begin DoDot:1
+21 ; reset date and end for each pass
+22 SET DATE=$PIECE(KMPDATE(0),U)-.1
SET END=$PIECE(KMPDATE(0),U,2)+.9
+23 SET KMPDTOT(KMPDSS)=0
+24 IF KMPDLUSS=""
SET GBL=$NAME(^KMPD(8973.2,XREF,KMPDSS))
+25 IF KMPDLUSS'=""
SET GBL=$NAME(^KMPD(8973.2,XREF,KMPDSS,KMPDLUSS))
+26 FOR
SET DATE=$ORDER(@GBL@(DATE))
if 'DATE!(DATE>END)
QUIT
Begin DoDot:2
+27 ; determine hour
+28 SET HR=+$EXTRACT($PIECE(DATE,".",2),1,2)
+29 SET HR=$SELECT(HR="":0,HR=24:0,1:HR)
+30 ; quit if not in HOUR() array
+31 if '$DATA(HOUR(HR))
QUIT
+32 ; hour & second
+33 SET TIME=$EXTRACT($PIECE(DATE,".",2),1,6)
if 'TIME
QUIT
+34 ; insert colon (:) between hour & second
+35 SET TIME=$EXTRACT(TIME,1,2)_":"_$EXTRACT(TIME,3,4)_":"_$EXTRACT(TIME,5,6)
+36 ; date without time
+37 SET DATE1=$PIECE(DATE,".")
+38 SET IEN=0
+39 FOR
SET IEN=$ORDER(@GBL@(DATE,IEN))
if 'IEN
QUIT
Begin DoDot:3
+40 if '$DATA(^KMPD(8973.2,IEN,0))
QUIT
SET DATA=^(0)
if DATA=""
QUIT
+41 SET DOT=DOT+1
if 'QUEUED&('(DOT#1000))
WRITE "."
+42 SET KMPDBIDX=$PIECE(DATA,U)
+43 SET ^TMP($JOB,"DATA",DATE,TIME,KMPDBIDX,KMPDSS)=DATA
+44 SET $PIECE(^TMP($JOB,"DATA",DATE,TIME,KMPDBIDX,KMPDSS),U,5)=$PIECE($GET(^VA(200,+$PIECE(DATA,U,5),0)),U)
+45 SET KMPDTOT(KMPDSS)=KMPDTOT(KMPDSS)+1
End DoDot:3
End DoDot:2
End DoDot:1
+46 ;
+47 QUIT
+48 ;
PRINT ;-- print data
+1 ;
+2 USE IO
+3 NEW KMPDCNAM,KMPDUNAM,KMPDIP,KMPDSET,KMPDPDT,KMPDTOTD
+4 DO HDR
+5 if '$DATA(^TMP($JOB))
QUIT
+6 NEW CONT,DATE,I,TOTAL
+7 SET DATE=""
SET CONT=1
SET TOTAL=0
+8 FOR
SET DATE=$ORDER(^TMP($JOB,"DATA",DATE))
if 'DATE
QUIT
Begin DoDot:1
+9 SET HR=""
+10 FOR
SET HR=$ORDER(^TMP($JOB,"DATA",DATE,HR))
if HR=""
QUIT
Begin DoDot:2
+11 IF $Y>(IOSL-4)
Begin DoDot:3
+12 DO CONTINUE^KMPDUTL4("",1,.CONT)
if 'CONT
QUIT
+13 ;W !,$$FMTE^XLFDT(DATE,2)
DO HDR
End DoDot:3
if 'CONT
QUIT
+14 SET KMPDBIDX=""
+15 FOR
SET KMPDBIDX=$ORDER(^TMP($JOB,"DATA",DATE,HR,KMPDBIDX))
if KMPDBIDX=""
QUIT
Begin DoDot:3
+16 SET KMPDSS=""
SET KMPDSET=1
SET KMPDTOTD=0
+17 FOR
SET KMPDSS=$ORDER(^TMP($JOB,"DATA",DATE,HR,KMPDBIDX,KMPDSS))
if KMPDSS=""
QUIT
Begin DoDot:4
+18 SET DATA=$GET(^TMP($JOB,"DATA",DATE,HR,KMPDBIDX,KMPDSS))
+19 IF KMPDSET
Begin DoDot:5
+20 SET KMPDUNAM=$SELECT($PIECE(DATA,U,5)]"":$EXTRACT($PIECE(DATA,U,5),1,23),1:"N/A")
+21 SET KMPDCNAM=$SELECT($PIECE(DATA,U,6)]"":$EXTRACT($PIECE(DATA,U,6),1,23),1:"N/A")
+22 SET KMPDIP=$SELECT($PIECE(DATA,U,9)]"":$PIECE(DATA,U,9),1:"N/A")
+23 SET KMPDSET=0
End DoDot:5
+24 SET KMPDTOTD=KMPDTOTD+$PIECE(DATA,U,4)
End DoDot:4
+25 ; W COMBINED DATA
+26 if KMPDTOTD<KMPDTSEC
QUIT
+27 SET TOTAL=TOTAL+1
+28 SET KMPDPDT=$$FMTE^XLFDT(DATE,2)
+29 WRITE !,$PIECE(KMPDPDT,"@",2),?10,KMPDUNAM,?35,KMPDCNAM,?60,KMPDIP,?76,KMPDTOTD
End DoDot:3
End DoDot:2
if 'CONT
QUIT
End DoDot:1
if 'CONT
QUIT
+30 KILL ^TMP($JOB)
+31 ;
+32 IF TOTAL
WRITE !!?3,"Total Count: ",$JUSTIFY($FNUMBER(TOTAL,",",0),$LENGTH(TOTAL)+1)
+33 ;
+34 ; pause if output to terminal
+35 IF CONT
DO CONTINUE^KMPDUTL4("Press RETURN to continue",1)
+36 ;
+37 QUIT
+38 ;
HDR ;-- print header
+1 WRITE @IOF
+2 NEW HRS
+3 SET X=$GET(KMPDTTL)
+4 WRITE !?(80-$LENGTH(X)\2),X
+5 SET HRS=$EXTRACT(KMPDATE(1),1,$LENGTH(KMPDATE(1))-1)
+6 SET X=$GET(KMPDATE(0))
SET X=$PIECE(X,U,3)_" - Hours: "_HRS
+7 WRITE !?(80-$LENGTH(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
+8 IF +KMPDSRCH<4
Begin DoDot:1
+9 SET X=$PIECE($GET(KMPDSRCH),U,2)_": "
+10 SET X=X_$PIECE($GET(KMPDSRCH(1)),U,$SELECT((+$GET(KMPDSRCH))=1:2,1:1))
+11 WRITE !?(80-$LENGTH(X)\2),X
End DoDot:1
+12 SET X="Threshold: "_$GET(KMPDTSEC)_" seconds"
+13 WRITE !?(80-$LENGTH(X)\2),X
+14 WRITE !
+15 WRITE !,"Time",?10,"User Name",?35,"Client Name",?60,"IP Address",?76,"TTL"
+16 WRITE !,$$REPEAT^XLFSTR("-",IOM)
+17 ;
+18 QUIT
+19 ;
EXIT ;-- cleanup on exit
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 DO ^%ZISC
+3 KILL KMPDATE,KMPDSRCH,KMPDTSEC,KMPDTTL
+4 QUIT
+5 ;
GLOBAL(KMPDSRCH) ;-- extrinsic function
+1 ;-----------------------------------------------------------------------
+2 ; KMPDSRCH... see above
+3 ;-----------------------------------------------------------------------
+4 if '$GET(KMPDSRCH)
QUIT ""
+5 NEW RETURN,TYPE
+6 SET RETURN=""
+7 SET TYPE=+$GET(KMPDSRCH)
SET KMPDSRCH(1)=$GET(KMPDSRCH(1))
+8 if 'TYPE
QUIT ""
+9 IF TYPE<4
if KMPDSRCH(1)=""
QUIT ""
+10 ; any occurrence
+11 IF TYPE=4
SET RETURN="ASSDTTM^"
+12 ; username
+13 IF TYPE=1
SET RETURN="ASSNPDTTM^"_+$PIECE(KMPDSRCH(1),U)
+14 ; client name
+15 IF TYPE=2
SET RETURN="ASSCLDTTM^"_KMPDSRCH(1)
+16 ; ip address
+17 IF TYPE=3
SET RETURN="ASSIPDTTM^"_KMPDSRCH(1)
+18 QUIT RETURN
+19 ;