ACDCLN ;IHS/ADC/EDE/KML - UTILITY TO CLEAN BROKEN LINKS IN DB;
;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
;*******************************************************************
;//PROG MODE
;*******************************************************************
EN ;EP
;//^ACDGSAVE
;
W !!,"Re-indexing files now.....",!
K ^ACDIIF("C") S DIK(1)="99.99^C",DIK="^ACDIIF(" D ENALL^DIK
K ^ACDTDC("C") S DIK(1)="99.99^C",DIK="^ACDTDC(" D ENALL^DIK
K ^ACDCS("C") S DIK(1)="99.99^C",DIK="^ACDCS(" D ENALL^DIK
K ^ACDVIS("B") S DIK(1)=".01^B",DIK="^ACDVIS(" D ENALL^DIK
K ^ACDVIS("C") S DIK(1)="99.99^C",DIK="^ACDVIS(" D ENALL^DIK
;
EN1 ;EP skip re-indexing
;//^ACDDFAC
;//^ACDPURG
;
D D
V ;Delete visits in ^ACDVIS last
W !!!!!,"Cleaning up entries from the CDMIS visit file that are not being"
W !,"referenced."
S ACDCNT=0 F ACDVISP=0:0 S ACDVISP=$O(^ACDVIS(ACDVISP)) Q:'ACDVISP D V1
W !,"Total of ",ACDCNT," visits deleted."
K DA,DIK,ACDVISP,ACD80,ACDDA,ACDOK,ACDDO,ACDCNT
Q
V1 ;
S ACDOK=0
I $O(^ACDIIF("C",ACDVISP,0)) S ACDOK=1
I $O(^ACDTDC("C",ACDVISP,0)) S ACDOK=1
I $O(^ACDCS("C",ACDVISP,0)) S ACDOK=1
I 'ACDOK D VDEL W !,"Entry ",ACDVISP," is unreferenced...deleting now."
;
Q
VDEL ;Delete unreferenced visit
S DA=ACDVISP,DIK="^ACDVIS(" D ^DIK
S ACDCNT=ACDCNT+1
Q
D ;Check link files first
S ACDCNT=0
W !,"Now cleaning up incomplete data links..."
F ACDDO=0:0 S ACDDO=$O(^ACDIIF(ACDDO)) Q:'ACDDO S ACDVISP=$S($D(^(ACDDO,"BWP")):^("BWP"),1:"??") I '$D(^ACDIIF(ACDDO,0))!('$D(^ACDIIF(ACDDO,"BWP")))!('$D(^ACDVIS(ACDVISP,0))) S DA=ACDDO,DIK="^ACDIIF(" D ^DIK W "." S ACDCNT=ACDCNT+1
F ACDDO=0:0 S ACDDO=$O(^ACDTDC(ACDDO)) Q:'ACDDO S ACDVISP=$S($D(^(ACDDO,"BWP")):^("BWP"),1:"??") I '$D(^ACDTDC(ACDDO,0))!('$D(^ACDTDC(ACDDO,"BWP")))!('$D(^ACDVIS(ACDVISP,0))) S DA=ACDDO,DIK="^ACDTDC(" D ^DIK W "." S ACDCNT=ACDCNT+1
F ACDDO=0:0 S ACDDO=$O(^ACDCS(ACDDO)) Q:'ACDDO S ACDVISP=$S($D(^(ACDDO,"BWP")):^("BWP"),1:"??") D
. S D=0
. I '$D(^ACDCS(ACDDO,0))!('$D(^ACDCS(ACDDO,"BWP")))!('$D(^ACDVIS(ACDVISP,0))) S D=1
. I 'D,$P(^ACDCS(ACDDO,0),U,2)="" S D=1
. I D S DA=ACDDO,DIK="^ACDCS(" D ^DIK W "." S ACDCNT=ACDCNT+1
. Q
;F ACDDO=0:0 S ACDDO=$O(^ACDCS(ACDDO)) Q:'ACDDO S ACDVISP=$S($D(^(ACDDO,"BWP")):^("BWP"),1:"??") I '$D(^ACDCS(ACDDO,0))!('$D(^ACDCS(ACDDO,"BWP")))!('$D(^ACDVIS(ACDVISP,0))) S DA=ACDDO,DIK="^ACDCS(" D ^DIK W "." S ACDCNT=ACDCNT+1
W !,"Total of ",ACDCNT," entries deleted."
Q
ACDCLN ;IHS/ADC/EDE/KML - UTILITY TO CLEAN BROKEN LINKS IN DB;
+1 ;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
+2 ;*******************************************************************
+3 ;//PROG MODE
+4 ;*******************************************************************
EN ;EP
+1 ;//^ACDGSAVE
+2 ;
+3 WRITE !!,"Re-indexing files now.....",!
+4 KILL ^ACDIIF("C")
SET DIK(1)="99.99^C"
SET DIK="^ACDIIF("
DO ENALL^DIK
+5 KILL ^ACDTDC("C")
SET DIK(1)="99.99^C"
SET DIK="^ACDTDC("
DO ENALL^DIK
+6 KILL ^ACDCS("C")
SET DIK(1)="99.99^C"
SET DIK="^ACDCS("
DO ENALL^DIK
+7 KILL ^ACDVIS("B")
SET DIK(1)=".01^B"
SET DIK="^ACDVIS("
DO ENALL^DIK
+8 KILL ^ACDVIS("C")
SET DIK(1)="99.99^C"
SET DIK="^ACDVIS("
DO ENALL^DIK
+9 ;
EN1 ;EP skip re-indexing
+1 ;//^ACDDFAC
+2 ;//^ACDPURG
+3 ;
+4 DO D
V ;Delete visits in ^ACDVIS last
+1 WRITE !!!!!,"Cleaning up entries from the CDMIS visit file that are not being"
+2 WRITE !,"referenced."
+3 SET ACDCNT=0
FOR ACDVISP=0:0
SET ACDVISP=$ORDER(^ACDVIS(ACDVISP))
IF 'ACDVISP
QUIT
DO V1
+4 WRITE !,"Total of ",ACDCNT," visits deleted."
+5 KILL DA,DIK,ACDVISP,ACD80,ACDDA,ACDOK,ACDDO,ACDCNT
+6 QUIT
V1 ;
+1 SET ACDOK=0
+2 IF $ORDER(^ACDIIF("C",ACDVISP,0))
SET ACDOK=1
+3 IF $ORDER(^ACDTDC("C",ACDVISP,0))
SET ACDOK=1
+4 IF $ORDER(^ACDCS("C",ACDVISP,0))
SET ACDOK=1
+5 IF 'ACDOK
DO VDEL
WRITE !,"Entry ",ACDVISP," is unreferenced...deleting now."
+6 ;
+7 QUIT
VDEL ;Delete unreferenced visit
+1 SET DA=ACDVISP
SET DIK="^ACDVIS("
DO ^DIK
+2 SET ACDCNT=ACDCNT+1
+3 QUIT
D ;Check link files first
+1 SET ACDCNT=0
+2 WRITE !,"Now cleaning up incomplete data links..."
+3 FOR ACDDO=0:0
SET ACDDO=$ORDER(^ACDIIF(ACDDO))
IF 'ACDDO
QUIT
SET ACDVISP=$SELECT($DATA(^(ACDDO,"BWP")):^("BWP"),1:"??")
IF '$DATA(^ACDIIF(ACDDO,0))!('$DATA(^ACDIIF(ACDDO,"BWP")))!('$DATA(^ACDVIS(ACDVISP,0)))
SET DA=ACDDO
SET DIK="^ACDIIF("
DO ^DIK
WRITE "."
SET ACDCNT=ACDCNT+1
+4 FOR ACDDO=0:0
SET ACDDO=$ORDER(^ACDTDC(ACDDO))
IF 'ACDDO
QUIT
SET ACDVISP=$SELECT($DATA(^(ACDDO,"BWP")):^("BWP"),1:"??")
IF '$DATA(^ACDTDC(ACDDO,0))!('$DATA(^ACDTDC(ACDDO,"BWP")))!('$DATA(^ACDVIS(ACDVISP,0)))
SET DA=ACDDO
SET DIK="^ACDTDC("
DO ^DIK
WRITE "."
SET ACDCNT=ACDCNT+1
+5 FOR ACDDO=0:0
SET ACDDO=$ORDER(^ACDCS(ACDDO))
IF 'ACDDO
QUIT
SET ACDVISP=$SELECT($DATA(^(ACDDO,"BWP")):^("BWP"),1:"??")
Begin DoDot:1
+6 SET D=0
+7 IF '$DATA(^ACDCS(ACDDO,0))!('$DATA(^ACDCS(ACDDO,"BWP")))!('$DATA(^ACDVIS(ACDVISP,0)))
SET D=1
+8 IF 'D
IF $PIECE(^ACDCS(ACDDO,0),U,2)=""
SET D=1
+9 IF D
SET DA=ACDDO
SET DIK="^ACDCS("
DO ^DIK
WRITE "."
SET ACDCNT=ACDCNT+1
+10 QUIT
End DoDot:1
+11 ;F ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO=0:0 S ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO=$O(^ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCS(ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO)) Q:'ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO S ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DVISP=$S($DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D(^(ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO,"BWP")):^("BWP"),1:"??") I '$DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D(^ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCS(ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO,0))!('$DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D(^ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCS(ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO,"BWP")))!('$DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D(^ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DVIS(ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DVISP,0))) S DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DA=ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DO,DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DIK="^ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCS(" DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D ^DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DIK W "." S ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCNT=ACDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">D">DCLN_source.html#xD">DCLN_source.html#xDCLN_source.html#xD">D">DCLN_source.html#xD">DCNT+1
+12 WRITE !,"Total of ",ACDCNT," entries deleted."
+13 QUIT