source: FOIAVistA/trunk/r/TOOLKIT-AWCM-XD-XIN-XPAR-XQAB-XT-XUC-XUR-ZIN-ZTED/XDRMERGB.m@ 1796

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

initial load of FOIAVistA 6/30/08 version

File size: 8.6 KB
Line 
1XDRMERGB ;SF-IRMFO.SEA/JLI - TENATIVE UPDATE POINTER NODES ;5/14/98 10:30
2 ;;7.3;TOOLKIT;**23**;Apr 25, 1995
3 ;;
4 Q
5 ;
6MERGEIT ; MERGE TWO ENTRIES IN FILE
7 N NODE,NODE1,NODE2,NODEA,SFILE,XDRFROM,XDRTO,NODEA,VALUE,XVALUE,XDRXX,NODEB,DIK,DA,I,Y,VREF,XNN,XFILNO,IENTOSTR,DFN,XDRZZ
8 N XDRAA ; DEBUG STATEMENT
9 ;
10 S XFILNO=+$P(@(XDRDIC_"0)"),U,2)
11 S IENTOSTR=IENTO_","_XDRIENS
12 S DFN=IENTO
13 ;
14 ; NOW MERGE DATA GOING NODE BY NODE
15 ;
16 S NODE=""
17 F D Q:NODE=""
18 . S NODE1=$O(@(XDRDIC_IENFROM_","""_NODE_""")"))
19 . I NODE1="" S NODE="" Q ; NOTHING MORE TO MOVE OVER
20 . S NODE2=$O(@(XDRDIC_IENTO_","""_NODE_""")"))
21 . I NODE2'="",NODE1]NODE2 S NODE=NODE2 Q ; NODE ON TO, BUT NOT ON FROM - GO TO NEXT
22 . S NODE=NODE1
23 . I $D(@(XDRDIC_IENFROM_","""_NODE_""")"))=1 D Q ; SINGLE NODE, MERGE DATA
24 . . I NODE2]NODE1!(NODE2="") D Q ; MISSING NODE, JUST MOVE IT OVER
25 . . . N XDRXX,FLD,N,J
26 . . . F N=0:0 S N=$O(^DD(XFILNO,"GL",NODE,N)) Q:N'>0 S FLD=$O(^(N,0)) I $O(^DD(XFILNO,FLD,1,0))>0 D
27 . . . . S X=0 F J=0:0 S J=$O(^DD(XFILNO,FLD,1,J)) Q:J'>0 I $O(^(J,0))>0 S X=1 Q
28 . . . . I X>0 D
29 . . . . . S XDRXX(XFILNO,IENTOSTR,FLD)=$P(@(XDRDIC_IENFROM_","""_NODE_""")"),U,N)
30 . . . K XDRAA I $D(XDRTESTK),$D(XDRXX) M XDRAA=XDRXX ; DEBUT STATEMENT
31 . . . K XDRZZ
32 . . . I $D(XDRXX) D FILE^DIE("","XDRXX","XDRZZ")
33 . . . I $D(XDRTESTK),$D(XDRZZ) S XDRTESTK=XDRTESTK+1 M ^XTMP("XDRTESTK",$$NOW^XLFDT(),XDRTESTK,"XX")=XDRAA,^("ZZ")=XDRZZ ; DEBUG STATMENT
34 . . . M @(XDRDIC_IENTO_","""_NODE_""")")=@(XDRDIC_IENFROM_","""_NODE_""")")
35 . . I $D(@(XDRDIC_IENTO_","""_NODE_""")"))>1 Q ; MISMATCH SO QUIT
36 . . N XDRXX,FLD
37 . . S X1=@(XDRDIC_IENFROM_","""_NODE_""")")
38 . . S (X2,X3)=@(XDRDIC_IENTO_","""_NODE_""")")
39 . . F I=1:1 Q:X1="" S X=$P(X1,U),X1=$P(X1,U,2,999) I X'="" D
40 . . . S Y=$P(X2,U,I)
41 . . . I Y="" D
42 . . . . S $P(X2,U,I)=X
43 . . . . S FLD=$O(^DD(XFILNO,"GL",NODE,I,0)) S JXFLD=FLD
44 . . . . I FLD>0,$O(^DD(XFILNO,FLD,1,0))>0 S XDRXX(XFILNO,IENTOSTR,FLD)=X
45 . . I X2'=X3 D
46 . . . I $D(XDRXX) D
47 . . . . K XDRAA I $D(XDRTESTK) M XDRAA=XDRXX ; DEBUG STATEMENT
48 . . . . K XDRZZ
49 . . . . N X2 D FILE^DIE("","XDRXX","XDRZZ")
50 . . . . I $D(XDRTESTK),$D(XDRZZ) S XDRTESTK=XDRTESTK+1 M ^XTMP("XDRTESTK",$$NOW^XLFDT(),XDRTESTK,"XX")=XDRAA,^("ZZ")=XDRZZ ; DEBUG STATMENT
51 . . . S @(XDRDIC_IENTO_","""_NODE_""")")=X2 ; SET MERGED DATA ON NODE
52 . ;
53 . ; THE FOLLOWING HANDLES NODES THAT HAVE MULTIPLES
54 . ;
55 . S XDRFROM=XDRDIC_IENFROM_","""_NODE_""","
56 . S XDRTO=XDRDIC_IENTO_","""_NODE_""","
57 . I NODE="DIS",XFILNO=2 D DODIS^XDRMERGA Q
58 . S IENTOSTR=IENTO_","_XDRIENS
59 . D DOSUBS^XDRMERGA(XDRFROM,XDRTO,IENTOSTR,IENTO)
60 S XDRXX=$P(@(XDRDIC_IENFROM_",0)"),U)
61 K DA N DIU S DIU(0)=1 S DIK=XDRDIC,DA=IENFROM,DFN=DA D ^DIK ; KILL OFF MERGED FROM ENTRY
62 S @(XDRDIC_IENFROM_",0)")=XDRXX
63 Q
64 ;
65SAVEMERG(FILE,IENFROM,IENTO) ;
66 N IENS,XDRFILE,YYY,ZZZ,XDRFDA,FROMARG,TOARG,XDRDA,Q,Q1,IENVAL,XDRSUB
67 S FROMARG=$O(@FROM@(IENFROM,IENTO,"")) Q:FROMARG=""
68 S TOARG=$O(@FROM@(IENFROM,IENTO,FROMARG,""))
69 S XDRDA=$$FIND1^DIC(15.4,"","Q",FROMARG)
70 I XDRDA>0,$P(^XDRM(XDRDA,0),U)'=FROMARG S XDRDA=0
71 I XDRDA'>0 D
72 . N XDRFDA
73 . S XDRFDA(15.4,"+1,",.01)=FROMARG
74 . S XDRFDA(15.4,"+1,",.02)=TOARG
75 . S XDRFDA(15.4,"+1,",.03)=DT
76 . D UPDATE^DIE("","XDRFDA","YYY") S IENS=YYY(1)
77 . S XDRDA=YYY(1)
78 S XDRFILE=$P(^DIC(FILE,0),U)
79 S IENS=$$FIND1^DIC(15.41,","_XDRDA_",","Q",XDRFILE)
80 I IENS'>0 D
81 . S IENS="+1,"_XDRDA_","
82 . S XDRFDA(15.41,IENS,.01)=XDRFILE
83 . I IENFROM>0 S XDRFDA(15.41,IENS,.02)=IENFROM
84 . K YYY
85 . D UPDATE^DIE("","XDRFDA","YYY","ZZZ") S IENS=YYY(1)
86 I IENFROM>0 D
87 . S XDRSUB=15.411,IENVAL=IENFROM
88 . D STORMERG
89 K XDRFDA
90 S IENS=$$FIND1^DIC(15.42,","_XDRDA_",","Q",XDRFILE)
91 I IENS'>0 D
92 . S IENS="+1,"_XDRDA_","
93 . S XDRFDA(15.42,IENS,.01)=XDRFILE
94 . I IENTO>0 S XDRFDA(15.42,IENS,.02)=IENTO
95 . K YYY,ZZZ
96 . D UPDATE^DIE("","XDRFDA","YYY","ZZZ") S IENS=YYY(1)
97 I IENTO>0 D
98 . S XDRSUB=15.421,IENVAL=IENTO
99 . D STORMERG
100 Q
101STORMERG ;
102 K ^VA(15.4,XDRDA,$S(XDRSUB=15.411:1,1:2),IENS,1) ; REMOVE ANY PREVIOUS TRIES
103 S IENS="+1,"_IENS_","_XDRDA_","
104 S Q=^DIC(FILE,0,"GL")_IENVAL_")",Q1=$E(Q,1,$L(Q)-1)
105 F S Q=$Q(@Q) Q:Q'[Q1 D
106 . K XDRFDA
107 . S XDRFDA(XDRSUB,IENS,.01)=$E(Q,2,$L(Q))
108 . I @Q'="" S XDRFDA(XDRSUB,IENS,1.01)=@Q
109 . D UPDATE^DIE("","XDRFDA")
110 Q
111 ;
112SAVEPNTR(IENFROM,IENTO,FILE,IENS,FIELD,VALUE) ;
113 N XDRFDA,XDRDA,FROMARG
114 S FROMARG=$O(@FROM@(IENFROM,IENTO,"")) Q:FROMARG=""
115 S XDRDA=$$FIND1^DIC(15.4,"","Q",FROMARG)
116 S X=FILE_";"_IENS_";"_FIELD
117 S XDRFDA(15.43,"+1,"_XDRDA_",",.01)=X
118 S XDRFDA(15.43,"+1,"_XDRDA_",",1.01)=VALUE
119 D UPDATE^DIE("","XDRFDA")
120 Q
121SNDMSG(XDRFDA) ;Sends msg when merge process has completed.
122 N XDRGRP,XMTEXT,XMSUB,XMDUZ,XDRNAME
123 S XDRNAME=$$GET1^DIQ(15.2,XDRFDA,.01)
124 S R(1,0)=XDRNAME_" merge process has completed."
125 S XDRGRP=$$GET1^DIQ(15.1,"2,",.29,"I")
126 S:XDRGRP>0 XDRGRPN=$$GET1^DIQ(3.8,XDRGRP,.01)
127 S XDRGRP=$S(XDRGRP>0:"G."_XDRGRPN,1:"")
128 S:XDRGRP'="" XMY(XDRGRP)=""
129 S:XDRGRP="" XMY(.5)="" ;If no mail grp found, send msg to postmaster
130 S XMTEXT="R(",XMSUB=XDRNAME_" Completed",XMDUZ=.5,XMCHAN=1
131 D ^XMD
132 Q
133 ;
134QUE ; (Moved from XDRMERG0)
135 ;
136 N XDRXX,XDRYY,XDRMA,DIE,DIC,DIR,DR,ZTDTH,ZTSK
137 N XDRX,XDRY,XDRFIL,XDRGLOB,X,Y,XDRNAME
138 N XDRFDA,XDRIENS,XDRI,XDRJ,XDRK,DA,DIK
139 ;
140 S XDRFIL=$$FILE^XDRDPICK() Q:XDRFIL'>0
141 I XDRFIL=2 D Q:Y
142 . N X,XDRKEY
143 . S (X,XDRKEY)=0 F S X=$O(^VA(200,DUZ,51,"B",X)) Q:X'>0!(XDRKEY) D
144 . . I $$GET1^DIQ(19.1,X,.01)="DG ELIGIBILITY" S XDRKEY=1
145 . . Q
146 . S Y=0 I 'XDRKEY W !!,"You should hold the 'DG ELIGIBILITY' key to run a patient file merge." S Y=1
147 . Q
148 S XDRDIC=^DIC(XDRFIL,0,"GL")
149 S XDRGLOB=$E(XDRDIC,2,999)
150 S X=""
151 S XNCNT=0,XNCNT0=0
152 F S X=$O(^VA(15,"AVDUP",XDRGLOB,X)) Q:X="" S Y=$O(^(X,0)) D
153 . N YVAL S YVAL=^VA(15,Y,0)
154 . I $P(YVAL,U,20)>0 Q ; ALREADY DONE OR SCHEDULED
155 . I $P(YVAL,U,3)'="V" Q ; TAKE ONLY VERIFIED
156 . I $P(YVAL,U,5)'=1 Q ; TAKE ONLY IF MARKED READY TO MERGE
157 . I $P(YVAL,U,13)>0 D
158 . . I '$D(@(XDRDIC_(+YVAL)_",0)"))!'$D(@(XDRDIC_(+$P(YVAL,U,2))_",0)")) Q
159 . . I $P(YVAL,U,4)'=2 S XDRX(+YVAL,+$P(YVAL,U,2))=Y ; get ien numbers from duplicate file
160 . . E S XDRX(+$P(YVAL,U,2),+YVAL)=Y ; Reverse - merge to switched
161 . . S XNCNT=XNCNT+1
162 W !!,XNCNT," Entries Ready to be included in merge"
163 I $O(XDRX(0))'>0 D Q
164 . W !!?15,$C(7),"No Verified Duplicates included in merge",$C(7),!!
165 ;
166 K DIR S DIR(0)="Y"
167 S DIR("A",1)="This process will take a **LONG** time (usually over 15 hours, and sometimes"
168 S DIR("A",2)="considerably longer), but you CAN stop and restart the process when you"
169 S DIR("A")="want using the options. OK"
170 D ^DIR K DIR Q:Y'>0
171NAME W !! S DIR(0)="F^2:30"
172 S DIR("A")="Name for Merge Process"
173 S DIR("?",1)="Enter a unique name by which the MERGE PROCESS will be identified"
174 S DIR("?")="This name should be 2 to 30 characters in length"
175 D ^DIR
176 K DIR Q:Y=U S XDRNAME=Y
177 I $$FIND1^DIC(15.2,",","Q",XDRNAME)>0 D G NAME
178 . W !!,$C(7),"The name entered has already been used. The name must be unique.",!!
179 ;
180 ; CREATE PROCESS ENTRY
181 ;
182 S XDRXX(15.2,"+1,",.01)=XDRNAME
183 S XDRXX(15.2,"+1,",.02)=XDRFIL
184 D UPDATE^DIE("","XDRXX","XDRYY","XDRMA")
185 S XDRFDA=$G(XDRYY(1))
186 ;
187 ; NOW MOVE LIST OF DUPLICATES TO BE PROCESSED INTO THIS ENTRY
188 S XDRIENS="+1,"_XDRFDA_","
189 F XDRI=0:0 S XDRI=$O(XDRX(XDRI)) Q:XDRI'>0 D
190 . S XDRJ=$O(XDRX(XDRI,0))
191 . S XDRK=XDRX(XDRI,XDRJ)
192 . K XDRXX,XDRYY
193 . S XDRXX(15.22,XDRIENS,.01)=XDRI ; IEN1
194 . S XDRXX(15.22,XDRIENS,.02)=XDRJ ; IEN2
195 . S XDRXX(15.22,XDRIENS,.03)=XDRK ; ENTRY # IN FILE 15
196 . D UPDATE^DIE("","XDRXX","XDRYY","XDRMA")
197 . K XDRXX,XDRYY,XDRMA
198 . ; AND MARK THEM AS IN THIS MERGE PROCESS IN FILE 15
199 . S XDRXX(15,XDRK_",",.05)=3
200 . S XDRXX(15,XDRK_",",.2)=XDRFDA
201 . D FILE^DIE("","XDRXX")
202 . ; JLI 3/12/98 - FOR SOME REASON THE .05 FIELD STILL DOESN'T SEEM TO BE GETTING SET TO 3, SO CHECK IT AND IF THAT IS THE CASE, HARDSET IT.
203 . I $P(^VA(15,XDRK,0),U,5)'=3 S $P(^(0),U,5)=3
204 ;
205 K DR S DR=".03;.04///S;" ; GET DESIRED START TIME AND MARK PROCESS AS SCHEDULED
206 S DIE="^VA(15.2,"
207 S DA=XDRFDA
208 D ^DIE
209 S ZTDTH=$P(^VA(15.2,XDRFDA,0),U,3) ; TAKE DESIRED TIME
210 I ZTDTH>0 D Q:$G(ZTSK)>0 ; AND SET UP TASK
211 . S ZTRTN="DQ^XDRMERG0",ZTDESC="MERGE PROCESS "_XDRNAME
212 . S ZTIO="NULL",ZTSAVE("XDRFDA")=""
213 . D ^%ZTLOAD
214 . I $G(ZTSK)>0 D
215 . . K DR S DR=".08///"_ZTSK_";",DIE="^VA(15.2,",DA=XDRFDA D ^DIE
216 . . W !!,"Merge process '",$P(^VA(15.2,XDRFDA,0),U),"' for Verified Duplicates in File ",XDRFIL," scheduled",!,"as task ",ZTSK,".",!
217 ;
218 ; TASK INFO, TIME, ETC. NOT COMPLETE - SO REVERSE IT
219 ;
220 F XDRI=0:0 S XDRI=$O(XDRX(XDRI)) Q:XDRI'>0 D
221 . S XDRJ=$O(XDRX(XDRI,0))
222 . S XDRK=XDRX(XDRI,XDRJ)
223 . K XDRXX,XDRYY
224 . S XDRXX(15,XDRK_",",.2)="@" ; UNMARK ENTRY IN FILE 15
225 . S XDRXX(15,XDRK_",",.05)=1
226 . D UPDATE^DIE("","XDRXX")
227 S DA=XDRFDA
228 S DIK="^VA(15.2,"
229 D ^DIK
230 W !!,$C(7),"The Merge Process has been aborted, no changes made."
231 Q
232 ;
Note: See TracBrowser for help on using the repository browser.