source: FOIAVistA/tag/r/TOOLKIT-AWCM-XD-XIN-XPAR-XQAB-XT-XUC-XUR-ZIN-ZTED/XDRMERG.m@ 719

Last change on this file since 719 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 8.5 KB
Line 
1XDRMERG ;SF-IRMFO.SEA/JLI - TENATIVE UPDATE POINTER NODES ;04/26/2001 08:17
2 ;;7.3;TOOLKIT;**23,34,38,44,45,49,54,73**;Apr 25, 1995
3 ;;
4 Q
5 ;
6 ; FILE is the file NUMBER of the file in which the pointed to fields
7 ; are being merged (e.g., 2 or 200)
8 ; FROM is a root under which paired arrays of FROM and TO ien values
9 ; may be found. If internal entry number 275 were being merged
10 ; merged into ien 75, and the array name to be used was XX,
11 ; the data would be stored as ARRYNAME(FROMIEN,TOIEN) OR
12 ; XX(275,75). The call would be
13 ;
14 ; D ENTRY^XDRMERG(2,"XX")
15 ;
16 ; Any number of pairs may be in the From/To array, and the higher
17 ; this number, the more efficient the conversion will be.
18 ;
19EN(FILE,FROM) ;
20 D RESTART(FILE,FROM)
21 Q
22 ;
23 ; The restart entry point permits the user to specify locations for
24 ; continuation of a previously interrupted merge process. The
25 ; first two arguments are as indicated above for the EN entry point.
26 ; The next three arguments are optional, and should only be set for
27 ; a restart of a merge which was interrupted in progress. Even
28 ; then these values could be omitted with minimal impact on the
29 ; first two phases of the merge operation.
30 ;
31 ; XDRTYPE is an indicator of the phase of the merge process
32 ;
33 ; SFILE indicates the pointer file number from which processing
34 ; should be continued.
35 ;
36 ; SENTRY indicates the internal entry number within SFILE from which
37 ; processing should be continued
38 ;
39RESTART(FILE,FROM,XDRTYPE,SFILE,SENTRY) ;
40 ;
41 N XBASIS,CURRTYPE,CURRFIL,XBASE,X,XDRXT,XDRH1,XDRH2,XDRH3,XTYPE
42 N XDRFGLOB,VAFCA08,XDRDVALF,XDRFILE,DIQUIET,RGRSICN
43 S VAFCA08=1,XDRDVALF=1,DIQUIET=1,RGRSICN=1
44 ;
45 S XDRFGLOB=$G(^DIC(FILE,0,"GL")) Q:XDRFGLOB=""
46 ;
47 I $G(XDRTYPE)<2 D CHKFROM^XDRMERG2(FROM,FILE) ; check for self-pointers, circular, etc.
48 ;
49 S XDRGID=$O(@FROM@("")) I XDRGID="" Q
50 S XDRGID=FILE_U_XDRGID_U_$O(@FROM@(XDRGID,""))
51 S ^XTMP("XDRSTAT",0)=$$FMADD^XLFDT(DT,30)_U_DT
52 S ^XTMP("XDRSTAT",XDRGID,"START",$J)=$$NOW^XLFDT()
53 ;
54 I $G(XDRTYPE)<2 D
55 . S XDRTYPE=1
56 . D DOMAIN^XDRMERG2(FILE,FROM)
57 . S XDRTYPE=2
58 I $D(ZTSTOP) Q
59 ;
60LOOP ;
61 I $G(SFILE)="" S SFILE=0
62 I $G(SENTRY)="" S SENTRY=0
63 S CURRTYPE=XDRTYPE
64 ;
65 D SETUP(XDRTYPE) ; identify files and fields to be processed
66 ;
67 F CURRFIL=SFILE-.0000001:0 Q:$D(ZTSTOP) S CURRFIL=$O(^TMP($J,"XFIL",CURRFIL)) Q:CURRFIL'>0 D
68 . I CURRFIL=1 Q
69 . I CURRFIL=15!(CURRFIL=15.4) Q
70 . I FILE=63,CURRFIL=2 Q
71 . ;
72 . I $D(XDRTHRED)>1,'$D(XDRTHRED(CURRFIL)) Q
73 . ;
74 . ;
75 . S XBASIS=^TMP($J,"XFIL",CURRFIL)
76 . I '$D(^TMP($J,"XGLOB",XBASIS)) D I X'[XBASIS Q
77 . . S X=$O(^TMP($J,"XGLOB",XBASIS))
78 . S XDRXT=$$NOW^XLFDT()
79 . I $D(XDRFDA) D I 1
80 . . S ^VA(15.2,XDRFDA,3,XDRFDA1,1)=XDRXT_U_CURRTYPE_U_CURRFIL_U
81 . E D
82 . . S ^XTMP("XDRSTAT",XDRGID,"TIME",$J)=XDRXT_U_CURRTYPE_U_CURRFIL_U
83 . S XDRH1=XDRXT
84 . S ^XTMP("XDRSTAT",XDRGID,"FIL",XDRTYPE,CURRFIL)=XDRH1
85 . S XTYPE=$$TYPE^XDRMERG1(XBASIS),XBAS=XBASIS D Q:$D(ZTSTOP)
86 . . I XDRTYPE=2 D Q
87LOOP2 . . . I XTYPE="DINUM" D DINUM^XDRMERG2(XBAS,XBAS,"")
88 . . . I XTYPE'="" D XREFS^XDRMERG2(XBAS,XBAS,"") ; LET DINUM IN TO CHECK FOR ANY OTHER XREFS UNDER XBAS
89 . . . S XBAS=$O(^TMP($J,"XGLOB",XBAS)) I XBAS[XBASIS S XTYPE=$$TYPE^XDRMERG1(XBAS) G LOOP2
90 . . . Q
91 . . D CHASE^XDRMERG1(XBASIS,XBASIS,"")
92 . S XDRH2=$$NOW^XLFDT()
93 . S XDRH3=$$FMDIFF^XLFDT(XDRH2,XDRH1,2)
94 . S ^XTMP("XDRSTAT",XDRGID,"FIL",XDRTYPE,CURRFIL)=XDRH1_U_XDRH2_U_XDRH3
95 ;
96 ; hook to stop special xref clean-up after phase II
97 I $D(XDRFDA),$P(^VA(15.2,XDRFDA,0),U)="FIX XREF PROCESS" Q
98 I '$D(ZTSTOP),XDRTYPE=2 D G LOOP ; NOW DO THE ONES WE HAVE TO HUNT
99 . S XDRTYPE=3
100 . S (SFILE,SENTRY)=0
101 . K XDRTHRD
102 . N I,MAXTHRED,THREADS S MAXTHRED=$P($G(^VA(15.1,FILE,1)),U),THREADS=$P($G(^(1)),U,2) S:'$D(XDRFDA) MAXTHRED=1 Q:MAXTHRED'>1 D SETUP(XDRTYPE)
103 . F I=1:1:MAXTHRED S XDRTHRD=$P(THREADS,";",I) Q:XDRTHRD'>0 D
104 . . S XDRTHRD(I,XDRTHRD)="" K ^TMP($J,"XFIL",XDRTHRD)
105 . S XDRTHRD=0 F S I=$S(I'<MAXTHRED:1,1:I+1) S XDRTHRD=$O(^TMP($J,"XFIL",XDRTHRD)) Q:XDRTHRD'>0 S XDRTHRD(I,XDRTHRD)="" K ^TMP($J,"XFIL",XDRTHRD)
106 . F XDRTHRD=2:1:MAXTHRED,1 D
107 . . K XDRTHRED M XDRTHRED=XDRTHRD(XDRTHRD) S XDRTHRED=XDRTHRD
108 . . I XDRTHRD=1 D Q
109 . . . F XDRTHRED=0:0 S XDRTHRED=$O(XDRTHRED(XDRTHRED)) Q:XDRTHRED'>0 S ^VA(15.2,XDRFDA,3,XDRFDA1,2,XDRTHRED,0)=XDRTHRED
110 . . S ZTRTN="DQTHREAD^XDRMERG0",ZTIO="",ZTDTH=$$NOW^XLFDT()
111 . . S ZTDESC="MERGE THREAD FOR "_XDRTHRD,ZTSAVE("XDRFDA")=""
112 . . S ZTSAVE("XDRTHRED")="",ZTSAVE("XDRTHRED(")="",ZTSAVE("XDRFILE")=FILE
113 . . D ^%ZTLOAD
114 . S XDRTHRED=""
115 ;
116 I $D(ZTSTOP) S ^XTMP("XDRSTAT",XDRGID,"HALT",$J)=$$NOW^XLFDT()
117 E I '$D(XDRFDA) D
118 . D CLOSEIT
119 . S ^XTMP("XDRSTAT",XDRGID,"DONE",$J)=$$NOW^XLFDT()
120 Q
121CLOSEIT ;
122 I $D(XDRXFLG) Q ; DON'T CLOSE IF JUST CHECKING
123 S:'$D(FILE) FILE=XDRFILE
124 S:'$D(FROM) FROM=$NA(^TMP("XDRFROM",$J)) ;FROM="XDRZZZ"
125 D SETUP(2)
126 S I="" F S I=$O(^TMP($J,"XGLOB",I)) Q:I="" D
127 . I I'["DA,",$P($G(^TMP($J,"XGLOB",I,0,1)),U,3)="DINUM" D
128 . . F XDRFR=0:0 S XDRFR=$O(@FROM@(XDRFR)) Q:XDRFR'>0 D
129 . . . K @(I_XDRFR_")")
130 I FILE'=2 D
131 . S I=^DIC(FILE,0,"GL")
132 . F XDRFR=0:0 S XDRFR=$O(@FROM@(XDRFR)) Q:XDRFR'>0 D
133 . . K @(I_XDRFR_")")
134 Q
135 ;
136SETUP(XDRTYPE) ; XDRTYPE=3 DOES NON-.01 FIELDS (AND .01 WITH NO DINUM OR X-REF)
137 N PFILE,PUFILE,PXFILE,PGLOB,PUFLD,PFLD,PNODE,PUNODE,NODE,PIECE,XREF,XGLOB,N,I,XREFFLAG,CHECK,STANDARD
138 ;
139 K ^TMP($J,"XGLO"),^TMP($J,"XGLOB"),^TMP($J,"XFIL")
140 N XDRDINUM S XDRDINUM(FILE)=""
141 N FILE
142 S FILE=""
143 F S FILE=$O(XDRDINUM(FILE)) Q:FILE="" D
144 . F PFILE=0:0 S PFILE=$O(^DD(FILE,0,"PT",PFILE)) Q:PFILE'>0 D
145 . . ; skip Imaging files
146 . . Q:PFILE=2006.55
147 . . Q:PFILE=2006.552
148 . . S PUFILE=PFILE,N=0
149 . . F Q:$D(^DIC(PUFILE,0,"GL")) D Q:PXFILE=""
150 . . . S PXFILE=$G(^DD(PUFILE,0,"UP")) I PXFILE="" Q
151 . . . S PUFLD=$O(^DD(PXFILE,"SB",PUFILE,0)) I PUFLD'>0 S PXFILE="" Q
152 . . . S PUNODE=$P($P(^DD(PXFILE,PUFLD,0),U,4),";")
153 . . . I PUNODE'=+PUNODE S PUNODE=""""_PUNODE_""""
154 . . . S N=N+1
155 . . . S PNODE(N)=PUNODE
156 . . . S PUFILE=PXFILE
157 . . I '$D(^DIC(PUFILE,0,"GL")) Q
158 . . K PGLOB
159 . . S PGLOB(0)=^DIC(PUFILE,0,"GL")
160 . . S ^TMP($J,"XFIL",PUFILE)=PGLOB(0)
161 . . S XGLOB=PGLOB(0)
162 . . F I=1:1 Q:N=0 D
163 . . . S PGLOB(I)=PGLOB(I-1)_"DA,"_PNODE(N)_","
164 . . . S N=N-1
165 . . . S ^TMP($J,"XGLO",PGLOB(I))=""
166 . . . S XGLOB=PGLOB(I)
167 . . F PFLD=0:0 S PFLD=$O(^DD(FILE,0,"PT",PFILE,PFLD)) Q:PFLD'>0 D
168 . . . I '$D(^DD(PFILE,PFLD,0)) Q
169 . . . I $P(^DD(PFILE,PFLD,0),U,2)'["V",$P(^(0),U,3)'=$E(^DIC(FILE,0,"GL"),2,200),PFILE'=53.51 Q ; MAKE SURE POINTER IS 'REALLY' POINTING TO FILE (E.G., FIELD 400 IN FILE 60)
170 . . . S NODE=$P($G(^DD(PFILE,PFLD,0)),U,4)
171 . . . I NODE="" Q
172 . . . S PIECE=$P(NODE,";",2)
173 . . . S NODE=$P(NODE,";")
174 . . . I NODE'=+NODE S NODE=""""_NODE_""""
175 . . . S XREF=""
176 . . . I PFLD=.01,$D(^DIC(PFILE,0)) D ; MODIFIED 03/24/99 - JLI USE DINUM ONLY AT TOP OF FILE
177 . . . . I ^DD(PFILE,PFLD,0)["DINUM" D
178 . . . . . S XREF="DINUM"
179 . . . . . S XDRDINUM(PFILE)=""
180 . . . ;
181 . . . ; the following section of code was modified to identify any pointer value reachable with
182 . . . ; a cross-reference whether top level or in a subfile. The x-reference is checked for
183 . . . ; the expected value for at least ten entries before being considered valid
184 . . . ; 03/24/99 - JLI
185 . . . ;
186 . . . I XREF="" D
187 . . . . N J,K,L,X1,NMAX,GLOBPCS,YGLOB,KN,KI,NCNT
188 . . . . S NMAX=$L(XGLOB,"DA,") F J=1:1:NMAX S GLOBPCS(J)=$P(XGLOB,"DA,",J)
189 . . . . F J=0:0 Q:XREF'="" S J=$O(^DD(PFILE,PFLD,1,J)) Q:J'>0 D
190 . . . . . S X1=$P($G(^DD(PFILE,PFLD,1,J,0)),U,2)
191 . . . . . Q:X1=""
192 . . . . . I X1'=+X1 S X1=""""_X1_""""
193 . . . . . S K="" F KN=1:1 S K=$O(@(GLOBPCS(1)_X1_","_$S(K'=+K:""""_K_"""",1:K)_")")) Q:K=""!(XREF'="") D S:KN>10&(XREF="") XREF=X1_U_J I KN>10 Q ; global value used as naked global on next line
194 . . . . . . S YGLOB=GLOBPCS(1),L=K,NCNT=0 F KI=1:1:NMAX S L=$O(^(L,"")) Q:L'>0!(L'=+L) S NCNT=NCNT+1,YGLOB=YGLOB_L_","_$S(NCNT<NMAX:GLOBPCS(KI+1),1:"") ; naked global used on above line and within loop (descending subscripts)
195 . . . . . . I NCNT'=NMAX S XREF=-1 Q
196 . . . . . . I $E($P($G(@(YGLOB_NODE_")")),U,PIECE),1,30)'=K S XREF=-1 ; MODIFIED 3/19/99 JLI
197 . . . . . I XREF=-1 S XREF=""
198 . . . I XREF'="",(XREF'="DINUM") D ;modified 3/6/2003 JDS XT*7.3*73
199 . . . . S CHECK=^DD(PFILE,PFLD,1,$P(XREF,U,2),1)
200 . . . . S STANDARD="S "_PGLOB(0)_$P(XREF,U)_",$E(X,1,30),DA"
201 . . . . I CHECK'[STANDARD S XREF=""
202 . . . I XREF'=""&(XDRTYPE'=3) S ^TMP($J,"XGLOB",XGLOB,NODE,PIECE)=PFILE_U_PFLD_U_XREF
203 . . . I (XREF=""&(XDRTYPE=3)) S ^TMP($J,"XGLOB",XGLOB,NODE,PIECE)=$S(XDRTYPE'=3:PFILE_U_PFLD_U_XREF,$O(^DD(PFILE,PFLD,1,0))>0:PFILE_U_PFLD,1:"")
204 . . . ; END OF CHANGES 03/24/99 - JLI
205 Q
Note: See TracBrowser for help on using the repository browser.