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

AUCDIC3.m

Go to the documentation of this file.
AUCDIC3 ; CHECK ^DD [ 11/29/87  2:11 PM ]
 ;
 S U="^"
 W !!,"Now checking ^DD entries." S AUCDFILE="" F AUCDL=0:0 S AUCDFILE=$O(^UTILITY("AUDSET",$J,AUCDFILE)) Q:AUCDFILE=""  W !,?5,"Checking ",AUCDFILE D AUCDDDC
 K AUCDANS,AUCDFILE,AUCDL
 Q
 ;
AUCDDDC ; CHECK ^DD ENTRY
 D CHKDD0 ; CHECK ^DD 0TH NODE
 D CHKPT ; CHECK "PT" NODE
 D CHKTRB ; CHECK "TRB" NODE
 D CHKACOMP ; CHECK "ACOMP" NODE
 D SBTRACE ; CHECK "SB" NODE
 Q
 ;
CHKDD0 ; CHECK 0TH NODE
 I '($D(^DD(AUCDFILE,.01,0))#2) W !,"File "_AUCDFILE_" has no ^DD("_AUCDFILE_",.01,0) entry."
 I '$D(^DD(AUCDFILE,0,"NM")) W !,"File "_AUCDFILE_" has no ^DD("_AUCDFILE_",0,""NM"") entry."
 E  S AUCDX=$O(^("NM","")),AUCDX=$O(^(AUCDX)) I AUCDX'="" W !,"File "_AUCDFILE_" has multiple names."
 Q
 ;
CHKPT ; CHECK "PT" NODE
 S AUCDPFLE="" F AUCDL=0:0 S AUCDPFLE=$O(^DD(AUCDFILE,0,"PT",AUCDPFLE)) Q:AUCDPFLE=""  S AUCDPFLD="" F AUCDL=0:0 S AUCDPFLD=$O(^DD(AUCDFILE,0,"PT",AUCDPFLE,AUCDPFLD)) Q:AUCDPFLD=""  D PT
 K AUCDPFLE,AUCDPFLD,AUCDX
 Q
