DINIT2A5 ;SFISC/MKO-KEY AND INDEX FILES ;10:50 AM 30 Mar 1999
;;22.2;VA FileMan;;Jan 05, 2016;Build 42
;;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.
;
F I=1:2 S X=$T(Q+I) Q:X="" S Y=$E($T(Q+I+1),4,999),X=$E(X,4,999) S:$A(Y)=126 I=I+1,Y=$E(Y,2,999)_$E($T(Q+I+1),5,99) S:$A(Y)=61 Y=$E(Y,2,999) S @X=Y
G ^DINIT2A6
Q Q
;;^DIC(.31,0,"GL")
;;=^DD("KEY",
;;^DIC("B","KEY",.31)
;;=
;;^DIC(.31,"%D",0)
;;=^^12^12^2980911^
;;^DIC(.31,"%D",1,0)
;;=This file stores information about keys on a file or subfile. A key is a
;;^DIC(.31,"%D",2,0)
;;=set of one or more fields that uniquely identifies a record in a file. If
;;^DIC(.31,"%D",3,0)
;;=more than one set of fields can uniquely identify a record, one of those
;;^DIC(.31,"%D",4,0)
;;=sets should be designated the primary key; all others should be designated
;;^DIC(.31,"%D",5,0)
;;=secondary keys. The primary key is the principal means of identifying
;;^DIC(.31,"%D",6,0)
;;=records in the file.
;;^DIC(.31,"%D",7,0)
;;=
;;^DIC(.31,"%D",8,0)
;;=To allow FileMan to enforce key uniqueness, the database designer must
;;^DIC(.31,"%D",9,0)
;;=define a regular index that consists of all the fields that make up the
;;^DIC(.31,"%D",10,0)
;;=key. This index is called the uniqueness index.
;;^DIC(.31,"%D",11,0)
;;=
;;^DIC(.31,"%D",12,0)
;;=All key fields must have values. They cannot be null.
;;^DD(.31,0)
;;=FIELD^^3^5
;;^DD(.31,0,"DDA")
;;=N
;;^DD(.31,0,"DT")
;;=2980611
;;^DD(.31,0,"IX","B",.31,.01)
;;=
;;^DD(.31,0,"NM","KEY")
;;=
;;^DD(.31,.01,0)
;;=FILE^RNJ20,7^^0;1^K:+X'=X!(X>999999999999)!(X<0)!(X?.E1"."8N.N) X
;;^DD(.31,.01,1,0)
;;=^.1^^-1
;;^DD(.31,.01,1,1,0)
;;=.31^B
;;^DD(.31,.01,1,1,1)
;;=S ^DD("KEY","B",$E(X,1,30),DA)=""
;;^DD(.31,.01,1,1,2)
;;=K ^DD("KEY","B",$E(X,1,30),DA)
;;^DD(.31,.01,1,1,3)
;;=Lets developers pick keys by their file number
;;^DD(.31,.01,1,1,"%D",0)
;;=^^2^2^2980911^^
;;^DD(.31,.01,1,1,"%D",1,0)
;;=The B index on the .01 (File) of the Key file lets developers pick keys by
;;^DD(.31,.01,1,1,"%D",2,0)
;;=the file whose records they uniquely distinguish.
;;^DD(.31,.01,3)
;;=Type a Number between 0 and 999999999999, 7 Decimal Digits. Answer '??' for more help.
;;^DD(.31,.01,4)
;;=
;;^DD(.31,.01,21,0)
;;=^^2^2^2980908^
;;^DD(.31,.01,21,1,0)
;;=Answer should be the number of the file or subfile identified by this key.
;;^DD(.31,.01,21,2,0)
;;=A file may have more than one key, but only one primary key.
;;^DD(.31,.01,"DT")
;;=2980611
;;^DD(.31,.02,0)
;;=NAME^RF^^0;2^K:$L(X)>1!($L(X)<1)!'(X?1U) X
;;^DD(.31,.02,3)
;;=Answer must be 1 upper case letter. Answer '??' for more help.
;;^DD(.31,.02,4)
;;=
;;^DD(.31,.02,21,0)
;;=^^3^3^2980908^^
;;^DD(.31,.02,21,1,0)
;;=Answer must be the name of this key. The name of a file's primary key
;;^DD(.31,.02,21,2,0)
;;=should be A, with subsequent keys for the same file named B, C, and so
;;^DD(.31,.02,21,3,0)
;;=on.
;;^DD(.31,.02,"DT")
;;=2960122
;;^DD(.31,1,0)
;;=PRIORITY^RS^P:PRIMARY;S:SECONDARY;^0;3^Q
;;^DD(.31,1,3)
;;=Answer '??' for more help.
;;^DD(.31,1,21,0)
;;=^^2^2^2980911^
;;^DD(.31,1,21,1,0)
;;=Answer 'PRIMARY' if this is the primary key of the file, the key that will
;;^DD(.31,1,21,2,0)
;;=usually be used for identifying entries. Otherwise, answer 'SECONDARY'.
;;^DD(.31,1,"DT")
;;=2970725
;;^DD(.31,2,0)
;;=FIELD^.312IA^^2;0
;;^DD(.31,2,"DT")
;;=2980310
;;^DD(.31,3,0)
;;=UNIQUENESS INDEX^*P.11'^DD("IX",^0;4^S DIC("S")="I 1 Q:'$D(DDS)!'$D(DIKKEY) I $P(^(0),U,9)=$P(^DD(""KEY"",DIKKEY,0),U)" D ^DIC K DIC S DIC=DIE,X=+Y K:Y<0 X
;;^DD(.31,3,3)
;;=Answer '??' for more help.
;;^DD(.31,3,12)
;;=Root File of Index must equal File of Key.
;;^DD(.31,3,12.1)
;;=S DIC("S")="I 1 Q:'$D(DDS)!'$D(DIKKEY) I $P(^(0),U,9)=$P(^DD(""KEY"",DIKKEY,0),U)"
;;^DD(.31,3,21,0)
;;=^^3^3^2981120^
;;^DD(.31,3,21,1,0)
;;=Answer with the index that FileMan should use to ensure that new key
;;^DD(.31,3,21,2,0)
;;=values are unique. It must be a new-style index that resides in the
;;^DD(.31,3,21,3,0)
;;=Index file, and must cross-reference the key fields in proper sequence.
;;^DD(.31,3,"DT")
;;=2980611
;;^DD(.312,0)
;;=FIELD SUB-FIELD^^1^3
;;^DD(.312,0,"DT")
;;=2960219
;;^DD(.312,0,"ID","WRITE")
;;=D EN^DDIOL(" "_$P(^(0),U,2),"","?0")
;;^DD(.312,0,"IX","B",.312,.01)
;;=
;;^DD(.312,0,"NM","FIELD")
;;=
;;^DD(.312,0,"UP")
;;=.31
;;^DD(.312,.01,0)
;;=FIELD^MRFX^^0;1^D ITFLD^DIKKDD I $D(X) K:$L(X)>20!($L(X)<1) X
;;^DD(.312,.01,1,0)
;;=^.1
;;^DD(.312,.01,1,1,0)
;;=.312^B
;;^DD(.312,.01,1,1,1)
;;=S ^DD("KEY",DA(1),2,"B",$E(X,1,30),DA)=""
;;^DD(.312,.01,1,1,2)
;;=K ^DD("KEY",DA(1),2,"B",$E(X,1,30),DA)
;;^DD(.312,.01,1,1,3)
;;=LETS DEVELOPER PICK KEY FIELDS BY NUMBER
;;^DD(.312,.01,1,1,"%D",0)
;;=^^2^2^2980908^
;;^DD(.312,.01,1,1,"%D",1,0)
;;=The B index, on the .01 (Field) of the Fields multiple, lets the developer
;;^DD(.312,.01,1,1,"%D",2,0)
;;=pick key fields by field number.
;;^DD(.312,.01,1,2,0)
;;=^^TRIGGER^.312^.02
;;^DD(.312,.01,1,2,1)
;;=K DIV S DIV=X,D0=DA(1),DIV(0)=D0,D1=DA,DIV(1)=D1 S Y(1)=$S($D(^DD("KEY",D0,2,D1,0)):^(0),1:"") S X=$P(Y(1),U,2),X=X S DIU=X K Y X ^DD(.312,.01,1,2,1.1) X ^DD(.312,.01,1,2,1.4)
;;^DD(.312,.01,1,2,1.1)
;;=S X=DIV S X=$P(^DD("KEY",DA(1),0),U)
;;^DD(.312,.01,1,2,1.4)
;;=S DIH=$S($D(^DD("KEY",DIV(0),2,DIV(1),0)):^(0),1:""),DIV=X S $P(^(0),U,2)=DIV,DIH=.312,DIG=.02 D ^DICR:$O(^DD(DIH,DIG,1,0))>0
;;^DD(.312,.01,1,2,2)
;;=Q
;;^DD(.312,.01,1,2,"CREATE VALUE")
;;=S X=$P(^DD("KEY",DA(1),0),U)
;;^DD(.312,.01,1,2,"DELETE VALUE")
;;=NO EFFECT
;;^DD(.312,.01,1,2,"DT")
;;=2980310
;;^DD(.312,.01,1,2,"FIELD")
;;=FILE
;;^DD(.312,.01,3)
;;=Answer must be 1-20 characters in length. Answer '??' for more help.
;;^DD(.312,.01,4)
;;=D EHFLD^DIKKDD
;;^DD(.312,.01,21,0)
;;=^^1^1^2980908^
;;^DD(.312,.01,21,1,0)
;;=Answer must be the number of one of this key's fields.
;;^DD(.312,.01,"DT")
;;=2980611
;;^DD(.312,.02,0)
;;=FILE^RNJ20,7I^^0;2^K:+X'=X!(X>999999999999)!(X<0)!(X?.E1"."8N.N) X
;;^DD(.312,.02,.1)
;;=
;;^DD(.312,.02,1,0)
;;=^.1^^0
;;^DD(.312,.02,3)
;;=Type a Number between 0 and 999999999999, 7 Decimal Digits. Answer '??' for more help.
;;^DD(.312,.02,5,1,0)
;;=.312^.01^2
;;^DD(.312,.02,21,0)
;;=^^3^3^2980908^
;;^DD(.312,.02,21,1,0)
;;=Answer must be the number of the file that holds this key field. It must
;;^DD(.312,.02,21,2,0)
;;=equal the number of the file whose records are uniquiely identified by
;;^DD(.312,.02,21,3,0)
;;=this key.
;;^DD(.312,.02,"DT")
;;=2980908
;;^DD(.312,1,0)
;;=SEQUENCE NUMBER^RNJ3,0^^0;3^K:+X'=X!(X>125)!(X<1)!(X?.E1"."1N.N) X
;;^DD(.312,1,3)
;;=Answer must be between 1 and 125, with no decimal digits. Answer '??' for more help.
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDINIT2A5 7191 printed Nov 22, 2024@18:01:25 Page 2
DINIT2A5 ;SFISC/MKO-KEY AND INDEX FILES ;10:50 AM 30 Mar 1999
+1 ;;22.2;VA FileMan;;Jan 05, 2016;Build 42
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
+4 ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
+5 ;;Licensed under the terms of the Apache License, Version 2.0.
+6 ;
+7 FOR I=1:2
SET X=$TEXT(Q+I)
if X=""
QUIT
SET Y=$EXTRACT($TEXT(Q+I+1),4,999)
SET X=$EXTRACT(X,4,999)
if $ASCII(Y)=126
SET I=I+1
SET Y=$EXTRACT(Y,2,999)_$EXTRACT($TEXT(Q+I+1),5,99)
if $ASCII(Y)=61
SET Y=$EXTRACT(Y,2,999)
SET @X=Y
+8 GOTO ^DINIT2A6
Q QUIT
+1 ;;^DIC(.31,0,"GL")
+2 ;;=^DD("KEY",
+3 ;;^DIC("B","KEY",.31)
+4 ;;=
+5 ;;^DIC(.31,"%D",0)
+6 ;;=^^12^12^2980911^
+7 ;;^DIC(.31,"%D",1,0)
+8 ;;=This file stores information about keys on a file or subfile. A key is a
+9 ;;^DIC(.31,"%D",2,0)
+10 ;;=set of one or more fields that uniquely identifies a record in a file. If
+11 ;;^DIC(.31,"%D",3,0)
+12 ;;=more than one set of fields can uniquely identify a record, one of those
+13 ;;^DIC(.31,"%D",4,0)
+14 ;;=sets should be designated the primary key; all others should be designated
+15 ;;^DIC(.31,"%D",5,0)
+16 ;;=secondary keys. The primary key is the principal means of identifying
+17 ;;^DIC(.31,"%D",6,0)
+18 ;;=records in the file.
+19 ;;^DIC(.31,"%D",7,0)
+20 ;;=
+21 ;;^DIC(.31,"%D",8,0)
+22 ;;=To allow FileMan to enforce key uniqueness, the database designer must
+23 ;;^DIC(.31,"%D",9,0)
+24 ;;=define a regular index that consists of all the fields that make up the
+25 ;;^DIC(.31,"%D",10,0)
+26 ;;=key. This index is called the uniqueness index.
+27 ;;^DIC(.31,"%D",11,0)
+28 ;;=
+29 ;;^DIC(.31,"%D",12,0)
+30 ;;=All key fields must have values. They cannot be null.
+31 ;;^DD(.31,0)
+32 ;;=FIELD^^3^5
+33 ;;^DD(.31,0,"DDA")
+34 ;;=N
+35 ;;^DD(.31,0,"DT")
+36 ;;=2980611
+37 ;;^DD(.31,0,"IX","B",.31,.01)
+38 ;;=
+39 ;;^DD(.31,0,"NM","KEY")
+40 ;;=
+41 ;;^DD(.31,.01,0)
+42 ;;=FILE^RNJ20,7^^0;1^K:+X'=X!(X>999999999999)!(X<0)!(X?.E1"."8N.N) X
+43 ;;^DD(.31,.01,1,0)
+44 ;;=^.1^^-1
+45 ;;^DD(.31,.01,1,1,0)
+46 ;;=.31^B
+47 ;;^DD(.31,.01,1,1,1)
+48 ;;=S ^DD("KEY","B",$E(X,1,30),DA)=""
+49 ;;^DD(.31,.01,1,1,2)
+50 ;;=K ^DD("KEY","B",$E(X,1,30),DA)
+51 ;;^DD(.31,.01,1,1,3)
+52 ;;=Lets developers pick keys by their file number
+53 ;;^DD(.31,.01,1,1,"%D",0)
+54 ;;=^^2^2^2980911^^
+55 ;;^DD(.31,.01,1,1,"%D",1,0)
+56 ;;=The B index on the .01 (File) of the Key file lets developers pick keys by
+57 ;;^DD(.31,.01,1,1,"%D",2,0)
+58 ;;=the file whose records they uniquely distinguish.
+59 ;;^DD(.31,.01,3)
+60 ;;=Type a Number between 0 and 999999999999, 7 Decimal Digits. Answer '??' for more help.
+61 ;;^DD(.31,.01,4)
+62 ;;=
+63 ;;^DD(.31,.01,21,0)
+64 ;;=^^2^2^2980908^
+65 ;;^DD(.31,.01,21,1,0)
+66 ;;=Answer should be the number of the file or subfile identified by this key.
+67 ;;^DD(.31,.01,21,2,0)
+68 ;;=A file may have more than one key, but only one primary key.
+69 ;;^DD(.31,.01,"DT")
+70 ;;=2980611
+71 ;;^DD(.31,.02,0)
+72 ;;=NAME^RF^^0;2^K:$L(X)>1!($L(X)<1)!'(X?1U) X
+73 ;;^DD(.31,.02,3)
+74 ;;=Answer must be 1 upper case letter. Answer '??' for more help.
+75 ;;^DD(.31,.02,4)
+76 ;;=
+77 ;;^DD(.31,.02,21,0)
+78 ;;=^^3^3^2980908^^
+79 ;;^DD(.31,.02,21,1,0)
+80 ;;=Answer must be the name of this key. The name of a file's primary key
+81 ;;^DD(.31,.02,21,2,0)
+82 ;;=should be A, with subsequent keys for the same file named B, C, and so
+83 ;;^DD(.31,.02,21,3,0)
+84 ;;=on.
+85 ;;^DD(.31,.02,"DT")
+86 ;;=2960122
+87 ;;^DD(.31,1,0)
+88 ;;=PRIORITY^RS^P:PRIMARY;S:SECONDARY;^0;3^Q
+89 ;;^DD(.31,1,3)
+90 ;;=Answer '??' for more help.
+91 ;;^DD(.31,1,21,0)
+92 ;;=^^2^2^2980911^
+93 ;;^DD(.31,1,21,1,0)
+94 ;;=Answer 'PRIMARY' if this is the primary key of the file, the key that will
+95 ;;^DD(.31,1,21,2,0)
+96 ;;=usually be used for identifying entries. Otherwise, answer 'SECONDARY'.
+97 ;;^DD(.31,1,"DT")
+98 ;;=2970725
+99 ;;^DD(.31,2,0)
+100 ;;=FIELD^.312IA^^2;0
+101 ;;^DD(.31,2,"DT")
+102 ;;=2980310
+103 ;;^DD(.31,3,0)
+104 ;;=UNIQUENESS INDEX^*P.11'^DD("IX",^0;4^S DIC("S")="I 1 Q:'$D(DDS)!'$D(DIKKEY) I $P(^(0),U,9)=$P(^DD(""KEY"",DIKKEY,0),U)" D ^DIC K DIC S DIC=DIE,X=+Y K:Y<0 X
+105 ;;^DD(.31,3,3)
+106 ;;=Answer '??' for more help.
+107 ;;^DD(.31,3,12)
+108 ;;=Root File of Index must equal File of Key.
+109 ;;^DD(.31,3,12.1)
+110 ;;=S DIC("S")="I 1 Q:'$D(DDS)!'$D(DIKKEY) I $P(^(0),U,9)=$P(^DD(""KEY"",DIKKEY,0),U)"
+111 ;;^DD(.31,3,21,0)
+112 ;;=^^3^3^2981120^
+113 ;;^DD(.31,3,21,1,0)
+114 ;;=Answer with the index that FileMan should use to ensure that new key
+115 ;;^DD(.31,3,21,2,0)
+116 ;;=values are unique. It must be a new-style index that resides in the
+117 ;;^DD(.31,3,21,3,0)
+118 ;;=Index file, and must cross-reference the key fields in proper sequence.
+119 ;;^DD(.31,3,"DT")
+120 ;;=2980611
+121 ;;^DD(.312,0)
+122 ;;=FIELD SUB-FIELD^^1^3
+123 ;;^DD(.312,0,"DT")
+124 ;;=2960219
+125 ;;^DD(.312,0,"ID","WRITE")
+126 ;;=D EN^DDIOL(" "_$P(^(0),U,2),"","?0")
+127 ;;^DD(.312,0,"IX","B",.312,.01)
+128 ;;=
+129 ;;^DD(.312,0,"NM","FIELD")
+130 ;;=
+131 ;;^DD(.312,0,"UP")
+132 ;;=.31
+133 ;;^DD(.312,.01,0)
+134 ;;=FIELD^MRFX^^0;1^D ITFLD^DIKKDD I $D(X) K:$L(X)>20!($L(X)<1) X
+135 ;;^DD(.312,.01,1,0)
+136 ;;=^.1
+137 ;;^DD(.312,.01,1,1,0)
+138 ;;=.312^B
+139 ;;^DD(.312,.01,1,1,1)
+140 ;;=S ^DD("KEY",DA(1),2,"B",$E(X,1,30),DA)=""
+141 ;;^DD(.312,.01,1,1,2)
+142 ;;=K ^DD("KEY",DA(1),2,"B",$E(X,1,30),DA)
+143 ;;^DD(.312,.01,1,1,3)
+144 ;;=LETS DEVELOPER PICK KEY FIELDS BY NUMBER
+145 ;;^DD(.312,.01,1,1,"%D",0)
+146 ;;=^^2^2^2980908^
+147 ;;^DD(.312,.01,1,1,"%D",1,0)
+148 ;;=The B index, on the .01 (Field) of the Fields multiple, lets the developer
+149 ;;^DD(.312,.01,1,1,"%D",2,0)
+150 ;;=pick key fields by field number.
+151 ;;^DD(.312,.01,1,2,0)
+152 ;;=^^TRIGGER^.312^.02
+153 ;;^DD(.312,.01,1,2,1)
+154 ;;=K DIV S DIV=X,D0=DA(1),DIV(0)=D0,D1=DA,DIV(1)=D1 S Y(1)=$S($D(^DD("KEY",D0,2,D1,0)):^(0),1:"") S X=$P(Y(1),U,2),X=X S DIU=X K Y X ^DD(.312,.01,1,2,1.1) X ^DD(.312,.01,1,2,1.4)
+155 ;;^DD(.312,.01,1,2,1.1)
+156 ;;=S X=DIV S X=$P(^DD("KEY",DA(1),0),U)
+157 ;;^DD(.312,.01,1,2,1.4)
+158 ;;=S DIH=$S($D(^DD("KEY",DIV(0),2,DIV(1),0)):^(0),1:""),DIV=X S $P(^(0),U,2)=DIV,DIH=.312,DIG=.02 D ^DICR:$O(^DD(DIH,DIG,1,0))>0
+159 ;;^DD(.312,.01,1,2,2)
+160 ;;=Q
+161 ;;^DD(.312,.01,1,2,"CREATE VALUE")
+162 ;;=S X=$P(^DD("KEY",DA(1),0),U)
+163 ;;^DD(.312,.01,1,2,"DELETE VALUE")
+164 ;;=NO EFFECT
+165 ;;^DD(.312,.01,1,2,"DT")
+166 ;;=2980310
+167 ;;^DD(.312,.01,1,2,"FIELD")
+168 ;;=FILE
+169 ;;^DD(.312,.01,3)
+170 ;;=Answer must be 1-20 characters in length. Answer '??' for more help.
+171 ;;^DD(.312,.01,4)
+172 ;;=D EHFLD^DIKKDD
+173 ;;^DD(.312,.01,21,0)
+174 ;;=^^1^1^2980908^
+175 ;;^DD(.312,.01,21,1,0)
+176 ;;=Answer must be the number of one of this key's fields.
+177 ;;^DD(.312,.01,"DT")
+178 ;;=2980611
+179 ;;^DD(.312,.02,0)
+180 ;;=FILE^RNJ20,7I^^0;2^K:+X'=X!(X>999999999999)!(X<0)!(X?.E1"."8N.N) X
+181 ;;^DD(.312,.02,.1)
+182 ;;=
+183 ;;^DD(.312,.02,1,0)
+184 ;;=^.1^^0
+185 ;;^DD(.312,.02,3)
+186 ;;=Type a Number between 0 and 999999999999, 7 Decimal Digits. Answer '??' for more help.
+187 ;;^DD(.312,.02,5,1,0)
+188 ;;=.312^.01^2
+189 ;;^DD(.312,.02,21,0)
+190 ;;=^^3^3^2980908^
+191 ;;^DD(.312,.02,21,1,0)
+192 ;;=Answer must be the number of the file that holds this key field. It must
+193 ;;^DD(.312,.02,21,2,0)
+194 ;;=equal the number of the file whose records are uniquiely identified by
+195 ;;^DD(.312,.02,21,3,0)
+196 ;;=this key.
+197 ;;^DD(.312,.02,"DT")
+198 ;;=2980908
+199 ;;^DD(.312,1,0)
+200 ;;=SEQUENCE NUMBER^RNJ3,0^^0;3^K:+X'=X!(X>125)!(X<1)!(X?.E1"."1N.N) X
+201 ;;^DD(.312,1,3)
+202 ;;=Answer must be between 1 and 125, with no decimal digits. Answer '??' for more help.