AMQQMGR2 ; IHS/CMI/THL - QMAN USAGE LOG ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;-----
ASK S DIR("??")="AMQQLOG"
S DIR("A")=$C(10)_" Your choice"
S DIR("?")="Enter a code from the list or type '??' for more information"
S DIR(0)="SO^1:ACTIVATE Log;2:INACTIVATE Log;3:PURGE Log;4:VIEW Log;9:HELP;0:EXIT"
D ^DIR
K DIR
I 'Y K DUOUT,DIRUT,DTOUT G EXIT
I Y=9 W !!,"Enter a code from the list or type '??' for more information." G ASK
D @("L"_Y)
I '$D(AMQQQUIT) G MENU
EXIT K AMQQQUIT,X,Y,AMQQLLD,AMQQLOG1,AMQQLOGN,%,%H,%I,A,B,C,D,FR,TO,H,M,S,T,Z
Q
;
CHK I $D(DTOUT)+$D(DUOUT)+(Y=-1)+(Y="") K DIRUT,DUOUT,DTOUT S AMQQQUIT="" Q
Q
;
LOG ; ENTRY POINT
I '$P($G(^AMQQ(8,DUZ(2),0)),U,7) Q
I '$D(^AMQQ(8,DUZ(2),4,0)) S ^(0)="^9009078.04D^^0"
N X,%,Y,DIC,DIE,DA,DR,DINUM,Z,%I,%H
S Z="D"
S %=$$KEYCHECK^AMQQUTIL("AMQQZCLIN")
I % S Z="C"
D NOW^%DTC
S (DINUM,X)=%
S DIC="^AMQQ(8,DA(1),4,"
S DIC(0)="L"
S DA(1)=DUZ(2)
D FILE^DICN
I Y=-1 Q
S (DA,AMQQLOGN)=+Y
S AMQQLOG1=%H
S DIE=DIC
S DR=".02////"_DUZ_";.03////"_Z
I $G(ION)'="" S DR=DR_";.04////"_$O(^%ZIS(1,"B",ION,""))
S %=$G(AMQQCNAM)
S:%="LIVING PATIENTS" %="PATIENTS"
I %'="" S %=%_": "
S Y=0
F Z=0:0 S Z=$O(^UTILITY("AMQQ",$J,"Q",Z)) Q:'Z S:Y %=%_", " S %=%_$P(^(Z),U,2),Y=1
I %'="" S %=$E(%,1,189),DR=DR_";.07////"_%
D ^DIE
Q
;
TIME ; ENTRY POINT
I '$D(AMQQLOGN)!('$D(AMQQLOG1)) K AMQQLOGN,AMQQLOG1 Q
N A,B,C,D,%,Z,DA,DR,DIE,DIC,%H,%I,T,S,H,M
D NOW^%DTC
S S=%H
S A=+S
S B=$P(S,",",2)
S Z=(60*60*24)
S C=+AMQQLOG1
S D=$P(AMQQLOG1,",",2)
I (B-D)<0 S B=B+Z,A=A-1
S S=((A-C)*Z)+(B-D)
S T=S
S H=T\3600
I H S T=T#3600
S M=T\60
I M S T=T#60
F %="H","M","T" S @%=$S('@%:"00",@%<10:("0"_@%),1:@%)
S T=H_":"_M_":"_T
S DA(1)=DUZ(2)
S DIE="^AMQQ(8,DA(1),4,"
S DA=AMQQLOGN
S DR=".05////"_S_";.06////"_T
D ^DIE
K AMQQLOGN,AMQQLOG1,%I
Q
;
TEST ;
S FLDS="[AMQQ LOG]"
S DIC="^AMQQ(8,"
S BY="@40,.01,@40,.05"
S FR="2910423.13000"
S TO="2910501,55"
D EN1^DIP
Q
;
L4 ; VIEW LOG
W @IOF,!,?20,"***** VIEW QUERY LOG *****",!!
S DIR(0)="DO^::ETS"
S DIR("A")="Start with what date"
D ^DIR
K DIR
I Y="" S Y=2100000 W " Start with first entry"
I 'Y K DUOUT,DTOUT,DIRUT Q
S AMQQLD1=Y
S DIR(0)="DO^::ETS"
S DIR("A")="End with what date"
D ^DIR
K DIR
I Y="" S Y=3900000 W " Go to last entry"
I 'Y K DUOUT,DTOUT,DIRUT Q
S AMQQLD2=Y
I AMQQLD1>AMQQLD2 W " ????",*7 H 2 G L4
W !!!,"When viewing the log, you may sort by one of the following attributes =>",!!
S DIR(0)="SO^1:USER (e.g. DOE,JOHN);2:SECURITY LEVEL (DEMOGRAPHIC or CLINICAL);3:OUTPUT DEVICE;4:SESSION DURATION (SECONDS);0:NONE"
S DIR("A")="Your choice"
S DIR("B")="NONE"
D ^DIR
K DIR
I Y=0 G LIST
I 'Y K DUOUT,DTOUT,DIRUT Q
S AMQQLBY=",@40,.0"_(Y+1)
LIST S BY="@40,.01"_$G(AMQQLBY)
S FR=AMQQLD1_",?"
S TO=AMQQLD2_",?"
S DIC="^AMQQ(8,"
S FLDS="[AMQQ LOG]"
S DHD="QMAN LOG"
W !! D EN1^DIP
S DIR(0)="E"
D ^DIR
K DUOUT,DTOUT,DIRUT,DIR
K AMQQLBY,AMQQLD1,AMQQLD2,DIJ,B
Q
;
L1 S X=1
G LACT
L2 S X=0
LACT S DIE="^AMQQ(8,"
S DA=DUZ(2)
S DR=".07////"_X
D ^DIE
K DIE,DA,DR
W !!,"The Q-Man LOG has been ",$S(X:"activated",1:"deactivated"),!!
H 2
Q
;
L3 ; PURGE
W !!
S DIR(0)="DO^::ET"
S DIR("A")="Purge all QMan LOG entries prior to what date"
S DIR("B")="NOW"
D ^DIR
K DIR
I 'Y K DUOUT,DTOUT,DIRUT Q
S AMQQLLD=Y
F DA=0:0 S DA=$O(^AMQQ(8,DUZ(2),4,DA)) Q:'DA Q:DA>AMQQLLD S DIK="^AMQQ(8,DA(1),4,",DA(1)=DUZ(2) D ^DIK W "."
K DA,DA,DIK,AMQQLLD
W !!,"The Q-MAN LOG has been purged as requested",!!
H 2
Q
;
AMQQMGR2 ; IHS/CMI/THL - QMAN USAGE LOG ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;-----
ASK SET DIR("??")="AMQQLOG"
+1 SET DIR("A")=$CHAR(10)_" Your choice"
+2 SET DIR("?")="Enter a code from the list or type '??' for more information"
+3 SET DIR(0)="SO^1:ACTIVATE Log;2:INACTIVATE Log;3:PURGE Log;4:VIEW Log;9:HELP;0:EXIT"
+4 DO ^DIR
+5 KILL DIR
+6 IF 'Y
KILL DUOUT,DIRUT,DTOUT
GOTO EXIT
+7 IF Y=9
WRITE !!,"Enter a code from the list or type '??' for more information."
GOTO ASK
+8 DO @("L"_Y)
+9 IF '$DATA(AMQQQUIT)
GOTO MENU
EXIT KILL AMQQQUIT,X,Y,AMQQLLD,AMQQLOG1,AMQQLOGN,%,%H,%I,A,B,C,D,FR,TO,H,M,S,T,Z
+1 QUIT
+2 ;
CHK IF $DATA(DTOUT)+$DATA(DUOUT)+(Y=-1)+(Y="")
KILL DIRUT,DUOUT,DTOUT
SET AMQQQUIT=""
QUIT
+1 QUIT
+2 ;
LOG ; ENTRY POINT
+1 IF '$PIECE($GET(^AMQQ(8,DUZ(2),0)),U,7)
QUIT
+2 IF '$DATA(^AMQQ(8,DUZ(2),4,0))
SET ^(0)="^9009078.04D^^0"
+3 NEW X,%,Y,DIC,DIE,DA,DR,DINUM,Z,%I,%H
+4 SET Z="D"
+5 SET %=$$KEYCHECK^AMQQUTIL("AMQQZCLIN")
+6 IF %
SET Z="C"
+7 DO NOW^%DTC
+8 SET (DINUM,X)=%
+9 SET DIC="^AMQQ(8,DA(1),4,"
+10 SET DIC(0)="L"
+11 SET DA(1)=DUZ(2)
+12 DO FILE^DICN
+13 IF Y=-1
QUIT
+14 SET (DA,AMQQLOGN)=+Y
+15 SET AMQQLOG1=%H
+16 SET DIE=DIC
+17 SET DR=".02////"_DUZ_";.03////"_Z
+18 IF $GET(ION)'=""
SET DR=DR_";.04////"_$ORDER(^%ZIS(1,"B",ION,""))
+19 SET %=$GET(AMQQCNAM)
+20 IF %="LIVING PATIENTS"
SET %="PATIENTS"
+21 IF %'=""
SET %=%_": "
+22 SET Y=0
+23 FOR Z=0:0
SET Z=$ORDER(^UTILITY("AMQQ",$JOB,"Q",Z))
IF 'Z
QUIT
IF Y
SET %=%_", "
SET %=%_$PIECE(^(Z),U,2)
SET Y=1
+24 IF %'=""
SET %=$EXTRACT(%,1,189)
SET DR=DR_";.07////"_%
+25 DO ^DIE
+26 QUIT
+27 ;
TIME ; ENTRY POINT
+1 IF '$DATA(AMQQLOGN)!('$DATA(AMQQLOG1))
KILL AMQQLOGN,AMQQLOG1
QUIT
+2 NEW A,B,C,D,%,Z,DA,DR,DIE,DIC,%H,%I,T,S,H,M
+3 DO NOW^%DTC
+4 SET S=%H
+5 SET A=+S
+6 SET B=$PIECE(S,",",2)
+7 SET Z=(60*60*24)
+8 SET C=+AMQQLOG1
+9 SET D=$PIECE(AMQQLOG1,",",2)
+10 IF (B-D)<0
SET B=B+Z
SET A=A-1
+11 SET S=((A-C)*Z)+(B-D)
+12 SET T=S
+13 SET H=T\3600
+14 IF H
SET T=T#3600
+15 SET M=T\60
+16 IF M
SET T=T#60
+17 FOR %="H","M","T"
SET @%=$SELECT('@%:"00",@%<10:("0"_@%),1:@%)
+18 SET T=H_":"_M_":"_T
+19 SET DA(1)=DUZ(2)
+20 SET DIE="^AMQQ(8,DA(1),4,"
+21 SET DA=AMQQLOGN
+22 SET DR=".05////"_S_";.06////"_T
+23 DO ^DIE
+24 KILL AMQQLOGN,AMQQLOG1,%I
+25 QUIT
+26 ;
TEST ;
+1 SET FLDS="[AMQQ LOG]"
+2 SET DIC="^AMQQ(8,"
+3 SET BY="@40,.01,@40,.05"
+4 SET FR="2910423.13000"
+5 SET TO="2910501,55"
+6 DO EN1^DIP
+7 QUIT
+8 ;
L4 ; VIEW LOG
+1 WRITE @IOF,!,?20,"***** VIEW QUERY LOG *****",!!
+2 SET DIR(0)="DO^::ETS"
+3 SET DIR("A")="Start with what date"
+4 DO ^DIR
+5 KILL DIR
+6 IF Y=""
SET Y=2100000
WRITE " Start with first entry"
+7 IF 'Y
KILL DUOUT,DTOUT,DIRUT
QUIT
+8 SET AMQQLD1=Y
+9 SET DIR(0)="DO^::ETS"
+10 SET DIR("A")="End with what date"
+11 DO ^DIR
+12 KILL DIR
+13 IF Y=""
SET Y=3900000
WRITE " Go to last entry"
+14 IF 'Y
KILL DUOUT,DTOUT,DIRUT
QUIT
+15 SET AMQQLD2=Y
+16 IF AMQQLD1>AMQQLD2
WRITE " ????",*7
HANG 2
GOTO L4
+17 WRITE !!!,"When viewing the log, you may sort by one of the following attributes =>",!!
+18 SET DIR(0)="SO^1:USER (e.g. DOE,JOHN);2:SECURITY LEVEL (DEMOGRAPHIC or CLINICAL);3:OUTPUT DEVICE;4:SESSION DURATION (SECONDS);0:NONE"
+19 SET DIR("A")="Your choice"
+20 SET DIR("B")="NONE"
+21 DO ^DIR
+22 KILL DIR
+23 IF Y=0
GOTO LIST
+24 IF 'Y
KILL DUOUT,DTOUT,DIRUT
QUIT
+25 SET AMQQLBY=",@40,.0"_(Y+1)
LIST SET BY="@40,.01"_$GET(AMQQLBY)
+1 SET FR=AMQQLD1_",?"
+2 SET TO=AMQQLD2_",?"
+3 SET DIC="^AMQQ(8,"
+4 SET FLDS="[AMQQ LOG]"
+5 SET DHD="QMAN LOG"
+6 WRITE !!
DO EN1^DIP
+7 SET DIR(0)="E"
+8 DO ^DIR
+9 KILL DUOUT,DTOUT,DIRUT,DIR
+10 KILL AMQQLBY,AMQQLD1,AMQQLD2,DIJ,B
+11 QUIT
+12 ;
L1 SET X=1
+1 GOTO LACT
L2 SET X=0
LACT SET DIE="^AMQQ(8,"
+1 SET DA=DUZ(2)
+2 SET DR=".07////"_X
+3 DO ^DIE
+4 KILL DIE,DA,DR
+5 WRITE !!,"The Q-Man LOG has been ",$SELECT(X:"activated",1:"deactivated"),!!
+6 HANG 2
+7 QUIT
+8 ;
L3 ; PURGE
+1 WRITE !!
+2 SET DIR(0)="DO^::ET"
+3 SET DIR("A")="Purge all QMan LOG entries prior to what date"
+4 SET DIR("B")="NOW"
+5 DO ^DIR
+6 KILL DIR
+7 IF 'Y
KILL DUOUT,DTOUT,DIRUT
QUIT
+8 SET AMQQLLD=Y
+9 FOR DA=0:0
SET DA=$ORDER(^AMQQ(8,DUZ(2),4,DA))
IF 'DA
QUIT
IF DA>AMQQLLD
QUIT
SET DIK="^AMQQ(8,DA(1),4,"
SET DA(1)=DUZ(2)
DO ^DIK
WRITE "."
+10 KILL DA,DA,DIK,AMQQLLD
+11 WRITE !!,"The Q-MAN LOG has been purged as requested",!!
+12 HANG 2
+13 QUIT
+14 ;