XDRMERG ;SF-IRMFO.SEA/JLI - TENATIVE UPDATE POINTER NODES ;04/26/2001 08:17 [ 12/18/2003 5:02 PM ]
;;7.3;TOOLKIT;**23,34,38,44,45,49,54,73,1002,1003**;Apr 03, 1995
;IHS/OIT/LJF 11/30/2006 PATCH 1003 added call to IHS subroutine for end of merge steps
;;
Q
;
; FILE is the file NUMBER of the file in which the pointed to fields
; are being merged (e.g., 2 or 200)
; FROM is a root under which paired arrays of FROM and TO ien values
; may be found. If internal entry number 275 were being merged
; merged into ien 75, and the array name to be used was XX,
; the data would be stored as ARRYNAME(FROMIEN,TOIEN) OR
; XX(275,75). The call would be
;
; D ENTRY^XDRMERG(2,"XX")
;
; Any number of pairs may be in the From/To array, and the higher
; this number, the more efficient the conversion will be.
;
EN(FILE,FROM) ;
D RESTART(FILE,FROM)
Q
;
; The restart entry point permits the user to specify locations for
; continuation of a previously interrupted merge process. The
; first two arguments are as indicated above for the EN entry point.
; The next three arguments are optional, and should only be set for
; a restart of a merge which was interrupted in progress. Even
; then these values could be omitted with minimal impact on the
; first two phases of the merge operation.
;
; XDRTYPE is an indicator of the phase of the merge process
;
; SFILE indicates the pointer file number from which processing
; should be continued.
;
; SENTRY indicates the internal entry number within SFILE from which
; processing should be continued
;
RESTART(FILE,FROM,XDRTYPE,SFILE,SENTRY) ;
;
N XBASIS,CURRTYPE,CURRFIL,XBASE,X,XDRXT,XDRH1,XDRH2,XDRH3,XTYPE
N XDRFGLOB,VAFCA08,XDRDVALF,XDRFILE,DIQUIET,RGRSICN
S VAFCA08=1,XDRDVALF=1,DIQUIET=1,RGRSICN=1
;
S XDRFGLOB=$G(^DIC(FILE,0,"GL")) Q:XDRFGLOB=""
;
I $G(XDRTYPE)<2 D CHKFROM^XDRMERG2(FROM,FILE) ; check for self-pointers, circular, etc.
;
S XDRGID=$O(@FROM@("")) I XDRGID="" Q
S XDRGID=FILE_U_XDRGID_U_$O(@FROM@(XDRGID,""))
S ^XTMP("XDRSTAT",0)=$$FMADD^XLFDT(DT,30)_U_DT
S ^XTMP("XDRSTAT",XDRGID,"START",$J)=$$NOW^XLFDT()
;
I $G(XDRTYPE)<2 D
. S XDRTYPE=1
. D DOMAIN^XDRMERG2(FILE,FROM)
. S XDRTYPE=2
I $D(ZTSTOP) Q
;
LOOP ;
I $G(SFILE)="" S SFILE=0
I $G(SENTRY)="" S SENTRY=0
S CURRTYPE=XDRTYPE
;
D SETUP(XDRTYPE) ; identify files and fields to be processed
;
F CURRFIL=SFILE-.0000001:0 Q:$D(ZTSTOP) S CURRFIL=$O(^TMP($J,"XFIL",CURRFIL)) Q:CURRFIL'>0 D
. I CURRFIL=1 Q
. I CURRFIL=15!(CURRFIL=15.4) Q
. I FILE=63,CURRFIL=2 Q
. ;
. I $D(XDRTHRED)>1,'$D(XDRTHRED(CURRFIL)) Q
. ;
. ;
. S XBASIS=^TMP($J,"XFIL",CURRFIL)
. I '$D(^TMP($J,"XGLOB",XBASIS)) D I X'[XBASIS Q
. . S X=$O(^TMP($J,"XGLOB",XBASIS))
. S XDRXT=$$NOW^XLFDT()
. I $D(XDRFDA) D I 1
. . S ^VA(15.2,XDRFDA,3,XDRFDA1,1)=XDRXT_U_CURRTYPE_U_CURRFIL_U
. E D
. . S ^XTMP("XDRSTAT",XDRGID,"TIME",$J)=XDRXT_U_CURRTYPE_U_CURRFIL_U
. S XDRH1=XDRXT
. S ^XTMP("XDRSTAT",XDRGID,"FIL",XDRTYPE,CURRFIL)=XDRH1
. S XTYPE=$$TYPE^XDRMERG1(XBASIS),XBAS=XBASIS D Q:$D(ZTSTOP)
. . I XDRTYPE=2 D Q
LOOP2 . . . I XTYPE="DINUM" D DINUM^XDRMERG2(XBAS,XBAS,"")
. . . I XTYPE'="" D XREFS^XDRMERG2(XBAS,XBAS,"") ; LET DINUM IN TO CHECK FOR ANY OTHER XREFS UNDER XBAS
. . . S XBAS=$O(^TMP($J,"XGLOB",XBAS)) I XBAS[XBASIS S XTYPE=$$TYPE^XDRMERG1(XBAS) G LOOP2
. . . Q
. . D CHASE^XDRMERG1(XBASIS,XBASIS,"")
. S XDRH2=$$NOW^XLFDT()
. S XDRH3=$$FMDIFF^XLFDT(XDRH2,XDRH1,2)
. S ^XTMP("XDRSTAT",XDRGID,"FIL",XDRTYPE,CURRFIL)=XDRH1_U_XDRH2_U_XDRH3
;
; hook to stop special xref clean-up after phase II
I $D(XDRFDA),$P(^VA(15.2,XDRFDA,0),U)="FIX XREF PROCESS" Q
I '$D(ZTSTOP),XDRTYPE=2 D G LOOP ; NOW DO THE ONES WE HAVE TO HUNT
. S XDRTYPE=3
. S (SFILE,SENTRY)=0
. K XDRTHRD
. 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)
. F I=1:1:MAXTHRED S XDRTHRD=$P(THREADS,";",I) Q:XDRTHRD'>0 D
. . S XDRTHRD(I,XDRTHRD)="" K ^TMP($J,"XFIL",XDRTHRD)
. 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)
. F XDRTHRD=2:1:MAXTHRED,1 D
. . K XDRTHRED M XDRTHRED=XDRTHRD(XDRTHRD) S XDRTHRED=XDRTHRD
. . I XDRTHRD=1 D Q
. . . F XDRTHRED=0:0 S XDRTHRED=$O(XDRTHRED(XDRTHRED)) Q:XDRTHRED'>0 S ^VA(15.2,XDRFDA,3,XDRFDA1,2,XDRTHRED,0)=XDRTHRED
. . S ZTRTN="DQTHREAD^XDRMERG0",ZTIO="",ZTDTH=$$NOW^XLFDT()
. . S ZTDESC="MERGE THREAD FOR "_XDRTHRD,ZTSAVE("XDRFDA")=""
. . S ZTSAVE("XDRTHRED")="",ZTSAVE("XDRTHRED(")="",ZTSAVE("XDRFILE")=FILE
. . D ^%ZTLOAD
. S XDRTHRED=""
;
I $D(ZTSTOP) S ^XTMP("XDRSTAT",XDRGID,"HALT",$J)=$$NOW^XLFDT()
E I '$D(XDRFDA) D
. D CLOSEIT
. S ^XTMP("XDRSTAT",XDRGID,"DONE",$J)=$$NOW^XLFDT()
Q
CLOSEIT ;
I $D(XDRXFLG) Q ; DON'T CLOSE IF JUST CHECKING
S:'$D(FILE) FILE=XDRFILE
S:'$D(FROM) FROM=$NA(^TMP("XDRFROM",$J)) ;FROM="XDRZZZ"
D SETUP(2)
S I="" F S I=$O(^TMP($J,"XGLOB",I)) Q:I="" D
. I I'["DA,",$P($G(^TMP($J,"XGLOB",I,0,1)),U,3)="DINUM" D
. . F XDRFR=0:0 S XDRFR=$O(@FROM@(XDRFR)) Q:XDRFR'>0 D
. . . ;
. . . ;IHS/OIT/LJF 11/30/2006 PATCH 1003 added call to IHS subroutine
. . . S BPMTO=$O(@FROM@(XDRFR,0))
. . . K @(I_XDRFR_")") ;original VA code
. . . I $$GET^XPAR("PKG","BPM USE IHS LOGIC") D ENDMRG^BPMMRG(XDRFR,BPMTO,I)
. . . K BPMTO
;
I FILE'=2 D
. S I=^DIC(FILE,0,"GL")
. F XDRFR=0:0 S XDRFR=$O(@FROM@(XDRFR)) Q:XDRFR'>0 D
. . K @(I_XDRFR_")")
Q
;
SETUP(XDRTYPE) ; XDRTYPE=3 DOES NON-.01 FIELDS (AND .01 WITH NO DINUM OR X-REF)
N PFILE,PUFILE,PXFILE,PGLOB,PUFLD,PFLD,PNODE,PUNODE,NODE,PIECE,XREF,XGLOB,N,I,XREFFLAG,CHECK,STANDARD
;
K ^TMP($J,"XGLO"),^TMP($J,"XGLOB"),^TMP($J,"XFIL")
N XDRDINUM S XDRDINUM(FILE)=""
N FILE
S FILE=""
F S FILE=$O(XDRDINUM(FILE)) Q:FILE="" D
. F PFILE=0:0 S PFILE=$O(^DD(FILE,0,"PT",PFILE)) Q:PFILE'>0 D
. . ; skip Imaging files
. . Q:PFILE=2006.55
. . Q:PFILE=2006.552
. . S PUFILE=PFILE,N=0
. . F Q:$D(^DIC(PUFILE,0,"GL")) D Q:PXFILE=""
. . . S PXFILE=$G(^DD(PUFILE,0,"UP")) I PXFILE="" Q
. . . S PUFLD=$O(^DD(PXFILE,"SB",PUFILE,0)) I PUFLD'>0 S PXFILE="" Q
. . . S PUNODE=$P($P(^DD(PXFILE,PUFLD,0),U,4),";")
. . . I PUNODE'=+PUNODE S PUNODE=""""_PUNODE_""""
. . . S N=N+1
. . . S PNODE(N)=PUNODE
. . . S PUFILE=PXFILE
. . I '$D(^DIC(PUFILE,0,"GL")) Q
. . K PGLOB
. . S PGLOB(0)=^DIC(PUFILE,0,"GL")
. . S ^TMP($J,"XFIL",PUFILE)=PGLOB(0)
. . S XGLOB=PGLOB(0)
. . F I=1:1 Q:N=0 D
. . . S PGLOB(I)=PGLOB(I-1)_"DA,"_PNODE(N)_","
. . . S N=N-1
. . . S ^TMP($J,"XGLO",PGLOB(I))=""
. . . S XGLOB=PGLOB(I)
. . F PFLD=0:0 S PFLD=$O(^DD(FILE,0,"PT",PFILE,PFLD)) Q:PFLD'>0 D
. . . I '$D(^DD(PFILE,PFLD,0)) Q
. . . 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)
. . . S NODE=$P($G(^DD(PFILE,PFLD,0)),U,4)
. . . I NODE="" Q
. . . S PIECE=$P(NODE,";",2)
. . . S NODE=$P(NODE,";")
. . . I NODE'=+NODE S NODE=""""_NODE_""""
. . . S XREF=""
. . . I PFLD=.01,$D(^DIC(PFILE,0)) D ; MODIFIED 03/24/99 - JLI USE DINUM ONLY AT TOP OF FILE
. . . . I ^DD(PFILE,PFLD,0)["DINUM" D
. . . . . S XREF="DINUM"
. . . . . S XDRDINUM(PFILE)=""
. . . ;
. . . ; the following section of code was modified to identify any pointer value reachable with
. . . ; a cross-reference whether top level or in a subfile. The x-reference is checked for
. . . ; the expected value for at least ten entries before being considered valid
. . . ; 03/24/99 - JLI
. . . ;
. . . I XREF="" D
. . . . N J,K,L,X1,NMAX,GLOBPCS,YGLOB,KN,KI,NCNT
. . . . S NMAX=$L(XGLOB,"DA,") F J=1:1:NMAX S GLOBPCS(J)=$P(XGLOB,"DA,",J)
. . . . F J=0:0 Q:XREF'="" S J=$O(^DD(PFILE,PFLD,1,J)) Q:J'>0 D
. . . . . S X1=$P($G(^DD(PFILE,PFLD,1,J,0)),U,2)
. . . . . Q:X1=""
. . . . . I X1'=+X1 S X1=""""_X1_""""
. . . . . 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
. . . . . . 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)
. . . . . . I NCNT'=NMAX S XREF=-1 Q
. . . . . . I $E($P($G(@(YGLOB_NODE_")")),U,PIECE),1,30)'=K S XREF=-1 ; MODIFIED 3/19/99 JLI
. . . . . I XREF=-1 S XREF=""
. . . I XREF'="",(XREF'="DINUM") D ;modified 3/6/2003 JDS XT*7.3*73
. . . . S CHECK=^DD(PFILE,PFLD,1,$P(XREF,U,2),1)
. . . . S STANDARD="S "_PGLOB(0)_$P(XREF,U)_",$E(X,1,30),DA"
. . . . I CHECK'[STANDARD S XREF=""
. . . I XREF'=""&(XDRTYPE'=3) S ^TMP($J,"XGLOB",XGLOB,NODE,PIECE)=PFILE_U_PFLD_U_XREF
. . . 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:"")
. . . ; END OF CHANGES 03/24/99 - JLI
Q
XDRMERG ;SF-IRMFO.SEA/JLI - TENATIVE UPDATE POINTER NODES ;04/26/2001 08:17 [ 12/18/2003 5:02 PM ]
+1 ;;7.3;TOOLKIT;**23,34,38,44,45,49,54,73,1002,1003**;Apr 03, 1995
+2 ;IHS/OIT/LJF 11/30/2006 PATCH 1003 added call to IHS subroutine for end of merge steps
+3 ;;
+4 QUIT
+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 ;
EN(FILE,FROM) ;
+1 DO RESTART(FILE,FROM)
+2 QUIT
+3 ;
+4 ; The restart entry point permits the user to specify locations for
+5 ; continuation of a previously interrupted merge process. The
+6 ; first two arguments are as indicated above for the EN entry point.
+7 ; The next three arguments are optional, and should only be set for
+8 ; a restart of a merge which was interrupted in progress. Even
+9 ; then these values could be omitted with minimal impact on the
+10 ; first two phases of the merge operation.
+11 ;
+12 ; XDRTYPE is an indicator of the phase of the merge process
+13 ;
+14 ; SFILE indicates the pointer file number from which processing
+15 ; should be continued.
+16 ;
+17 ; SENTRY indicates the internal entry number within SFILE from which
+18 ; processing should be continued
+19 ;
RESTART(FILE,FROM,XDRTYPE,SFILE,SENTRY) ;
+1 ;
+2 NEW XBASIS,CURRTYPE,CURRFIL,XBASE,X,XDRXT,XDRH1,XDRH2,XDRH3,XTYPE
+3 NEW XDRFGLOB,VAFCA08,XDRDVALF,XDRFILE,DIQUIET,RGRSICN
+4 SET VAFCA08=1
SET XDRDVALF=1
SET DIQUIET=1
SET RGRSICN=1
+5 ;
+6 SET XDRFGLOB=$GET(^DIC(FILE,0,"GL"))
IF XDRFGLOB=""
QUIT
+7 ;
+8 ; check for self-pointers, circular, etc.
IF $GET(XDRTYPE)<2
DO CHKFROM^XDRMERG2(FROM,FILE)
+9 ;
+10 SET XDRGID=$ORDER(@FROM@(""))
IF XDRGID=""
QUIT
+11 SET XDRGID=FILE_U_XDRGID_U_$ORDER(@FROM@(XDRGID,""))
+12 SET ^XTMP("XDRSTAT",0)=$$FMADD^XLFDT(DT,30)_U_DT
+13 SET ^XTMP("XDRSTAT",XDRGID,"START",$JOB)=$$NOW^XLFDT()
+14 ;
+15 IF $GET(XDRTYPE)<2
Begin DoDot:1
+16 SET XDRTYPE=1
+17 DO DOMAIN^XDRMERG2(FILE,FROM)
+18 SET XDRTYPE=2
End DoDot:1
+19 IF $DATA(ZTSTOP)
QUIT
+20 ;
LOOP ;
+1 IF $GET(SFILE)=""
SET SFILE=0
+2 IF $GET(SENTRY)=""
SET SENTRY=0
+3 SET CURRTYPE=XDRTYPE
+4 ;
+5 ; identify files and fields to be processed
DO SETUP(XDRTYPE)
+6 ;
+7 FOR CURRFIL=SFILE-.0000001:0
IF $DATA(ZTSTOP)
QUIT
SET CURRFIL=$ORDER(^TMP($JOB,"XFIL",CURRFIL))
IF CURRFIL'>0
QUIT
Begin DoDot:1
+8 IF CURRFIL=1
QUIT
+9 IF CURRFIL=15!(CURRFIL=15.4)
QUIT
+10 IF FILE=63
IF CURRFIL=2
QUIT
+11 ;
+12 IF $DATA(XDRTHRED)>1
IF '$DATA(XDRTHRED(CURRFIL))
QUIT
+13 ;
+14 ;
+15 SET XBASIS=^TMP($JOB,"XFIL",CURRFIL)
+16 IF '$DATA(^TMP($JOB,"XGLOB",XBASIS))
Begin DoDot:2
+17 SET X=$ORDER(^TMP($JOB,"XGLOB",XBASIS))
End DoDot:2
IF X'[XBASIS
QUIT
+18 SET XDRXT=$$NOW^XLFDT()
+19 IF $DATA(XDRFDA)
Begin DoDot:2
+20 SET ^VA(15.2,XDRFDA,3,XDRFDA1,1)=XDRXT_U_CURRTYPE_U_CURRFIL_U
End DoDot:2
IF 1
+21 IF '$TEST
Begin DoDot:2
+22 SET ^XTMP("XDRSTAT",XDRGID,"TIME",$JOB)=XDRXT_U_CURRTYPE_U_CURRFIL_U
End DoDot:2
+23 SET XDRH1=XDRXT
+24 SET ^XTMP("XDRSTAT",XDRGID,"FIL",XDRTYPE,CURRFIL)=XDRH1
+25 SET XTYPE=$$TYPE^XDRMERG1(XBASIS)
SET XBAS=XBASIS
Begin DoDot:2
+26 IF XDRTYPE=2
Begin DoDot:3
LOOP2 IF XTYPE="DINUM"
DO DINUM^XDRMERG2(XBAS,XBAS,"")
+1 ; LET DINUM IN TO CHECK FOR ANY OTHER XREFS UNDER XBAS
IF XTYPE'=""
DO XREFS^XDRMERG2(XBAS,XBAS,"")
+2 SET XBAS=$ORDER(^TMP($JOB,"XGLOB",XBAS))
IF XBAS[XBASIS
SET XTYPE=$$TYPE^XDRMERG1(XBAS)
GOTO LOOP2
+3 QUIT
End DoDot:3
QUIT
+4 DO CHASE^XDRMERG1(XBASIS,XBASIS,"")
End DoDot:2
IF $DATA(ZTSTOP)
QUIT
+5 SET XDRH2=$$NOW^XLFDT()
+6 SET XDRH3=$$FMDIFF^XLFDT(XDRH2,XDRH1,2)
+7 SET ^XTMP("XDRSTAT",XDRGID,"FIL",XDRTYPE,CURRFIL)=XDRH1_U_XDRH2_U_XDRH3
End DoDot:1
+8 ;
+9 ; hook to stop special xref clean-up after phase II
+10 IF $DATA(XDRFDA)
IF $PIECE(^VA(15.2,XDRFDA,0),U)="FIX XREF PROCESS"
QUIT
+11 ; NOW DO THE ONES WE HAVE TO HUNT
IF '$DATA(ZTSTOP)
IF XDRTYPE=2
Begin DoDot:1
+12 SET XDRTYPE=3
+13 SET (SFILE,SENTRY)=0
+14 KILL XDRTHRD
+15 NEW I,MAXTHRED,THREADS
SET MAXTHRED=$PIECE($GET(^VA(15.1,FILE,1)),U)
SET THREADS=$PIECE($GET(^(1)),U,2)
IF '$DATA(XDRFDA)
SET MAXTHRED=1
IF MAXTHRED'>1
QUIT
DO SETUP(XDRTYPE)
+16 FOR I=1:1:MAXTHRED
SET XDRTHRD=$PIECE(THREADS,";",I)
IF XDRTHRD'>0
QUIT
Begin DoDot:2
+17 SET XDRTHRD(I,XDRTHRD)=""
KILL ^TMP($JOB,"XFIL",XDRTHRD)
End DoDot:2
+18 SET XDRTHRD=0
FOR
SET I=$SELECT(I'<MAXTHRED:1,1:I+1)
SET XDRTHRD=$ORDER(^TMP($JOB,"XFIL",XDRTHRD))
IF XDRTHRD'>0
QUIT
SET XDRTHRD(I,XDRTHRD)=""
KILL ^TMP($JOB,"XFIL",XDRTHRD)
+19 FOR XDRTHRD=2:1:MAXTHRED,1
Begin DoDot:2
+20 KILL XDRTHRED
MERGE XDRTHRED=XDRTHRD(XDRTHRD)
SET XDRTHRED=XDRTHRD
+21 IF XDRTHRD=1
Begin DoDot:3
+22 FOR XDRTHRED=0:0
SET XDRTHRED=$ORDER(XDRTHRED(XDRTHRED))
IF XDRTHRED'>0
QUIT
SET ^VA(15.2,XDRFDA,3,XDRFDA1,2,XDRTHRED,0)=XDRTHRED
End DoDot:3
QUIT
+23 SET ZTRTN="DQTHREAD^XDRMERG0"
SET ZTIO=""
SET ZTDTH=$$NOW^XLFDT()
+24 SET ZTDESC="MERGE THREAD FOR "_XDRTHRD
SET ZTSAVE("XDRFDA")=""
+25 SET ZTSAVE("XDRTHRED")=""
SET ZTSAVE("XDRTHRED(")=""
SET ZTSAVE("XDRFILE")=FILE
+26 DO ^%ZTLOAD
End DoDot:2
+27 SET XDRTHRED=""
End DoDot:1
GOTO LOOP
+28 ;
+29 IF $DATA(ZTSTOP)
SET ^XTMP("XDRSTAT",XDRGID,"HALT",$JOB)=$$NOW^XLFDT()
+30 IF '$TEST
IF '$DATA(XDRFDA)
Begin DoDot:1
+31 DO CLOSEIT
+32 SET ^XTMP("XDRSTAT",XDRGID,"DONE",$JOB)=$$NOW^XLFDT()
End DoDot:1
+33 QUIT
CLOSEIT ;
+1 ; DON'T CLOSE IF JUST CHECKING
IF $DATA(XDRXFLG)
QUIT
+2 IF '$DATA(FILE)
SET FILE=XDRFILE
+3 ;FROM="XDRZZZ"
IF '$DATA(FROM)
SET FROM=$NAME(^TMP("XDRFROM",$JOB))
+4 DO SETUP(2)
+5 SET I=""
FOR
SET I=$ORDER(^TMP($JOB,"XGLOB",I))
IF I=""
QUIT
Begin DoDot:1
+6 IF I'["DA,"
IF $PIECE($GET(^TMP($JOB,"XGLOB",I,0,1)),U,3)="DINUM"
Begin DoDot:2
+7 FOR XDRFR=0:0
SET XDRFR=$ORDER(@FROM@(XDRFR))
IF XDRFR'>0
QUIT
Begin DoDot:3
+8 ;
+9 ;IHS/OIT/LJF 11/30/2006 PATCH 1003 added call to IHS subroutine
+10 SET BPMTO=$ORDER(@FROM@(XDRFR,0))
+11 ;original VA code
KILL @(I_XDRFR_")")
+12 IF $$GET^XPAR("PKG","BPM USE IHS LOGIC")
DO ENDMRG^BPMMRG(XDRFR,BPMTO,I)
+13 KILL BPMTO
End DoDot:3
End DoDot:2
End DoDot:1
+14 ;
+15 IF FILE'=2
Begin DoDot:1
+16 SET I=^DIC(FILE,0,"GL")
+17 FOR XDRFR=0:0
SET XDRFR=$ORDER(@FROM@(XDRFR))
IF XDRFR'>0
QUIT
Begin DoDot:2
+18 KILL @(I_XDRFR_")")
End DoDot:2
End DoDot:1
+19 QUIT
+20 ;
SETUP(XDRTYPE) ; XDRTYPE=3 DOES NON-.01 FIELDS (AND .01 WITH NO DINUM OR X-REF)
+1 NEW PFILE,PUFILE,PXFILE,PGLOB,PUFLD,PFLD,PNODE,PUNODE,NODE,PIECE,XREF,XGLOB,N,I,XREFFLAG,CHECK,STANDARD
+2 ;
+3 KILL ^TMP($JOB,"XGLO"),^TMP($JOB,"XGLOB"),^TMP($JOB,"XFIL")
+4 NEW XDRDINUM
SET XDRDINUM(FILE)=""
+5 NEW FILE
+6 SET FILE=""
+7 FOR
SET FILE=$ORDER(XDRDINUM(FILE))
IF FILE=""
QUIT
Begin DoDot:1
+8 FOR PFILE=0:0
SET PFILE=$ORDER(^DD(FILE,0,"PT",PFILE))
IF PFILE'>0
QUIT
Begin DoDot:2
+9 ; skip Imaging files
+10 IF PFILE=2006.55
QUIT
+11 IF PFILE=2006.552
QUIT
+12 SET PUFILE=PFILE
SET N=0
+13 FOR
IF $DATA(^DIC(PUFILE,0,"GL"))
QUIT
Begin DoDot:3
+14 SET PXFILE=$GET(^DD(PUFILE,0,"UP"))
IF PXFILE=""
QUIT
+15 SET PUFLD=$ORDER(^DD(PXFILE,"SB",PUFILE,0))
IF PUFLD'>0
SET PXFILE=""
QUIT
+16 SET PUNODE=$PIECE($PIECE(^DD(PXFILE,PUFLD,0),U,4),";")
+17 IF PUNODE'=+PUNODE
SET PUNODE=""""_PUNODE_""""
+18 SET N=N+1
+19 SET PNODE(N)=PUNODE
+20 SET PUFILE=PXFILE
End DoDot:3
IF PXFILE=""
QUIT
+21 IF '$DATA(^DIC(PUFILE,0,"GL"))
QUIT
+22 KILL PGLOB
+23 SET PGLOB(0)=^DIC(PUFILE,0,"GL")
+24 SET ^TMP($JOB,"XFIL",PUFILE)=PGLOB(0)
+25 SET XGLOB=PGLOB(0)
+26 FOR I=1:1
IF N=0
QUIT
Begin DoDot:3
+27 SET PGLOB(I)=PGLOB(I-1)_"DA,"_PNODE(N)_","
+28 SET N=N-1
+29 SET ^TMP($JOB,"XGLO",PGLOB(I))=""
+30 SET XGLOB=PGLOB(I)
End DoDot:3
+31 FOR PFLD=0:0
SET PFLD=$ORDER(^DD(FILE,0,"PT",PFILE,PFLD))
IF PFLD'>0
QUIT
Begin DoDot:3
+32 IF '$DATA(^DD(PFILE,PFLD,0))
QUIT
+33 ; MAKE SURE POINTER IS 'REALLY' POINTING TO FILE (E.G., FIELD 400 IN FILE 60)
IF $PIECE(^DD(PFILE,PFLD,0),U,2)'["V"
IF $PIECE(^(0),U,3)'=$EXTRACT(^DIC(FILE,0,"GL"),2,200)
IF PFILE'=53.51
QUIT
+34 SET NODE=$PIECE($GET(^DD(PFILE,PFLD,0)),U,4)
+35 IF NODE=""
QUIT
+36 SET PIECE=$PIECE(NODE,";",2)
+37 SET NODE=$PIECE(NODE,";")
+38 IF NODE'=+NODE
SET NODE=""""_NODE_""""
+39 SET XREF=""
+40 ; MODIFIED 03/24/99 - JLI USE DINUM ONLY AT TOP OF FILE
IF PFLD=.01
IF $DATA(^DIC(PFILE,0))
Begin DoDot:4
+41 IF ^DD(PFILE,PFLD,0)["DINUM"
Begin DoDot:5
+42 SET XREF="DINUM"
+43 SET XDRDINUM(PFILE)=""
End DoDot:5
End DoDot:4
+44 ;
+45 ; the following section of code was modified to identify any pointer value reachable with
+46 ; a cross-reference whether top level or in a subfile. The x-reference is checked for
+47 ; the expected value for at least ten entries before being considered valid
+48 ; 03/24/99 - JLI
+49 ;
+50 IF XREF=""
Begin DoDot:4
+51 NEW J,K,L,X1,NMAX,GLOBPCS,YGLOB,KN,KI,NCNT
+52 SET NMAX=$LENGTH(XGLOB,"DA,")
FOR J=1:1:NMAX
SET GLOBPCS(J)=$PIECE(XGLOB,"DA,",J)
+53 FOR J=0:0
IF XREF'=""
QUIT
SET J=$ORDER(^DD(PFILE,PFLD,1,J))
IF J'>0
QUIT
Begin DoDot:5
+54 SET X1=$PIECE($GET(^DD(PFILE,PFLD,1,J,0)),U,2)
+55 IF X1=""
QUIT
+56 IF X1'=+X1
SET X1=""""_X1_""""
+57 ; global value used as naked global on next line
SET K=""
FOR KN=1:1
SET K=$ORDER(@(GLOBPCS(1)_X1_","_$SELECT(K'=+K:""""_K_"""",1:K)_")"))
IF K=""!(XREF'="")
QUIT
Begin DoDot:6
+58 ; naked global used on above line and within loop (descending subscripts)
SET YGLOB=GLOBPCS(1)
SET L=K
SET NCNT=0
FOR KI=1:1:NMAX
SET L=$ORDER(^(L,""))
IF L'>0!(L'=+L)
QUIT
SET NCNT=NCNT+1
SET YGLOB=YGLOB_L_","_$SELECT(NCNT<NMAX:GLOBPCS(KI+1),1:"")
+59 IF NCNT'=NMAX
SET XREF=-1
QUIT
+60 ; MODIFIED 3/19/99 JLI
IF $EXTRACT($PIECE($GET(@(YGLOB_NODE_")")),U,PIECE),1,30)'=K
SET XREF=-1
End DoDot:6
IF KN>10&(XREF="")
SET XREF=X1_U_J
IF KN>10
QUIT
+61 IF XREF=-1
SET XREF=""
End DoDot:5
End DoDot:4
+62 ;modified 3/6/2003 JDS XT*7.3*73
IF XREF'=""
IF (XREF'="DINUM")
Begin DoDot:4
+63 SET CHECK=^DD(PFILE,PFLD,1,$PIECE(XREF,U,2),1)
+64 SET STANDARD="S "_PGLOB(0)_$PIECE(XREF,U)_",$E(X,1,30),DA"
+65 IF CHECK'[STANDARD
SET XREF=""
End DoDot:4
+66 IF XREF'=""&(XDRTYPE'=3)
SET ^TMP($JOB,"XGLOB",XGLOB,NODE,PIECE)=PFILE_U_PFLD_U_XREF
+67 IF (XREF=""&(XDRTYPE=3))
SET ^TMP($JOB,"XGLOB",XGLOB,NODE,PIECE)=$SELECT(XDRTYPE'=3:PFILE_U_PFLD_U_XREF,$ORDER(^DD(PFILE,PFLD,1,0))>0:PFILE_U_PFLD,1:"")
+68 ; END OF CHANGES 03/24/99 - JLI
End DoDot:3
End DoDot:2
End DoDot:1
+69 QUIT