KMPDTP4 ;OAK/RAK/JML - CP Timing Hourly Time-to-Load ;9/1/2015
;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
;
EN ;-- entry point
;
N KMPDATE,KMPDTTL,POP,X,Y,ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
N KMPDLBG,KMPDLFG,KMPDDTSS
;
S KMPDTTL=" Hourly Coversheet Time-to-Load (TTL) Detail Report "
D HDR^KMPDUTL4(KMPDTTL)
W !
W !?7,"This detail report displays the hourly time-to-load values"
W !?7,"for the coversheet at this site. The report breaks the"
W !?7,"time-to-load metrics into ten second groupings."
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) ***"
;
; select date range - 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))=""
;
; 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^KMPDTP4"
.S ZTSAVE("KMPDATE(")="",ZTSAVE("KMPDTTL")=""
.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
Q:'$D(KMPDATE)
N KMPDTOT,KMPDFG,KMPDBG
K ^TMP($J)
D DATA,PRINT,EXIT
K ^TMP($J)
Q
;
DATA ;-- compile data
;
Q:'$D(KMPDATE)
;
N DATA,DATE,DATE1,DELTA,DOT,END,HOUR,HR,I,IEN,PTNP,QUEUED,TOTAL
N KMPDSUB,KMPDBIDX
;
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)
; Loop data - combine Foreground and Background timings
F KMPDSUB="ORWCV","ORWCV-FT" D
.S KMPDTOT(KMPDSUB)=0
.S DATE=$P(KMPDATE(0),U)-.1,END=$P(KMPDATE(0),U,2)+.9
.F S DATE=$O(^KMPD(8973.2,"ASSDTTM",KMPDSUB,DATE)) Q:'DATE!(DATE>END) D
..S HR=+$E($P(DATE,".",2),1,2) S:HR="" HR="0"
..Q:'$D(HOUR(HR))
..S (IEN,TOTAL)=0,TOTAL(KMPDSUB)=0
..F S IEN=$O(^KMPD(8973.2,"ASSDTTM",KMPDSUB,DATE,IEN)) Q:'IEN D
...S DATA=$G(^KMPD(8973.2,IEN,0))
...Q:DATA=""
...S KMPDBIDX=$P(DATA,U)
...S ^TMP($J,"DATA",DATE,KMPDBIDX,KMPDSUB)=$P(DATA,U,4)
...S KMPDTOT(KMPDSUB)=KMPDTOT(KMPDSUB)+1
;
; Calculate percentages
S DATE=""
F S DATE=$O(^TMP($J,"DATA",DATE)) Q:DATE="" D
.; date without time
.S DATE1=$P(DATE,".")
.; set up HOUR() array
.M:'$D(^TMP($J,"RPT",DATE1)) ^TMP($J,"RPT",DATE1)=HOUR
.; set up TOTAL() array
.M:'$D(TOTAL(DATE1)) TOTAL(DATE1)=HOUR
.S KMPDBIDX=""
.F S KMPDBIDX=$O(^TMP($J,"DATA",DATE,KMPDBIDX)) Q:KMPDBIDX="" D
..S (DELTA,KMPDSUB)=""
..F S KMPDSUB=$O(^TMP($J,"DATA",DATE,KMPDBIDX,KMPDSUB)) Q:KMPDSUB="" D
...S DELTA=DELTA+$G(^TMP($J,"DATA",DATE,KMPDBIDX,KMPDSUB))
..S DOT=DOT+1 W:'QUEUED&('(DOT#1000)) "."
..S HR=+$E($P(DATE,".",2),1,2) S:HR="" HR="0"
..; if delta is null increment by 1 and quit
..I DELTA="" S $P(^TMP($J,"RPT",DATE1,HR),U,50)=$P(^TMP($J,"RPT",DATE1,HR),U,50)+1 Q
..; loop - less than I*10 seconds
..F I=1:1:9 I DELTA<(I*10) S $P(^TMP($J,"RPT",DATE1,HR),U,I)=$P(^TMP($J,"RPT",DATE1,HR),U,I)+1 Q
..; 90 or greater seconds
..I DELTA>89 S $P(^TMP($J,"RPT",DATE1,HR),U,10)=$P(^TMP($J,"RPT",DATE1,HR),U,10)+1
..; total
..S TOTAL(DATE1,HR)=TOTAL(DATE1,HR)+1
; determine percentage
S DATE1=0
F S DATE1=$O(TOTAL(DATE1)) Q:'DATE1 S HR="" D
.F S HR=$O(TOTAL(DATE1,HR)) Q:HR="" I TOTAL(DATE1,HR) F I=1:1:10 D
..S $P(^TMP($J,"RPT",DATE1,HR,1),U,I)=$FN($P(^TMP($J,"RPT",DATE1,HR),U,I)/TOTAL(DATE1,HR)*100,"",1)
Q
;
PRINT ;-- print data
;
U IO
D HDR
Q:'$D(^TMP($J))
N CONT,DATE,I,TOTAL,KMPDFGBG,KMPDMESS
S (KMPDFG,KMPDBG)=0
S DATE="",CONT=1
F S DATE=$O(^TMP($J,"RPT",DATE)) Q:'DATE D Q:'CONT
.W !,$$FMTE^XLFDT(DATE,2) S HR=""
.F S HR=$O(^TMP($J,"RPT",DATE,HR)) Q:HR="" D Q:'CONT
..I $Y>(IOSL-9) D Q:'CONT
...D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT
...D HDR W !,$$FMTE^XLFDT(DATE,2)
..W ?12,HR
..S TOTAL="",DATA=^TMP($J,"RPT",DATE,HR),DATA(1)=$G(^TMP($J,"RPT",DATE,HR,1))
..; if no data
..I DATA="" W ?12," <No Data>",! Q
..; display data
..F I=1:1:9 D
...W ?16,I-1*10," to <",I*10
...W ?32,$J($FN($P(DATA,U,I),",",0),10)
...; percentages
...W ?48,$J($FN($P(DATA(1),U,I),"",1),10),"%"
...W !
...; totals
...S $P(TOTAL,U)=$P(TOTAL,U)+$P(DATA,U,I)
...S $P(TOTAL,U,2)=$P(TOTAL,U,2)+$P(DATA(1),U,I)
..; greater than 90
..W ?16,"90 or greater",?32,$J($FN($P(DATA,U,10),",",0),10)
..W ?48,$J($FN($P(DATA(1),U,10),"",1),10),"%"
..S $P(TOTAL,U)=$P(TOTAL,U)+$P(DATA,U,10)
..S $P(TOTAL,U,2)=$P(TOTAL,U,2)+$P(DATA(1),U,10)
..; totals
..W !?32,"----------",?48,"----------"
..W !?32,$J($FN($P(TOTAL,U),",",0),10)
..W ?48,$J($FN($P(TOTAL,U,2),"",0),10),"%"
..W !?16,"Incomplete",?32,$J($FN($P(DATA,U,50),",",0),10),!
..; page feed if another date
..I $O(^TMP($J,DATE)) D
...D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT
...D HDR
..W !
;
I CONT D
.; legend
.S KMPDFGBG=0
.I $G(KMPDTOT("ORWCV"))>0 S KMPDFGBG=KMPDFGBG+1
.I $G(KMPDTOT("ORWCV-FT"))>0 S KMPDFGBG=KMPDFGBG+2
.W !!?2,"CV = Coversheet",?30,"Coversheet sections run in:"
.W !?2,"TTL = Time-to-Load"
.W ?30,$S(KMPDFGBG=1:"Background Only",KMPDFGBG=2:"Foreground Only",KMPDFGBG=3:"Both Foreground and Background",1:"Unknown")
.; pause if output to terminal
.D CONTINUE^KMPDUTL4("Press RETURN to continue",1)
;
Q
;
HDR ;-- print header
W @IOF
S X=$G(KMPDTTL)
W !?(80-$L(X)\2),X
S X=$G(KMPDATE(0)),X=$P(X,U,3)_" - "_$P(X,U,4)
W !?(80-$L(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
W !
W !,"Date",?12,"Hr",?16,"TTL Seconds",?32,"# CV Loads",?48,"CV Percent"
W !,$$REPEAT^XLFSTR("-",IOM)
;
Q
;
EXIT ;-- cleanup on exit
S:$D(ZTQUEUED) ZTREQ="@"
D ^%ZISC
K KMPDATE,KMPDTTL
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTP4 6181 printed Oct 16, 2024@17:41:40 Page 2
KMPDTP4 ;OAK/RAK/JML - CP Timing Hourly Time-to-Load ;9/1/2015
+1 ;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
+2 ;
EN ;-- entry point
+1 ;
+2 NEW KMPDATE,KMPDTTL,POP,X,Y,ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
+3 NEW KMPDLBG,KMPDLFG,KMPDDTSS
+4 ;
+5 SET KMPDTTL=" Hourly Coversheet Time-to-Load (TTL) Detail Report "
+6 DO HDR^KMPDUTL4(KMPDTTL)
+7 WRITE !
+8 WRITE !?7,"This detail report displays the hourly time-to-load values"
+9 WRITE !?7,"for the coversheet at this site. The report breaks the"
+10 WRITE !?7,"time-to-load metrics into ten second groupings."
+11 WRITE !
+12 ;
+13 ; if no data
+14 IF '$ORDER(^KMPD(8973.2,0))
Begin DoDot:1
+15 WRITE !!?7,"*** There is currently no data in file #8973.2 (CP TIMING) ***"
End DoDot:1
QUIT
+16 ;
+17 ; select date range - first determine which subscript to use in API due to addition of foreground processing
+18 SET KMPDLFG=$ORDER(^KMPD(8973.2,"ASSDTTM","ORWCV-FT","A"),-1)
+19 SET KMPDLBG=$ORDER(^KMPD(8973.2,"ASSDTTM","ORWCV","A"),-1)
+20 SET KMPDDTSS=$SELECT(KMPDLFG=KMPDLBG:"ORWCV-FT",KMPDLFG>KMPDLBG:"ORWCV-FT",KMPDLFG<KMPDLBG:"ORWCV",1:"UNKNOWN")
+21 DO DTTMRNG^KMPDTU10(KMPDDTSS,1,.KMPDATE,8)
+22 if $GET(KMPDATE(0))=""
QUIT
+23 if $GET(KMPDATE(1))=""
QUIT
+24 ;
+25 ; select output device.
+26 SET %ZIS="Q"
SET %ZIS("A")="Device: "
SET %ZIS("B")="HOME"
+27 WRITE !
DO ^%ZIS
IF POP
WRITE !,"No action taken."
QUIT
+28 ; if queued.
+29 IF $DATA(IO("Q"))
KILL IO("Q")
Begin DoDot:1
+30 SET ZTDESC=KMPDTTL
+31 SET ZTRTN="EN1^KMPDTP4"
+32 SET ZTSAVE("KMPDATE(")=""
SET ZTSAVE("KMPDTTL")=""
+33 DO ^%ZTLOAD
if $GET(ZTSK)
WRITE !,"Task #",ZTSK
+34 DO EXIT
End DoDot:1
QUIT
+35 ;
+36 ; if output to terminal display message.
+37 if $EXTRACT(IOST,1,2)="C-"
WRITE !,"Compiling timing stats..."
+38 DO EN1
+39 ;
+40 QUIT
+41 ;
EN1 ;-- entry point from taskman
+1 if '$DATA(KMPDATE)
QUIT
+2 NEW KMPDTOT,KMPDFG,KMPDBG
+3 KILL ^TMP($JOB)
+4 DO DATA
DO PRINT
DO EXIT
+5 KILL ^TMP($JOB)
+6 QUIT
+7 ;
DATA ;-- compile data
+1 ;
+2 if '$DATA(KMPDATE)
QUIT
+3 ;
+4 NEW DATA,DATE,DATE1,DELTA,DOT,END,HOUR,HR,I,IEN,PTNP,QUEUED,TOTAL
+5 NEW KMPDSUB,KMPDBIDX
+6 ;
+7 SET DOT=1
SET QUEUED=$DATA(ZTQUEUED)
+8 ; set up HOUR() array
+9 FOR I=1:1:24
if $PIECE(KMPDATE(1),",",I)'=""
SET HOUR(+$PIECE(KMPDATE(1),",",I))=""
+10 if '$DATA(HOUR)
QUIT
+11 SET DATE=$PIECE(KMPDATE(0),U)-.1
SET END=$PIECE(KMPDATE(0),U,2)+.9
+12 if 'DATE!('END)
QUIT
+13 ; Loop data - combine Foreground and Background timings
+14 FOR KMPDSUB="ORWCV","ORWCV-FT"
Begin DoDot:1
+15 SET KMPDTOT(KMPDSUB)=0
+16 SET DATE=$PIECE(KMPDATE(0),U)-.1
SET END=$PIECE(KMPDATE(0),U,2)+.9
+17 FOR
SET DATE=$ORDER(^KMPD(8973.2,"ASSDTTM",KMPDSUB,DATE))
if 'DATE!(DATE>END)
QUIT
Begin DoDot:2
+18 SET HR=+$EXTRACT($PIECE(DATE,".",2),1,2)
if HR=""
SET HR="0"
+19 if '$DATA(HOUR(HR))
QUIT
+20 SET (IEN,TOTAL)=0
SET TOTAL(KMPDSUB)=0
+21 FOR
SET IEN=$ORDER(^KMPD(8973.2,"ASSDTTM",KMPDSUB,DATE,IEN))
if 'IEN
QUIT
Begin DoDot:3
+22 SET DATA=$GET(^KMPD(8973.2,IEN,0))
+23 if DATA=""
QUIT
+24 SET KMPDBIDX=$PIECE(DATA,U)
+25 SET ^TMP($JOB,"DATA",DATE,KMPDBIDX,KMPDSUB)=$PIECE(DATA,U,4)
+26 SET KMPDTOT(KMPDSUB)=KMPDTOT(KMPDSUB)+1
End DoDot:3
End DoDot:2
End DoDot:1
+27 ;
+28 ; Calculate percentages
+29 SET DATE=""
+30 FOR
SET DATE=$ORDER(^TMP($JOB,"DATA",DATE))
if DATE=""
QUIT
Begin DoDot:1
+31 ; date without time
+32 SET DATE1=$PIECE(DATE,".")
+33 ; set up HOUR() array
+34 if '$DATA(^TMP($JOB,"RPT",DATE1))
MERGE ^TMP($JOB,"RPT",DATE1)=HOUR
+35 ; set up TOTAL() array
+36 if '$DATA(TOTAL(DATE1))
MERGE TOTAL(DATE1)=HOUR
+37 SET KMPDBIDX=""
+38 FOR
SET KMPDBIDX=$ORDER(^TMP($JOB,"DATA",DATE,KMPDBIDX))
if KMPDBIDX=""
QUIT
Begin DoDot:2
+39 SET (DELTA,KMPDSUB)=""
+40 FOR
SET KMPDSUB=$ORDER(^TMP($JOB,"DATA",DATE,KMPDBIDX,KMPDSUB))
if KMPDSUB=""
QUIT
Begin DoDot:3
+41 SET DELTA=DELTA+$GET(^TMP($JOB,"DATA",DATE,KMPDBIDX,KMPDSUB))
End DoDot:3
+42 SET DOT=DOT+1
if 'QUEUED&('(DOT#1000))
WRITE "."
+43 SET HR=+$EXTRACT($PIECE(DATE,".",2),1,2)
if HR=""
SET HR="0"
+44 ; if delta is null increment by 1 and quit
+45 IF DELTA=""
SET $PIECE(^TMP($JOB,"RPT",DATE1,HR),U,50)=$PIECE(^TMP($JOB,"RPT",DATE1,HR),U,50)+1
QUIT
+46 ; loop - less than I*10 seconds
+47 FOR I=1:1:9
IF DELTA<(I*10)
SET $PIECE(^TMP($JOB,"RPT",DATE1,HR),U,I)=$PIECE(^TMP($JOB,"RPT",DATE1,HR),U,I)+1
QUIT
+48 ; 90 or greater seconds
+49 IF DELTA>89
SET $PIECE(^TMP($JOB,"RPT",DATE1,HR),U,10)=$PIECE(^TMP($JOB,"RPT",DATE1,HR),U,10)+1
+50 ; total
+51 SET TOTAL(DATE1,HR)=TOTAL(DATE1,HR)+1
End DoDot:2
End DoDot:1
+52 ; determine percentage
+53 SET DATE1=0
+54 FOR
SET DATE1=$ORDER(TOTAL(DATE1))
if 'DATE1
QUIT
SET HR=""
Begin DoDot:1
+55 FOR
SET HR=$ORDER(TOTAL(DATE1,HR))
if HR=""
QUIT
IF TOTAL(DATE1,HR)
FOR I=1:1:10
Begin DoDot:2
+56 SET $PIECE(^TMP($JOB,"RPT",DATE1,HR,1),U,I)=$FNUMBER($PIECE(^TMP($JOB,"RPT",DATE1,HR),U,I)/TOTAL(DATE1,HR)*100,"",1)
End DoDot:2
End DoDot:1
+57 QUIT
+58 ;
PRINT ;-- print data
+1 ;
+2 USE IO
+3 DO HDR
+4 if '$DATA(^TMP($JOB))
QUIT
+5 NEW CONT,DATE,I,TOTAL,KMPDFGBG,KMPDMESS
+6 SET (KMPDFG,KMPDBG)=0
+7 SET DATE=""
SET CONT=1
+8 FOR
SET DATE=$ORDER(^TMP($JOB,"RPT",DATE))
if 'DATE
QUIT
Begin DoDot:1
+9 WRITE !,$$FMTE^XLFDT(DATE,2)
SET HR=""
+10 FOR
SET HR=$ORDER(^TMP($JOB,"RPT",DATE,HR))
if HR=""
QUIT
Begin DoDot:2
+11 IF $Y>(IOSL-9)
Begin DoDot:3
+12 DO CONTINUE^KMPDUTL4("",1,.CONT)
if 'CONT
QUIT
+13 DO HDR
WRITE !,$$FMTE^XLFDT(DATE,2)
End DoDot:3
if 'CONT
QUIT
+14 WRITE ?12,HR
+15 SET TOTAL=""
SET DATA=^TMP($JOB,"RPT",DATE,HR)
SET DATA(1)=$GET(^TMP($JOB,"RPT",DATE,HR,1))
+16 ; if no data
+17 IF DATA=""
WRITE ?12," <No Data>",!
QUIT
+18 ; display data
+19 FOR I=1:1:9
Begin DoDot:3
+20 WRITE ?16,I-1*10," to <",I*10
+21 WRITE ?32,$JUSTIFY($FNUMBER($PIECE(DATA,U,I),",",0),10)
+22 ; percentages
+23 WRITE ?48,$JUSTIFY($FNUMBER($PIECE(DATA(1),U,I),"",1),10),"%"
+24 WRITE !
+25 ; totals
+26 SET $PIECE(TOTAL,U)=$PIECE(TOTAL,U)+$PIECE(DATA,U,I)
+27 SET $PIECE(TOTAL,U,2)=$PIECE(TOTAL,U,2)+$PIECE(DATA(1),U,I)
End DoDot:3
+28 ; greater than 90
+29 WRITE ?16,"90 or greater",?32,$JUSTIFY($FNUMBER($PIECE(DATA,U,10),",",0),10)
+30 WRITE ?48,$JUSTIFY($FNUMBER($PIECE(DATA(1),U,10),"",1),10),"%"
+31 SET $PIECE(TOTAL,U)=$PIECE(TOTAL,U)+$PIECE(DATA,U,10)
+32 SET $PIECE(TOTAL,U,2)=$PIECE(TOTAL,U,2)+$PIECE(DATA(1),U,10)
+33 ; totals
+34 WRITE !?32,"----------",?48,"----------"
+35 WRITE !?32,$JUSTIFY($FNUMBER($PIECE(TOTAL,U),",",0),10)
+36 WRITE ?48,$JUSTIFY($FNUMBER($PIECE(TOTAL,U,2),"",0),10),"%"
+37 WRITE !?16,"Incomplete",?32,$JUSTIFY($FNUMBER($PIECE(DATA,U,50),",",0),10),!
+38 ; page feed if another date
+39 IF $ORDER(^TMP($JOB,DATE))
Begin DoDot:3
+40 DO CONTINUE^KMPDUTL4("",1,.CONT)
if 'CONT
QUIT
+41 DO HDR
End DoDot:3
+42 WRITE !
End DoDot:2
if 'CONT
QUIT
End DoDot:1
if 'CONT
QUIT
+43 ;
+44 IF CONT
Begin DoDot:1
+45 ; legend
+46 SET KMPDFGBG=0
+47 IF $GET(KMPDTOT("ORWCV"))>0
SET KMPDFGBG=KMPDFGBG+1
+48 IF $GET(KMPDTOT("ORWCV-FT"))>0
SET KMPDFGBG=KMPDFGBG+2
+49 WRITE !!?2,"CV = Coversheet",?30,"Coversheet sections run in:"
+50 WRITE !?2,"TTL = Time-to-Load"
+51 WRITE ?30,$SELECT(KMPDFGBG=1:"Background Only",KMPDFGBG=2:"Foreground Only",KMPDFGBG=3:"Both Foreground and Background",1:"Unknown")
+52 ; pause if output to terminal
+53 DO CONTINUE^KMPDUTL4("Press RETURN to continue",1)
End DoDot:1
+54 ;
+55 QUIT
+56 ;
HDR ;-- print header
+1 WRITE @IOF
+2 SET X=$GET(KMPDTTL)
+3 WRITE !?(80-$LENGTH(X)\2),X
+4 SET X=$GET(KMPDATE(0))
SET X=$PIECE(X,U,3)_" - "_$PIECE(X,U,4)
+5 WRITE !?(80-$LENGTH(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
+6 WRITE !
+7 WRITE !,"Date",?12,"Hr",?16,"TTL Seconds",?32,"# CV Loads",?48,"CV Percent"
+8 WRITE !,$$REPEAT^XLFSTR("-",IOM)
+9 ;
+10 QUIT
+11 ;
EXIT ;-- cleanup on exit
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 DO ^%ZISC
+3 KILL KMPDATE,KMPDTTL
+4 QUIT