source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DIKKUTL2.m@ 1714

Last change on this file since 1714 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.9 KB
RevLine 
[613]1DIKKUTL2 ;SFISC/MKO-KEY DEFINITION, SOME UTILITIES ;1:25 PM 17 Jul 1998
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ;==================
6 ; GET(file,.count)
7 ;==================
8 ;Returns:
9 ; CNT = # keys^file#
10 ; CNT(keyName) = key#
11 ; CNT(keyName,0) = file#^Name^Priority^UniqIndex
12 ; CNT(keyName,seq#) = field#^file#^seq#
13 ;
14GET(FIL,CNT) ;Get information about keys on file FIL
15 N FLD,KEY,NAM
16 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
17 ;
18 K CNT S CNT=0
19 S NAM="" F S NAM=$O(^DD("KEY","BB",FIL,NAM)) Q:NAM="" S KEY=$O(^(NAM,0)) Q:'KEY D
20 . I $G(^DD("KEY",KEY,0))?."^" D Q
21 .. K ^DD("KEY","B",FIL,KEY),^DD("KEY","BB",FIL,NAM,KEY)
22 . S CNT=CNT+1
23 . S CNT(NAM)=KEY
24 . S CNT(NAM,0)=^DD("KEY",KEY,0)
25 . S FLD=0 F S FLD=$O(^DD("KEY",KEY,2,FLD)) Q:'FLD D
26 .. I $D(^DD("KEY",KEY,2,FLD,0))#2,+$P(^(0),U,3) S CNT(NAM,$P(^(0),U,3))=^(0)
27 S $P(CNT,U,2)=FIL
28 Q
29 ;
30 ;=====================
31 ; LIST(.count,header)
32 ;=====================
33 ;List the keys in the CNT array
34 ;In:
35 ; CNT = Array of keys to print (obtained by GET call above)
36 ; HDR = Text to print before listing
37 ; (default is 'Current Indexes[ on [sub]file #xxx]:')
38 ;
39LIST(CNT,HDR) ;
40 I '$G(CNT) D Q
41 . W !,"There are no Keys defined on "_$$FSTR^DIKCUTL2($P(CNT,U,2))_"."
42 ;
43 N DIERR,FIL,FILE01,FLD,KEY,MSG,NAM,PRIO,SN,TAG,UI,UITXT
44 ;
45 ;Write header
46 S:$G(HDR)="" HDR="Keys defined on "_$$FSTR^DIKCUTL2($P(CNT,U,2))_":"
47 W !,HDR
48 ;
49 ;Loop through keys in CNT array
50 S NAM="" F S NAM=$O(CNT(NAM)) Q:NAM="" D
51 . S KEY=CNT(NAM)
52 . S FILE01=$P(CNT(NAM,0),U),PRIO=$P(CNT(NAM,0),U,3)
53 . S UI=$P(CNT(NAM,0),U,4)
54 . I UI]"" D
55 .. S UI=$G(^DD("IX",UI,0))
56 .. S UITXT=$P(UI,U,2)
57 .. S:$P(UI,U)'=$P(UI,U,9) UITXT=UITXT_"; Whole File (#"_$P(UI,U)_")"
58 . W !!?2,NAM,?5,$$EXTERNAL^DILFD(.31,1,"",PRIO,"MSG")_" KEY"
59 . W:UI]"" ?20,"Uniqueness Index: "_UITXT
60 . ;
61 . ;Loop through fields in key
62 . S TAG="Field(s): "
63 . I $O(CNT(NAM,0)) S SN=0 F S SN=$O(CNT(NAM,SN)) Q:'SN D
64 .. S FLD=$P(CNT(NAM,SN),U),FIL=$P(CNT(NAM,SN),U,2)
65 .. W !?9,TAG_SN_") "_$P($G(^DD(FIL,FLD,0)),U)_" (#"_FLD_$S(FIL=FILE01:")",1:", from File #"_FIL)
66 .. S TAG=$J("",11)
67 Q
68 ;
69 ;=========================
70 ; $$CHOOSE(.count,prompt)
71 ;=========================
72 ;Prompt for a key from the DIKKCNT array
73 ;In:
74 ; .DIKKCNT = Array contain key data (obtained by GET call above)
75 ; DIKCPR = Action to include with the prompt
76 ;Returns:
77 ; Key ien (or 0, if none selected)
78 ;
79CHOOSE(DIKKCNT,DIKKPR) ;Choose a key
80 Q:'$G(DIKKCNT) 0
81 N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
82 S DIR(0)="FAO^1:30^K:$D(DIKKCNT(X))[0 X"
83 S DIR("A")="Which Key do you wish to "_DIKKPR_"? "
84 S:+DIKKCNT=1 DIR("B")=$O(DIKKCNT(0))
85 S DIR("?")="^D LIST^DIKKUTL2(.DIKKCNT)"
86 W ! D ^DIR I $D(DIRUT) Q 0
87 Q DIKKCNT(Y)
88 ;
89 ;===================================================
90 ; GETFLD(key#,uniqIndex#,.keyField,.uniqIndexField)
91 ;===================================================
92 ;Get the fields in key and uniqueness index
93 ;In:
94 ; KEY = key ien
95 ; UI = uniqueness index ien
96 ;Out:
97 ; KEYFLD = # items in array
98 ; KEYFLD(I) = file^field
99 ; UIFLD = # items in array
100 ; UIFLD(I) = file^field
101 ;
102GETFLD(KEY,UI,KEYFLD,UIFLD) ;
103 N I,FIL,FLD,ORD,S
104 ;
105 ;Loop through "S" index on Sequence Number of the Field multiple
106 ;of the Key and set the KEYFLD array
107 S I=0 K KEYFLD
108 I $G(KEY),$D(^DD("KEY",KEY,0))#2 D
109 . S S=0 F S S=$O(^DD("KEY",KEY,2,"S",S)) Q:'S D
110 .. S FLD=$O(^DD("KEY",KEY,2,"S",S,0)) Q:'FLD S FIL=$O(^(FLD,0)) Q:'FIL
111 .. S I=I+1,KEYFLD(I)=FIL_U_FLD
112 S KEYFLD=I
113 ;
114 ;Loop through the "AC" index on Subscript Number of the Cross-
115 ;Reference Values multiple of the Index file and set the UIFLD
116 ;array
117 S I=0 K UIFLD
118 I $G(UI),$D(^DD("IX",UI,0))#2 D
119 . S S=0 F S S=$O(^DD("IX",UI,11.1,"AC",S)) Q:'S D
120 .. S ORD=$O(^DD("IX",UI,11.1,"AC",S,0)) Q:'ORD
121 .. S FIL=$P($G(^DD("IX",UI,11.1,ORD,0)),U,3),FLD=$P($G(^(0)),U,4)
122 .. Q:'FIL Q:'FLD
123 .. S I=I+1,UIFLD(I)=FIL_U_FLD
124 S UIFLD=I
125 Q
Note: See TracBrowser for help on using the repository browser.