DIT ;SFISC/GFT-GET XFR ANSWERS ;14FEB2005
 ;;22.0;VA FileMan;**1012**;Mar 30, 1999
 ;;
0 S DIC="^DOPT(""DIT""," G OPT:$D(^DOPT("DIT",3)) S ^(0)="TRANSFER OPTION^1.01" K ^("B")
 F X=1,2,3 S ^DOPT("DIT",X,0)=$P("TRANSFER FILE ENTRIES^COMPARE/MERGE FILE ENTRIES^NAMESPACE COMPARE",U,X)
 S DIK=DIC D IXALL^DIK
OPT W !! S DIC(0)="AEQZI" D ^DIC G Q:Y<0,UCI^DITCP:+Y=3 I +Y=2 D ^DITM K DIC G 0
 D Q S DLAYGO=1 D W^DICRW G Q:$D(DTOUT) Q:Y<0  S DFL=$P(Y,U,2)_": " I '$D(DIC) D DIE^DIB Q:'$D(DG)  S L=DG,Y=DLAYGO K DG,DIE,DQ G FROM
 S DIC("B")=+Y,L=DIC
FROM S DMRG=1,DKP=1,(DDF(1),DDT(0))=+Y,DIC=1,DIC(0)="EQAZ",DIC("A")="TRANSFER FROM FILE: "
 S DIC("S")="S DIFILE=+Y,DIAC=""RD"" D ^DIAC I %"
 D ^DIC K DIC G Q:Y<0,Q:'$D(^(0,"GL")) S DTO=^("GL") I DUZ(0)'="@",$S($D(^VA(200,DUZ,"FOF",+Y,0)):1,1:$D(^DIC(3,DUZ,"FOF",+Y,0))) G DTR:+$P(^(0),U,3),Q
 I DUZ(0)'="@",$D(^DIC(+Y,0,"DEL")) F X=1:1 G Q:X>$L(^("DEL")) Q:DUZ(0)[$E(^("DEL"),X)
DTR D PTS I +Y=DDF(1) G ^DIT0
TWO S (DTO(0),F)=L,L(+Y)=DDT(0),L=0,DDF(1)=+Y,DFR(1)=DTO_"D0,",DHIT=DLAYGO-(Y#1),%=0
 W !! K ^UTILITY("DITR",$J),A I DLAYGO-1 W "DO YOU WANT TO TRANSFER THE '",$P(Y,U,2),"'",!,"DATA DICTIONARY INTO YOUR NEW FILE" D YN^DICN G Q:%<1 D ^DIT1:%=1
 K DITF,Y,B W ! G Q:'$D(L)
 D MAP I '$D(DITF) W $C(7),"FILES DON'T MATCH!" G Q
 W:$X>40 ! W:'$D(A) "  WILL BE TRANSFERRED",!!
 S %=2,DMRG=0 I @("$O("_DTO(0)_"0))>0") W !,"WANT TO MERGE TRANSFERRED ENTRIES WITH ONES ALREADY THERE" D YN^DICN G Q:%<1 I %=1 S DMRG=1
 S (DIK,DIC)=DTO,DTO=1,L="TRANSFER ENTRIES",FLDS="",DHD="@",%ZIS="F"
D S %=0 W !,"WANT EACH ENTRY TO BE DELETED AS IT'S TRANSFERRED" D YN^DICN S DHIT="S DI=99 D F^DITR"_$P(",^DIK",%,%=1) G Q:%<0 I '% D F G D
 S DISTOP=0,DIOEND="S DIK=DTO(0),DIK(0)=""B"" D KL^DIT,IXALL^DIK,Q^DIT" D EN1^DIP
Q ;
 K ^UTILITY("DITR",$J),^UTILITY("DIT",$J),DIT,DIC,DA,DB1,DFR,DIK,L,FLDS,DHIT,DISTOP,DIOEND,%ZIS
KL K DIU,DIV,DIG,DIH,DLAYGO,DITF,DFN,DMRG,DTO,DTN,DDF,DTL,DFL,DDT,A,B,DKP,W,X,FLDS,Y,Z Q
 ;
MAP ;BUILD MAP OF FIELDS FROM 'FROM' TO 'TO' FILE
 N DFL S DFL=1
MAP2 ;ENTRY POINT FROM ^DIT3
 K:L]"" L(L) S L=$O(L(0)) Q:L']""
 F Y=0:0 S Y=$O(^DD(L,Y)) G MAP2:Y="",MAP2:'$D(^(Y,0)) S %=^(0) I $P(%,U,2)'["C" S DIC=$P(%,U,1),X=$O(^DD(L(L),"B",DIC,0)) I X>0,'^(X),$P(^DD(L(L),X,0),U,2)'["C" D T
 Q
T S Z=$P(^(0),U,4),V=$P($P(^(0),U,2),U,Z[";0"),^UTILITY("DITR",$J,L,Y)=$P(Z,";",2)_U_$P(Z,";",1) S:V ^(Y)=^(Y)_U_V,L(+$P(%,U,2))=+V I Z="0;1",DDF(DFL)=L S DITF=$P(%,U,4)
 Q:$D(A)  W:$X ", " W:$L(DIC)+$X>66 ! W "'"_DIC_"' FIELDS" Q
 ;
PTS ;Find re-pointable fields (not containing "I"!)
 S DL=0 F X=0:0 S X=$O(^DD(+Y,0,"PT",X)) Q:X'>0  F Z=.001:0 S Z=$O(^DD(+Y,0,"PT",X,Z)) Q:Z'>0  I $D(^DD(X,Z,0))#2 S %=^(0) I (U_$P(%,U,3)=DTO!($D(^DD(X,Z,"V","B",+Y)))),$P(%,U,2)'["I" S DL=DL+1,^UTILITY("DIT",$J,0,DL)=X_U_Z_U_$P(%,U,2)
 Q
 ;
F W !?7,"(TYPE '^' TO FORGET THE WHOLE THING!)",!
 Q
 ;
TRNMRG(DIFLG,DIFFNO,DITFNO,DIFIEN,DITIEN) ; SILENT TRANSFER/MERGE OF SINGLE RECORDS IN FILE OR SUBFILE
 ;DIFLG  = FLAGS
 ;DIFFNO = TRANSFER 'FROM' FILE/SUBFILE NO. OR ROOT
 ;DITFNO = TRANSFER 'TO' FILE/SUBFILE NO.
 ;DIFIEN = TRANSFER 'FROM' IEN STRING
 ;DITIEN = TRANSFER 'TO' IEN STRING (PASS BY REFERENCE)
 G TRNMRG^DIT3
