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

DIKKUTL2.m

Go to the documentation of this file.
  1. DIKKUTL2 ;SFISC/MKO-KEY DEFINITION, SOME UTILITIES ;1:25 PM 17 Jul 1998
  1. ;;22.0;VA FileMan;;Mar 30, 1999
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. ;==================
  1. ; GET(file,.count)
  1. ;==================
  1. ;Returns:
  1. ; CNT = # keys^file#
  1. ; CNT(keyName) = key#
  1. ; CNT(keyName,0) = file#^Name^Priority^UniqIndex
  1. ; CNT(keyName,seq#) = field#^file#^seq#
  1. ;
  1. GET(FIL,CNT) ;Get information about keys on file FIL
  1. N FLD,KEY,NAM
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. ;
  1. K CNT S CNT=0
  1. S NAM="" F S NAM=$O(^DD("KEY","BB",FIL,NAM)) Q:NAM="" S KEY=$O(^(NAM,0)) Q:'KEY D
  1. . I $G(^DD("KEY",KEY,0))?."^" D Q
  1. .. K ^DD("KEY","B",FIL,KEY),^DD("KEY","BB",FIL,NAM,KEY)
  1. . S CNT=CNT+1
  1. . S CNT(NAM)=KEY
  1. . S CNT(NAM,0)=^DD("KEY",KEY,0)
  1. . S FLD=0 F S FLD=$O(^DD("KEY",KEY,2,FLD)) Q:'FLD D
  1. .. I $D(^DD("KEY",KEY,2,FLD,0))#2,+$P(^(0),U,3) S CNT(NAM,$P(^(0),U,3))=^(0)
  1. S $P(CNT,U,2)=FIL
  1. Q
  1. ;
  1. ;=====================
  1. ; LIST(.count,header)
  1. ;=====================
  1. ;List the keys in the CNT array
  1. ;In:
  1. ; CNT = Array of keys to print (obtained by GET call above)
  1. ; HDR = Text to print before listing
  1. ; (default is 'Current Indexes[ on [sub]file #xxx]:')
  1. ;
  1. LIST(CNT,HDR) ;
  1. I '$G(CNT) D Q
  1. . W !,"There are no Keys defined on "_$$FSTR^DIKCUTL2($P(CNT,U,2))_"."
  1. ;
  1. N DIERR,FIL,FILE01,FLD,KEY,MSG,NAM,PRIO,SN,TAG,UI,UITXT
  1. ;
  1. ;Write header
  1. S:$G(HDR)="" HDR="Keys defined on "_$$FSTR^DIKCUTL2($P(CNT,U,2))_":"
  1. W !,HDR
  1. ;
  1. ;Loop through keys in CNT array
  1. S NAM="" F S NAM=$O(CNT(NAM)) Q:NAM="" D
  1. . S KEY=CNT(NAM)
  1. . S FILE01=$P(CNT(NAM,0),U),PRIO=$P(CNT(NAM,0),U,3)
  1. . S UI=$P(CNT(NAM,0),U,4)
  1. . I UI]"" D
  1. .. S UI=$G(^DD("IX",UI,0))
  1. .. S UITXT=$P(UI,U,2)
  1. .. S:$P(UI,U)'=$P(UI,U,9) UITXT=UITXT_"; Whole File (#"_$P(UI,U)_")"
  1. . W !!?2,NAM,?5,$$EXTERNAL^DILFD(.31,1,"",PRIO,"MSG")_" KEY"
  1. . W:UI]"" ?20,"Uniqueness Index: "_UITXT
  1. . ;
  1. . ;Loop through fields in key
  1. . S TAG="Field(s): "
  1. . I $O(CNT(NAM,0)) S SN=0 F S SN=$O(CNT(NAM,SN)) Q:'SN D
  1. .. S FLD=$P(CNT(NAM,SN),U),FIL=$P(CNT(NAM,SN),U,2)
  1. .. W !?9,TAG_SN_") "_$P($G(^DD(FIL,FLD,0)),U)_" (#"_FLD_$S(FIL=FILE01:")",1:", from File #"_FIL)
  1. .. S TAG=$J("",11)
  1. Q
  1. ;
  1. ;=========================
  1. ; $$CHOOSE(.count,prompt)
  1. ;=========================
  1. ;Prompt for a key from the DIKKCNT array
  1. ;In:
  1. ; .DIKKCNT = Array contain key data (obtained by GET call above)
  1. ; DIKCPR = Action to include with the prompt
  1. ;Returns:
  1. ; Key ien (or 0, if none selected)
  1. ;
  1. CHOOSE(DIKKCNT,DIKKPR) ;Choose a key
  1. Q:'$G(DIKKCNT) 0
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. S DIR(0)="FAO^1:30^K:$D(DIKKCNT(X))[0 X"
  1. S DIR("A")="Which Key do you wish to "_DIKKPR_"? "
  1. S:+DIKKCNT=1 DIR("B")=$O(DIKKCNT(0))
  1. S DIR("?")="^D LIST^DIKKUTL2(.DIKKCNT)"
  1. W ! D ^DIR I $D(DIRUT) Q 0
  1. Q DIKKCNT(Y)
  1. ;
  1. ;===================================================
  1. ; GETFLD(key#,uniqIndex#,.keyField,.uniqIndexField)
  1. ;===================================================
  1. ;Get the fields in key and uniqueness index
  1. ;In:
  1. ; KEY = key ien
  1. ; UI = uniqueness index ien
  1. ;Out:
  1. ; KEYFLD = # items in array
  1. ; KEYFLD(I) = file^field
  1. ; UIFLD = # items in array
  1. ; UIFLD(I) = file^field
  1. ;
  1. GETFLD(KEY,UI,KEYFLD,UIFLD) ;
  1. N I,FIL,FLD,ORD,S
  1. ;
  1. ;Loop through "S" index on Sequence Number of the Field multiple
  1. ;of the Key and set the KEYFLD array
  1. S I=0 K KEYFLD
  1. I $G(KEY),$D(^DD("KEY",KEY,0))#2 D
  1. . S S=0 F S S=$O(^DD("KEY",KEY,2,"S",S)) Q:'S D
  1. .. S FLD=$O(^DD("KEY",KEY,2,"S",S,0)) Q:'FLD S FIL=$O(^(FLD,0)) Q:'FIL
  1. .. S I=I+1,KEYFLD(I)=FIL_U_FLD
  1. S KEYFLD=I
  1. ;
  1. ;Loop through the "AC" index on Subscript Number of the Cross-
  1. ;Reference Values multiple of the Index file and set the UIFLD
  1. ;array
  1. S I=0 K UIFLD
  1. I $G(UI),$D(^DD("IX",UI,0))#2 D
  1. . S S=0 F S S=$O(^DD("IX",UI,11.1,"AC",S)) Q:'S D
  1. .. S ORD=$O(^DD("IX",UI,11.1,"AC",S,0)) Q:'ORD
  1. .. S FIL=$P($G(^DD("IX",UI,11.1,ORD,0)),U,3),FLD=$P($G(^(0)),U,4)
  1. .. Q:'FIL Q:'FLD
  1. .. S I=I+1,UIFLD(I)=FIL_U_FLD
  1. S UIFLD=I
  1. Q