DICF1 ;SEA/TOAD,SF/TKW-VA FileMan: Finder, Part 2 (Transform) ;1:48 PM 17 Jun 2013
;;22.0;VA FileMan;**15,51,70,135,170**;Mar 30, 1999;Build 12
;Per VHA Directive 2004-038, this routine should not be modified.
;
XFORM(DIFLAGS,DIVALUE,DISCREEN,DINDEX) ;
; FIND--produce array of values and screens by transforming input
; subroutine, DIVALUE, DINDEX, & DISCREEN passed by reference
N DISUB F DISUB=1:1:DINDEX("#") D VALUES
Q
VALUES ; Set original lookup value into array.
I $D(DIVALUE(DISUB,0,1)) S DIVALUE(DISUB)=DIVALUE(DISUB,0,1)
N I F I="PART","FROM","TO" I $D(DIVALUE(DISUB,0,1,I)) D
. S DINDEX(DISUB,I)=DIVALUE(DISUB,0,1,I) Q
D
. S I=-1 F S I=$O(DIVALUE(DISUB,I)) Q:I="" K DIVALUE(DISUB,I)
. S I=-1 F S I=$O(DISCREEN(DISUB,I)) Q:I="" K DISCREEN(DISUB,I)
. Q
S DIVALUE(DISUB,1)=DIVALUE(DISUB)
Q:DIVALUE(DISUB)=""
I DIFLAGS["Q" D LONG Q
LOWER ;
I DIVALUE(DISUB)?.E1L.E,DIFLAGS'["X" D
. S DIVALUE(DISUB,2)=$$OUT^DIALOGU(DIVALUE(DISUB),"UC")
. Q
;
CHK ; Quit if data type not free-text, pointer or vp, or if lookup value is numeric or a date.
Q:"PVF"'[$G(DINDEX(DISUB,"TYPE"))
I DIVALUE(DISUB)?.NP D LONG Q ;**170
N Y D Q:Y>0
. N X S X=DIVALUE(DISUB) N %DT,DIFLAGS,DIVALUE,DISCREEN,DINDEX,DISUB
. S %DT="T" D ^%DT Q
COMMA I DIVALUE(DISUB)[",",DIFLAGS'["X" D
. N DISTEMP,DIPIECE1 S DISTEMP="",DIPIECE1=$P(DIVALUE(DISUB),",")
. Q:$L(DIPIECE1)>DINDEX(DISUB,"LENGTH")
. Q:'$L(DIPIECE1) ;SO
21 . I DIFLAGS["C" D
. . N DIPART1 S DIPART1=" I %?.E1P1"""
. . N DIPART2 S DIPART2=""".E!(D'=""B""&(%?1"""
. . N DIPART3 S DIPART3=""".E))"
. . N DIOUT S DIOUT=0
. . N DIPIECE,DIVPIECE F DIPIECE=2:1 D I DIOUT Q
. . . S DIVPIECE=$P(DIVALUE(DISUB),",",DIPIECE)
. . . I DIVPIECE["""" Q
. . . I $E(DIVPIECE)=" " S DIVPIECE=$E(DIVPIECE,2,$L(DIVPIECE))
. . . I DIVPIECE="" S DIOUT=1 Q
. . . I $L(DIVPIECE)*2+$L(DISTEMP)+33+14+34>255 S DIOUT=1 Q
. . . S DISTEMP=DISTEMP_DIPART1_DIVPIECE_DIPART2_DIVPIECE_DIPART3
. . . Q:DISTEMP=""
. . . S DISTEMP="S %=DIVAL "_DISTEMP Q ;22*135
. . I DISTEMP="" Q
22 . I DIFLAGS'["C" N DIPIECE2,DIPC2 D
. . S (DIPC2,DIPIECE2)=$P(DIVALUE(DISUB),",",2)
. . I DIPIECE2["""" S DIPC2=$$CONVQQ^DILIBF(DIPIECE2)
. . S DISTEMP="S %=$P(DIVAL,"","",2) I $E(%,1,"_$L(DIPIECE2)_")="""_DIPC2_""""
. . Q
23 . S DIVALUE(DISUB,3)=DIPIECE1
. S DISCREEN(DISUB,3)=DISTEMP
. I DIFLAGS'["C" S DIVALUE(DISUB,3,"c")=DIPIECE2
24 . I DIVALUE(DISUB)'?.E1L.E Q
. S DIVALUE(DISUB,4)=$$OUT^DIALOGU(DIPIECE1,"UC")
. S DISCREEN(DISUB,4)=$$OUT^DIALOGU(DISTEMP,"UC")
. I DIFLAGS'["C" S DIVALUE(DISUB,4,"c")=$$OUT^DIALOGU(DIPIECE2,"UC")
;
LONG I $L(DIVALUE(DISUB))'>DINDEX(DISUB,"LENGTH") Q
N J,X,DISLONG,DISPART,DISXACT,DIREF
F I=0:0 S I=$O(DIVALUE(DISUB,I)) Q:'I D
. N L,M S L=DINDEX(DISUB,"LENGTH")
. Q:$L(DIVALUE(DISUB,I))'>L
. S X=DIVALUE(DISUB,I) K DIVALUE(DISUB,I) S DIVALUE(DISUB,0,I)=X
. I $G(DISCREEN(DISUB,I))]"" S X=DISCREEN(DISUB,I) K DISCREEN(DISUB,I) S DISCREEN(DISUB,0,I)=X
. S DIVALUE(DISUB,I)=$E(DIVALUE(DISUB,0,I),1,L)
. I I=1 D
. . S (DIVALUE(DISUB),DINDEX(DISUB))=DIVALUE(DISUB,I)
. . F J="PART","FROM","TO" S M=$L($G(DINDEX(DISUB,J))) D:M>L
. . . S DIVALUE(DISUB,0,I,J)=DINDEX(DISUB,J)
. . . S DINDEX(DISUB,J)=$E(DINDEX(DISUB,J),1,L) Q
. . Q
. S DISLONG=""
. I $D(DISCREEN(DISUB,0,I)) S DISLONG=" X DISCREEN("_DISUB_",0,"_I_")"
. S DIREF="DINDEX("_DISUB_",0,"_I_")"
. S DISPART="I $P(DIVAL,$G("_DIREF_"))="""""_DISLONG ;DI*22*70
. S DISXACT="I $P(DIVAL,U)="_DIREF_DISLONG
L10 . I DIFLAGS["X" S DISCREEN(DISUB,I)=DISXACT Q
. I DIFLAGS'["O" S DISCREEN(DISUB,I)=DISPART Q
. S DISCREEN(DISUB,I)=DISXACT
. S DISCREEN(DISUB,I,2)=DISPART
. Q
Q
;
SPECIAL(DIFILE,DIEN,DIFIEN,DIFLAGS,DIVALUE,DINDEX,DISCREEN,DIDENT,DIOUT,DILIST) ;
; Process space-bar return, 'IEN or DIVALUE equal to an IEN.
S DIOUT=0
11 I DIVALUE=" " D S DIOUT=1 Q
. N DIROOT S DIROOT=$$ROOT^DIQGU(DIFILE,DIFIEN,"Q")
. N DINODE S DINODE=$G(^DISV(DUZ,$E(DIROOT,1,28)))
. N DINODEL S DINODEL=$L(DINODE,",")
. I $P(DINODE,",",1,DINODEL-1)'=$E(DIROOT,29,9999) Q
. S DIEN=$P(DINODE,",",DINODEL)
. I 'DIEN S DIEN="" Q
. D ENTRY Q
12 I DIVALUE?1"`".NP D Q:DIOUT=1
. S DIEN=$E(DIVALUE,2,$L(DIVALUE)) Q:+DIEN'=DIEN
. D ENTRY S DIOUT=1 Q
13 I $S(DIVALUE?1.N:1,DIVALUE'?.NP:0,1:+DIVALUE=DIVALUE) D
. N DI001 S DI001=$D(^DD(DIFILE,.001))
. N DI01FLAG S DI01FLAG=$P($G(^DD(DIFILE,.01,0)),U,2)
. I $D(@DIFILE(DIFILE)@(DIVALUE)) D
. . I DIFLAGS'["A",'DI001,DI01FLAG["N"!($O(@DIFILE(DIFILE)@("A["))'="") Q
. . S DIEN=DIVALUE
. . D ENTRY
. . I $G(DINDEX("DONE"))!($G(DIERR)) S DIEN="",DIOUT=1
Q
;
ENTRY ; Execute screens, and if entry passes, do ACCEPT to add it to output.
N DI0NODE S DI0NODE=$G(@DIFILE(DIFILE)@(DIEN,0))
Q:$$SCREEN^DICL2(.DIFILE,.DIEN,DIFLAGS,DIFIEN,.DISCREEN,.DINDEX,DI0NODE)
D ACCEPT^DICL2(.DIFILE,.DIEN,.DIFLAGS,DIFIEN,.DINDEX,.DIDENT,.DILIST,DI0NODE)
Q
DICF1 ;SEA/TOAD,SF/TKW-VA FileMan: Finder, Part 2 (Transform) ;1:48 PM 17 Jun 2013
+1 ;;22.0;VA FileMan;**15,51,70,135,170**;Mar 30, 1999;Build 12
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
XFORM(DIFLAGS,DIVALUE,DISCREEN,DINDEX) ;
+1 ; FIND--produce array of values and screens by transforming input
+2 ; subroutine, DIVALUE, DINDEX, & DISCREEN passed by reference
+3 NEW DISUB
FOR DISUB=1:1:DINDEX("#")
DO VALUES
+4 QUIT
VALUES ; Set original lookup value into array.
+1 IF $DATA(DIVALUE(DISUB,0,1))
SET DIVALUE(DISUB)=DIVALUE(DISUB,0,1)
+2 NEW I
FOR I="PART","FROM","TO"
IF $DATA(DIVALUE(DISUB,0,1,I))
Begin DoDot:1
+3 SET DINDEX(DISUB,I)=DIVALUE(DISUB,0,1,I)
QUIT
End DoDot:1
+4 Begin DoDot:1
+5 SET I=-1
FOR
SET I=$ORDER(DIVALUE(DISUB,I))
IF I=""
QUIT
KILL DIVALUE(DISUB,I)
+6 SET I=-1
FOR
SET I=$ORDER(DISCREEN(DISUB,I))
IF I=""
QUIT
KILL DISCREEN(DISUB,I)
+7 QUIT
End DoDot:1
+8 SET DIVALUE(DISUB,1)=DIVALUE(DISUB)
+9 IF DIVALUE(DISUB)=""
QUIT
+10 IF DIFLAGS["Q"
DO LONG
QUIT
LOWER ;
+1 IF DIVALUE(DISUB)?.E1L.E
IF DIFLAGS'["X"
Begin DoDot:1
+2 SET DIVALUE(DISUB,2)=$$OUT^DIALOGU(DIVALUE(DISUB),"UC")
+3 QUIT
End DoDot:1
+4 ;
CHK ; Quit if data type not free-text, pointer or vp, or if lookup value is numeric or a date.
+1 IF "PVF"'[$GET(DINDEX(DISUB,"TYPE"))
QUIT
+2 ;**170
IF DIVALUE(DISUB)?.NP
DO LONG
QUIT
+3 NEW Y
Begin DoDot:1
+4 NEW X
SET X=DIVALUE(DISUB)
NEW %DT,DIFLAGS,DIVALUE,DISCREEN,DINDEX,DISUB
+5 SET %DT="T"
DO ^%DT
QUIT
End DoDot:1
IF Y>0
QUIT
COMMA IF DIVALUE(DISUB)[","
IF DIFLAGS'["X"
Begin DoDot:1
+1 NEW DISTEMP,DIPIECE1
SET DISTEMP=""
SET DIPIECE1=$PIECE(DIVALUE(DISUB),",")
+2 IF $LENGTH(DIPIECE1)>DINDEX(DISUB,"LENGTH")
QUIT
+3 ;SO
IF '$LENGTH(DIPIECE1)
QUIT
21 IF DIFLAGS["C"
Begin DoDot:2
+1 NEW DIPART1
SET DIPART1=" I %?.E1P1"""
+2 NEW DIPART2
SET DIPART2=""".E!(D'=""B""&(%?1"""
+3 NEW DIPART3
SET DIPART3=""".E))"
+4 NEW DIOUT
SET DIOUT=0
+5 NEW DIPIECE,DIVPIECE
FOR DIPIECE=2:1
Begin DoDot:3
+6 SET DIVPIECE=$PIECE(DIVALUE(DISUB),",",DIPIECE)
+7 IF DIVPIECE[""""
QUIT
+8 IF $EXTRACT(DIVPIECE)=" "
SET DIVPIECE=$EXTRACT(DIVPIECE,2,$LENGTH(DIVPIECE))
+9 IF DIVPIECE=""
SET DIOUT=1
QUIT
+10 IF $LENGTH(DIVPIECE)*2+$LENGTH(DISTEMP)+33+14+34>255
SET DIOUT=1
QUIT
+11 SET DISTEMP=DISTEMP_DIPART1_DIVPIECE_DIPART2_DIVPIECE_DIPART3
+12 IF DISTEMP=""
QUIT
+13 ;22*135
SET DISTEMP="S %=DIVAL "_DISTEMP
QUIT
End DoDot:3
IF DIOUT
QUIT
+14 IF DISTEMP=""
QUIT
End DoDot:2
22 IF DIFLAGS'["C"
NEW DIPIECE2,DIPC2
Begin DoDot:2
+1 SET (DIPC2,DIPIECE2)=$PIECE(DIVALUE(DISUB),",",2)
+2 IF DIPIECE2[""""
SET DIPC2=$$CONVQQ^DILIBF(DIPIECE2)
+3 SET DISTEMP="S %=$P(DIVAL,"","",2) I $E(%,1,"_$LENGTH(DIPIECE2)_")="""_DIPC2_""""
+4 QUIT
End DoDot:2
23 SET DIVALUE(DISUB,3)=DIPIECE1
+1 SET DISCREEN(DISUB,3)=DISTEMP
+2 IF DIFLAGS'["C"
SET DIVALUE(DISUB,3,"c")=DIPIECE2
24 IF DIVALUE(DISUB)'?.E1L.E
QUIT
+1 SET DIVALUE(DISUB,4)=$$OUT^DIALOGU(DIPIECE1,"UC")
+2 SET DISCREEN(DISUB,4)=$$OUT^DIALOGU(DISTEMP,"UC")
+3 IF DIFLAGS'["C"
SET DIVALUE(DISUB,4,"c")=$$OUT^DIALOGU(DIPIECE2,"UC")
End DoDot:1
+4 ;
LONG IF $LENGTH(DIVALUE(DISUB))'>DINDEX(DISUB,"LENGTH")
QUIT
+1 NEW J,X,DISLONG,DISPART,DISXACT,DIREF
+2 FOR I=0:0
SET I=$ORDER(DIVALUE(DISUB,I))
IF 'I
QUIT
Begin DoDot:1
+3 NEW L,M
SET L=DINDEX(DISUB,"LENGTH")
+4 IF $LENGTH(DIVALUE(DISUB,I))'>L
QUIT
+5 SET X=DIVALUE(DISUB,I)
KILL DIVALUE(DISUB,I)
SET DIVALUE(DISUB,0,I)=X
+6 IF $GET(DISCREEN(DISUB,I))]""
SET X=DISCREEN(DISUB,I)
KILL DISCREEN(DISUB,I)
SET DISCREEN(DISUB,0,I)=X
+7 SET DIVALUE(DISUB,I)=$EXTRACT(DIVALUE(DISUB,0,I),1,L)
+8 IF I=1
Begin DoDot:2
+9 SET (DIVALUE(DISUB),DINDEX(DISUB))=DIVALUE(DISUB,I)
+10 FOR J="PART","FROM","TO"
SET M=$LENGTH($GET(DINDEX(DISUB,J)))
IF M>L
Begin DoDot:3
+11 SET DIVALUE(DISUB,0,I,J)=DINDEX(DISUB,J)
+12 SET DINDEX(DISUB,J)=$EXTRACT(DINDEX(DISUB,J),1,L)
QUIT
End DoDot:3
+13 QUIT
End DoDot:2
+14 SET DISLONG=""
+15 IF $DATA(DISCREEN(DISUB,0,I))
SET DISLONG=" X DISCREEN("_DISUB_",0,"_I_")"
+16 SET DIREF="DINDEX("_DISUB_",0,"_I_")"
+17 ;DI*22*70
SET DISPART="I $P(DIVAL,$G("_DIREF_"))="""""_DISLONG
+18 SET DISXACT="I $P(DIVAL,U)="_DIREF_DISLONG
L10 IF DIFLAGS["X"
SET DISCREEN(DISUB,I)=DISXACT
QUIT
+1 IF DIFLAGS'["O"
SET DISCREEN(DISUB,I)=DISPART
QUIT
+2 SET DISCREEN(DISUB,I)=DISXACT
+3 SET DISCREEN(DISUB,I,2)=DISPART
+4 QUIT
End DoDot:1
+5 QUIT
+6 ;
SPECIAL(DIFILE,DIEN,DIFIEN,DIFLAGS,DIVALUE,DINDEX,DISCREEN,DIDENT,DIOUT,DILIST) ;
+1 ; Process space-bar return, 'IEN or DIVALUE equal to an IEN.
+2 SET DIOUT=0
11 IF DIVALUE=" "
Begin DoDot:1
+1 NEW DIROOT
SET DIROOT=$$ROOT^DIQGU(DIFILE,DIFIEN,"Q")
+2 NEW DINODE
SET DINODE=$GET(^DISV(DUZ,$EXTRACT(DIROOT,1,28)))
+3 NEW DINODEL
SET DINODEL=$LENGTH(DINODE,",")
+4 IF $PIECE(DINODE,",",1,DINODEL-1)'=$EXTRACT(DIROOT,29,9999)
QUIT
+5 SET DIEN=$PIECE(DINODE,",",DINODEL)
+6 IF 'DIEN
SET DIEN=""
QUIT
+7 DO ENTRY
QUIT
End DoDot:1
SET DIOUT=1
QUIT
12 IF DIVALUE?1"`".NP
Begin DoDot:1
+1 SET DIEN=$EXTRACT(DIVALUE,2,$LENGTH(DIVALUE))
IF +DIEN'=DIEN
QUIT
+2 DO ENTRY
SET DIOUT=1
QUIT
End DoDot:1
IF DIOUT=1
QUIT
13 IF $SELECT(DIVALUE?1.N:1,DIVALUE'?.NP:0,1:+DIVALUE=DIVALUE)
Begin DoDot:1
+1 NEW DI001
SET DI001=$DATA(^DD(DIFILE,.001))
+2 NEW DI01FLAG
SET DI01FLAG=$PIECE($GET(^DD(DIFILE,.01,0)),U,2)
+3 IF $DATA(@DIFILE(DIFILE)@(DIVALUE))
Begin DoDot:2
+4 IF DIFLAGS'["A"
IF 'DI001
IF DI01FLAG["N"!($ORDER(@DIFILE(DIFILE)@("A["))'="")
QUIT
+5 SET DIEN=DIVALUE
+6 DO ENTRY
+7 IF $GET(DINDEX("DONE"))!($GET(DIERR))
SET DIEN=""
SET DIOUT=1
End DoDot:2
End DoDot:1
+8 QUIT
+9 ;
ENTRY ; Execute screens, and if entry passes, do ACCEPT to add it to output.
+1 NEW DI0NODE
SET DI0NODE=$GET(@DIFILE(DIFILE)@(DIEN,0))
+2 IF $$SCREEN^DICL2(.DIFILE,.DIEN,DIFLAGS,DIFIEN,.DISCREEN,.DINDEX,DI0NODE)
QUIT
+3 DO ACCEPT^DICL2(.DIFILE,.DIEN,.DIFLAGS,DIFIEN,.DINDEX,.DIDENT,.DILIST,DI0NODE)
+4 QUIT