source: IHS-VA_UTILITIES-XB/trunk/XBRXREF.m@ 830

Last change on this file since 830 was 642, checked in by Sam Habiel, 15 years ago

Modified directory structure; moved routines.

File size: 3.9 KB
Line 
1XBRXREF ; IHS/ADC/GTH - RE-XREF SELECTED XREFS ; [ 02/07/97 3:02 PM ]
2 ;;4.0;XB;;Jul 20, 2009;Build 2
3 ;
4 ; This routine re-xrefs selected cross references for a file.
5 ; The xrefs are killed at the highest level and then reset.
6 ; This is very different from what FileMan does when you
7 ; RE-INDEX a field. FileMan does a logical kill and then
8 ; sets the new xrefs. The reason for this is multiple fields
9 ; may set the same xref so you would want to kill only the
10 ; ones set by the field being RE-INDEXed.
11 ;
12 ; You must re-xref all fields that set any one of the xrefs
13 ; being killed and reset, unless the xref is set the same
14 ; from multiple fields. Very hard to explain. If you do
15 ; not understand the problem, you probably shouldn't be
16 ; running this routine.
17 ;
18 ; This routine executes an entry point in ^DIK to build the
19 ; xref logic for all xrefs on the file. It then deletes the
20 ; logic for all xrefs not selected, and executes another
21 ; entry point in ^DIK to actually xref the file.
22 ;
23 ; TRIGGERS are very complex animals, which do not have a
24 ; xref to kill plus may be conditional and may have no affect
25 ; on the SET side at all. Because of the uncertainties here
26 ; this routine will not do TRIGGERS.
27 ;
28 ; Xrefs at the multiple level would require a $O through the
29 ; data global to kill, therefore, sub-file xrefs are not
30 ; selectable unless they are cross-referenced to the whole
31 ; file.
32 ;
33START ;
34 D INIT^XBRXREF2 ; Do initialization
35 D GETFILE^XBRXREF2 ; Get file to be RE-XREFed
36 I XBRXREF("QFLG") D EOJ Q
37 D BLDXRT^XBRXREF2 ; Build xref table
38 I XBRXREF("QFLG") D EOJ Q
39 D CONFIRM^XBRXREF2 ; Get confirmation from user
40 I XBRXREF("QFLG") D EOJ Q
41EN ; EXTERNAL ENTRY POINT
42 D SETUP ; Set up xrefs for ^DIK
43 D KILL ; Kill xrefs
44 D XREF ; For each entry, set xrefs
45 D EOJ ; Clean up
46 Q
47 ;
48SETUP ; SETUP XREFS FOR ^DIK
49 S DIK=XBRXREF("GBL"),X=1
50 D DD^DIK
51 S XBRXREF("DIK FILE")=""
52 F XBRXREF("L")=0:0 S XBRXREF("DIK FILE")=$O(^UTILITY("DIK",$J,XBRXREF("DIK FILE"))) Q:XBRXREF("DIK FILE")="" D SETUPB
53 Q
54 ;
55SETUPB ; KILL OFF DIK FILE/SUB-FILES NOT NEEDED
56 I '$D(^TMP("XBRXREF",$J,XBRXREF("DIK FILE"))) KILL ^UTILITY("DIK",$J,XBRXREF("DIK FILE")) Q
57 S XBRXREF("DIK FIELD")=""
58 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
59 Q
60 ;
61SETUPC ; KILL OFF DIK FIELDS NOT NEEDED
62 I '$D(^TMP("XBRXREF",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD"))) KILL ^UTILITY("DIK",$J,XBRXREF("DIK FILE"),XBRXREF("DIK FIELD")) Q
63 S XBRXREF("DIK XREF")=0
64 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
65 Q
66 ;
67SETUPD ; KILL OFF DIK XREFS NOT NEEDED
68 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
69 Q
70 ;
71KILL ; KILL XREFS
72 S XBRXREF("FILE")=""
73 F XBRXREF("L")=0:0 S XBRXREF("FILE")=$O(^TMP("XBRXREF",$J,XBRXREF("FILE"))) Q:XBRXREF("FILE")="" D KILL2
74 Q
75 ;
76KILL2 ;
77 S XBRXREF("FIELD")=""
78 F XBRXREF("L")=0:0 S XBRXREF("FIELD")=$O(^TMP("XBRXREF",$J,XBRXREF("FILE"),XBRXREF("FIELD"))) Q:XBRXREF("FIELD")="" D KILL3
79 Q
80KILL3 ;
81 S XBRXREF("XREF")=""
82 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)")
83 Q
84 ;
85XREF ; SET XREFS FOR ALL ENTRIES
86 D NOW^%DTC
87 S Y=%
88 X ^DD("DD")
89 W !!,"Beginning run at ",$P(Y,"@",2)," <WAIT>"
90 S (DA,DCNT)=0
91 D CNT^DIK1
92 Q
93 ;
94EOJ ; EOJ HOUSEKEEPING
95 I 'XBRXREF("QFLG") D NOW^%DTC S Y=% X ^DD("DD") W !!,"Finished run at ",$P(Y,"@",2)
96 KILL XBRXREF,%,%H,%I,DA,DCNT,DIC,DIK,X,Y,^TMP("XBRXREF",$J),^UTILITY("DIK",$J)
97 Q
98 ;
Note: See TracBrowser for help on using the repository browser.