Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: KMPDTP5

KMPDTP5.m

Go to the documentation of this file.
  1. KMPDTP5 ;OAK/RAK/JML - CP Timing Threshold Alert ;9/1/2015
  1. ;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
  1. ;
  1. EN ;-- entry point
  1. ;
  1. N I,KMPDATE,KMPDSRCH,KMPDTSEC,KMPDTTL,POP,X,Y
  1. N ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
  1. N KMPDLBG,KMPDLFG,KMPDDTSS
  1. ;
  1. S KMPDTTL=" Coversheet Time-to-Load (TTL) Alert Report "
  1. D HDR^KMPDUTL4(KMPDTTL)
  1. W !
  1. W !?7,"This alerting report shows the particular coversheet loads"
  1. W !?7,"that had excessive time-to-load values. This report will"
  1. W !?7,"search for a particular person, a particular client name or"
  1. W !?7,"IP address."
  1. W !?7,"Foreground and background times are combined."
  1. W !
  1. ;
  1. ; if no data
  1. I '$O(^KMPD(8973.2,0)) D Q
  1. .W !!?7,"*** There is currently no data in file #8973.2 (CP TIMING) ***"
  1. ;
  1. ; date & hour(s) - first determine which subscript to use in API due to addition of foreground processing
  1. S KMPDLFG=$O(^KMPD(8973.2,"ASSDTTM","ORWCV-FT","A"),-1)
  1. S KMPDLBG=$O(^KMPD(8973.2,"ASSDTTM","ORWCV","A"),-1)
  1. S KMPDDTSS=$S(KMPDLFG=KMPDLBG:"ORWCV-FT",KMPDLFG>KMPDLBG:"ORWCV-FT",KMPDLFG<KMPDLBG:"ORWCV",1:"UNKNOWN")
  1. D DTTMRNG^KMPDTU10(KMPDDTSS,1,.KMPDATE,8)
  1. Q:$G(KMPDATE(0))=""
  1. Q:$G(KMPDATE(1))=""
  1. ;
  1. ; time-to-load threshold seconds
  1. S KMPDTSEC=$$TTLSEC^KMPDTU10
  1. Q:'KMPDTSEC
  1. ;
  1. ; search by
  1. D SRCHBY^KMPDTU10(.KMPDSRCH,"ORWCV")
  1. Q:'KMPDSRCH
  1. ;
  1. ; select output device.
  1. S %ZIS="Q",%ZIS("A")="Device: ",%ZIS("B")="HOME"
  1. W ! D ^%ZIS I POP W !,"No action taken." Q
  1. ; if queued.
  1. I $D(IO("Q")) K IO("Q") D Q
  1. .S ZTDESC=KMPDTTL
  1. .S ZTRTN="EN1^KMPDTP5"
  1. .F I="KMPDATE(","KMPDSRCH(","KMPDTSEC","KMPDTTL" S ZTSAVE(I)=""
  1. .D ^%ZTLOAD W:$G(ZTSK) !,"Task #",ZTSK
  1. .D EXIT
  1. ;
  1. ; if output to terminal display message.
  1. W:$E(IOST,1,2)="C-" !,"Compiling timing stats..."
  1. D EN1
  1. ;
  1. Q
  1. ;
  1. EN1 ;-- entry point from taskman
  1. I '$D(KMPDATE) D EXIT Q
  1. I '$D(KMPDSRCH) D EXIT Q
  1. I '$G(KMPDTSEC) D EXIT Q
  1. I $G(KMPDTTL)="" D EXIT Q
  1. ;
  1. K ^TMP($J)
  1. U IO
  1. D DATA,PRINT,EXIT
  1. K ^TMP($J)
  1. Q
  1. ;
  1. DATA ;-- compile data
  1. ;
  1. Q:'$D(KMPDATE)
  1. Q:'$G(KMPDSRCH)
  1. Q:'$G(KMPDTSEC)
  1. ;
  1. N DATA,DATE,DATE1,DELTA,DOT,END,GBL,GBLREF,HOUR,HR,I,IEN,QUEUED,TIME,XREF
  1. N KMPDBIDX,KMPDTOT,KMPDSS,KMPDLUSS
  1. ;
  1. S GBLREF=$$GLOBAL(.KMPDSRCH) Q:GBLREF=""
  1. S XREF=$P(GBLREF,U),KMPDLUSS=$P(GBLREF,U,2)
  1. ;
  1. S DOT=1,QUEUED=$D(ZTQUEUED)
  1. ; set up HOUR() array
  1. F I=1:1:24 S:$P(KMPDATE(1),",",I)'="" HOUR(+$P(KMPDATE(1),",",I))=""
  1. Q:'$D(HOUR)
  1. S DATE=$P(KMPDATE(0),U)-.1,END=$P(KMPDATE(0),U,2)+.9
  1. Q:'DATE!('END)
  1. ;
  1. K ^TMP($J)
  1. F KMPDSS="ORWCV","ORWCV-FT" D
  1. .; reset date and end for each pass
  1. .S DATE=$P(KMPDATE(0),U)-.1,END=$P(KMPDATE(0),U,2)+.9
  1. .S KMPDTOT(KMPDSS)=0
  1. .I KMPDLUSS="" S GBL=$NA(^KMPD(8973.2,XREF,KMPDSS))
  1. .I KMPDLUSS'="" S GBL=$NA(^KMPD(8973.2,XREF,KMPDSS,KMPDLUSS))
  1. .F S DATE=$O(@GBL@(DATE)) Q:'DATE!(DATE>END) D
  1. ..; determine hour
  1. ..S HR=+$E($P(DATE,".",2),1,2)
  1. ..S HR=$S(HR="":0,HR=24:0,1:HR)
  1. ..; quit if not in HOUR() array
  1. ..Q:'$D(HOUR(HR))
  1. ..; hour & second
  1. ..S TIME=$E($P(DATE,".",2),1,6) Q:'TIME
  1. ..; insert colon (:) between hour & second
  1. ..S TIME=$E(TIME,1,2)_":"_$E(TIME,3,4)_":"_$E(TIME,5,6)
  1. ..; date without time
  1. ..S DATE1=$P(DATE,".")
  1. ..S IEN=0
  1. ..F S IEN=$O(@GBL@(DATE,IEN)) Q:'IEN D
  1. ...Q:'$D(^KMPD(8973.2,IEN,0)) S DATA=^(0) Q:DATA=""
  1. ...S DOT=DOT+1 W:'QUEUED&('(DOT#1000)) "."
  1. ...S KMPDBIDX=$P(DATA,U)
  1. ...S ^TMP($J,"DATA",DATE,TIME,KMPDBIDX,KMPDSS)=DATA
  1. ...S $P(^TMP($J,"DATA",DATE,TIME,KMPDBIDX,KMPDSS),U,5)=$P($G(^VA(200,+$P(DATA,U,5),0)),U)
  1. ...S KMPDTOT(KMPDSS)=KMPDTOT(KMPDSS)+1
  1. ;
  1. Q
  1. ;
  1. PRINT ;-- print data
  1. ;
  1. U IO
  1. N KMPDCNAM,KMPDUNAM,KMPDIP,KMPDSET,KMPDPDT,KMPDTOTD
  1. D HDR
  1. Q:'$D(^TMP($J))
  1. N CONT,DATE,I,TOTAL
  1. S DATE="",CONT=1,TOTAL=0
  1. F S DATE=$O(^TMP($J,"DATA",DATE)) Q:'DATE D Q:'CONT
  1. .S HR=""
  1. .F S HR=$O(^TMP($J,"DATA",DATE,HR)) Q:HR="" D Q:'CONT
  1. ..I $Y>(IOSL-4) D Q:'CONT
  1. ...D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT
  1. ...D HDR ;W !,$$FMTE^XLFDT(DATE,2)
  1. ..S KMPDBIDX=""
  1. ..F S KMPDBIDX=$O(^TMP($J,"DATA",DATE,HR,KMPDBIDX)) Q:KMPDBIDX="" D
  1. ...S KMPDSS="",KMPDSET=1,KMPDTOTD=0
  1. ...F S KMPDSS=$O(^TMP($J,"DATA",DATE,HR,KMPDBIDX,KMPDSS)) Q:KMPDSS="" D
  1. ....S DATA=$G(^TMP($J,"DATA",DATE,HR,KMPDBIDX,KMPDSS))
  1. ....I KMPDSET D
  1. .....S KMPDUNAM=$S($P(DATA,U,5)]"":$E($P(DATA,U,5),1,23),1:"N/A")
  1. .....S KMPDCNAM=$S($P(DATA,U,6)]"":$E($P(DATA,U,6),1,23),1:"N/A")
  1. .....S KMPDIP=$S($P(DATA,U,9)]"":$P(DATA,U,9),1:"N/A")
  1. .....S KMPDSET=0
  1. ....S KMPDTOTD=KMPDTOTD+$P(DATA,U,4)
  1. ...; W COMBINED DATA
  1. ...Q:KMPDTOTD<KMPDTSEC
  1. ...S TOTAL=TOTAL+1
  1. ...S KMPDPDT=$$FMTE^XLFDT(DATE,2)
  1. ...W !,$P(KMPDPDT,"@",2),?10,KMPDUNAM,?35,KMPDCNAM,?60,KMPDIP,?76,KMPDTOTD
  1. K ^TMP($J)
  1. ;
  1. I TOTAL W !!?3,"Total Count: ",$J($FN(TOTAL,",",0),$L(TOTAL)+1)
  1. ;
  1. ; pause if output to terminal
  1. I CONT D CONTINUE^KMPDUTL4("Press RETURN to continue",1)
  1. ;
  1. Q
  1. ;
  1. HDR ;-- print header
  1. W @IOF
  1. N HRS
  1. S X=$G(KMPDTTL)
  1. W !?(80-$L(X)\2),X
  1. S HRS=$E(KMPDATE(1),1,$L(KMPDATE(1))-1)
  1. S X=$G(KMPDATE(0)),X=$P(X,U,3)_" - Hours: "_HRS
  1. W !?(80-$L(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
  1. I +KMPDSRCH<4 D
  1. .S X=$P($G(KMPDSRCH),U,2)_": "
  1. .S X=X_$P($G(KMPDSRCH(1)),U,$S((+$G(KMPDSRCH))=1:2,1:1))
  1. .W !?(80-$L(X)\2),X
  1. S X="Threshold: "_$G(KMPDTSEC)_" seconds"
  1. W !?(80-$L(X)\2),X
  1. W !
  1. W !,"Time",?10,"User Name",?35,"Client Name",?60,"IP Address",?76,"TTL"
  1. W !,$$REPEAT^XLFSTR("-",IOM)
  1. ;
  1. Q
  1. ;
  1. EXIT ;-- cleanup on exit
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. D ^%ZISC
  1. K KMPDATE,KMPDSRCH,KMPDTSEC,KMPDTTL
  1. Q
  1. ;
  1. GLOBAL(KMPDSRCH) ;-- extrinsic function
  1. ;-----------------------------------------------------------------------
  1. ; KMPDSRCH... see above
  1. ;-----------------------------------------------------------------------
  1. Q:'$G(KMPDSRCH) ""
  1. N RETURN,TYPE
  1. S RETURN=""
  1. S TYPE=+$G(KMPDSRCH),KMPDSRCH(1)=$G(KMPDSRCH(1))
  1. Q:'TYPE ""
  1. I TYPE<4 Q:KMPDSRCH(1)="" ""
  1. ; any occurrence
  1. I TYPE=4 S RETURN="ASSDTTM^"
  1. ; username
  1. I TYPE=1 S RETURN="ASSNPDTTM^"_+$P(KMPDSRCH(1),U)
  1. ; client name
  1. I TYPE=2 S RETURN="ASSCLDTTM^"_KMPDSRCH(1)
  1. ; ip address
  1. I TYPE=3 S RETURN="ASSIPDTTM^"_KMPDSRCH(1)
  1. Q RETURN
  1. ;