XBRXREF ; IHS/ADC/GTH - RE-XREF SELECTED XREFS ; [ 02/07/97 3:02 PM ]
;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
;
; This routine re-xrefs selected cross references for a file.
; The xrefs are killed at the highest level and then reset.
; This is very different from what FileMan does when you
; RE-INDEX a field. FileMan does a logical kill and then
; sets the new xrefs. The reason for this is multiple fields
; may set the same xref so you would want to kill only the
; ones set by the field being RE-INDEXed.
;
; You must re-xref all fields that set any one of the xrefs
; being killed and reset, unless the xref is set the same
; from multiple fields. Very hard to explain. If you do
; not understand the problem, you probably shouldn't be
; running this routine.
;
; This routine executes an entry point in ^DIK to build the
; xref logic for all xrefs on the file. It then deletes the
; logic for all xrefs not selected, and executes another
; entry point in ^DIK to actually xref the file.
;
; TRIGGERS are very complex animals, which do not have a
; xref to kill plus may be conditional and may have no affect
; on the SET side at all. Because of the uncertainties here
; this routine will not do TRIGGERS.
;
; Xrefs at the multiple level would require a $O through the
; data global to kill, therefore, sub-file xrefs are not
; selectable unless they are cross-referenced to the whole
; file.
;
START ;
D INIT^XBRXREF2 ; Do initialization
D GETFILE^XBRXREF2 ; Get file to be RE-XREFed
I XBRXREF("QFLG") D EOJ Q
D BLDXRT^XBRXREF2 ; Build xref table
I XBRXREF("QFLG") D EOJ Q
D CONFIRM^XBRXREF2 ; Get confirmation from user
I XBRXREF("QFLG") D EOJ Q
EN ; EXTERNAL ENTRY POINT
D SETUP ; Set up xrefs for ^DIK
D KILL ; Kill xrefs
D XREF ; For each entry, set xrefs
D EOJ ; Clean up
Q
;
SETUP ; SETUP XREFS FOR ^DIK
S DIK=XBRXREF("GBL"),X=1
D DD^DIK
S XBRXREF("DIK FILE")=""
F XBRXREF("L")=0:0 S XBRXREF("DIK FILE")=$O(^UTILITY("DIK",$J,XBRXREF("DIK FILE"))) Q:XBRXREF("DIK FILE")="" D SETUPB
Q
;
SETUPB ; KILL OFF DIK FILE/SUB-FILES NOT NEEDED
I '$D(^TMP("XBRXREF",$J,XBRXREF("DIK FILE"))) KILL ^UTILITY("DIK",$J,XBRXREF("DIK FILE")) Q
S XBRXREF("DIK FIELD")=""
F XBRXREF("L")=0:0 S XBRXREF("DIK FIELD")=$O(^UTILITY("DIK",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"))) Q:XBRXREF("DIK FIELD")="" D SETUPC
Q
;
SETUPC ; KILL OFF DIK FIELDS NOT NEEDED
I '$D(^TMP("XBRXREF",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"))) KILL ^UTILITY("DIK",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD")) Q
S XBRXREF("DIK XREF")=0
F XBRXREF("L")=0:0 S XBRXREF("DIK XREF")=$O(^UTILITY("DIK",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"),XBRXREF("DIK XREF"))) Q:XBRXREF("DIK XREF")="" D SETUPD
Q
;
SETUPD ; KILL OFF DIK XREFS NOT NEEDED
I '$D(^TMP("XBRXREF",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"),XBRXREF("DIK XREF"))) KILL ^UTILITY("DIK",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"),XBRXREF("DIK XREF")) Q
Q
;
KILL ; KILL XREFS
S XBRXREF("FILE")=""
F XBRXREF("L")=0:0 S XBRXREF("FILE")=$O(^TMP("XBRXREF",$J,XBRXREF("FILE"))) Q:XBRXREF("FILE")="" D KILL2
Q
;
KILL2 ;
S XBRXREF("FIELD")=""
F XBRXREF("L")=0:0 S XBRXREF("FIELD")=$O(^TMP("XBRXREF",$J,XBRXREF("FILE"),XBRXREF("FIELD"))) Q:XBRXREF("FIELD")="" D KILL3
Q
KILL3 ;
S XBRXREF("XREF")=""
F XBRXREF("L")=0:0 S XBRXREF("XREF")=$O(^TMP("XBRXREF",$J,XBRXREF("FILE"),XBRXREF("FIELD"),XBRXREF("XREF"))) Q:XBRXREF("XREF")="" S X=^(XBRXREF("XREF")) W !,"Killing ",X KILL @(XBRXREF("GBL")_"X)")
Q
;
XREF ; SET XREFS FOR ALL ENTRIES
D NOW^%DTC
S Y=%
X ^DD("DD")
W !!,"Beginning run at ",$P(Y,"@",2)," <WAIT>"
S (DA,DCNT)=0
D CNT^DIK1
Q
;
EOJ ; EOJ HOUSEKEEPING
I 'XBRXREF("QFLG") D NOW^%DTC S Y=% X ^DD("DD") W !!,"Finished run at ",$P(Y,"@",2)
KILL XBRXREF,%,%H,%I,DA,DCNT,DIC,DIK,X,Y,^TMP("XBRXREF",$J),^UTILITY("DIK",$J)
Q
;
XBRXREF ; IHS/ADC/GTH - RE-XREF SELECTED XREFS ; [ 02/07/97 3:02 PM ]
+1 ;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
+2 ;
+3 ; This routine re-xrefs selected cross references for a file.
+4 ; The xrefs are killed at the highest level and then reset.
+5 ; This is very different from what FileMan does when you
+6 ; RE-INDEX a field. FileMan does a logical kill and then
+7 ; sets the new xrefs. The reason for this is multiple fields
+8 ; may set the same xref so you would want to kill only the
+9 ; ones set by the field being RE-INDEXed.
+10 ;
+11 ; You must re-xref all fields that set any one of the xrefs
+12 ; being killed and reset, unless the xref is set the same
+13 ; from multiple fields. Very hard to explain. If you do
+14 ; not understand the problem, you probably shouldn't be
+15 ; running this routine.
+16 ;
+17 ; This routine executes an entry point in ^DIK to build the
+18 ; xref logic for all xrefs on the file. It then deletes the
+19 ; logic for all xrefs not selected, and executes another
+20 ; entry point in ^DIK to actually xref the file.
+21 ;
+22 ; TRIGGERS are very complex animals, which do not have a
+23 ; xref to kill plus may be conditional and may have no affect
+24 ; on the SET side at all. Because of the uncertainties here
+25 ; this routine will not do TRIGGERS.
+26 ;
+27 ; Xrefs at the multiple level would require a $O through the
+28 ; data global to kill, therefore, sub-file xrefs are not
+29 ; selectable unless they are cross-referenced to the whole
+30 ; file.
+31 ;
START ;
+1 ; Do initialization
DO INIT^XBRXREF2
+2 ; Get file to be RE-XREFed
DO GETFILE^XBRXREF2
+3 IF XBRXREF("QFLG")
DO EOJ
QUIT
+4 ; Build xref table
DO BLDXRT^XBRXREF2
+5 IF XBRXREF("QFLG")
DO EOJ
QUIT
+6 ; Get confirmation from user
DO CONFIRM^XBRXREF2
+7 IF XBRXREF("QFLG")
DO EOJ
QUIT
EN ; EXTERNAL ENTRY POINT
+1 ; Set up xrefs for ^DIK
DO SETUP
+2 ; Kill xrefs
DO KILL
+3 ; For each entry, set xrefs
DO XREF
+4 ; Clean up
DO EOJ
+5 QUIT
+6 ;
SETUP ; SETUP XREFS FOR ^DIK
+1 SET DIK=XBRXREF("GBL")
SET X=1
+2 DO DD^DIK
+3 SET XBRXREF("DIK FILE")=""
+4 FOR XBRXREF("L")=0:0
SET XBRXREF("DIK FILE")=$ORDER(^UTILITY("DIK",$JOB,XBRXREF("DIK FILE")))
IF XBRXREF("DIK FILE")=""
QUIT
DO SETUPB
+5 QUIT
+6 ;
SETUPB ; KILL OFF DIK FILE/SUB-FILES NOT NEEDED
+1 IF '$DATA(^TMP("XBRXREF",$JOB,XBRXREF("DIK FILE")))
KILL ^UTILITY("DIK",$JOB,XBRXREF("DIK FILE"))
QUIT
+2 SET XBRXREF("DIK FIELD")=""
+3 FOR XBRXREF("L")=0:0
SET XBRXREF("DIK FIELD")=$ORDER(^UTILITY("DIK",$JOB,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD")))
IF XBRXREF("DIK FIELD")=""
QUIT
DO SETUPC
+4 QUIT
+5 ;
SETUPC ; KILL OFF DIK FIELDS NOT NEEDED
+1 IF '$DATA(^TMP("XBRXREF",$JOB,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD")))
KILL ^UTILITY("DIK",$JOB,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"))
QUIT
+2 SET XBRXREF("DIK XREF")=0
+3 FOR XBRXREF("L")=0:0
SET XBRXREF("DIK XREF")=$ORDER(^UTILITY("DIK",$JOB,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"),XBRXREF("DIK XREF")))
IF XBRXREF("DIK XREF")=""
QUIT
DO SETUPD
+4 QUIT
+5 ;
SETUPD ; KILL OFF DIK XREFS NOT NEEDED
+1 IF '$DATA(^TMP("XBRXREF",$JOB,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"),XBRXREF("DIK XREF")))
KILL ^UTILITY("DIK",$JOB,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"),XBRXREF("DIK XREF"))
QUIT
+2 QUIT
+3 ;
KILL ; KILL XREFS
+1 SET XBRXREF("FILE")=""
+2 FOR XBRXREF("L")=0:0
SET XBRXREF("FILE")=$ORDER(^TMP("XBRXREF",$JOB,XBRXREF("FILE")))
IF XBRXREF("FILE")=""
QUIT
DO KILL2
+3 QUIT
+4 ;
KILL2 ;
+1 SET XBRXREF("FIELD")=""
+2 FOR XBRXREF("L")=0:0
SET XBRXREF("FIELD")=$ORDER(^TMP("XBRXREF",$JOB,XBRXREF("FILE"),XBRXREF("FIELD")))
IF XBRXREF("FIELD")=""
QUIT
DO KILL3
+3 QUIT
KILL3 ;
+1 SET XBRXREF("XREF")=""
+2 FOR XBRXREF("L")=0:0
SET XBRXREF("XREF")=$ORDER(^TMP("XBRXREF",$JOB,XBRXREF("FILE"),XBRXREF("FIELD"),XBRXREF("XREF")))
IF XBRXREF("XREF")=""
QUIT
SET X=^(XBRXREF("XREF"))
WRITE !,"Killing ",X
KILL @(XBRXREF("GBL")_"X)")
+3 QUIT
+4 ;
XREF ; SET XREFS FOR ALL ENTRIES
+1 DO NOW^%DTC
+2 SET Y=%
+3 XECUTE ^DD("DD")
+4 WRITE !!,"Beginning run at ",$PIECE(Y,"@",2)," <WAIT>"
+5 SET (DA,DCNT)=0
+6 DO CNT^DIK1
+7 QUIT
+8 ;
EOJ ; EOJ HOUSEKEEPING
+1 IF 'XBRXREF("QFLG")
DO NOW^%DTC
SET Y=%
XECUTE ^DD("DD")
WRITE !!,"Finished run at ",$PIECE(Y,"@",2)
+2 KILL XBRXREF,%,%H,%I,DA,DCNT,DIC,DIK,X,Y,^TMP("XBRXREF",$JOB),^UTILITY("DIK",$JOB)
+3 QUIT
+4 ;