Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DICUIX

DICUIX.m

Go to the documentation of this file.
DICUIX ;SEA/TOAD,SF/TKW - FileMan: Lookup Tools, Indexes ;24SEP2016
 ;;22.2;VA FileMan;**2**;Jan 05, 2016;Build 139
 ;;Per VA Directive 6402, this routine should not be modified.
 ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
 ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
 ;;Licensed under the terms of the Apache License, Version 2.0.
 ;;GFT;**20,28,67,165,1035,1041**
 ;
 ;
INDEX(DIFILE,DIFLAGS,DINDEX,DIFROM,DIPART,DINUMBER,DISCREEN,DILIST,DIOUT) ;
 ;
 ; build DINDEX array data for index
 ;
I1 ; try to find Index in Index file
 ;
 N DICODE,DIGET,DILENGTH,DINODE,DISUB,DITEMP,DITEMP2,DITO,DITOIEN,DITYPE,DIWAY,DIXIEN
 S DINDEX("FLIST")="",DINDEX("AT")=1,DIFROM("IEN")=+$G(DIFROM("IEN")),DIXIEN="",DIGET=1
 S:DINDEX'="#" DIXIEN=$O(^DD("IX","BB",DIFILE,DINDEX,""))
 I 'DIXIEN D XREF(.DIFILE,.DIFLAGS,.DINDEX,.DIPART,.DIFROM) Q
 ;
