KMPRBD03 ;OAK/RAK - Resource Usage Monitor Data Compression ;5/28/03 08:38
;;2.0;CAPACITY MANAGEMENT - RUM;;May 28, 2003
;
; Background Driver (cont.)
;
FILE(KMPRDATE,KMPRNODE,KMPROPT,KMPRPT,KMPRNP,KMPRPTHR,KMPRNPHR,KMPROK,KMPRMSG) ;
;-----------------------------------------------------------------------
; KMPRDATE.... Date in $H Format
; KMPRNODE.... Node Name
; KMPROPT..... Option (in 2 pieces with "***" as delimiter)
; piece 1 - option name
; piece 2 - protocol (optional)
; KMPRPT().... Array for Prime Time data - passed by reference
; (1)... Prime Time Data (8 elements)
; (1.1). Hour count (24 hours)
; (1.2). User count (24 hours)
; KMPRNP().... Array fo Non-Prime data - passed by reference
; (1)... Non-Prime Time Data (8 elements)
; (1.1). Hour count (24 hours)
; (1.2). User count (24 hours)
; KMPRPTHR.... Number of Prime Time Hours
; KMPRNPHR.... Number of Non Prime Hours
; KMPROK...... Returns: 0 - update not successful
; 1 - update successful
; KMPRMSG..... If KMPROK = 0 then message text will be returned in this
; array (passed by reference)
;
; File data in file #8971.1 (RESOUCE USAGE MONITOR)
;-----------------------------------------------------------------------
;
S KMPROK=0
Q:'$G(KMPRDATE)
Q:$G(KMPRNODE)=""
Q:$G(KMPROPT)=""
Q:'$D(KMPRPT)&('$D(KMPRNP))
S KMPRPTHR=+$G(KMPRPTHR),KMPRNPHR=+$G(KMPRNPHR)
S KMPROK=1
K KMPRMSG
;
N FDA,FMDATE,I,J,MESSAGE,OPT,WORKDAY,ZIEN
;
S FMDATE=$$HTFM^XLFDT(KMPRDATE),WORKDAY=$$WORKDAY^XUWORKDY(FMDATE)
;
; date
S FDA($J,8971.1,"+1,",.01)=FMDATE
; sent to cm national database
S FDA($J,8971.1,"+1,",.02)=0
; cpu node
S FDA($J,8971.1,"+1,",.03)=KMPRNODE
; option
S OPT=$P(KMPROPT,"***")
; rum designation
S FDA($J,8971.1,"+1,",.08)=$$RUMDESIG(OPT)
; if the first character of OPT is '`' then this is an RPC
I $E(OPT)="`" S FDA($J,8971.1,"+1,",.07)=$E(OPT,2,999)
; if the first character of OPT is '&' then this is an HL7
E I $E(OPT)="&" S FDA($J,8971.1,"+1,",.09)=$E(OPT,2,999)
; option
E S FDA($J,8971.1,"+1,",.04)=$$OPTION(OPT)
; protocol
S:$P(KMPROPT,"***",2)'="" FDA($J,8971.1,"+1,",.05)=$P(KMPROPT,"***",2)
;
;--Populate prime time, non-prime time and non-workday fields
F I=1:1:8 S J=I*.01 D
.;
.; subscript 1 - workday prime time (PT)
.I $P($G(KMPRPT(1)),U,I)'=""&(KMPRPTHR) D
..S FDA($J,8971.1,"+1,",1+J)=$FN($P(KMPRPT(1),U,I),"",2)
.;
.I $P($G(KMPRNP(1)),U,I)'=""&(KMPRNPHR) D
..; subscript 2 - workday non-prime time (NP)
..I WORKDAY S FDA($J,8971.1,"+1,",2+J)=$FN($P(KMPRNP(1),U,I),"",2)
..; subscript 3 - entire non-workday time (NW)
..E S FDA($J,8971.1,"+1,",3+J)=$FN($P(KMPRNP(1),U,I),"",2)
;
;--Populate workday and non-workday hourly occurrence and user counts
; non-workday is considered non-prime time
F I=1:1:24 S J=I*.001 D
.;
.; subscript 1.1 - workday (WD) hourly occurrence counts
.I $P($G(KMPRPT(1.1)),U,I)'="" D
..S FDA($J,8971.1,"+1,",1.1+J)=$P(KMPRPT(1.1),U,I)
.;
.; subscript 1.2 - workday (WD) hourly user counts
.I $P($G(KMPRPT(1.2)),U,I)'="" D
..S FDA($J,8971.1,"+1,",1.2+J)=$P(KMPRPT(1.2),U,I)
.;
.; subscript 2.1 - non-workday (NW) hourly occurrence counts
.I $P($G(KMPRNP(1.1)),U,I)'="" D
..S FDA($J,8971.1,"+1,",2.1+J)=$P(KMPRNP(1.1),U,I)
.;
.; subscript 2.2 - non-workday (NW) hourly user counts
.I $P($G(KMPRNP(1.2)),U,I)'="" D
..S FDA($J,8971.1,"+1,",2.2+J)=$P(KMPRNP(1.2),U,I)
;
; update file 8971.1
D UPDATE^DIE("","FDA($J)","ZIEN","MESSAGE")
; if error message
I $D(MESSAGE) S KMPROK=0 D MSG^DIALOG("A",.KMPRMSG,60,10,"MESSAGE")
;
Q
;
RUMDESIG(KMPROPT) ;-- extrinsic function - determine rum designation
;-----------------------------------------------------------------------
; KMPROPT... Option name
;
; Return: RUM Designation (see field #.08 RUM DESIGNATION in file
; #8971.1)
;-----------------------------------------------------------------------
;
; 5 = other
Q:$G(KMPROPT)="" 5
; 1 = taskman
Q:KMPROPT="$AFTR ZTMS$"!(KMPROPT="$STRT ZTMS$")!($E(KMPROPT)="!") 1
; 3 = broker
Q:$E(KMPROPT)="`" 3
; 4 = users
Q:$E(KMPROPT)="#" 4
; 2 - option
Q 2
;
OPTION(KMPROPT) ;-- extrinsic function - option name
;-----------------------------------------------------------------------
; KMPROPT... Option name as it appears from ^KMPTMP("KMPR","DLY")
;
; Return: Option name with extraneous characters removed
;-----------------------------------------------------------------------
;
Q:$G(KMPROPT)="" ""
Q:$E(KMPROPT)="!" $E(KMPROPT,2,999)
; rpc
Q:$E(KMPROPT)="`" ""
Q KMPROPT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPRBD03 4755 printed Nov 22, 2024@16:51:46 Page 2
KMPRBD03 ;OAK/RAK - Resource Usage Monitor Data Compression ;5/28/03 08:38
+1 ;;2.0;CAPACITY MANAGEMENT - RUM;;May 28, 2003
+2 ;
+3 ; Background Driver (cont.)
+4 ;
FILE(KMPRDATE,KMPRNODE,KMPROPT,KMPRPT,KMPRNP,KMPRPTHR,KMPRNPHR,KMPROK,KMPRMSG) ;
+1 ;-----------------------------------------------------------------------
+2 ; KMPRDATE.... Date in $H Format
+3 ; KMPRNODE.... Node Name
+4 ; KMPROPT..... Option (in 2 pieces with "***" as delimiter)
+5 ; piece 1 - option name
+6 ; piece 2 - protocol (optional)
+7 ; KMPRPT().... Array for Prime Time data - passed by reference
+8 ; (1)... Prime Time Data (8 elements)
+9 ; (1.1). Hour count (24 hours)
+10 ; (1.2). User count (24 hours)
+11 ; KMPRNP().... Array fo Non-Prime data - passed by reference
+12 ; (1)... Non-Prime Time Data (8 elements)
+13 ; (1.1). Hour count (24 hours)
+14 ; (1.2). User count (24 hours)
+15 ; KMPRPTHR.... Number of Prime Time Hours
+16 ; KMPRNPHR.... Number of Non Prime Hours
+17 ; KMPROK...... Returns: 0 - update not successful
+18 ; 1 - update successful
+19 ; KMPRMSG..... If KMPROK = 0 then message text will be returned in this
+20 ; array (passed by reference)
+21 ;
+22 ; File data in file #8971.1 (RESOUCE USAGE MONITOR)
+23 ;-----------------------------------------------------------------------
+24 ;
+25 SET KMPROK=0
+26 if '$GET(KMPRDATE)
QUIT
+27 if $GET(KMPRNODE)=""
QUIT
+28 if $GET(KMPROPT)=""
QUIT
+29 if '$DATA(KMPRPT)&('$DATA(KMPRNP))
QUIT
+30 SET KMPRPTHR=+$GET(KMPRPTHR)
SET KMPRNPHR=+$GET(KMPRNPHR)
+31 SET KMPROK=1
+32 KILL KMPRMSG
+33 ;
+34 NEW FDA,FMDATE,I,J,MESSAGE,OPT,WORKDAY,ZIEN
+35 ;
+36 SET FMDATE=$$HTFM^XLFDT(KMPRDATE)
SET WORKDAY=$$WORKDAY^XUWORKDY(FMDATE)
+37 ;
+38 ; date
+39 SET FDA($JOB,8971.1,"+1,",.01)=FMDATE
+40 ; sent to cm national database
+41 SET FDA($JOB,8971.1,"+1,",.02)=0
+42 ; cpu node
+43 SET FDA($JOB,8971.1,"+1,",.03)=KMPRNODE
+44 ; option
+45 SET OPT=$PIECE(KMPROPT,"***")
+46 ; rum designation
+47 SET FDA($JOB,8971.1,"+1,",.08)=$$RUMDESIG(OPT)
+48 ; if the first character of OPT is '`' then this is an RPC
+49 IF $EXTRACT(OPT)="`"
SET FDA($JOB,8971.1,"+1,",.07)=$EXTRACT(OPT,2,999)
+50 ; if the first character of OPT is '&' then this is an HL7
+51 IF '$TEST
IF $EXTRACT(OPT)="&"
SET FDA($JOB,8971.1,"+1,",.09)=$EXTRACT(OPT,2,999)
+52 ; option
+53 IF '$TEST
SET FDA($JOB,8971.1,"+1,",.04)=$$OPTION(OPT)
+54 ; protocol
+55 if $PIECE(KMPROPT,"***",2)'=""
SET FDA($JOB,8971.1,"+1,",.05)=$PIECE(KMPROPT,"***",2)
+56 ;
+57 ;--Populate prime time, non-prime time and non-workday fields
+58 FOR I=1:1:8
SET J=I*.01
Begin DoDot:1
+59 ;
+60 ; subscript 1 - workday prime time (PT)
+61 IF $PIECE($GET(KMPRPT(1)),U,I)'=""&(KMPRPTHR)
Begin DoDot:2
+62 SET FDA($JOB,8971.1,"+1,",1+J)=$FNUMBER($PIECE(KMPRPT(1),U,I),"",2)
End DoDot:2
+63 ;
+64 IF $PIECE($GET(KMPRNP(1)),U,I)'=""&(KMPRNPHR)
Begin DoDot:2
+65 ; subscript 2 - workday non-prime time (NP)
+66 IF WORKDAY
SET FDA($JOB,8971.1,"+1,",2+J)=$FNUMBER($PIECE(KMPRNP(1),U,I),"",2)
+67 ; subscript 3 - entire non-workday time (NW)
+68 IF '$TEST
SET FDA($JOB,8971.1,"+1,",3+J)=$FNUMBER($PIECE(KMPRNP(1),U,I),"",2)
End DoDot:2
End DoDot:1
+69 ;
+70 ;--Populate workday and non-workday hourly occurrence and user counts
+71 ; non-workday is considered non-prime time
+72 FOR I=1:1:24
SET J=I*.001
Begin DoDot:1
+73 ;
+74 ; subscript 1.1 - workday (WD) hourly occurrence counts
+75 IF $PIECE($GET(KMPRPT(1.1)),U,I)'=""
Begin DoDot:2
+76 SET FDA($JOB,8971.1,"+1,",1.1+J)=$PIECE(KMPRPT(1.1),U,I)
End DoDot:2
+77 ;
+78 ; subscript 1.2 - workday (WD) hourly user counts
+79 IF $PIECE($GET(KMPRPT(1.2)),U,I)'=""
Begin DoDot:2
+80 SET FDA($JOB,8971.1,"+1,",1.2+J)=$PIECE(KMPRPT(1.2),U,I)
End DoDot:2
+81 ;
+82 ; subscript 2.1 - non-workday (NW) hourly occurrence counts
+83 IF $PIECE($GET(KMPRNP(1.1)),U,I)'=""
Begin DoDot:2
+84 SET FDA($JOB,8971.1,"+1,",2.1+J)=$PIECE(KMPRNP(1.1),U,I)
End DoDot:2
+85 ;
+86 ; subscript 2.2 - non-workday (NW) hourly user counts
+87 IF $PIECE($GET(KMPRNP(1.2)),U,I)'=""
Begin DoDot:2
+88 SET FDA($JOB,8971.1,"+1,",2.2+J)=$PIECE(KMPRNP(1.2),U,I)
End DoDot:2
End DoDot:1
+89 ;
+90 ; update file 8971.1
+91 DO UPDATE^DIE("","FDA($J)","ZIEN","MESSAGE")
+92 ; if error message
+93 IF $DATA(MESSAGE)
SET KMPROK=0
DO MSG^DIALOG("A",.KMPRMSG,60,10,"MESSAGE")
+94 ;
+95 QUIT
+96 ;
RUMDESIG(KMPROPT) ;-- extrinsic function - determine rum designation
+1 ;-----------------------------------------------------------------------
+2 ; KMPROPT... Option name
+3 ;
+4 ; Return: RUM Designation (see field #.08 RUM DESIGNATION in file
+5 ; #8971.1)
+6 ;-----------------------------------------------------------------------
+7 ;
+8 ; 5 = other
+9 if $GET(KMPROPT)=""
QUIT 5
+10 ; 1 = taskman
+11 if KMPROPT="$AFTR ZTMS$"!(KMPROPT="$STRT ZTMS$")!($EXTRACT(KMPROPT)="!")
QUIT 1
+12 ; 3 = broker
+13 if $EXTRACT(KMPROPT)="`"
QUIT 3
+14 ; 4 = users
+15 if $EXTRACT(KMPROPT)="#"
QUIT 4
+16 ; 2 - option
+17 QUIT 2
+18 ;
OPTION(KMPROPT) ;-- extrinsic function - option name
+1 ;-----------------------------------------------------------------------
+2 ; KMPROPT... Option name as it appears from ^KMPTMP("KMPR","DLY")
+3 ;
+4 ; Return: Option name with extraneous characters removed
+5 ;-----------------------------------------------------------------------
+6 ;
+7 if $GET(KMPROPT)=""
QUIT ""
+8 if $EXTRACT(KMPROPT)="!"
QUIT $EXTRACT(KMPROPT,2,999)
+9 ; rpc
+10 if $EXTRACT(KMPROPT)="`"
QUIT ""
+11 QUIT KMPROPT