AMQQRMD ; IHS/CMI/THL - DATE BUCKETS ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;-----
I AMQQCCLS="V" G:$D(AMQP(1)) START Q
I '$D(AMQQHOLD)!('$D(AMQQUATN)) Q
S %=$P($G(^UTILITY("AMQQ",$J,"AG",AMQQUATN,AMQQHOLD)),U,3)
I '% Q
S AMQP(1)=%
START I '$D(AMQQDZ) S (AMQQDZ,AMQQDX)=0
S AMQQDZ=AMQQDZ+1
I IOST["C-",AMQQDZ>1 W $C(13),AMQQDZ I AMQQDX W " (",AMQQDX,")"
I AMQQDZ>1 D SET Q
I IOST["C-" W !!!!,"CRUNCH, CRUNCH....",!!
D PRE
D SET
EXIT K %,%H,%T,%Y,A,G,I,J,N,Z
Q
;
FAIL S AMQQDX=AMQQDX+1
I AMQQDZ>1 W $C(13),AMQQDZ," (",AMQQDX,")"
Q
;
COUNT S (D1,AMQQDDS)=AMQQDDS\1
S (D2,AMQQDDF)=AMQQDDF\1
S Y=AMQQDDS
X ^DD("DD")
S AMQQDDS=Y
S Y=AMQQDDF
X ^DD("DD")
S AMQQDDF=Y
I (D2-D1)<8 K D1,D2 Q
F Y=2,1 S X=@("D"_Y) D H^%DTC S X(Y)=%H
S X(0)=%Y
S X=X(2)-X(1)+1
S Y=X\7
S Z=X#7
S %=$E("01234560123456",%Y+1,%Y+Z)
S X=""
F I=1:1:7 S X=X_(Y+(%[(I-1)))_U
S AMQQDD=X K D1,D2
Q
;
PRE K ^UTILITY("AMQQ",$J,"DOW")
S AMQQDGR="^UTILITY(""AMQQ"",$J,""DOW"")"
F I=0:1:23 S @AMQQDGR@("B",I)=0
F I=0:1:6 S @AMQQDGR@("C",I)=0
S AMQQDTOT=0
Q
;
SET S %=+^AUPNVSIT(AMQP(1),0),AMQQDAY=%\1
I %'["." D FAIL Q
I '$D(AMQQDDS) S AMQQDDS=%
I '$D(AMQQDDF) S AMQQDDF=%
I %<AMQQDDS S AMQQDDS=%
I %>AMQQDDF S AMQQDDF=%
S %=$P(%,".",2)
S %="."_%
S %=$J(%,1,4)
S AMQQDTIM=(%*100)\1
S X=AMQQDAY
D H^%DTC
S AMQQDAY=%Y
S %=$G(@AMQQDGR@("A",AMQQDTIM,AMQQDAY)),^(AMQQDAY)=%+1
S %=$G(@AMQQDGR@("B",AMQQDTIM)),^(AMQQDTIM)=%+1
S %=$G(@AMQQDGR@("C",AMQQDAY)),^(AMQQDAY)=%+1
S AMQQDTOT=AMQQDTOT+1
Q
;
PRINT I '$D(AMQQDDS) G PEXIT
D COUNT
D HEADER
S AMQQDGR="^UTILITY(""AMQQ"",$J,""DOW"")"
F AMQQDLIN=0:1:23 D:AMQQDLIN&'(AMQQDLIN#(IOSL-4)) PAUSE G:AMQQDLIN=999999 PEXIT D B1
W !!,"TOTAL"
S I=0
F J=16:8 W ?J,@AMQQDGR@("C",I) S I=I+1 I I=7 W ?(J+8),AMQQDTOT Q
I $D(AMQQDD) W !,"DAYS" S (I,N)=0 F J=16:8 S I=I+1 W ?J,$P(AMQQDD,U,I) S N=N+$P(AMQQDD,U,I) I I=7 W ?(J+8),N Q
I $D(AMQQDD) W !,"AVERAGE" S I=0 F J=16:8 D AVE I I=7 W ?(J+8) S %=AMQQDTOT/N,%=$J(%,1,1) W % Q
I IOST'?1"C-".E W @IOF D ^%ZISC G PEXIT
D ^%ZISC
R !!,"<>",AMQQDY:DTIME
PEXIT K X,Y,Z,A,G,AMQQDZ,AMQQDX,AMQQDLIN,N,AMQQDAY,AMQQDTIM,AMQQDTOT,%H,%Y,%T,AMQQDY,AMQQDGR,AMQQDDS,AMQQDDF,AMQQDD,AMQQRMFL
Q
;
AVE S I=I+1
I '$P(AMQQDD,U,I) S %=0
E S %=@AMQQDGR@("C",I-1)/$P(AMQQDD,U,I)
S %=$J(%,1,1)
W ?J,%
Q
;
B1 S %=AMQQDLIN
S %=%*100
S X=%
S Y=%+59
S I=0
I %<1000 S X="0"_X,Y="0"_Y
I X="00" S X="0000",Y="0059"
W !,X,"-",Y
F J=16:8 W ?J,$S($D(@AMQQDGR@("A",AMQQDLIN,I)):^(I),1:".") S I=I+1 I I=7 W ?(J+8),@AMQQDGR@("B",AMQQDLIN) Q
Q
;
PAUSE I IOST["C-" R !,"<>",AMQQRQ:DTIME S:'$T!(AMQQRQ=U) AMQQDLIN=999999 K AMQQRQ
I AMQQDLIN=999999 Q
D HEADER
Q
;
W !,"WORKLOAD DISTRIBUTION REPORT: ",AMQQDDS," to ",AMQQDDF,!
W "VISIT TIME"
S I=0
F J=14:8 S I=I+1 W ?J,$P("SUN^MON^TUE^WED^THU^FRI^SAT",U,I) I I=7 W ?(J+8),"TOT" Q
S AMQQDY=""
S $P(AMQQDY,"-",80)=""
W !,AMQQDY
K AMQQRI,AMQQRJ,AMQQDY
Q
;
WORKTASK S ZTRTN="WORKRUN^AMQQRMD"
S ZTIO=ION
S ZTDTH="NOW"
S ZTDESC="Q-MAN WORKLOAD DISTRIBUTION REPORT"
F I=1:1 S %=$P("AMQQRMFL;AMQV(;AMQQ200(;AMQQRV;AMQQNV;AMQQXV;^UTILITY(""AMQQ"",$J,;^UTILITY(""AMQQ RAND"",$J,;^UTILITY(""AMQQ TAX"",$J,",";",I) Q:%="" S ZTSAVE(%)=""
D ^%ZTLOAD
D ^%ZISC
W !!,$S($D(ZTSK):"Request queued!",1:"Request cancelled!"),!!!
H 3
Q
;
WORK ; ENTRY POINT FROM AMQQCMPL
D DEV
I $D(AMQQQUIT) Q
S AMQQRMFL="^AMQQRMD"
I $D(IO("Q")) D WORKTASK D ^%ZISC W @IOF Q
U IO D WORKRUN D ^%ZISC
Q
;
DEV W !!!
S %ZIS="Q"
D ^%ZIS
I POP K DUOUT,DTOUT,POP S AMQQQUIT=""
D PRINT^AMQQSEC E W " <= Not a secure device!!",*7 G DEV
I $D(IO("Q")),IO=IO(0) W !!,"You can not queue a job to a slave printer..Try again",!!,*7 G DEV
Q
;
WORKRUN W @IOF
X AMQV(0)
D PRINT
I IOST["P-" W @IOF
I $D(ZTQUEUED) D EXIT2^AMQQKILL S ZTREQ="@"
Q
;
AMQQRMD ; IHS/CMI/THL - DATE BUCKETS ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;-----
+3 IF AMQQCCLS="V"
IF $DATA(AMQP(1))
GOTO START
QUIT
+4 IF '$DATA(AMQQHOLD)!('$DATA(AMQQUATN))
QUIT
+5 SET %=$PIECE($GET(^UTILITY("AMQQ",$JOB,"AG",AMQQUATN,AMQQHOLD)),U,3)
+6 IF '%
QUIT
+7 SET AMQP(1)=%
START IF '$DATA(AMQQDZ)
SET (AMQQDZ,AMQQDX)=0
+1 SET AMQQDZ=AMQQDZ+1
+2 IF IOST["C-"
IF AMQQDZ>1
WRITE $CHAR(13),AMQQDZ
IF AMQQDX
WRITE " (",AMQQDX,")"
+3 IF AMQQDZ>1
DO SET
QUIT
+4 IF IOST["C-"
WRITE !!!!,"CRUNCH, CRUNCH....",!!
+5 DO PRE
+6 DO SET
EXIT KILL %,%H,%T,%Y,A,G,I,J,N,Z
+1 QUIT
+2 ;
FAIL SET AMQQDX=AMQQDX+1
+1 IF AMQQDZ>1
WRITE $CHAR(13),AMQQDZ," (",AMQQDX,")"
+2 QUIT
+3 ;
COUNT SET (D1,AMQQDDS)=AMQQDDS\1
+1 SET (D2,AMQQDDF)=AMQQDDF\1
+2 SET Y=AMQQDDS
+3 XECUTE ^DD("DD")
+4 SET AMQQDDS=Y
+5 SET Y=AMQQDDF
+6 XECUTE ^DD("DD")
+7 SET AMQQDDF=Y
+8 IF (D2-D1)<8
KILL D1,D2
QUIT
+9 FOR Y=2,1
SET X=@("D"_Y)
DO H^%DTC
SET X(Y)=%H
+10 SET X(0)=%Y
+11 SET X=X(2)-X(1)+1
+12 SET Y=X\7
+13 SET Z=X#7
+14 SET %=$EXTRACT("01234560123456",%Y+1,%Y+Z)
+15 SET X=""
+16 FOR I=1:1:7
SET X=X_(Y+(%[(I-1)))_U
+17 SET AMQQDD=X
KILL D1,D2
+18 QUIT
+19 ;
PRE KILL ^UTILITY("AMQQ",$JOB,"DOW")
+1 SET AMQQDGR="^UTILITY(""AMQQ"",$J,""DOW"")"
+2 FOR I=0:1:23
SET @AMQQDGR@("B",I)=0
+3 FOR I=0:1:6
SET @AMQQDGR@("C",I)=0
+4 SET AMQQDTOT=0
+5 QUIT
+6 ;
SET SET %=+^AUPNVSIT(AMQP(1),0)
SET AMQQDAY=%\1
+1 IF %'["."
DO FAIL
QUIT
+2 IF '$DATA(AMQQDDS)
SET AMQQDDS=%
+3 IF '$DATA(AMQQDDF)
SET AMQQDDF=%
+4 IF %<AMQQDDS
SET AMQQDDS=%
+5 IF %>AMQQDDF
SET AMQQDDF=%
+6 SET %=$PIECE(%,".",2)
+7 SET %="."_%
+8 SET %=$JUSTIFY(%,1,4)
+9 SET AMQQDTIM=(%*100)\1
+10 SET X=AMQQDAY
+11 DO H^%DTC
+12 SET AMQQDAY=%Y
+13 SET %=$GET(@AMQQDGR@("A",AMQQDTIM,AMQQDAY))
SET ^(AMQQDAY)=%+1
+14 SET %=$GET(@AMQQDGR@("B",AMQQDTIM))
SET ^(AMQQDTIM)=%+1
+15 SET %=$GET(@AMQQDGR@("C",AMQQDAY))
SET ^(AMQQDAY)=%+1
+16 SET AMQQDTOT=AMQQDTOT+1
+17 QUIT
+18 ;
PRINT IF '$DATA(AMQQDDS)
GOTO PEXIT
+1 DO COUNT
+2 DO HEADER
+3 SET AMQQDGR="^UTILITY(""AMQQ"",$J,""DOW"")"
+4 FOR AMQQDLIN=0:1:23
IF AMQQDLIN&'(AMQQDLIN#(IOSL-4))
DO PAUSE
IF AMQQDLIN=999999
GOTO PEXIT
DO B1
+5 WRITE !!,"TOTAL"
+6 SET I=0
+7 FOR J=16:8
WRITE ?J,@AMQQDGR@("C",I)
SET I=I+1
IF I=7
WRITE ?(J+8),AMQQDTOT
QUIT
+8 IF $DATA(AMQQDD)
WRITE !,"DAYS"
SET (I,N)=0
FOR J=16:8
SET I=I+1
WRITE ?J,$PIECE(AMQQDD,U,I)
SET N=N+$PIECE(AMQQDD,U,I)
IF I=7
WRITE ?(J+8),N
QUIT
+9 IF $DATA(AMQQDD)
WRITE !,"AVERAGE"
SET I=0
FOR J=16:8
DO AVE
IF I=7
WRITE ?(J+8)
SET %=AMQQDTOT/N
SET %=$JUSTIFY(%,1,1)
WRITE %
QUIT
+10 IF IOST'?1"C-".E
WRITE @IOF
DO ^%ZISC
GOTO PEXIT
+11 DO ^%ZISC
+12 READ !!,"<>",AMQQDY:DTIME
PEXIT KILL X,Y,Z,A,G,AMQQDZ,AMQQDX,AMQQDLIN,N,AMQQDAY,AMQQDTIM,AMQQDTOT,%H,%Y,%T,AMQQDY,AMQQDGR,AMQQDDS,AMQQDDF,AMQQDD,AMQQRMFL
+1 QUIT
+2 ;
AVE SET I=I+1
+1 IF '$PIECE(AMQQDD,U,I)
SET %=0
+2 IF '$TEST
SET %=@AMQQDGR@("C",I-1)/$PIECE(AMQQDD,U,I)
+3 SET %=$JUSTIFY(%,1,1)
+4 WRITE ?J,%
+5 QUIT
+6 ;
B1 SET %=AMQQDLIN
+1 SET %=%*100
+2 SET X=%
+3 SET Y=%+59
+4 SET I=0
+5 IF %<1000
SET X="0"_X
SET Y="0"_Y
+6 IF X="00"
SET X="0000"
SET Y="0059"
+7 WRITE !,X,"-",Y
+8 FOR J=16:8
WRITE ?J,$SELECT($DATA(@AMQQDGR@("A",AMQQDLIN,I)):^(I),1:".")
SET I=I+1
IF I=7
WRITE ?(J+8),@AMQQDGR@("B",AMQQDLIN)
QUIT
+9 QUIT
+10 ;
PAUSE IF IOST["C-"
READ !,"<>",AMQQRQ:DTIME
IF '$TEST!(AMQQRQ=U)
SET AMQQDLIN=999999
KILL AMQQRQ
+1 IF AMQQDLIN=999999
QUIT
+2 DO HEADER
+3 QUIT
+4 ;
+1 WRITE !,"WORKLOAD DISTRIBUTION REPORT: ",AMQQDDS," to ",AMQQDDF,!
+2 WRITE "VISIT TIME"
+3 SET I=0
+4 FOR J=14:8
SET I=I+1
WRITE ?J,$PIECE("SUN^MON^TUE^WED^THU^FRI^SAT",U,I)
IF I=7
WRITE ?(J+8),"TOT"
QUIT
+5 SET AMQQDY=""
+6 SET $PIECE(AMQQDY,"-",80)=""
+7 WRITE !,AMQQDY
+8 KILL AMQQRI,AMQQRJ,AMQQDY
+9 QUIT
+10 ;
WORKTASK SET ZTRTN="WORKRUN^AMQQRMD"
+1 SET ZTIO=ION
+2 SET ZTDTH="NOW"
+3 SET ZTDESC="Q-MAN WORKLOAD DISTRIBUTION REPORT"
+4 FOR I=1:1
SET %=$PIECE("AMQQRMFL;AMQV(;AMQQ200(;AMQQRV;AMQQNV;AMQQXV;^UTILITY(""AMQQ"",$J,;^UTILITY(""AMQQ RAND"",$J,;^UTILITY(""AMQQ TAX"",$J,",";",I)
IF %=""
QUIT
SET ZTSAVE(%)=""
+5 DO ^%ZTLOAD
+6 DO ^%ZISC
+7 WRITE !!,$SELECT($DATA(ZTSK):"Request queued!",1:"Request cancelled!"),!!!
+8 HANG 3
+9 QUIT
+10 ;
WORK ; ENTRY POINT FROM AMQQCMPL
+1 DO DEV
+2 IF $DATA(AMQQQUIT)
QUIT
+3 SET AMQQRMFL="^AMQQRMD"
+4 IF $DATA(IO("Q"))
DO WORKTASK
DO ^%ZISC
WRITE @IOF
QUIT
+5 USE IO
DO WORKRUN
DO ^%ZISC
+6 QUIT
+7 ;
DEV WRITE !!!
+1 SET %ZIS="Q"
+2 DO ^%ZIS
+3 IF POP
KILL DUOUT,DTOUT,POP
SET AMQQQUIT=""
+4 DO PRINT^AMQQSEC
IF '$TEST
WRITE " <= Not a secure device!!",*7
GOTO DEV
+5 IF $DATA(IO("Q"))
IF IO=IO(0)
WRITE !!,"You can not queue a job to a slave printer..Try again",!!,*7
GOTO DEV
+6 QUIT
+7 ;
WORKRUN WRITE @IOF
+1 XECUTE AMQV(0)
+2 DO PRINT
+3 IF IOST["P-"
WRITE @IOF
+4 IF $DATA(ZTQUEUED)
DO EXIT2^AMQQKILL
SET ZTREQ="@"
+5 QUIT
+6 ;