KMPRUTL3 ;SF/RAK - Resource Usage Monitor Utilities ;1/20/00 07:37
;;1.0;CAPACITY MANAGEMENT - RUM;**1**;Dec 09, 1998
;
HRSDAYS(KMPRSDT,KMPREDT,KMPRKILL,KMPRRES) ;-- hours/days.
;-----------------------------------------------------------------------
; KMPRSDT.. Stat Date in internal fileman format.
; KMPREDT.. End Date in internal fileman format.
; KMPRKILL. Kill node after processing:
; 0 - do not kill.
; 1 - kill
; KMPRRES.. Array (passed by reference) containing days/hours info
; in format: KMPRRES(KMPRSDT,Node)=Data
; Where Data equals:
; '^' Piece 1 - Prime Time Days
; '^' Piece 2 - Prime Time Hours
; '^' Piece 3 - Non-Prime Time Days
; '^' Piece 4 - Non-Prime Time Hours
; Example:
; KMPRRES(2990130,"999A01")=5^9^7^15
; KMPRRES(2990130,"999A02")=5^4^7^10
; KMPRRES(2990130,"999A03")=5^9^7^15
; KMPRRES(...,...)=...
;-----------------------------------------------------------------------
;
K KMPRRES
;
Q:'$G(KMPRSDT)
Q:'$G(KMPREDT)
S KMPRKILL=+$G(KMPRKILL)
;
N DATA,DATE,DAYS,HOURS,I,NODE
;
D HOURS(KMPRSDT,KMPREDT,KMPRKILL,.HOURS) Q:'$D(HOURS)
S NODE=""
F S NODE=$O(HOURS(NODE)) Q:NODE="" D
.S (DATE,DAYS,HOURS)=0
.F S DATE=$O(HOURS(NODE,DATE)) Q:'DATE D
..S DATA=HOURS(NODE,DATE)
..; piece 1 - prime time.
..; piece 2 - non-prime time.
..F I=1,2 D
...; total hours.
...S $P(HOURS,U,I)=$P(HOURS,U,I)+$P(DATA,U,I)
...; if current day has hours then increment total days.
...S:$P(DATA,U,I) $P(DAYS,U,I)=$P(DAYS,U,I)+1
.; back to NODE level.
.S KMPRRES(KMPRSDT,NODE)=$P(DAYS,U)_"^"_$P(HOURS,U)_"^"_$P(DAYS,U,2)_"^"_$P(HOURS,U,2)
Q
;
HOURS(KMPRSDT,KMPREDT,KMPRKILL,KMPRRES) ;-- determine prime time & non-prime time hours
;-----------------------------------------------------------------------
; KMPRSDT.. Stat Date in internal fileman format.
; KMPREDT.. End Date in internal fileman format.
; KMPRKILL. Kill node after processing:
; 0 - do not kill.
; 1 - kill
; KMPRRES.. Array (passed by reference) containing days/hours info
; in format: KMPRRES(Date,Node)=Data
; Where Data equals:
; '^' Piece 1 - Prime Time Days
; '^' Piece 2 - Prime Time Hours
; '^' Piece 3 - Non-Prime Time Days
; '^' Piece 4 - Non-Prime Time Hours
; Example:
; KMPRRES(2990130,"999A01")=5^9^7^15
; KMPRRES(2990130,"999A02")=5^4^7^10
; KMPRRES(2990131,"999A01")=5^9^7^15
; KMPRRES(...,...)=...
;-----------------------------------------------------------------------
;
K KMPRRES
;
Q:'$G(KMPRSDT)
Q:'$G(KMPREDT)
S KMPRKILL=+$G(KMPRKILL)
;
N DATA,DATE,DOW,END,HOURS,HRS,I,NODE,PIECE
; end date.
S END=KMPREDT
S DATE=KMPRSDT-.1,(DAYS,HOURS)=""
F S DATE=$O(^XTMP("KMPR","HOURS",DATE)) Q:'DATE!(DATE>END) D
.Q:DATE<KMPRSDT!(DATE>END)
.S NODE="",DOW=$$DOW^XLFDT(DATE,1)
.; prime time (8am to 5pm).
.; if not saturday or sunday or holiday then prime time (piece 1).
.; if saturday or sunday then non-prime time (piece 2).
.S PIECE=$S(DOW'=0&(DOW'=6)&('$G(^HOLIDAY(DATE,0))):1,1:2)
.F S NODE=$O(^XTMP("KMPR","HOURS",DATE,NODE)) Q:NODE="" D
..S DATA=$G(^XTMP("KMPR","HOURS",DATE,NODE)) Q:DATA=""
..S (HOURS,HRS)=0
..;
..;*** times are offset by 1 so zero hour is in piece 1
..;*** one hour is in piece 2
..;*** two hour is in piece 3
..;*** etc.
..; prime time.
..F I=9:1:17 S HRS=HRS+$P(DATA,U,I)
..S $P(HOURS,U,PIECE)=$P(HOURS,U,PIECE)+HRS
..; non-prime time.
..S HRS=0
..F I=1:1:8,18:1:24 S HRS=HRS+$P(DATA,U,I)
..S $P(HOURS,U,2)=$P(HOURS,U,2)+HRS
..S KMPRRES(NODE,DATE)=HOURS
..K:KMPRKILL ^XTMP("KMPR","HOURS",DATE,NODE)
;
Q
;
PURGE(KMPRDDT,KMPRHRS) ;-- purge data in file #8971.1
;-----------------------------------------------------------------------
; KMPRDDT.. Date to begin purge in internal fileman format. Purge will
; reverse $order and delete entries 'EARLIER' than KMPRDDT.
; KMPRHRS.. Purge Hours/Days data from ^XTMP("KMPR","HOURS". Entries
; 'EARLIER' than KMPRDDT will be deleted.
; 0 - do not purge hours/days data.
; 1 - purge hours/days data.
;-----------------------------------------------------------------------
;
Q:'$G(KMPRDDT)
S KMPRHRS=+$G(KMPRHRS)
;
N DA,DATE,DIK,IEN
W:'$D(ZTQUEUED) !,"Deleting old records..."
S DATE=KMPRDDT
F S DATE=$O(^KMPR(8971.1,"B",DATE),-1) Q:'DATE!(DATE>KMPRDDT) D
.F IEN=0:0 S IEN=$O(^KMPR(8971.1,"B",DATE,IEN)) Q:'IEN D
..; quit if not 'sent to cm database'.
..Q:'$P($G(^KMPR(8971.1,IEN,0)),U,2)
..; Delete entry.
..S DA=IEN,DIK="^KMPR(8971.1," D ^DIK
;
Q:'KMPRHRS
W:'$D(ZTQUEUED) !,"Deleting old entries from ^XTMP(""KMPR"",""HOURS""..."
S DATE=KMPRDDT
F S DATE=$O(^XTMP("KMPR","HOURS",DATE),-1) Q:'DATE!(DATE>KMPRDDT) D
.K ^XTMP("KMPR","HOURS",DATE)
;
Q
KMPRUTL3 ;SF/RAK - Resource Usage Monitor Utilities ;1/20/00 07:37
+1 ;;1.0;CAPACITY MANAGEMENT - RUM;**1**;Dec 09, 1998
+2 ;
HRSDAYS(KMPRSDT,KMPREDT,KMPRKILL,KMPRRES) ;-- hours/days.
+1 ;-----------------------------------------------------------------------
+2 ; KMPRSDT.. Stat Date in internal fileman format.
+3 ; KMPREDT.. End Date in internal fileman format.
+4 ; KMPRKILL. Kill node after processing:
+5 ; 0 - do not kill.
+6 ; 1 - kill
+7 ; KMPRRES.. Array (passed by reference) containing days/hours info
+8 ; in format: KMPRRES(KMPRSDT,Node)=Data
+9 ; Where Data equals:
+10 ; '^' Piece 1 - Prime Time Days
+11 ; '^' Piece 2 - Prime Time Hours
+12 ; '^' Piece 3 - Non-Prime Time Days
+13 ; '^' Piece 4 - Non-Prime Time Hours
+14 ; Example:
+15 ; KMPRRES(2990130,"999A01")=5^9^7^15
+16 ; KMPRRES(2990130,"999A02")=5^4^7^10
+17 ; KMPRRES(2990130,"999A03")=5^9^7^15
+18 ; KMPRRES(...,...)=...
+19 ;-----------------------------------------------------------------------
+20 ;
+21 KILL KMPRRES
+22 ;
+23 IF '$GET(KMPRSDT)
QUIT
+24 IF '$GET(KMPREDT)
QUIT
+25 SET KMPRKILL=+$GET(KMPRKILL)
+26 ;
+27 NEW DATA,DATE,DAYS,HOURS,I,NODE
+28 ;
+29 DO HOURS(KMPRSDT,KMPREDT,KMPRKILL,.HOURS)
IF '$DATA(HOURS)
QUIT
+30 SET NODE=""
+31 FOR
SET NODE=$ORDER(HOURS(NODE))
IF NODE=""
QUIT
Begin DoDot:1
+32 SET (DATE,DAYS,HOURS)=0
+33 FOR
SET DATE=$ORDER(HOURS(NODE,DATE))
IF 'DATE
QUIT
Begin DoDot:2
+34 SET DATA=HOURS(NODE,DATE)
+35 ; piece 1 - prime time.
+36 ; piece 2 - non-prime time.
+37 FOR I=1,2
Begin DoDot:3
+38 ; total hours.
+39 SET $PIECE(HOURS,U,I)=$PIECE(HOURS,U,I)+$PIECE(DATA,U,I)
+40 ; if current day has hours then increment total days.
+41 IF $PIECE(DATA,U,I)
SET $PIECE(DAYS,U,I)=$PIECE(DAYS,U,I)+1
End DoDot:3
End DoDot:2
+42 ; back to NODE level.
+43 SET KMPRRES(KMPRSDT,NODE)=$PIECE(DAYS,U)_"^"_$PIECE(HOURS,U)_"^"_$PIECE(DAYS,U,2)_"^"_$PIECE(HOURS,U,2)
End DoDot:1
+44 QUIT
+45 ;
HOURS(KMPRSDT,KMPREDT,KMPRKILL,KMPRRES) ;-- determine prime time & non-prime time hours
+1 ;-----------------------------------------------------------------------
+2 ; KMPRSDT.. Stat Date in internal fileman format.
+3 ; KMPREDT.. End Date in internal fileman format.
+4 ; KMPRKILL. Kill node after processing:
+5 ; 0 - do not kill.
+6 ; 1 - kill
+7 ; KMPRRES.. Array (passed by reference) containing days/hours info
+8 ; in format: KMPRRES(Date,Node)=Data
+9 ; Where Data equals:
+10 ; '^' Piece 1 - Prime Time Days
+11 ; '^' Piece 2 - Prime Time Hours
+12 ; '^' Piece 3 - Non-Prime Time Days
+13 ; '^' Piece 4 - Non-Prime Time Hours
+14 ; Example:
+15 ; KMPRRES(2990130,"999A01")=5^9^7^15
+16 ; KMPRRES(2990130,"999A02")=5^4^7^10
+17 ; KMPRRES(2990131,"999A01")=5^9^7^15
+18 ; KMPRRES(...,...)=...
+19 ;-----------------------------------------------------------------------
+20 ;
+21 KILL KMPRRES
+22 ;
+23 IF '$GET(KMPRSDT)
QUIT
+24 IF '$GET(KMPREDT)
QUIT
+25 SET KMPRKILL=+$GET(KMPRKILL)
+26 ;
+27 NEW DATA,DATE,DOW,END,HOURS,HRS,I,NODE,PIECE
+28 ; end date.
+29 SET END=KMPREDT
+30 SET DATE=KMPRSDT-.1
SET (DAYS,HOURS)=""
+31 FOR
SET DATE=$ORDER(^XTMP("KMPR","HOURS",DATE))
IF 'DATE!(DATE>END)
QUIT
Begin DoDot:1
+32 IF DATE<KMPRSDT!(DATE>END)
QUIT
+33 SET NODE=""
SET DOW=$$DOW^XLFDT(DATE,1)
+34 ; prime time (8am to 5pm).
+35 ; if not saturday or sunday or holiday then prime time (piece 1).
+36 ; if saturday or sunday then non-prime time (piece 2).
+37 SET PIECE=$SELECT(DOW'=0&(DOW'=6)&('$GET(^HOLIDAY(DATE,0))):1,1:2)
+38 FOR
SET NODE=$ORDER(^XTMP("KMPR","HOURS",DATE,NODE))
IF NODE=""
QUIT
Begin DoDot:2
+39 SET DATA=$GET(^XTMP("KMPR","HOURS",DATE,NODE))
IF DATA=""
QUIT
+40 SET (HOURS,HRS)=0
+41 ;
+42 ;*** times are offset by 1 so zero hour is in piece 1
+43 ;*** one hour is in piece 2
+44 ;*** two hour is in piece 3
+45 ;*** etc.
+46 ; prime time.
+47 FOR I=9:1:17
SET HRS=HRS+$PIECE(DATA,U,I)
+48 SET $PIECE(HOURS,U,PIECE)=$PIECE(HOURS,U,PIECE)+HRS
+49 ; non-prime time.
+50 SET HRS=0
+51 FOR I=1:1:8,18:1:24
SET HRS=HRS+$PIECE(DATA,U,I)
+52 SET $PIECE(HOURS,U,2)=$PIECE(HOURS,U,2)+HRS
+53 SET KMPRRES(NODE,DATE)=HOURS
+54 IF KMPRKILL
KILL ^XTMP("KMPR","HOURS",DATE,NODE)
End DoDot:2
End DoDot:1
+55 ;
+56 QUIT
+57 ;
PURGE(KMPRDDT,KMPRHRS) ;-- purge data in file #8971.1
+1 ;-----------------------------------------------------------------------
+2 ; KMPRDDT.. Date to begin purge in internal fileman format. Purge will
+3 ; reverse $order and delete entries 'EARLIER' than KMPRDDT.
+4 ; KMPRHRS.. Purge Hours/Days data from ^XTMP("KMPR","HOURS". Entries
+5 ; 'EARLIER' than KMPRDDT will be deleted.
+6 ; 0 - do not purge hours/days data.
+7 ; 1 - purge hours/days data.
+8 ;-----------------------------------------------------------------------
+9 ;
+10 IF '$GET(KMPRDDT)
QUIT
+11 SET KMPRHRS=+$GET(KMPRHRS)
+12 ;
+13 NEW DA,DATE,DIK,IEN
+14 IF '$DATA(ZTQUEUED)
WRITE !,"Deleting old records..."
+15 SET DATE=KMPRDDT
+16 FOR
SET DATE=$ORDER(^KMPR(8971.1,"B",DATE),-1)
IF 'DATE!(DATE>KMPRDDT)
QUIT
Begin DoDot:1
+17 FOR IEN=0:0
SET IEN=$ORDER(^KMPR(8971.1,"B",DATE,IEN))
IF 'IEN
QUIT
Begin DoDot:2
+18 ; quit if not 'sent to cm database'.
+19 IF '$PIECE($GET(^KMPR(8971.1,IEN,0)),U,2)
QUIT
+20 ; Delete entry.
+21 SET DA=IEN
SET DIK="^KMPR(8971.1,"
DO ^DIK
End DoDot:2
End DoDot:1
+22 ;
+23 IF 'KMPRHRS
QUIT
+24 IF '$DATA(ZTQUEUED)
WRITE !,"Deleting old entries from ^XTMP(""KMPR"",""HOURS""..."
+25 SET DATE=KMPRDDT
+26 FOR
SET DATE=$ORDER(^XTMP("KMPR","HOURS",DATE),-1)
IF 'DATE!(DATE>KMPRDDT)
QUIT
Begin DoDot:1
+27 KILL ^XTMP("KMPR","HOURS",DATE)
End DoDot:1
+28 ;
+29 QUIT