LEXXFI6 ; ISL/KER - File Info - DD Information      ; 07/28/2004
 ;;2.0;LEXICON UTILITY;**32**;Sep 23, 1996
 Q
 ;                        
 ; Global Variables
 ;   ^TMP("LEXI",$J      SACC 2.3.2.5.1
 ;                       
 ; External References
 ;   DBIA 10022  %XY^%RCR
 ;                            
DDI(X,LEX) ; Data Dictionary Information
 N %X,%Y,LEXFI,LEXFLD,LEXLOC,LEXND,LEXNDD,LEXNM,LEXSF
 K ^TMP("LEXI",$J) S LEXFI=+($G(X)) Q:+LEXFI'>0
 S %X="^DD("_LEXFI_",",%Y="^TMP(""LEXI"",$J,"_LEXFI_"," D %XY^%RCR
 S LEX("DD",LEXFI,0)=$G(^TMP("LEXI",$J,LEXFI,0))
 S LEXNM=$O(^TMP("LEXI",$J,LEXFI,0,"NM",""))
 S:$L(LEXNM) LEX("DD",LEXFI,0,"NM",LEXNM)=""
 S LEXFLD=0 F  S LEXFLD=$O(^TMP("LEXI",$J,LEXFI,LEXFLD)) Q:+LEXFLD=0  D
 . S LEXLOC=$G(^TMP("LEXI",$J,LEXFI,LEXFLD,0))
 . Q:+($P($P(LEXLOC,"^",4),";",2))>0
 . S LEX("DD",LEXFI,LEXFLD,0)=$G(^TMP("LEXI",$J,LEXFI,LEXFLD,0))
 S LEXND="" F  S LEXND=$O(^TMP("LEXI",$J,LEXFI,"GL",LEXND)) Q:LEXND=""  D
 . S LEXLOC="" F  S LEXLOC=$O(^TMP("LEXI",$J,LEXFI,"GL",LEXND,LEXLOC)) Q:LEXLOC=""  D
 . . Q:+LEXLOC>0  S LEXFLD=0
 . . F  S LEXFLD=$O(^TMP("LEXI",$J,LEXFI,"GL",LEXND,LEXLOC,LEXFLD)) Q:+LEXFLD=0  D
 . . . S LEXNDD=$G(^TMP("LEXI",$J,LEXFI,LEXFLD,0))
 . . . S LEXSF=+($P(LEXNDD,"^",2)) Q:+LEXSF=0
 . . . S LEX("DD",LEXFI,"GL",LEXND,LEXLOC,LEXFLD)=""
 . . . S:+LEXSF>0 LEX("DD",LEXFI,"GL",LEXND,LEXLOC,LEXFLD)=+LEXSF
 S LEXSF=0 F  S LEXSF=$O(^TMP("LEXI",$J,LEXFI,"SB",LEXSF)) Q:+LEXSF=0  D
 . S LEXFLD=0 F  S LEXFLD=$O(^TMP("LEXI",$J,LEXFI,"SB",LEXSF,LEXFLD)) Q:+LEXFLD=0  D
 . . S LEX("DD",LEXFI,"SB",LEXSF,LEXFLD)=""
 I $L($G(^TMP("LEXI",$J,LEXFI,0,"UP"))) D
 . S LEX("DD",LEXFI,0,"UP")=$G(^TMP("LEXI",$J,LEXFI,0,"UP"))
 K ^TMP("LEXI",$J,LEXFI)
 S %X="^DIC("_LEXFI_",",%Y="^TMP(""LEXI"",$J,"_LEXFI_"," D %XY^%RCR
 I $D(^TMP("LEXI",$J,LEXFI,0)) D
 . S LEX("DIC",LEXFI,0)=$G(^TMP("LEXI",$J,LEXFI,0))
 I $D(^TMP("LEXI",$J,LEXFI,0,"GL")) D
 . S LEX("DIC",LEXFI,0,"GL")=$G(^TMP("LEXI",$J,LEXFI,0,"GL"))
 K ^TMP("LEXI",$J,LEXFI)
 S LEXSF=0 F  S LEXSF=$O(LEX("DD",LEXFI,"SB",LEXSF)) Q:+LEXSF'>0  D DDI2
 I $D(LEX("DD",LEXFI,0,"UP")) D DDI3
 Q
DDI2 ; Sub-Files
 Q:+($G(LEXSF))'>0  Q:$D(LEX("DD",LEXSF))
 N LEXTSF,LEXTFI S LEXTSF=LEXSF,LEXTFI=LEXFI
 N LEXFI S LEXFI=+LEXTSF K ^TMP("LEXI",$J,LEXTFI)
 D DDI(LEXFI,.LEX)
 Q
DDI3 ; Parent Files
 Q:'$D(LEX("DD",LEXFI,0,"UP"))
 N LEXUP,LEXTFI
 S LEXUP=+($G(LEX("DD",LEXFI,0,"UP"))) Q:$D(LEX("DD",LEXUP))
 S LEXTFI=LEXFI N LEXFI S LEXFI=+LEXUP
 D DDI(LEXFI,.LEX)
 Q