I2 ; in Index file, build list of subscript data
 ;
 S DINODE=^DD("IX",DIXIEN,0)
 S DINDEX("IXTYPE")=$P(DINODE,U,4) S:DIFLAGS["4" DINDEX("IXFILE")=DIXIEN
 S DINDEX("#")=0
 S DISUB=$O(^DD("IX",DIXIEN,11.1,"AC","Z"),-1)
 I $G(DIFROM(DISUB+1)) M DIFROM("IEN")=DIFROM(DISUB+1)
 S (DISUB,DIOUT)=0 N S
 F  D  Q:'DISUB  Q:DIOUT
 . S DISUB=$O(^DD("IX",DIXIEN,11.1,"AC",DISUB)) Q:'DISUB  S S=$O(^(DISUB,0)) Q:'S
 . S DINDEX("#")=DISUB,DIGET=1
 . S DINODE=$G(^DD("IX",DIXIEN,11.1,S,0))
 . I DIFLAGS["l" N X D  S DINDEX(DISUB,"PROMPT")=X
 . . S X=$P(DINODE,U,8) Q:X]""
EGP . . I $P(DINODE,U,3),$P(DINODE,U,4) S X=$$LABEL^DIALOGZ($P(DINODE,U,3),$P(DINODE,U,4)) ;**
 . . Q
 . S DINDEX(DISUB,"FIELD")=$P(DINODE,U,4)
 . S DINDEX(DISUB,"FILE")=$P(DINODE,U,3)
 . I $P(DINODE,U,2)["C"!(DINDEX(DISUB,"FILE")="") S DINDEX(DISUB,"FIELD")=""
 . I DINDEX(DISUB,"FILE"),DINDEX(DISUB,"FIELD") D
 . . I $G(^DD("IX",DIXIEN,11.1,S,4))]"" S DINDEX(DISUB,"TRANCODE")=^(4) ;TRANSFORM FOR LOOKUP
 . . I $G(^DD("IX",DIXIEN,11.1,S,2))]"" D
 . . . I $G(^DD("IX",DIXIEN,11.1,S,3))="" S DIGET=0 Q
 . . . S DINDEX(DISUB,"TRANOUT")=^DD("IX",DIXIEN,11.1,S,3),DIGET=3 Q  ;TRANSFORM FOR DISPLAY
 . . I "KSMU"[DINDEX("IXTYPE") S DIGET=2
 . . Q
 . S DILENGTH=$P(DINODE,U,5) I 'DILENGTH S DILENGTH=30 ;!(DILENGTH>100) ;GETS THE LENGTH FROM THE DEFINITION OF THE INDEX
 . S DIWAY=$S($P(DINODE,U,7)="B":-1,1:1)
 . D COMMON1^DICUIX2
 . Q
 I DIOUT S @DILIST@(0)="0^"_DINUMBER_"^0" D OUT^DICL Q
 D:DIFLAGS'["q" COMMON2^DICUIX2
 S DINDEX("FLIST")=DINDEX("FLIST")_"^"
 I DIFLAGS'["l",DIFLAGS'["h" Q
 N F,F1,F2,I S F=DINDEX("FLIST")
 F I=1:1:DINDEX("#") I $G(DINDEX(I,"GETEXT"))=0 S F1=$G(DINDEX(I,"FILE")),F2=$G(DINDEX(I,"FIELD")) I F1=DIFILEI,F2 D
 . S F1=$F(F,("^"_F2_"^")) Q:'F1  S F1=F1-2
 . S $E(F,(F1-$L(F2)),F1)="" Q
 S DINDEX("FLISTD")=F Q
 ;
 ;
 ;
XREF(DIFILE,DIFLAGS,DINDEX,DIPART,DIFROM) ;
 ; Index is in "IX" nodes
 ;
X1 ; Set DINDEX for search through upright file
 ;
 I DINDEX="#" D  Q
 . S DINDEX("#")=0,DINDEX(1,"FILE")=DIFILE,DINDEX(1,"ROOT")=DIFILE(DIFILE),DINDEX(1,"TYPE")="N"
 . N X S X=$S($G(DIFROM(1)):DIFROM(1),DIPART(1):DIPART(1),1:$G(DIFROM("IEN")))
 . S (DIFROM,DIFROM(1))=X S:X DIFROM("IEN")=X
 . I DIFLAGS["l"!(DIFLAGS["h") S DINDEX("FLISTD")=""
 . D:DIFLAGS'["q" COMMON2^DICUIX2 Q
 S DINDEX("#")=1,DINDEX("IXTYPE")="R"
 S DINDEX(1,"FILE")=$O(^DD(DIFILE,0,"IX",DINDEX,""))
 ;
X2 ; Build DINDEX for index in IX nodes.
 ;
 S DIOUT=0,DILENGTH=30
 S DINDEX(1,"FIELD")=""
 I DINDEX(1,"FILE") S DINDEX(1,"FIELD")=$O(^DD(DIFILE,0,"IX",DINDEX,DINDEX(1,"FILE"),""))
 I DINDEX(1,"FIELD")="",DINDEX="B" D
 . S DINDEX(1,"FILE")=DIFILE
 . S DINDEX(1,"FIELD")=.01 Q
 I DIFLAGS[3,DINDEX="B",'$D(@DIFILE(DIFILE)@("B")) D
 . D TMPB^DICUIX1(.DITEMP,DIFILE)
 . S DIFILE(DIFILE,"NO B")=DITEMP Q
 I DIFLAGS["l" S DINDEX(1,"PROMPT")=""
 I DINDEX(1,"FILE"),DINDEX(1,"FIELD") D  I DINDEX("IXTYPE")="*" K DINDEX S DINDEX="" Q
EGP2 . I DIFLAGS["l" S DINDEX(1,"PROMPT")=$$LABEL^DIALOGZ(DINDEX(1,"FILE"),DINDEX(1,"FIELD")) ;** FIELD LABEL
 . N I,X,Y,DIXFILE,DIXFIELD S DIXFILE=DINDEX(1,"FILE"),DIXFIELD=DINDEX(1,"FIELD")
 . F I=0:0 S I=$O(^DD(DINDEX(1,"FILE"),DINDEX(1,"FIELD"),1,I)) Q:'I  S X=$G(^(I,0)) I $P(X,U,2)=DINDEX S Y=$G(^(1)) D  Q
 . . S X=$E($P(X,U,3),1,2)
 . . S DINDEX("IXTYPE")=$S(X="":"R",X="KW":"K",X="SO":"S",(X="TR")!(X="BU"):"*",X]"":X,1:"R") ;WHAT KIND OF CROSS-REF IS IT?
 . . I "KSMU"[DINDEX("IXTYPE") S DIGET=2
 . . S DILENGTH=+$P(Y,"$E(X,1,",2)
 . . S:'DILENGTH DILENGTH=30 ;!(DILENGTH>100)
 . . S X=$P($P(^DD(DINDEX(1,"FILE"),DINDEX(1,"FIELD"),0),U,2),"t",2) I X,$G(^DI(.81,+X,201,2,31))]"" D  ;V 23.0: EXTENDED DATA TYPE INPUT TRANSFORM
 ...S DINDEX(1,"TRANEX","EXTENDED")=^(31)
 ...S DINDEX(1,"TRANEX")="N DIPA,DIQUIET S DIQUIET=1  D DIPA^DIETLIBF("_DIXFILE_","_DIXFIELD_") X DINDEX(1,""TRANEX"",""EXTENDED"") I '$D(X) S X="""""
 I $G(DIFROM(2)) S DIFROM("IEN")=DIFROM(2)
 S DISUB=1,DIWAY=1,DIOUT=0
 N I,X,Y
 D COMMON1^DICUIX2
 I DIOUT S @DILIST@(0)="0^"_DINUMBER_"^0" D OUT^DICL Q
 D:DIFLAGS'["q" COMMON2^DICUIX2
 S DINDEX("FLIST")=DINDEX("FLIST")_"^"
 I DIFLAGS["l"!(DIFLAGS["h") D
 . I DIGET=2 S DINDEX("FLISTD")="^^" Q
 . S DINDEX("FLISTD")=DINDEX("FLIST") Q
 S DITEMP=$G(DIFILE(DIFILE,"NO B")) I DITEMP]"" D BLDB^DICUIX1(DIFILE(DIFILE),DITEMP)
 Q
 ;
 ;