PT ;
 W "."
 I '$D(^DD(AUCDPFLE)) W "|" K ^DD(AUCDFILE,0,"PT",AUCDPFLE) Q
 I '$D(^DD(AUCDPFLE,AUCDPFLD)) W "|" K ^DD(AUCDFILE,0,"PT",AUCDPFLE,AUCDPFLD) Q
 S AUCDX=$P(^DD(AUCDPFLE,AUCDPFLD,0),U,2)
 I AUCDX["V",$D(^DD(AUCDPFLE,AUCDPFLD,"V","B",AUCDFILE)) Q
 I AUCDX["P",AUCDX[AUCDFILE Q
 W "|" K ^DD(AUCDFILE,0,"PT",AUCDPFLE,AUCDPFLD)
 Q
 ;
CHKTRB ; CHECK "TRB" NODE
 Q:'$D(^DD(AUCDFILE,"TRB"))
 S AUCDTFLE="" F AUCDL=0:0 S AUCDTFLE=$O(^DD(AUCDFILE,"TRB",AUCDTFLE)) Q:AUCDTFLE=""  S AUCDTFLD="" F AUCDL=0:0 S AUCDTFLD=$O(^DD(AUCDFILE,"TRB",AUCDTFLE,AUCDTFLD)) Q:AUCDTFLD=""  D TRB
 K AUCDTFLE,AUCDTFLD,AUCDX
 Q
TRB ;
 ; THIS CAN CHECK MORE THAN IT DOES ***
 W "."
 I '$D(^DD(AUCDTFLE)) W "|" K ^DD(AUCDFILE,"TRB",AUCDTFLE) Q
 I '$D(^DD(AUCDTFLE,AUCDTFLD)) W "|" K ^DD(AUCDFILE,"TRB",AUCDTFLE,AUCDTFLD) Q
 Q
 ;
CHKACOMP ; CHECK "ACOMP" ENTRIES
 Q:'$D(^DD("ACOMP",AUCDFILE))
 S AUCDFLD="" F AUCDL=0:0 S AUCDFLD=$O(^DD("ACOMP",AUCDFILE,AUCDFLD)) Q:AUCDFLD'=+AUCDFLD  D CHKFIELD
 K AUCDFLD
 Q
CHKFIELD S AUCDAFLE="" F AUCDL=0:0 S AUCDAFLE=$O(^DD("ACOMP",AUCDFILE,AUCDFLD,AUCDAFLE)) Q:AUCDAFLE=""  S AUCDAFLD="" F AUCDL=0:0 S AUCDAFLD=$O(^DD("ACOMP",AUCDFILE,AUCDFLD,AUCDAFLE,AUCDAFLD)) Q:AUCDAFLD=""  D ACOMP
 K AUCDAFLE,AUCDAFLD,AUCDX
 Q
ACOMP ;
 W "."
 I '$D(^DD(AUCDAFLE)) W "|" K ^DD("ACOMP",AUCDFILE,AUCDFLD,AUCDAFLE) Q
 I '$D(^DD(AUCDAFLE,AUCDAFLD)) W "|" K ^DD("ACOMP",AUCDFILE,AUCDFLD,AUCDAFLE,AUCDAFLD) Q
 I '($D(^DD(AUCDAFLE,AUCDAFLD,0))#2) W "|" K ^DD("ACOMP",AUCDFILE,AUCDFLD,AUCDAFLE,AUCDAFLD) Q
 S AUCDX=$P(^DD(AUCDAFLE,AUCDAFLD,0),U,2)
 I AUCDX'["C" W "|" K ^DD("ACOMP",AUCDFILE,AUCDFLD,AUCDAFLE,AUCDAFLD)
 Q
 ;
SBTRACE ; CHECK ALL SUB-FILES
 K AUCDSFL S AUCDC=1,AUCDSFL="",AUCDSFL(AUCDC)=AUCDFILE
 F AUCDL=0:0 S AUCDI=$O(AUCDSFL("")) Q:AUCDI=""  S AUCDSF=AUCDSFL(AUCDI) D SBTRACE2 S AUCDI=$O(AUCDSFL("")) W "."  K AUCDSFL(AUCDI)
 K AUCDC,AUCDI,AUCDSF,AUCDSFL,AUCDY,AUCDZ
 Q
SBTRACE2 ;
 S AUCDI=0 F AUCDL=0:0 S AUCDI=$O(^DD(AUCDSF,"SB",AUCDI)) Q:AUCDI=""  W "." S AUCDC=AUCDC+1,AUCDSFL(AUCDC)=AUCDI D SBTRACE3,SBTRACE4
 Q
SBTRACE3 ;
 I '$D(^DD(AUCDI,0,"UP")),$D(^DIC(AUCDI)) W !,?10,AUCDI," is a primary file.  Deleting ^DD(",AUCDSF,",""SB"",",AUCDI,")" K ^DD(AUCDSF,"SB",AUCDI) Q
 I $D(^DD(AUCDI,0,"PT")) W !,?10,AUCDI," sub-file has ""PT"" node.  Deleting." K ^DD(AUCDI,0,"PT")
 I '$D(^DD(AUCDI,0,"UP")) W !,?10,AUCDI," has no ""UP"" node.  Creating ^DD(",AUCDI,",0,""UP"")=",AUCDSF S ^DD(AUCDI,0,"UP")=AUCDSF
 Q:^DD(AUCDI,0,"UP")=AUCDSF
 I ^DD(AUCDI,0,"UP")="" W !,?10,AUCDI," ""UP"" node is NULL.  Setting ^DD(",AUCDI,",0,""UP"")=",AUCDSF S ^DD(AUCDI,0,"UP")=AUCDSF Q
 W !,?10,AUCDSF," lists ",AUCDI," as a sub-file.  The ""UP"" node in ",!,?10+$L(AUCDSF)+1,AUCDI," is ",^DD(AUCDI,0,"UP"),"."
 I $D(^DD(^DD(AUCDI,0,"UP"),"SB",AUCDSF)) W !,?12,"The ""SB"" in ",^DD(AUCDI,0,"UP")," agrees.  Fixing." K ^DD(AUCDSF,"SB",AUCDI) Q
 E  W !,?12,"The ""SB"" in ",^DD(AUCDI,0,"UP")," disagrees.  Fixing." S ^DD(AUCDI,0,"UP")=AUCDSF
 Q
SBTRACE4 ;
 I '$D(^DD(AUCDI,0,"NM")) W !,?10,"Sub-file "_AUCDI_" has no ^DD("_AUCDI_",0,""NM"") entry.  Fixing." D SBTFIX
 E  S AUCDX=$O(^("NM","")),AUCDX=$O(^(AUCDX)) I AUCDX'="" W !,?10,"Sub-file "_AUCDI_" has multiple names.  Fixing." D SBTFIX
 Q
SBTFIX ; FIX "NM"
 K ^DD(AUCDI,0,"NM")
 I '$D(^DD(AUCDI,0,"UP")) W !,?12,"Can't fix.  No ""UP"" node." Q
 S AUCDX=^("UP")
 I AUCDX="" W !,?12,"Can't fix.  ""UP"" node is NULL." Q
 I '$D(^DD(AUCDX,"SB",AUCDI)) W !,?12,"Can't fix because can't locate parent field." Q
 S AUCDY=$O(^(AUCDI,"")),AUCDZ=$P(^DD(AUCDX,AUCDY,0),U,1)
 S ^DD(AUCDI,0,"NM",AUCDZ)=""
 Q