DDS4 ;SFISC/MKO-FILE AND RELOAD ;21SEP2006
;;22.0;VA FileMan;**11,151**;Mar 30, 1999;Build 10
;Per VHA Directive 2004-038, this routine should not be modified.
D ^DDS41 Q:Y'=1
N DA,DDO,DIE,DDP,DDSDA
;
S DX=0,DY=IOSL-1 X IOXY W "Filing form"_$P(DDGLCLR,DDGLDEL)
;
;File data
S DDS4FI="F"
F S DDS4FI=$O(@DDSREFT@(DDS4FI)) Q:DDS4FI'?1"F".E D
. S DDP=$E(DDS4FI,2,999),DDS4DA=" "
. F S DDS4DA=$O(@DDSREFT@(DDS4FI,DDS4DA)) Q:DDS4DA="" D REC
;
;Reload all pages on form
S DDS4P=0
F S DDS4P=$O(@DDSREFT@(DDS4P)) Q:'DDS4P D
. S DDS4B=0
. F S DDS4B=$O(@DDSREFT@(DDS4P,DDS4B)) Q:'DDS4B D
.. S DDP=$P(@DDSREFS@(DDS4P,DDS4B),U,3),DDSDA=" "
.. F S DDSDA=$O(@DDSREFT@(DDS4P,DDS4B,DDSDA)) Q:'DDSDA D
... S $P(@DDSREFT@(DDS4P,DDS4B,DDSDA),U)=1,DIE=^(DDSDA,"GL")
... Q:$P(@DDSREFT@(DDS4P,DDS4B,DDSDA),U,6)>1
... D GDA(DDSDA)
... D ^DDS11(DDS4B,1)
;
I $G(^DIST(.403,+DDS,14))'?."^" D
. I $G(DDSPTB)_$G(DDSREP)]"" N DIE,DDP,DDSDA,DA,DDSDL D
.. S DA=DDSDAORG,DDSDL=DDSDLORG,DDSDA=DA_","
.. F DDSI=1:1:DDSDL S DA(DDSI)=DDSDAORG(DDSI),DDSDA=DDSDA_DA(DDSI)_","
.. S DDP=$P($G(DDSFLORG),U),DIE=U_$P($G(DDSFLORG),U,2) S:DIE=U DIE=""
. X ^DIST(.403,+DDS,14)
I '$G(DDSSAVE),$G(DDSPARM)["S" S DDSSAVE=1
S (Y,DDSH)=1,(DDSCHG,DX)=0,DY=IOSL-1 X IOXY W $P(DDGLCLR,DDGLDEL)
K @DDSREFT@("ADD"),@DDSREFT@("RXR")
K DIC,DDS1B,DDS1DA,DDS4B,DDS4DA,DDS4FI,DDS4FLD,DDS4FO,DDS4P
K DDSEXT,DDSI,DDSINT,DDSLC,DDSLN,DDSND,DDSOND,DDSOLD,DDSP,DDSPC
K DDSW,DDSX,DV
Q
REC ;
G:DDS4FI="F0" FORMONLY
;
S DIE=$G(@DDSREFT@(DDS4FI,DDS4DA,"GL")) I DIE="" Q ;JUST TO BE SAFE!
D GDA(DDS4DA)
S DDSOND=-1 K DDSLN
S DDS4FLD=""
F S DDS4FLD=$O(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD)) Q:DDS4FLD="" D FLD
S:$D(DDSLN)#2 @(DIE_"DA,DDSND)")=DDSLN
;
I $D(@DDSREFT@("RXR")) D
. D FIRE^DIKC(DDP,.DA,"KS",$NA(@DDSREFT@("RXR")),"O^")
. K @DDSREFT@("RXR")
Q
FLD ;
Q:'$G(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"F")) S ^("F")=""
I '$G(DDSCHANG),$G(DDSPARM)["C" S DDSCHANG=1
S DDSINT=$G(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"D"))
;
;Word processing fields (quit if multiple)
I $D(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"M"))#2 D:'$P(^("M"),U) Q
. N FR,TO
. S FR=$NA(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"D"))
. S TO=U_$$CREF^DILF($P(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"M"),U,2))
. K @TO
. M @TO=@FR
. K @FR,@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"F")
;
Q:$G(^DD(DDP,DDS4FLD,0))?."^" S DDSND=$P(^(0),U,4)
S DDSPC=$P(DDSND,";",2) Q:"0 "[DDSPC
S DDSND=$P(DDSND,";")
;
I DDSOND'=DDSND D
. S:$D(DDSLN)#2 @(DIE_"DA,DDSOND)")=DDSLN
. S DDSLN=$G(@(DIE_"DA,DDSND)"))
. S DDSOND=DDSND
;
I DDSPC D
. S DDSOLD=$P(DDSLN,U,DDSPC)
. S $P(DDSLN,U,DDSPC)=DDSINT
E D
. S DDSW=$E(DDSPC,2,999),DDSP=$P(DDSW,",",2)+1
. S DDSOLD=$E(DDSLN,+DDSW,DDSP-1)
. S DDSX=$E(DDSLN,DDSP,999)
. S DDSLN=$E(DDSLN,1,DDSW-1)_$J("",DDSW-1-$L(DDSLN))_DDSINT
. S:DDSX'?." " DDSLN=DDSLN_$J("",DDSP-DDSW-$L(DDSINT))_DDSX
;
I $D(^DD(DDP,DDS4FLD,1))!($P(^(0),U,2)["a")!$D(^DD("IX","F",DDP,DDS4FLD)) D XR
Q
XR ;
N DICRREC,DG,DP,DDS4AUD1,DDS4AUD2,DIANUM,DIIX,C,Y
S DP=DDP,DDSOND=-1
I $D(DDSLN)#2 S @(DIE_"DA,DDSND)")=DDSLN K DDSLN
S DICRREC="TRIG^DDS4"
;
I $P(^DD(DDP,DDS4FLD,0),U,2)["a" D
. S (DDS4AUD1,DDS4AUD2)=1
. I $G(^DD(DDP,DDS4FLD,"AUDIT"))["e",DDSOLD="" S DDS4AUD1=0
;
I DDSOLD]"" D
. S DG=0 F S DG=$O(^DD(DDP,DDS4FLD,1,DG)) Q:DG<1 D
.. S DIC=DIE,X=DDSOLD
.. X:$D(^DD(DDP,DDS4FLD,1,DG,2))#2 ^(2)
. I $G(DDS4AUD2) S DG=1,X=DDSOLD,DIIX="2^"_DDS4FLD D AUDIT^DIET
;
I DDSINT]"" D
. S DG=0 F S DG=$O(^DD(DDP,DDS4FLD,1,DG)) Q:DG<1 D
.. S DIC=DIE,X=DDSINT
.. X:$D(^DD(DDP,DDS4FLD,1,DG,1))#2 ^(1)
. I $G(DDS4AUD1) S DG=1,X=DDSINT,DIIX="3^"_DDS4FLD D AUDIT^DIET
Q:'$D(^DD("IX","F",DDP,DDS4FLD))
;
;Process index file xrefs
N DDSFXR,DDSFXREF,DDSRXREF
D LOADFLD^DIKC1(DDP,DDS4FLD,"KS","",$NA(@DDSREFT@("F"))_"_","DDSFXR",$NA(@DDSREFT@("RXR")),.DDSFXREF,.DDSRXREF)
I $G(DDSRXREF)]""!($G(DDSFXREF)]"") D
. S @DDSREFT@("F"_DDP,DDS4DA,DDS4FLD,"O")=DDSOLD ;BRX-0404-11337
D:$G(DDSFXREF)]"" FIRE^DIKC(DDP,.DA,"KS","DDSFXR","O^")
Q
GDA(DDSDA) ;
N I
K DA S DA=$P(DDSDA,",")
F I=2:1:$L(DDSDA,",")-1 S DA(I-1)=$P(DDSDA,",",I)
Q
;
FORMONLY ;
N X
D GDA(DDS4DA)
S DDS4FLD=""
F S DDS4FLD=$O(@DDSREFT@("F0",DDS4DA,DDS4FLD)) Q:DDS4FLD="" D
. Q:'$G(@DDSREFT@("F0",DDS4DA,DDS4FLD,"F"))
. S DDS4FO=$P(DDS4FLD,","),DDS4B=$P(DDS4FLD,",",2)
. S DDSOLD=$G(@DDSREFT@("F0",DDS4DA,DDS4FLD,"O")),X=$G(^("D")),DDSEXT=$G(^("X"),X)
. X:$G(^DIST(.404,DDS4B,40,DDS4FO,23))'?."^" ^(23)
. S ^("O")=@DDSREFT@("F0",DDS4DA,DDS4FLD,"D"),^("F")=""
Q
;
TRIG ;Called from trigger logic (from DICR via DICRREC)
N DDSRXREF
D LOADFLD^DIKC1(DIH,DIG,"KS","",$NA(@DDSREFT@("F"))_"_","",$NA(@DDSREFT@("RXR")),"",.DDSRXREF)
I $G(DDSRXREF)]"",'$D(@DDSREFT@("F"_DIH,DICRIENS,DIG,"O")) S ^("O")=DIU
Q
DDS4 ;SFISC/MKO-FILE AND RELOAD ;21SEP2006
+1 ;;22.0;VA FileMan;**11,151**;Mar 30, 1999;Build 10
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 DO ^DDS41
IF Y'=1
QUIT
+4 NEW DA,DDO,DIE,DDP,DDSDA
+5 ;
+6 SET DX=0
SET DY=IOSL-1
XECUTE IOXY
WRITE "Filing form"_$PIECE(DDGLCLR,DDGLDEL)
+7 ;
+8 ;File data
+9 SET DDS4FI="F"
+10 FOR
SET DDS4FI=$ORDER(@DDSREFT@(DDS4FI))
IF DDS4FI'?1"F".E
QUIT
Begin DoDot:1
+11 SET DDP=$EXTRACT(DDS4FI,2,999)
SET DDS4DA=" "
+12 FOR
SET DDS4DA=$ORDER(@DDSREFT@(DDS4FI,DDS4DA))
IF DDS4DA=""
QUIT
DO REC
End DoDot:1
+13 ;
+14 ;Reload all pages on form
+15 SET DDS4P=0
+16 FOR
SET DDS4P=$ORDER(@DDSREFT@(DDS4P))
IF 'DDS4P
QUIT
Begin DoDot:1
+17 SET DDS4B=0
+18 FOR
SET DDS4B=$ORDER(@DDSREFT@(DDS4P,DDS4B))
IF 'DDS4B
QUIT
Begin DoDot:2
+19 SET DDP=$PIECE(@DDSREFS@(DDS4P,DDS4B),U,3)
SET DDSDA=" "
+20 FOR
SET DDSDA=$ORDER(@DDSREFT@(DDS4P,DDS4B,DDSDA))
IF 'DDSDA
QUIT
Begin DoDot:3
+21 SET $PIECE(@DDSREFT@(DDS4P,DDS4B,DDSDA),U)=1
SET DIE=^(DDSDA,"GL")
+22 IF $PIECE(@DDSREFT@(DDS4P,DDS4B,DDSDA),U,6)>1
QUIT
+23 DO GDA(DDSDA)
+24 DO ^DDS11(DDS4B,1)
End DoDot:3
End DoDot:2
End DoDot:1
+25 ;
+26 IF $GET(^DIST(.403,+DDS,14))'?."^"
Begin DoDot:1
+27 IF $GET(DDSPTB)_$GET(DDSREP)]""
NEW DIE,DDP,DDSDA,DA,DDSDL
Begin DoDot:2
+28 SET DA=DDSDAORG
SET DDSDL=DDSDLORG
SET DDSDA=DA_","
+29 FOR DDSI=1:1:DDSDL
SET DA(DDSI)=DDSDAORG(DDSI)
SET DDSDA=DDSDA_DA(DDSI)_","
+30 SET DDP=$PIECE($GET(DDSFLORG),U)
SET DIE=U_$PIECE($GET(DDSFLORG),U,2)
IF DIE=U
SET DIE=""
End DoDot:2
+31 XECUTE ^DIST(.403,+DDS,14)
End DoDot:1
+32 IF '$GET(DDSSAVE)
IF $GET(DDSPARM)["S"
SET DDSSAVE=1
+33 SET (Y,DDSH)=1
SET (DDSCHG,DX)=0
SET DY=IOSL-1
XECUTE IOXY
WRITE $PIECE(DDGLCLR,DDGLDEL)
+34 KILL @DDSREFT@("ADD"),@DDSREFT@("RXR")
+35 KILL DIC,DDS1B,DDS1DA,DDS4B,DDS4DA,DDS4FI,DDS4FLD,DDS4FO,DDS4P
+36 KILL DDSEXT,DDSI,DDSINT,DDSLC,DDSLN,DDSND,DDSOND,DDSOLD,DDSP,DDSPC
+37 KILL DDSW,DDSX,DV
+38 QUIT
REC ;
+1 IF DDS4FI="F0"
GOTO FORMONLY
+2 ;
+3 ;JUST TO BE SAFE!
SET DIE=$GET(@DDSREFT@(DDS4FI,DDS4DA,"GL"))
IF DIE=""
QUIT
+4 DO GDA(DDS4DA)
+5 SET DDSOND=-1
KILL DDSLN
+6 SET DDS4FLD=""
+7 FOR
SET DDS4FLD=$ORDER(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD))
IF DDS4FLD=""
QUIT
DO FLD
+8 IF $DATA(DDSLN)#2
SET @(DIE_"DA,DDSND)")=DDSLN
+9 ;
+10 IF $DATA(@DDSREFT@("RXR"))
Begin DoDot:1
+11 DO FIRE^DIKC(DDP,.DA,"KS",$NAME(@DDSREFT@("RXR")),"O^")
+12 KILL @DDSREFT@("RXR")
End DoDot:1
+13 QUIT
FLD ;
+1 IF '$GET(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"F"))
QUIT
SET ^("F")=""
+2 IF '$GET(DDSCHANG)
IF $GET(DDSPARM)["C"
SET DDSCHANG=1
+3 SET DDSINT=$GET(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"D"))
+4 ;
+5 ;Word processing fields (quit if multiple)
+6 IF $DATA(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"M"))#2
IF '$PIECE(^("M"),U)
Begin DoDot:1
+7 NEW FR,TO
+8 SET FR=$NAME(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"D"))
+9 SET TO=U_$$CREF^DILF($PIECE(@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"M"),U,2))
+10 KILL @TO
+11 MERGE @TO=@FR
+12 KILL @FR,@DDSREFT@(DDS4FI,DDS4DA,DDS4FLD,"F")
End DoDot:1
QUIT
+13 ;
+14 IF $GET(^DD(DDP,DDS4FLD,0))?."^"
QUIT
SET DDSND=$PIECE(^(0),U,4)
+15 SET DDSPC=$PIECE(DDSND,";",2)
IF "0 "[DDSPC
QUIT
+16 SET DDSND=$PIECE(DDSND,";")
+17 ;
+18 IF DDSOND'=DDSND
Begin DoDot:1
+19 IF $DATA(DDSLN)#2
SET @(DIE_"DA,DDSOND)")=DDSLN
+20 SET DDSLN=$GET(@(DIE_"DA,DDSND)"))
+21 SET DDSOND=DDSND
End DoDot:1
+22 ;
+23 IF DDSPC
Begin DoDot:1
+24 SET DDSOLD=$PIECE(DDSLN,U,DDSPC)
+25 SET $PIECE(DDSLN,U,DDSPC)=DDSINT
End DoDot:1
+26 IF '$TEST
Begin DoDot:1
+27 SET DDSW=$EXTRACT(DDSPC,2,999)
SET DDSP=$PIECE(DDSW,",",2)+1
+28 SET DDSOLD=$EXTRACT(DDSLN,+DDSW,DDSP-1)
+29 SET DDSX=$EXTRACT(DDSLN,DDSP,999)
+30 SET DDSLN=$EXTRACT(DDSLN,1,DDSW-1)_$JUSTIFY("",DDSW-1-$LENGTH(DDSLN))_DDSINT
+31 IF DDSX'?." "
SET DDSLN=DDSLN_$JUSTIFY("",DDSP-DDSW-$LENGTH(DDSINT))_DDSX
End DoDot:1
+32 ;
+33 IF $DATA(^DD(DDP,DDS4FLD,1))!($PIECE(^(0),U,2)["a")!$DATA(^DD("IX","F",DDP,DDS4FLD))
DO XR
+34 QUIT
XR ;
+1 NEW DICRREC,DG,DP,DDS4AUD1,DDS4AUD2,DIANUM,DIIX,C,Y
+2 SET DP=DDP
SET DDSOND=-1
+3 IF $DATA(DDSLN)#2
SET @(DIE_"DA,DDSND)")=DDSLN
KILL DDSLN
+4 SET DICRREC="TRIG^DDS4"
+5 ;
+6 IF $PIECE(^DD(DDP,DDS4FLD,0),U,2)["a"
Begin DoDot:1
+7 SET (DDS4AUD1,DDS4AUD2)=1
+8 IF $GET(^DD(DDP,DDS4FLD,"AUDIT"))["e"
IF DDSOLD=""
SET DDS4AUD1=0
End DoDot:1
+9 ;
+10 IF DDSOLD]""
Begin DoDot:1
+11 SET DG=0
FOR
SET DG=$ORDER(^DD(DDP,DDS4FLD,1,DG))
IF DG<1
QUIT
Begin DoDot:2
+12 SET DIC=DIE
SET X=DDSOLD
+13 IF $DATA(^DD(DDP,DDS4FLD,1,DG,2))#2
XECUTE ^(2)
End DoDot:2
+14 IF $GET(DDS4AUD2)
SET DG=1
SET X=DDSOLD
SET DIIX="2^"_DDS4FLD
DO AUDIT^DIET
End DoDot:1
+15 ;
+16 IF DDSINT]""
Begin DoDot:1
+17 SET DG=0
FOR
SET DG=$ORDER(^DD(DDP,DDS4FLD,1,DG))
IF DG<1
QUIT
Begin DoDot:2
+18 SET DIC=DIE
SET X=DDSINT
+19 IF $DATA(^DD(DDP,DDS4FLD,1,DG,1))#2
XECUTE ^(1)
End DoDot:2
+20 IF $GET(DDS4AUD1)
SET DG=1
SET X=DDSINT
SET DIIX="3^"_DDS4FLD
DO AUDIT^DIET
End DoDot:1
+21 IF '$DATA(^DD("IX","F",DDP,DDS4FLD))
QUIT
+22 ;
+23 ;Process index file xrefs
+24 NEW DDSFXR,DDSFXREF,DDSRXREF
+25 DO LOADFLD^DIKC1(DDP,DDS4FLD,"KS","",$NAME(@DDSREFT@("F"))_"_","DDSFXR",$NAME(@DDSREFT@("RXR")),.DDSFXREF,.DDSRXREF)
+26 IF $GET(DDSRXREF)]""!($GET(DDSFXREF)]"")
Begin DoDot:1
+27 ;BRX-0404-11337
SET @DDSREFT@("F"_DDP,DDS4DA,DDS4FLD,"O")=DDSOLD
End DoDot:1
+28 IF $GET(DDSFXREF)]""
DO FIRE^DIKC(DDP,.DA,"KS","DDSFXR","O^")
+29 QUIT
GDA(DDSDA) ;
+1 NEW I
+2 KILL DA
SET DA=$PIECE(DDSDA,",")
+3 FOR I=2:1:$LENGTH(DDSDA,",")-1
SET DA(I-1)=$PIECE(DDSDA,",",I)
+4 QUIT
+5 ;
FORMONLY ;
+1 NEW X
+2 DO GDA(DDS4DA)
+3 SET DDS4FLD=""
+4 FOR
SET DDS4FLD=$ORDER(@DDSREFT@("F0",DDS4DA,DDS4FLD))
IF DDS4FLD=""
QUIT
Begin DoDot:1
+5 IF '$GET(@DDSREFT@("F0",DDS4DA,DDS4FLD,"F"))
QUIT
+6 SET DDS4FO=$PIECE(DDS4FLD,",")
SET DDS4B=$PIECE(DDS4FLD,",",2)
+7 SET DDSOLD=$GET(@DDSREFT@("F0",DDS4DA,DDS4FLD,"O"))
SET X=$GET(^("D"))
SET DDSEXT=$GET(^("X"),X)
+8 IF $GET(^DIST(.404,DDS4B,40,DDS4FO,23))'?."^"
XECUTE ^(23)
+9 SET ^("O")=@DDSREFT@("F0",DDS4DA,DDS4FLD,"D")
SET ^("F")=""
End DoDot:1
+10 QUIT
+11 ;
TRIG ;Called from trigger logic (from DICR via DICRREC)
+1 NEW DDSRXREF
+2 DO LOADFLD^DIKC1(DIH,DIG,"KS","",$NAME(@DDSREFT@("F"))_"_","",$NAME(@DDSREFT@("RXR")),"",.DDSRXREF)
+3 IF $GET(DDSRXREF)]""
IF '$DATA(@DDSREFT@("F"_DIH,DICRIENS,DIG,"O"))
SET ^("O")=DIU
+4 QUIT