BDWPURG ; IHS/CMI/LAB - PURGE DW LOG ;
;;1.0;IHS DATA WAREHOUSE;;JAN 23, 2006
;
D INIT
I BDW("QFLG") D EOJ W !!,"Bye",!! K DIR S DIR(0)="E",DIR("A")="Press ENTER to continue" D ^DIR K DIR Q
D PROCESS
D EOJ
W !!,"DONE",!!
Q
;
PROCESS ;
S BDW("LOG")=BDW("OLDEST LOG")-1 F S BDW("LOG")=$O(^BDWXLOG(BDW("LOG"))) Q:BDW("LOG")'=+BDW("LOG") D DELCHK Q:BDW("QFLG")
Q
DELCHK ;
S X=^BDWXLOG(BDW("LOG"),0),BDW("BEGIN DATE")=$P(X,U),BDW("END DATE")=$P(X,U,2),BDW("COUNT")=$P(X,U,6)
S Y=BDW("BEGIN DATE") X ^DD("DD") S BDW("BEGIN DATE")=Y
S Y=BDW("END DATE") X ^DD("DD") S BDW("END DATE")=Y
S BDW("VISITS")=$P(^BDWXLOG(BDW("LOG"),21,0),U,4)
W !!,"Log entry ",BDW("LOG")," was for date range ",BDW("BEGIN DATE")," through ",BDW("END DATE"),!,"and generated ",BDW("COUNT")," transactions from ",BDW("VISITS")," encounters."
RDD ;
S DIR(0)="Y",DIR("A")="Do you want to delete the VISIT pointers for this log entry",DIR("B")="N" K DA D ^DIR K DIR
I Y K ^BDWXLOG(BDW("LOG"),21),^BDWXLOG(BDW("LOG"),51),^BDWXLOG(BDW("LOG"),41) W " Done" Q
S BDW("QFLG")=1
Q
;
INIT ;
K BDW
I '$D(DUZ(2))#2 W !!,$C(7),$C(7),"SITE NOT SET!!!" S BDW("QFLG")=1 Q
S BDW("COUNT")=0,BDW("QFLG")=0
D CHKSITE^BDWRDRI
Q:BDW("QFLG")
S (BDW("X"),BDW("LAST LOG"))=$P(^BDWXLOG(0),U,3) F S BDW("X")=$O(^BDWXLOG(BDW("X"))) Q:BDW("X")'=+BDW("X") S BDW("LAST LOG")=BDW("X")
S BDW("OLDEST LOG")=BDW("LAST LOG") F BDW("X")=BDW("LAST LOG"):-1:1 I $D(^BDWXLOG(BDW("X"))) Q:'$D(^BDWXLOG(BDW("X"),21)) S BDW("OLDEST LOG")=BDW("X"),BDW("COUNT")=BDW("COUNT")+1
I BDW("COUNT")=0 W !!,"No log entries with VISIT data." S BDW("QFLG")=1 Q
W !!,"There ",$S(BDW("COUNT")>1:"are",1:"is")," ",BDW("COUNT")," generation",$S(BDW("COUNT")>1:"s ",1:" "),"with ENCOUNTER/VISIT data."
RD ;
S DIR(0)="Y",DIR("A")="Do you want to continue",DIR("B")="N" K DA D ^DIR K DIR
I $D(DIRUT)!('Y) S BDW("QFLG")=1
Q
;
CHKENTRY ; CHECK LOG ENTRY
Q:'$D(^BDWXLOG(BDW("X"),21))
S:BDW("OLDEST LOG")="" BDW("OLDEST LOG")=BDW("X")
S BDW("COUNT")=BDW("COUNT")+1
Q
;
EOJ ; EOJ CLEAN UP
K BDW
Q
BDWPURG ; IHS/CMI/LAB - PURGE DW LOG ;
+1 ;;1.0;IHS DATA WAREHOUSE;;JAN 23, 2006
+2 ;
+3 DO INIT
+4 IF BDW("QFLG")
DO EOJ
WRITE !!,"Bye",!!
KILL DIR
SET DIR(0)="E"
SET DIR("A")="Press ENTER to continue"
DO ^DIR
KILL DIR
QUIT
+5 DO PROCESS
+6 DO EOJ
+7 WRITE !!,"DONE",!!
+8 QUIT
+9 ;
PROCESS ;
+1 SET BDW("LOG")=BDW("OLDEST LOG")-1
FOR
SET BDW("LOG")=$ORDER(^BDWXLOG(BDW("LOG")))
IF BDW("LOG")'=+BDW("LOG")
QUIT
DO DELCHK
IF BDW("QFLG")
QUIT
+2 QUIT
DELCHK ;
+1 SET X=^BDWXLOG(BDW("LOG"),0)
SET BDW("BEGIN DATE")=$PIECE(X,U)
SET BDW("END DATE")=$PIECE(X,U,2)
SET BDW("COUNT")=$PIECE(X,U,6)
+2 SET Y=BDW("BEGIN DATE")
XECUTE ^DD("DD")
SET BDW("BEGIN DATE")=Y
+3 SET Y=BDW("END DATE")
XECUTE ^DD("DD")
SET BDW("END DATE")=Y
+4 SET BDW("VISITS")=$PIECE(^BDWXLOG(BDW("LOG"),21,0),U,4)
+5 WRITE !!,"Log entry ",BDW("LOG")," was for date range ",BDW("BEGIN DATE")," through ",BDW("END DATE"),!,"and generated ",BDW("COUNT")," transactions from ",BDW("VISITS")," encounters."
RDD ;
+1 SET DIR(0)="Y"
SET DIR("A")="Do you want to delete the VISIT pointers for this log entry"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+2 IF Y
KILL ^BDWXLOG(BDW("LOG"),21),^BDWXLOG(BDW("LOG"),51),^BDWXLOG(BDW("LOG"),41)
WRITE " Done"
QUIT
+3 SET BDW("QFLG")=1
+4 QUIT
+5 ;
INIT ;
+1 KILL BDW
+2 IF '$DATA(DUZ(2))#2
WRITE !!,$CHAR(7),$CHAR(7),"SITE NOT SET!!!"
SET BDW("QFLG")=1
QUIT
+3 SET BDW("COUNT")=0
SET BDW("QFLG")=0
+4 DO CHKSITE^BDWRDRI
+5 IF BDW("QFLG")
QUIT
+6 SET (BDW("X"),BDW("LAST LOG"))=$PIECE(^BDWXLOG(0),U,3)
FOR
SET BDW("X")=$ORDER(^BDWXLOG(BDW("X")))
IF BDW("X")'=+BDW("X")
QUIT
SET BDW("LAST LOG")=BDW("X")
+7 SET BDW("OLDEST LOG")=BDW("LAST LOG")
FOR BDW("X")=BDW("LAST LOG"):-1:1
IF $DATA(^BDWXLOG(BDW("X")))
IF '$DATA(^BDWXLOG(BDW("X"),21))
QUIT
SET BDW("OLDEST LOG")=BDW("X")
SET BDW("COUNT")=BDW("COUNT")+1
+8 IF BDW("COUNT")=0
WRITE !!,"No log entries with VISIT data."
SET BDW("QFLG")=1
QUIT
+9 WRITE !!,"There ",$SELECT(BDW("COUNT")>1:"are",1:"is")," ",BDW("COUNT")," generation",$SELECT(BDW("COUNT")>1:"s ",1:" "),"with ENCOUNTER/VISIT data."
RD ;
+1 SET DIR(0)="Y"
SET DIR("A")="Do you want to continue"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+2 IF $DATA(DIRUT)!('Y)
SET BDW("QFLG")=1
+3 QUIT
+4 ;
CHKENTRY ; CHECK LOG ENTRY
+1 IF '$DATA(^BDWXLOG(BDW("X"),21))
QUIT
+2 IF BDW("OLDEST LOG")=""
SET BDW("OLDEST LOG")=BDW("X")
+3 SET BDW("COUNT")=BDW("COUNT")+1
+4 QUIT
+5 ;
EOJ ; EOJ CLEAN UP
+1 KILL BDW
+2 QUIT