KMPDTP7 ;OAK/RAK/JML - Real-Time CP Timing Hourly Time-to-Load ;9/1/2015
;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
;
EN ;-- entry point
N KMPDTTL,POP,X,Y,ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
S KMPDTTL=" Real-Time Hourly Coversheet Time-to-Load (TTL) Report "
D HDR^KMPDUTL4(KMPDTTL)
W !
W !?7,"This report displays the hourly average time-to-load value"
W !?7,"for the coversheet at this site over 24 hours."
W !
;
; if no data
I ($O(^KMPTMP("KMPDT","ORWCV",""))="")&($O(^KMPTMP("KMPDT","ORWCV-FT",""))="") D Q
.W !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"", ***"
;
; 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^KMPDTP7"
.S 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
K ^TMP($J)
D DATA,PRINT,EXIT
K ^TMP($J)
Q
;
DATA ;-- compile data
;
N DATA,DATA1,DATE,DATE1,DELTA,DOT,HOURS,HR,I,QUEUED,TIME
N KMPDSS,DELTA,TOTDELT,HRDATE,COMPLETE
;
S DOT=1,QUEUED=$D(ZTQUEUED),DATE=$$DT^XLFDT
; array with hours
S HOURS=$$RLTMHR^KMPDTU11(1,0) Q:HOURS=""
F I=1:1 Q:$P(HOURS,",",I)="" S ^TMP($J,"RPT",DATE,$P(HOURS,",",I))=""
; collect raw data
F KMPDSS="ORWCV","ORWCV-FT" D
.S I=""
.F S I=$O(^KMPTMP("KMPDT",KMPDSS,I)) Q:I="" S DATA=^(I) I DATA]"" D
..S DOT=DOT+1 W:'QUEUED&('(DOT#1000)) "."
..; start/end date/time in fileman format
..S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
..Q:'DATE(1)!('DATE(2))
..S ^TMP($J,"DATA",I,KMPDSS)=DATA
; collate raw data - combined FG and BG
S I=""
F S I=$O(^TMP($J,"DATA",I)) Q:I="" D
.S (KMPDSS,DATA1,HRDATE,TOTDELT)=""
.S DELTA=0,COMPLETE=1
.F KMPDSS="ORWCV","ORWCV-FT" D
..S DATA=$G(^TMP($J,"DATA",I,KMPDSS))
..Q:DATA=""
..S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
..I DATE(1)>1 S HRDATE=DATE(1)
..I (DATE(1)<0)!(DATE(2)<0) S COMPLETE=0 Q
..; get delta
..S DELTA=$$HDIFF^XLFDT($P(DATA,U,2),$P(DATA,U),2)
..; date without time
..S DATE1=$P(DATE(1),".") I 'DATE1 Q
..S TOTDELT=$G(TOTDELT)+DELTA
.; determine hour
.Q:TOTDELT=""
.Q:HRDATE=""
.S HR=+$E($P(HRDATE,".",2),1,2)
.S HR=$S(HR="":0,HR=24:0,1:HR)
.; calculate min/max/tot/count
.; if delta
.I COMPLETE D
..; minimum delta
..I $P(^TMP($J,"RPT",DATE,HR),U,2)=""!(TOTDELT<$P(^TMP($J,"RPT",DATE,HR),U,2)) D
...S $P(^TMP($J,"RPT",DATE,HR),U,2)=TOTDELT
..; maximum delta
..I TOTDELT>$P(^TMP($J,"RPT",DATE,HR),U,3) S $P(^TMP($J,"RPT",DATE,HR),U,3)=TOTDELT
..; total delta
..S $P(^TMP($J,"RPT",DATE,HR),U,4)=$P(^TMP($J,"RPT",DATE,HR),U,4)+TOTDELT
..; count
..S $P(^TMP($J,"RPT",DATE,HR),U,5)=$P(^TMP($J,"RPT",DATE,HR),U,5)+1
.; if no delta
.E S $P(^TMP($J,"RPT",DATE,HR),U,6)=$P(^TMP($J,"RPT",DATE,HR),U,6)+1
; calculate average
F HR=1:1 S I=$P(HOURS,",",HR) Q:I="" I $P(^TMP($J,"RPT",DATE,I),U,5) D
.S $P(^TMP($J,"RPT",DATE,I),U)=$P(^TMP($J,"RPT",DATE,I),U,4)/$P(^TMP($J,"RPT",DATE,I),U,5)
Q
;
PRINT ;-- print data
U IO
D HDR
Q:'$D(^TMP($J))
N CONT,DATE,HR,I,TOTAL
S DATE="",CONT=1
F S DATE=$O(^TMP($J,"RPT",DATE)) Q:'DATE S HR="" D Q:'CONT
.S TOTAL=""
.W !,$$FMTE^XLFDT(DATE,2)
.F S HR=$O(^TMP($J,"RPT",DATE,HR)) Q:HR="" D Q:'CONT
..; page feed
..I $Y>(IOSL-3) D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT D HDR W !
..W ?12," ",$S($L(HR)=1:"0",1:""),HR
..S DATA=^TMP($J,"RPT",DATE,HR)
..W ?20,$J($FN($P(DATA,U),",",0),10)
..W ?34,$J($FN($P(DATA,U,2),",",0),10)
..W ?48,$J($FN($P(DATA,U,3),",",0),10)
..W ?62,$J($FN($P(DATA,U,5),",",0),10)
..W !
..S $P(TOTAL,U)=$P(TOTAL,U)+$P(DATA,U,5)
..S $P(TOTAL,U,2)=$P(TOTAL,U,2)+$P(DATA,U,6)
.;
.; back to DATE level
.; totals
.W ?62,"----------",!?62,$J($FN(TOTAL,",",0),10),!
.W !?12,"Incomplete: ",$J($FN($P(TOTAL,U,2),",",0),$L($P(TOTAL,U,2))+2),!
.; if another date
.I $O(^TMP($J,"RPT",DATE)) D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT D HDR W !
;
I CONT D
.; legend
.W !!?2,"CV = Coversheet",!?2,"TTL = Time-to-Load"
.; 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=$$FMTE^XLFDT($$DT^XLFDT)
W !?(80-$L(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
W !
W !?20,"|---------------Seconds---------------|"
W !,"Date",?12,"Hour",?20,"TTL Average",?34,"TTL Minimum",?48,"TTL Maximum",?62,"# of CV Loads"
W !,$$REPEAT^XLFSTR("-",IOM)
;
Q
;
EXIT ;-- cleanup on exit
S:$D(ZTQUEUED) ZTREQ="@"
D ^%ZISC
K KMPDTTL
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTP7 4827 printed Dec 13, 2024@01:40:51 Page 2
KMPDTP7 ;OAK/RAK/JML - Real-Time 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 NEW KMPDTTL,POP,X,Y,ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
+2 SET KMPDTTL=" Real-Time Hourly Coversheet Time-to-Load (TTL) Report "
+3 DO HDR^KMPDUTL4(KMPDTTL)
+4 WRITE !
+5 WRITE !?7,"This report displays the hourly average time-to-load value"
+6 WRITE !?7,"for the coversheet at this site over 24 hours."
+7 WRITE !
+8 ;
+9 ; if no data
+10 IF ($ORDER(^KMPTMP("KMPDT","ORWCV",""))="")&($ORDER(^KMPTMP("KMPDT","ORWCV-FT",""))="")
Begin DoDot:1
+11 WRITE !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"", ***"
End DoDot:1
QUIT
+12 ;
+13 ; select output device.
+14 SET %ZIS="Q"
SET %ZIS("A")="Device: "
SET %ZIS("B")="HOME"
+15 WRITE !
DO ^%ZIS
IF POP
WRITE !,"No action taken."
QUIT
+16 ; if queued.
+17 IF $DATA(IO("Q"))
KILL IO("Q")
Begin DoDot:1
+18 SET ZTDESC=KMPDTTL
+19 SET ZTRTN="EN1^KMPDTP7"
+20 SET ZTSAVE("KMPDTTL")=""
+21 DO ^%ZTLOAD
if $GET(ZTSK)
WRITE !,"Task #",ZTSK
+22 DO EXIT
End DoDot:1
QUIT
+23 ;
+24 ; if output to terminal display message.
+25 if $EXTRACT(IOST,1,2)="C-"
WRITE !,"Compiling timing stats..."
+26 DO EN1
+27 ;
+28 QUIT
+29 ;
EN1 ;-- entry point from taskman
+1 KILL ^TMP($JOB)
+2 DO DATA
DO PRINT
DO EXIT
+3 KILL ^TMP($JOB)
+4 QUIT
+5 ;
DATA ;-- compile data
+1 ;
+2 NEW DATA,DATA1,DATE,DATE1,DELTA,DOT,HOURS,HR,I,QUEUED,TIME
+3 NEW KMPDSS,DELTA,TOTDELT,HRDATE,COMPLETE
+4 ;
+5 SET DOT=1
SET QUEUED=$DATA(ZTQUEUED)
SET DATE=$$DT^XLFDT
+6 ; array with hours
+7 SET HOURS=$$RLTMHR^KMPDTU11(1,0)
if HOURS=""
QUIT
+8 FOR I=1:1
if $PIECE(HOURS,",",I)=""
QUIT
SET ^TMP($JOB,"RPT",DATE,$PIECE(HOURS,",",I))=""
+9 ; collect raw data
+10 FOR KMPDSS="ORWCV","ORWCV-FT"
Begin DoDot:1
+11 SET I=""
+12 FOR
SET I=$ORDER(^KMPTMP("KMPDT",KMPDSS,I))
if I=""
QUIT
SET DATA=^(I)
IF DATA]""
Begin DoDot:2
+13 SET DOT=DOT+1
if 'QUEUED&('(DOT#1000))
WRITE "."
+14 ; start/end date/time in fileman format
+15 SET DATE(1)=$$HTFM^XLFDT($PIECE(DATA,U))
SET DATE(2)=$$HTFM^XLFDT($PIECE(DATA,U,2))
+16 if 'DATE(1)!('DATE(2))
QUIT
+17 SET ^TMP($JOB,"DATA",I,KMPDSS)=DATA
End DoDot:2
End DoDot:1
+18 ; collate raw data - combined FG and BG
+19 SET I=""
+20 FOR
SET I=$ORDER(^TMP($JOB,"DATA",I))
if I=""
QUIT
Begin DoDot:1
+21 SET (KMPDSS,DATA1,HRDATE,TOTDELT)=""
+22 SET DELTA=0
SET COMPLETE=1
+23 FOR KMPDSS="ORWCV","ORWCV-FT"
Begin DoDot:2
+24 SET DATA=$GET(^TMP($JOB,"DATA",I,KMPDSS))
+25 if DATA=""
QUIT
+26 SET DATE(1)=$$HTFM^XLFDT($PIECE(DATA,U))
SET DATE(2)=$$HTFM^XLFDT($PIECE(DATA,U,2))
+27 IF DATE(1)>1
SET HRDATE=DATE(1)
+28 IF (DATE(1)<0)!(DATE(2)<0)
SET COMPLETE=0
QUIT
+29 ; get delta
+30 SET DELTA=$$HDIFF^XLFDT($PIECE(DATA,U,2),$PIECE(DATA,U),2)
+31 ; date without time
+32 SET DATE1=$PIECE(DATE(1),".")
IF 'DATE1
QUIT
+33 SET TOTDELT=$GET(TOTDELT)+DELTA
End DoDot:2
+34 ; determine hour
+35 if TOTDELT=""
QUIT
+36 if HRDATE=""
QUIT
+37 SET HR=+$EXTRACT($PIECE(HRDATE,".",2),1,2)
+38 SET HR=$SELECT(HR="":0,HR=24:0,1:HR)
+39 ; calculate min/max/tot/count
+40 ; if delta
+41 IF COMPLETE
Begin DoDot:2
+42 ; minimum delta
+43 IF $PIECE(^TMP($JOB,"RPT",DATE,HR),U,2)=""!(TOTDELT<$PIECE(^TMP($JOB,"RPT",DATE,HR),U,2))
Begin DoDot:3
+44 SET $PIECE(^TMP($JOB,"RPT",DATE,HR),U,2)=TOTDELT
End DoDot:3
+45 ; maximum delta
+46 IF TOTDELT>$PIECE(^TMP($JOB,"RPT",DATE,HR),U,3)
SET $PIECE(^TMP($JOB,"RPT",DATE,HR),U,3)=TOTDELT
+47 ; total delta
+48 SET $PIECE(^TMP($JOB,"RPT",DATE,HR),U,4)=$PIECE(^TMP($JOB,"RPT",DATE,HR),U,4)+TOTDELT
+49 ; count
+50 SET $PIECE(^TMP($JOB,"RPT",DATE,HR),U,5)=$PIECE(^TMP($JOB,"RPT",DATE,HR),U,5)+1
End DoDot:2
+51 ; if no delta
+52 IF '$TEST
SET $PIECE(^TMP($JOB,"RPT",DATE,HR),U,6)=$PIECE(^TMP($JOB,"RPT",DATE,HR),U,6)+1
End DoDot:1
+53 ; calculate average
+54 FOR HR=1:1
SET I=$PIECE(HOURS,",",HR)
if I=""
QUIT
IF $PIECE(^TMP($JOB,"RPT",DATE,I),U,5)
Begin DoDot:1
+55 SET $PIECE(^TMP($JOB,"RPT",DATE,I),U)=$PIECE(^TMP($JOB,"RPT",DATE,I),U,4)/$PIECE(^TMP($JOB,"RPT",DATE,I),U,5)
End DoDot:1
+56 QUIT
+57 ;
PRINT ;-- print data
+1 USE IO
+2 DO HDR
+3 if '$DATA(^TMP($JOB))
QUIT
+4 NEW CONT,DATE,HR,I,TOTAL
+5 SET DATE=""
SET CONT=1
+6 FOR
SET DATE=$ORDER(^TMP($JOB,"RPT",DATE))
if 'DATE
QUIT
SET HR=""
Begin DoDot:1
+7 SET TOTAL=""
+8 WRITE !,$$FMTE^XLFDT(DATE,2)
+9 FOR
SET HR=$ORDER(^TMP($JOB,"RPT",DATE,HR))
if HR=""
QUIT
Begin DoDot:2
+10 ; page feed
+11 IF $Y>(IOSL-3)
DO CONTINUE^KMPDUTL4("",1,.CONT)
if 'CONT
QUIT
DO HDR
WRITE !
+12 WRITE ?12," ",$SELECT($LENGTH(HR)=1:"0",1:""),HR
+13 SET DATA=^TMP($JOB,"RPT",DATE,HR)
+14 WRITE ?20,$JUSTIFY($FNUMBER($PIECE(DATA,U),",",0),10)
+15 WRITE ?34,$JUSTIFY($FNUMBER($PIECE(DATA,U,2),",",0),10)
+16 WRITE ?48,$JUSTIFY($FNUMBER($PIECE(DATA,U,3),",",0),10)
+17 WRITE ?62,$JUSTIFY($FNUMBER($PIECE(DATA,U,5),",",0),10)
+18 WRITE !
+19 SET $PIECE(TOTAL,U)=$PIECE(TOTAL,U)+$PIECE(DATA,U,5)
+20 SET $PIECE(TOTAL,U,2)=$PIECE(TOTAL,U,2)+$PIECE(DATA,U,6)
End DoDot:2
if 'CONT
QUIT
+21 ;
+22 ; back to DATE level
+23 ; totals
+24 WRITE ?62,"----------",!?62,$JUSTIFY($FNUMBER(TOTAL,",",0),10),!
+25 WRITE !?12,"Incomplete: ",$JUSTIFY($FNUMBER($PIECE(TOTAL,U,2),",",0),$LENGTH($PIECE(TOTAL,U,2))+2),!
+26 ; if another date
+27 IF $ORDER(^TMP($JOB,"RPT",DATE))
DO CONTINUE^KMPDUTL4("",1,.CONT)
if 'CONT
QUIT
DO HDR
WRITE !
End DoDot:1
if 'CONT
QUIT
+28 ;
+29 IF CONT
Begin DoDot:1
+30 ; legend
+31 WRITE !!?2,"CV = Coversheet",!?2,"TTL = Time-to-Load"
+32 ; pause if output to terminal
+33 DO CONTINUE^KMPDUTL4("Press RETURN to continue",1)
End DoDot:1
+34 ;
+35 QUIT
+36 ;
HDR ;-- print header
+1 WRITE @IOF
+2 SET X=$GET(KMPDTTL)
+3 WRITE !?(80-$LENGTH(X)\2),X
+4 SET X=$$FMTE^XLFDT($$DT^XLFDT)
+5 WRITE !?(80-$LENGTH(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
+6 WRITE !
+7 WRITE !?20,"|---------------Seconds---------------|"
+8 WRITE !,"Date",?12,"Hour",?20,"TTL Average",?34,"TTL Minimum",?48,"TTL Maximum",?62,"# of CV Loads"
+9 WRITE !,$$REPEAT^XLFSTR("-",IOM)
+10 ;
+11 QUIT
+12 ;
EXIT ;-- cleanup on exit
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 DO ^%ZISC
+3 KILL KMPDTTL
+4 QUIT