DITMGM2A ;SFISC/EDE(OHPRD),TKW-CONTINUATION OF ^DITMGM2 ;4/7/94 08:49 [ 04/02/2003 8:23 AM ]
;;22.0;VA FileMan;**1001**;APR 1, 2003
;;22.0;VA FileMan;;Mar 30, 1999
;THIS ROUTINE CONTAINS AN IHS MODIFICATION BY IHS/ANMC/LJF 2/18/2000
;Per VHA Directive 10-93-142, this routine should not be modified.
;
FIELD ; PROCESS ONE FIELD IN ONE FILE/SUBFILE
S DITMGMPF=^UTILITY("DITMGMRG",$J,DITMGMFL,DITMGMFD)
S DITMGMX=$P(^DD(DITMGMFL,DITMGMFD,0),U,4),DITMGMNO=$P(DITMGMX,";",1),DITMGMPC=$P(DITMGMX,";",2),DITMGMDI=$S(DITMGMFD=.01&($P(^(0),U,5,99)["DINUM"):1,1:0)
S DITMGMV=$S($P(^DD(DITMGMFL,DITMGMFD,0),U,2)["V":1,1:0)
I DITMGMV D
. N % S %=$P(^DIC(DITMGMPF,0,"GL"),U,2) I %["""" S %=$$CONVQQ^DILIBF(%)
. S DITMGMF=DITMGMF_";"_%,DITMGMT=DITMGMT_";"_% Q
S DITMGMXR="",DITMGMX=0 F DITMGML=0:0 S DITMGMX=$O(^DD(DITMGMFL,DITMGMFD,1,DITMGMX)) Q:DITMGMX'=+DITMGMX D Q:DITMGMXR'=""
. S DITMGMXR=$P(^(DITMGMX,0),U,2),DITMGMTY=$P(^(0),U,3),DITMGMTZ=$P(^(0),U,1)
. I DITMGMTY="",'DITMGMMU Q
. I DITMGMTY="",DITMGMMU,DITMGMFL'=DITMGMTZ,'$D(^DD(DITMGMTZ,0,"UP")) Q
. S DITMGMXR=""
. Q
K DA I DITMGMXR="" D NOXREF Q
Q:'$D(@(DITMGMG_""""_DITMGMXR_""","""_DITMGMF_""")"))
S DITMGMN="" F DITMGML=0:0 S DITMGMN=$O(@(DITMGMG_""""_DITMGMXR_""","""_DITMGMF_""",DITMGMN)")) Q:DITMGMN="" D ENTRY:'DITMGMMU,MULTIPLE:DITMGMMU
Q
;
MULTIPLE ; MULTIPLE WITH XREF TO FILE
N DIXR,DICNT,DIDA,DIEND,DITMGZZZ
S DITMGZZZ=DITMGMN,(DICNT,DIEND)=+$P(DITMGMGM,"DA(",2),DIDA(DICNT)=DITMGMN
S DIXR(DICNT)=DITMGMG_""""_DITMGMXR_""","""_DITMGMF_""","_DITMGMN_","
S DICNT=DICNT-1
M2 I DICNT=DIEND S DITMGMN=DITMGZZZ Q
S DIDA(DICNT)=$O(@(DIXR(DICNT+1)_+$G(DIDA(DICNT))_")"))
I 'DIDA(DICNT) S DICNT=DICNT+1 G M2
I DICNT=0 D G M2
. N DA F I=0:1:DIEND S DA(I)=DIDA(I)
. S DA=DA(0) K DA(0)
. N DIXR,DICNT,DIDA,DIEND D ENTRY
. Q
S DIXR(DICNT)=DIXR(DICNT+1)_DIDA(DICNT)_","
S DICNT=DICNT-1 G M2
;
NOXREF ; FILES WITH NO REGULAR XREF ON POINTING FIELD
I DITMGMDI,'DITMGMMU S DITMGMN=$S($D(@(DITMGMG_DITMGMF_")")):DITMGMF,1:"") D:DITMGMN ENTRY Q ; If DINUM file xref not needed
I '$D(@(DITMGMG_"0)")) W:'$D(DITMGM2("NOTALK")) !,"No Data Global: ",DITMGMG Q
;----- BEGIN IHS MODIFICATION
;THE LINE BELOW IS COMMENTED OUT AND REPLACED BY A NEW LINE.
;NO BACKGROUND TASKS - NEED TO KNOW WHEN MERGE IS REALLY DONE
;ORIGINAL MODIFICATION BY IHS/ANMC/LJF 2/18/2000
;I '$D(^%ZTSK)!($P(@(DITMGMG_"0)"),U,4)<3001) D SEARCH Q ; If <= 3000 search gbl
D SEARCH Q
;----- END IHS MODIFICATION
W:'$D(DITMGM2("NOTALK")) !,"No REGULAR xref on ",DITMGMFL,",",DITMGMFD," Merging entries for this file will",!,"now occur via Taskman in background!"
; SETUP CALL TO TASKMAN
K DITMGMZT S:$D(ZTSK) DITMGMZT=ZTSK
K ZTSAVE F %="DITMGMG","DITMGMGM","DITMGMNO","DITMGMPC","DITMGMF","DITMGMT","DITMGMFL","DITMGMFD","DITMGMDI","DITMGMXR","DITMGMMU","DITMGMV" S ZTSAVE(%)=""
S ZTRTN="ZTM^DITMGM2",ZTDESC="PROCESS POINTER FIELD #"_DITMGMFD_" IN FILE #"_DITMGMFL_" FROM "_DITMGMF_" TO "_DITMGMT
S ZTIO="",ZTDTH=DT D ^%ZTLOAD K ZTSK
S:$D(DITMGMZT) ZTSK=DITMGMZT
K DITMGMZT
Q
;
SEARCH ; $O THRU DATA GBL
D SEARCH^DITMGM2B
Q
;
ENTRY ; PROCESS ONE FILE/SUBFILE ENTRY
D ENTRY^DITMGM2B
Q
QUOTES ;
N %P,%Q S %W1="",%Q="""" F %P=1:1:$L(%W,%Q)-1 S %W1=%W1_$P(%W,%Q,%P)_%Q_%Q
S %W1=%W1_$P(%W,%Q,$L(%W,%Q))
Q
DITMGM2A ;SFISC/EDE(OHPRD),TKW-CONTINUATION OF ^DITMGM2 ;4/7/94 08:49 [ 04/02/2003 8:23 AM ]
+1 ;;22.0;VA FileMan;**1001**;APR 1, 2003
+2 ;;22.0;VA FileMan;;Mar 30, 1999
+3 ;THIS ROUTINE CONTAINS AN IHS MODIFICATION BY IHS/ANMC/LJF 2/18/2000
+4 ;Per VHA Directive 10-93-142, this routine should not be modified.
+5 ;
FIELD ; PROCESS ONE FIELD IN ONE FILE/SUBFILE
+1 SET DITMGMPF=^UTILITY("DITMGMRG",$JOB,DITMGMFL,DITMGMFD)
+2 SET DITMGMX=$PIECE(^DD(DITMGMFL,DITMGMFD,0),U,4)
SET DITMGMNO=$PIECE(DITMGMX,";",1)
SET DITMGMPC=$PIECE(DITMGMX,";",2)
SET DITMGMDI=$SELECT(DITMGMFD=.01&($PIECE(^(0),U,5,99)["DINUM"):1,1:0)
+3 SET DITMGMV=$SELECT($PIECE(^DD(DITMGMFL,DITMGMFD,0),U,2)["V":1,1:0)
+4 IF DITMGMV
Begin DoDot:1
+5 NEW %
SET %=$PIECE(^DIC(DITMGMPF,0,"GL"),U,2)
IF %[""""
SET %=$$CONVQQ^DILIBF(%)
+6 SET DITMGMF=DITMGMF_";"_%
SET DITMGMT=DITMGMT_";"_%
QUIT
End DoDot:1
+7 SET DITMGMXR=""
SET DITMGMX=0
FOR DITMGML=0:0
SET DITMGMX=$ORDER(^DD(DITMGMFL,DITMGMFD,1,DITMGMX))
IF DITMGMX'=+DITMGMX
QUIT
Begin DoDot:1
+8 SET DITMGMXR=$PIECE(^(DITMGMX,0),U,2)
SET DITMGMTY=$PIECE(^(0),U,3)
SET DITMGMTZ=$PIECE(^(0),U,1)
+9 IF DITMGMTY=""
IF 'DITMGMMU
QUIT
+10 IF DITMGMTY=""
IF DITMGMMU
IF DITMGMFL'=DITMGMTZ
IF '$DATA(^DD(DITMGMTZ,0,"UP"))
QUIT
+11 SET DITMGMXR=""
+12 QUIT
End DoDot:1
IF DITMGMXR'=""
QUIT
+13 KILL DA
IF DITMGMXR=""
DO NOXREF
QUIT
+14 IF '$DATA(@(DITMGMG_""""_DITMGMXR_""","""_DITMGMF_""")"))
QUIT
+15 SET DITMGMN=""
FOR DITMGML=0:0
SET DITMGMN=$ORDER(@(DITMGMG_""""_DITMGMXR_""","""_DITMGMF_""",DITMGMN)"))
IF DITMGMN=""
QUIT
IF 'DITMGMMU
DO ENTRY
IF DITMGMMU
DO MULTIPLE
+16 QUIT
+17 ;
MULTIPLE ; MULTIPLE WITH XREF TO FILE
+1 NEW DIXR,DICNT,DIDA,DIEND,DITMGZZZ
+2 SET DITMGZZZ=DITMGMN
SET (DICNT,DIEND)=+$PIECE(DITMGMGM,"DA(",2)
SET DIDA(DICNT)=DITMGMN
+3 SET DIXR(DICNT)=DITMGMG_""""_DITMGMXR_""","""_DITMGMF_""","_DITMGMN_","
+4 SET DICNT=DICNT-1
M2 IF DICNT=DIEND
SET DITMGMN=DITMGZZZ
QUIT
+1 SET DIDA(DICNT)=$ORDER(@(DIXR(DICNT+1)_+$GET(DIDA(DICNT))_")"))
+2 IF 'DIDA(DICNT)
SET DICNT=DICNT+1
GOTO M2
+3 IF DICNT=0
Begin DoDot:1
+4 NEW DA
FOR I=0:1:DIEND
SET DA(I)=DIDA(I)
+5 SET DA=DA(0)
KILL DA(0)
+6 NEW DIXR,DICNT,DIDA,DIEND
DO ENTRY
+7 QUIT
End DoDot:1
GOTO M2
+8 SET DIXR(DICNT)=DIXR(DICNT+1)_DIDA(DICNT)_","
+9 SET DICNT=DICNT-1
GOTO M2
+10 ;
NOXREF ; FILES WITH NO REGULAR XREF ON POINTING FIELD
+1 ; If DINUM file xref not needed
IF DITMGMDI
IF 'DITMGMMU
SET DITMGMN=$SELECT($DATA(@(DITMGMG_DITMGMF_")")):DITMGMF,1:"")
IF DITMGMN
DO ENTRY
QUIT
+2 IF '$DATA(@(DITMGMG_"0)"))
IF '$DATA(DITMGM2("NOTALK"))
WRITE !,"No Data Global: ",DITMGMG
QUIT
+3 ;----- BEGIN IHS MODIFICATION
+4 ;THE LINE BELOW IS COMMENTED OUT AND REPLACED BY A NEW LINE.
+5 ;NO BACKGROUND TASKS - NEED TO KNOW WHEN MERGE IS REALLY DONE
+6 ;ORIGINAL MODIFICATION BY IHS/ANMC/LJF 2/18/2000
+7 ;I '$D(^%ZTSK)!($P(@(DITMGMG_"0)"),U,4)<3001) D SEARCH Q ; If <= 3000 search gbl
+8 DO SEARCH
QUIT
+9 ;----- END IHS MODIFICATION
+10 IF '$DATA(DITMGM2("NOTALK"))
WRITE !,"No REGULAR xref on ",DITMGMFL,",",DITMGMFD," Merging entries for this file will",!,"now occur via Taskman in background!"
+11 ; SETUP CALL TO TASKMAN
+12 KILL DITMGMZT
IF $DATA(ZTSK)
SET DITMGMZT=ZTSK
+13 KILL ZTSAVE
FOR %="DITMGMG","DITMGMGM","DITMGMNO","DITMGMPC","DITMGMF","DITMGMT","DITMGMFL","DITMGMFD","DITMGMDI","DITMGMXR","DITMGMMU","DITMGMV"
SET ZTSAVE(%)=""
+14 SET ZTRTN="ZTM^DITMGM2"
SET ZTDESC="PROCESS POINTER FIELD #"_DITMGMFD_" IN FILE #"_DITMGMFL_" FROM "_DITMGMF_" TO "_DITMGMT
+15 SET ZTIO=""
SET ZTDTH=DT
DO ^%ZTLOAD
KILL ZTSK
+16 IF $DATA(DITMGMZT)
SET ZTSK=DITMGMZT
+17 KILL DITMGMZT
+18 QUIT
+19 ;
SEARCH ; $O THRU DATA GBL
+1 DO SEARCH^DITMGM2B
+2 QUIT
+3 ;
ENTRY ; PROCESS ONE FILE/SUBFILE ENTRY
+1 DO ENTRY^DITMGM2B
+2 QUIT
QUOTES ;
+1 NEW %P,%Q
SET %W1=""
SET %Q=""""
FOR %P=1:1:$LENGTH(%W,%Q)-1
SET %W1=%W1_$PIECE(%W,%Q,%P)_%Q_%Q
+2 SET %W1=%W1_$PIECE(%W,%Q,$LENGTH(%W,%Q))
+3 QUIT