KMPDTU11 ;OAK/RAK/JML - CP Tools Timing Utility ;9/1/2015
;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
;
RLTMHR(KMPDQIET,KMPDASK,KMPDEF) ;-- extrinsic function - real time hours
;-----------------------------------------------------------------------
; KMPDQIET... Display output
; 0 - display output (not quiet)
; 1 - do not display output (quiet)
; KMPDASK.... Ask user to select hours
; 0 - do not ask user to select
; 1 - ask user to select
; KMPDEF..... Default
; 0 - do not use default
; 1 - use time range as default
;
; Return: List of hours (ie, 1,2,5,6,7...)
; "" - no selection made
;-----------------------------------------------------------------------
;
S KMPDQIET=+$G(KMPDQIET),KMPDASK=+$G(KMPDASK),KMPDEF=+$G(KMPDEF)
N DATA,DIR,DOT,HOURS,HR,I,QUEUED,X,Y,KMPDSUB
W:'KMPDQIET !," ==> building Hours list..."
F KMPDSUB="ORWCV","ORWCV-FT" D
.S I="",DOT=0
.F S I=$O(^KMPTMP("KMPDT",KMPDSUB,I)) Q:I="" S DATA=^(I) I DATA]"" D
..S DOT=DOT+1 W:'(DOT#1000)&('KMPDQIET) "."
..; change $h to fileman format and get hour
..S HR=$E($P($$HTFM^XLFDT($P(DATA,U)),".",2),1,2) S:HR>23 HR="0"
..; create HOURS() array
..S:HR'="" HOURS(+HR)=""
;
; if no HOURS() array
Q:'$D(HOURS) ""
;
; do not ask user to select hours
I 'KMPDASK D Q X
.S (I,X)="" F S I=$O(HOURS(I)) Q:I="" S X=X_I_","
;
; ask user to select hour(s)
S DIR(0)="LO^"_$O(HOURS(""))_":"_$O(HOURS("A"),-1)
S DIR("A")="Select Hour(s)"
S:KMPDEF DIR("B")=$O(HOURS(""))_"-"_$O(HOURS("A"),-1)
W ! D ^DIR
Q $S(Y=""!(Y="^"):"",1:$G(Y(0)))
;
TIMING(KMPDSS,KMPDNODE,KMPDST,KMPDHTM,KMPDUZ,KMPDCL) ;-- start/stop timing stats
;--------------------------------------------------------------------
; KMPDSS... subscript (free text)
; KMPDNODE. node name (free text)
; KMPDST... start/stop
; 1 - start
; 2 - stop
; KMPDHTM.. (optional - if not defined the current $h will be used)
; time in $h format
; KMPDUZ... (optional -if not defined the current duz will be used)
; user duz
; KMPDCL... (optional - if not defined the current IO("CLNM")) will be used)
; client name (free text)
;
;--------------------------------------------------------------------
; quit if timing stats not turned on
Q:'$G(^KMPTMP("KMPD-CPRS"))
; quit if no subscript
Q:$G(KMPDSS)=""
; quit if no node
Q:$G(KMPDNODE)=""
; start/stop
S KMPDST=+$G(KMPDST)
Q:KMPDST<1!(KMPDST>2)
S:'$G(KMPDHTM) KMPDHTM=$H
S:'$G(KMPDUZ) KMPDUZ=$G(DUZ)
S:$G(KMPDCL)="" KMPDCL=$G(IO("CLNM"))
;
; start timing
S:KMPDST=1 ^KMPTMP("KMPDT",KMPDSS,KMPDNODE)=KMPDHTM_"^^"_KMPDUZ_"^"_KMPDCL
; stop timing
S:KMPDST=2 $P(^KMPTMP("KMPDT",KMPDSS,KMPDNODE),"^",2)=KMPDHTM
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTU11 2877 printed Oct 16, 2024@17:41:46 Page 2
KMPDTU11 ;OAK/RAK/JML - CP Tools Timing Utility ;9/1/2015
+1 ;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
+2 ;
RLTMHR(KMPDQIET,KMPDASK,KMPDEF) ;-- extrinsic function - real time hours
+1 ;-----------------------------------------------------------------------
+2 ; KMPDQIET... Display output
+3 ; 0 - display output (not quiet)
+4 ; 1 - do not display output (quiet)
+5 ; KMPDASK.... Ask user to select hours
+6 ; 0 - do not ask user to select
+7 ; 1 - ask user to select
+8 ; KMPDEF..... Default
+9 ; 0 - do not use default
+10 ; 1 - use time range as default
+11 ;
+12 ; Return: List of hours (ie, 1,2,5,6,7...)
+13 ; "" - no selection made
+14 ;-----------------------------------------------------------------------
+15 ;
+16 SET KMPDQIET=+$GET(KMPDQIET)
SET KMPDASK=+$GET(KMPDASK)
SET KMPDEF=+$GET(KMPDEF)
+17 NEW DATA,DIR,DOT,HOURS,HR,I,QUEUED,X,Y,KMPDSUB
+18 if 'KMPDQIET
WRITE !," ==> building Hours list..."
+19 FOR KMPDSUB="ORWCV","ORWCV-FT"
Begin DoDot:1
+20 SET I=""
SET DOT=0
+21 FOR
SET I=$ORDER(^KMPTMP("KMPDT",KMPDSUB,I))
if I=""
QUIT
SET DATA=^(I)
IF DATA]""
Begin DoDot:2
+22 SET DOT=DOT+1
if '(DOT#1000)&('KMPDQIET)
WRITE "."
+23 ; change $h to fileman format and get hour
+24 SET HR=$EXTRACT($PIECE($$HTFM^XLFDT($PIECE(DATA,U)),".",2),1,2)
if HR>23
SET HR="0"
+25 ; create HOURS() array
+26 if HR'=""
SET HOURS(+HR)=""
End DoDot:2
End DoDot:1
+27 ;
+28 ; if no HOURS() array
+29 if '$DATA(HOURS)
QUIT ""
+30 ;
+31 ; do not ask user to select hours
+32 IF 'KMPDASK
Begin DoDot:1
+33 SET (I,X)=""
FOR
SET I=$ORDER(HOURS(I))
if I=""
QUIT
SET X=X_I_","
End DoDot:1
QUIT X
+34 ;
+35 ; ask user to select hour(s)
+36 SET DIR(0)="LO^"_$ORDER(HOURS(""))_":"_$ORDER(HOURS("A"),-1)
+37 SET DIR("A")="Select Hour(s)"
+38 if KMPDEF
SET DIR("B")=$ORDER(HOURS(""))_"-"_$ORDER(HOURS("A"),-1)
+39 WRITE !
DO ^DIR
+40 QUIT $SELECT(Y=""!(Y="^"):"",1:$GET(Y(0)))
+41 ;
TIMING(KMPDSS,KMPDNODE,KMPDST,KMPDHTM,KMPDUZ,KMPDCL) ;-- start/stop timing stats
+1 ;--------------------------------------------------------------------
+2 ; KMPDSS... subscript (free text)
+3 ; KMPDNODE. node name (free text)
+4 ; KMPDST... start/stop
+5 ; 1 - start
+6 ; 2 - stop
+7 ; KMPDHTM.. (optional - if not defined the current $h will be used)
+8 ; time in $h format
+9 ; KMPDUZ... (optional -if not defined the current duz will be used)
+10 ; user duz
+11 ; KMPDCL... (optional - if not defined the current IO("CLNM")) will be used)
+12 ; client name (free text)
+13 ;
+14 ;--------------------------------------------------------------------
+15 ; quit if timing stats not turned on
+16 if '$GET(^KMPTMP("KMPD-CPRS"))
QUIT
+17 ; quit if no subscript
+18 if $GET(KMPDSS)=""
QUIT
+19 ; quit if no node
+20 if $GET(KMPDNODE)=""
QUIT
+21 ; start/stop
+22 SET KMPDST=+$GET(KMPDST)
+23 if KMPDST<1!(KMPDST>2)
QUIT
+24 if '$GET(KMPDHTM)
SET KMPDHTM=$HOROLOG
+25 if '$GET(KMPDUZ)
SET KMPDUZ=$GET(DUZ)
+26 if $GET(KMPDCL)=""
SET KMPDCL=$GET(IO("CLNM"))
+27 ;
+28 ; start timing
+29 if KMPDST=1
SET ^KMPTMP("KMPDT",KMPDSS,KMPDNODE)=KMPDHTM_"^^"_KMPDUZ_"^"_KMPDCL
+30 ; stop timing
+31 if KMPDST=2
SET $PIECE(^KMPTMP("KMPDT",KMPDSS,KMPDNODE),"^",2)=KMPDHTM
+32 ;
+33 QUIT