DINIT2BB ;SFISC/MKO-SQLI FILES ;10:51 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 ^DINIT2BC
Q Q
 ;;^DIC(1.5218,0,"GL")
 ;;=^DMSQ("P",
 ;;^DIC("B","SQLI_PRIMARY_KEY",1.5218)
 ;;=
 ;;^DIC(1.5218,"%D",0)
 ;;=^^9^9^2970806^^^
 ;;^DIC(1.5218,"%D",1,0)
 ;;=A chosen set of columns which uniquely identify a table.
 ;;^DIC(1.5218,"%D",2,0)
 ;;=In the relational model (as in set theory) the columns of a primary key
 ;;^DIC(1.5218,"%D",3,0)
 ;;=are not ordered. In SQLI they must be, in order to map to the quasi-
 ;;^DIC(1.5218,"%D",4,0)
 ;;=hierarchical model of M globals.
 ;;^DIC(1.5218,"%D",5,0)
 ;;= 
 ;;^DIC(1.5218,"%D",6,0)
 ;;=FileMan subfiles (multiples) have a primary key element for each parent
 ;;^DIC(1.5218,"%D",7,0)
 ;;=plus one for the subfile. Each contains a pointer to its primary key table
 ;;^DIC(1.5218,"%D",8,0)
 ;;=element (SQLI_TABLE-ELEMENT), a sequence and a column in the local base
 ;;^DIC(1.5218,"%D",9,0)
 ;;= table (SQL_COLUMN).
 ;;^DD(1.5218,0)
 ;;=FIELD^^7^8
 ;;^DD(1.5218,0,"DDA")
 ;;=N
 ;;^DD(1.5218,0,"DT")
 ;;=2961014
 ;;^DD(1.5218,0,"IX","B",1.5218,.01)
 ;;=
 ;;^DD(1.5218,0,"IX","C",1.5218,2)
 ;;=
 ;;^DD(1.5218,0,"IX","D",1.5218,1)
 ;;=
 ;;^DD(1.5218,0,"NM","SQLI_PRIMARY_KEY")
 ;;=
 ;;^DD(1.5218,0,"PT",1.5219,1)
 ;;=
 ;;^DD(1.5218,0,"VRPK")
 ;;=DI
 ;;^DD(1.5218,.01,0)
 ;;=P_TBL_ELEMENT^RP1.5216'^DMSQ("E",^0;1^Q
 ;;^DD(1.5218,.01,.1)
 ;;=Key Element
 ;;^DD(1.5218,.01,1,0)
 ;;=^.1
 ;;^DD(1.5218,.01,1,1,0)
 ;;=1.5218^B
 ;;^DD(1.5218,.01,1,1,1)
 ;;=S ^DMSQ("P","B",$E(X,1,30),DA)=""
 ;;^DD(1.5218,.01,1,1,2)
 ;;=K ^DMSQ("P","B",$E(X,1,30),DA)
 ;;^DD(1.5218,.01,3)
 ;;=
 ;;^DD(1.5218,.01,9)
 ;;=^
 ;;^DD(1.5218,.01,21,0)
 ;;=^^1^1^2960926^^
 ;;^DD(1.5218,.01,21,1,0)
 ;;=IEN of table element in SQLI_TABLE_ELEMENT
 ;;^DD(1.5218,.01,"DT")
 ;;=2960823
 ;;^DD(1.5218,1,0)
 ;;=P_COLUMN^RP1.5217'^DMSQ("C",^0;2^Q
 ;;^DD(1.5218,1,.1)
 ;;=Column
 ;;^DD(1.5218,1,1,0)
 ;;=^.1
 ;;^DD(1.5218,1,1,1,0)
 ;;=1.5218^D
 ;;^DD(1.5218,1,1,1,1)
 ;;=S ^DMSQ("P","D",$E(X,1,30),DA)=""
 ;;^DD(1.5218,1,1,1,2)
 ;;=K ^DMSQ("P","D",$E(X,1,30),DA)
 ;;^DD(1.5218,1,1,1,"DT")
 ;;=2960830
 ;;^DD(1.5218,1,9)
 ;;=^
 ;;^DD(1.5218,1,21,0)
 ;;=^^1^1^2960926^^^
 ;;^DD(1.5218,1,21,1,0)
 ;;=IEN of column in SQLI_COLUMN corresponding to this primary key
 ;;^DD(1.5218,1,"DT")
 ;;=2960830
 ;;^DD(1.5218,2,0)
 ;;=P_SEQUENCE^RNJ1,0^^0;3^K:+X'=X!(X>9)!(X<1)!(X?.E1"."1N.N) X
 ;;^DD(1.5218,2,.1)
 ;;=Seq
 ;;^DD(1.5218,2,1,0)
 ;;=^.1
 ;;^DD(1.5218,2,1,1,0)
 ;;=1.5218^C^MUMPS
 ;;^DD(1.5218,2,1,1,1)
 ;;=S ^DMSQ("P","C",$P(^DMSQ("P",DA,0),U),X,DA)=""
 ;;^DD(1.5218,2,1,1,2)
 ;;=K ^DMSQ("P","C",$P(^DMSQ("P",DA,0),U),X,DA)
 ;;^DD(1.5218,2,1,1,"%D",0)
 ;;=^^1^1^2960827^^
 ;;^DD(1.5218,2,1,1,"%D",1,0)
 ;;=Primary key by table by sequence
 ;;^DD(1.5218,2,1,1,"DT")
 ;;=2960823
 ;;^DD(1.5218,2,3)
 ;;=Type a Number between 1 and 9, 0 Decimal Digits
 ;;^DD(1.5218,2,9)
 ;;=^
 ;;^DD(1.5218,2,21,0)
 ;;=^^1^1^2960926^
 ;;^DD(1.5218,2,21,1,0)
 ;;=Sequence number of primary key
 ;;^DD(1.5218,2,23,0)
 ;;=^^1^1^2960926^
 ;;^DD(1.5218,2,23,1,0)
 ;;=Sequence is automatically generated and must not be changed.
 ;;^DD(1.5218,2,"DT")
 ;;=2960926
 ;;^DD(1.5218,3,0)
 ;;=P_START_AT^F^^0;4^K:$L(X)>30!($L(X)<1) X
 ;;^DD(1.5218,3,.1)
 ;;=Start
 ;;^DD(1.5218,3,3)
 ;;=Answer must be 1-30 characters in length.
 ;;^DD(1.5218,3,9)
 ;;=^
 ;;^DD(1.5218,3,21,0)
 ;;=^^1^1^2960926^
 ;;^DD(1.5218,3,21,1,0)
 ;;=Initial value of key before a $ORDER loop
 ;;^DD(1.5218,3,"DT")
 ;;=2960820
 ;;^DD(1.5218,4,0)
 ;;=P_END_IF^K^^1;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 ;;^DD(1.5218,4,.1)
 ;;=End If
 ;;^DD(1.5218,4,3)
 ;;=This is a Standard M expression returning False at end
 ;;^DD(1.5218,4,9)
 ;;=^
 ;;^DD(1.5218,4,21,0)
 ;;=^^1^1^2960926^
 ;;^DD(1.5218,4,21,1,0)
 ;;=M expression in key value, {K}, which, if false, ends the $ORDER loop
 ;;^DD(1.5218,4,"DT")
 ;;=2960926
 ;;^DD(1.5218,5,0)
 ;;=P_ROW_COUNT^NJ10,2^^0;5^K:+X'=X!(X>9999999)!(X<1)!(X?.E1"."3N.N) X
 ;;^DD(1.5218,5,.1)
 ;;=Rows
 ;;^DD(1.5218,5,3)
 ;;=Type a Number between 1 and 9999999, 2 Decimal Digits
 ;;^DD(1.5218,5,9)
 ;;=^
 ;;^DD(1.5218,5,21,0)
 ;;=^^1^1^2960926^^
 ;;^DD(1.5218,5,21,1,0)
 ;;=Estimated number of rows per record set at this level
 ;;^DD(1.5218,5,"DT")
 ;;=2960926
 ;;^DD(1.5218,6,0)
 ;;=P_PRESELECT^K^^2;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 ;;^DD(1.5218,6,.1)
 ;;=Preselect M Code
 ;;^DD(1.5218,6,3)
 ;;=This is Standard MUMPS code.
 ;;^DD(1.5218,6,9)
 ;;=^
 ;;^DD(1.5218,6,21,0)
 ;;=^^1^1^2960926^^
 ;;^DD(1.5218,6,21,1,0)
 ;;=Code to be executed before selecting this key, before optimization.
 ;;^DD(1.5218,6,"DT")
 ;;=2960926
 ;;^DD(1.5218,7,0)
 ;;=P_KEY_FORMAT^P1.5213'^DMSQ("KF",^0;6^Q
 ;;^DD(1.5218,7,9)
 ;;=^
 ;;^DD(1.5218,7,21,0)
 ;;=^^4^4^2961014^
 ;;^DD(1.5218,7,21,1,0)
 ;;=Key formats map internal storage values to their value when used as keys.
 ;;^DD(1.5218,7,21,2,0)
 ;;=In general, information is lost in the process; they can't be converted
 ;;^DD(1.5218,7,21,3,0)
 ;;=back. This means data must be converted to key format before it can be
 ;;^DD(1.5218,7,21,4,0)
 ;;=compared to such a key.
 ;;^DD(1.5218,7,"DT")
 ;;=2961014
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDINIT2BB   5725     printed  Sep 23, 2025@20:27:50                                                                                                                                                                                                    Page 2
DINIT2BB  ;SFISC/MKO-SQLI FILES ;10:51 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 ^DINIT2BC
Q          QUIT 
 +1       ;;^DIC(1.5218,0,"GL")
 +2       ;;=^DMSQ("P",
 +3       ;;^DIC("B","SQLI_PRIMARY_KEY",1.5218)
 +4       ;;=
 +5       ;;^DIC(1.5218,"%D",0)
 +6       ;;=^^9^9^2970806^^^
 +7       ;;^DIC(1.5218,"%D",1,0)
 +8       ;;=A chosen set of columns which uniquely identify a table.
 +9       ;;^DIC(1.5218,"%D",2,0)
 +10      ;;=In the relational model (as in set theory) the columns of a primary key
 +11      ;;^DIC(1.5218,"%D",3,0)
 +12      ;;=are not ordered. In SQLI they must be, in order to map to the quasi-
 +13      ;;^DIC(1.5218,"%D",4,0)
 +14      ;;=hierarchical model of M globals.
 +15      ;;^DIC(1.5218,"%D",5,0)
 +16      ;;= 
 +17      ;;^DIC(1.5218,"%D",6,0)
 +18      ;;=FileMan subfiles (multiples) have a primary key element for each parent
 +19      ;;^DIC(1.5218,"%D",7,0)
 +20      ;;=plus one for the subfile. Each contains a pointer to its primary key table
 +21      ;;^DIC(1.5218,"%D",8,0)
 +22      ;;=element (SQLI_TABLE-ELEMENT), a sequence and a column in the local base
 +23      ;;^DIC(1.5218,"%D",9,0)
 +24      ;;= table (SQL_COLUMN).
 +25      ;;^DD(1.5218,0)
 +26      ;;=FIELD^^7^8
 +27      ;;^DD(1.5218,0,"DDA")
 +28      ;;=N
 +29      ;;^DD(1.5218,0,"DT")
 +30      ;;=2961014
 +31      ;;^DD(1.5218,0,"IX","B",1.5218,.01)
 +32      ;;=
 +33      ;;^DD(1.5218,0,"IX","C",1.5218,2)
 +34      ;;=
 +35      ;;^DD(1.5218,0,"IX","D",1.5218,1)
 +36      ;;=
 +37      ;;^DD(1.5218,0,"NM","SQLI_PRIMARY_KEY")
 +38      ;;=
 +39      ;;^DD(1.5218,0,"PT",1.5219,1)
 +40      ;;=
 +41      ;;^DD(1.5218,0,"VRPK")
 +42      ;;=DI
 +43      ;;^DD(1.5218,.01,0)
 +44      ;;=P_TBL_ELEMENT^RP1.5216'^DMSQ("E",^0;1^Q
 +45      ;;^DD(1.5218,.01,.1)
 +46      ;;=Key Element
 +47      ;;^DD(1.5218,.01,1,0)
 +48      ;;=^.1
 +49      ;;^DD(1.5218,.01,1,1,0)
 +50      ;;=1.5218^B
 +51      ;;^DD(1.5218,.01,1,1,1)
 +52      ;;=S ^DMSQ("P","B",$E(X,1,30),DA)=""
 +53      ;;^DD(1.5218,.01,1,1,2)
 +54      ;;=K ^DMSQ("P","B",$E(X,1,30),DA)
 +55      ;;^DD(1.5218,.01,3)
 +56      ;;=
 +57      ;;^DD(1.5218,.01,9)
 +58      ;;=^
 +59      ;;^DD(1.5218,.01,21,0)
 +60      ;;=^^1^1^2960926^^
 +61      ;;^DD(1.5218,.01,21,1,0)
 +62      ;;=IEN of table element in SQLI_TABLE_ELEMENT
 +63      ;;^DD(1.5218,.01,"DT")
 +64      ;;=2960823
 +65      ;;^DD(1.5218,1,0)
 +66      ;;=P_COLUMN^RP1.5217'^DMSQ("C",^0;2^Q
 +67      ;;^DD(1.5218,1,.1)
 +68      ;;=Column
 +69      ;;^DD(1.5218,1,1,0)
 +70      ;;=^.1
 +71      ;;^DD(1.5218,1,1,1,0)
 +72      ;;=1.5218^D
 +73      ;;^DD(1.5218,1,1,1,1)
 +74      ;;=S ^DMSQ("P","D",$E(X,1,30),DA)=""
 +75      ;;^DD(1.5218,1,1,1,2)
 +76      ;;=K ^DMSQ("P","D",$E(X,1,30),DA)
 +77      ;;^DD(1.5218,1,1,1,"DT")
 +78      ;;=2960830
 +79      ;;^DD(1.5218,1,9)
 +80      ;;=^
 +81      ;;^DD(1.5218,1,21,0)
 +82      ;;=^^1^1^2960926^^^
 +83      ;;^DD(1.5218,1,21,1,0)
 +84      ;;=IEN of column in SQLI_COLUMN corresponding to this primary key
 +85      ;;^DD(1.5218,1,"DT")
 +86      ;;=2960830
 +87      ;;^DD(1.5218,2,0)
 +88      ;;=P_SEQUENCE^RNJ1,0^^0;3^K:+X'=X!(X>9)!(X<1)!(X?.E1"."1N.N) X
 +89      ;;^DD(1.5218,2,.1)
 +90      ;;=Seq
 +91      ;;^DD(1.5218,2,1,0)
 +92      ;;=^.1
 +93      ;;^DD(1.5218,2,1,1,0)
 +94      ;;=1.5218^C^MUMPS
 +95      ;;^DD(1.5218,2,1,1,1)
 +96      ;;=S ^DMSQ("P","C",$P(^DMSQ("P",DA,0),U),X,DA)=""
 +97      ;;^DD(1.5218,2,1,1,2)
 +98      ;;=K ^DMSQ("P","C",$P(^DMSQ("P",DA,0),U),X,DA)
 +99      ;;^DD(1.5218,2,1,1,"%D",0)
 +100     ;;=^^1^1^2960827^^
 +101     ;;^DD(1.5218,2,1,1,"%D",1,0)
 +102     ;;=Primary key by table by sequence
 +103     ;;^DD(1.5218,2,1,1,"DT")
 +104     ;;=2960823
 +105     ;;^DD(1.5218,2,3)
 +106     ;;=Type a Number between 1 and 9, 0 Decimal Digits
 +107     ;;^DD(1.5218,2,9)
 +108     ;;=^
 +109     ;;^DD(1.5218,2,21,0)
 +110     ;;=^^1^1^2960926^
 +111     ;;^DD(1.5218,2,21,1,0)
 +112     ;;=Sequence number of primary key
 +113     ;;^DD(1.5218,2,23,0)
 +114     ;;=^^1^1^2960926^
 +115     ;;^DD(1.5218,2,23,1,0)
 +116     ;;=Sequence is automatically generated and must not be changed.
 +117     ;;^DD(1.5218,2,"DT")
 +118     ;;=2960926
 +119     ;;^DD(1.5218,3,0)
 +120     ;;=P_START_AT^F^^0;4^K:$L(X)>30!($L(X)<1) X
 +121     ;;^DD(1.5218,3,.1)
 +122     ;;=Start
 +123     ;;^DD(1.5218,3,3)
 +124     ;;=Answer must be 1-30 characters in length.
 +125     ;;^DD(1.5218,3,9)
 +126     ;;=^
 +127     ;;^DD(1.5218,3,21,0)
 +128     ;;=^^1^1^2960926^
 +129     ;;^DD(1.5218,3,21,1,0)
 +130     ;;=Initial value of key before a $ORDER loop
 +131     ;;^DD(1.5218,3,"DT")
 +132     ;;=2960820
 +133     ;;^DD(1.5218,4,0)
 +134     ;;=P_END_IF^K^^1;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 +135     ;;^DD(1.5218,4,.1)
 +136     ;;=End If
 +137     ;;^DD(1.5218,4,3)
 +138     ;;=This is a Standard M expression returning False at end
 +139     ;;^DD(1.5218,4,9)
 +140     ;;=^
 +141     ;;^DD(1.5218,4,21,0)
 +142     ;;=^^1^1^2960926^
 +143     ;;^DD(1.5218,4,21,1,0)
 +144     ;;=M expression in key value, {K}, which, if false, ends the $ORDER loop
 +145     ;;^DD(1.5218,4,"DT")
 +146     ;;=2960926
 +147     ;;^DD(1.5218,5,0)
 +148     ;;=P_ROW_COUNT^NJ10,2^^0;5^K:+X'=X!(X>9999999)!(X<1)!(X?.E1"."3N.N) X
 +149     ;;^DD(1.5218,5,.1)
 +150     ;;=Rows
 +151     ;;^DD(1.5218,5,3)
 +152     ;;=Type a Number between 1 and 9999999, 2 Decimal Digits
 +153     ;;^DD(1.5218,5,9)
 +154     ;;=^
 +155     ;;^DD(1.5218,5,21,0)
 +156     ;;=^^1^1^2960926^^
 +157     ;;^DD(1.5218,5,21,1,0)
 +158     ;;=Estimated number of rows per record set at this level
 +159     ;;^DD(1.5218,5,"DT")
 +160     ;;=2960926
 +161     ;;^DD(1.5218,6,0)
 +162     ;;=P_PRESELECT^K^^2;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 +163     ;;^DD(1.5218,6,.1)
 +164     ;;=Preselect M Code
 +165     ;;^DD(1.5218,6,3)
 +166     ;;=This is Standard MUMPS code.
 +167     ;;^DD(1.5218,6,9)
 +168     ;;=^
 +169     ;;^DD(1.5218,6,21,0)
 +170     ;;=^^1^1^2960926^^
 +171     ;;^DD(1.5218,6,21,1,0)
 +172     ;;=Code to be executed before selecting this key, before optimization.
 +173     ;;^DD(1.5218,6,"DT")
 +174     ;;=2960926
 +175     ;;^DD(1.5218,7,0)
 +176     ;;=P_KEY_FORMAT^P1.5213'^DMSQ("KF",^0;6^Q
 +177     ;;^DD(1.5218,7,9)
 +178     ;;=^
 +179     ;;^DD(1.5218,7,21,0)
 +180     ;;=^^4^4^2961014^
 +181     ;;^DD(1.5218,7,21,1,0)
 +182     ;;=Key formats map internal storage values to their value when used as keys.
 +183     ;;^DD(1.5218,7,21,2,0)
 +184     ;;=In general, information is lost in the process; they can't be converted
 +185     ;;^DD(1.5218,7,21,3,0)
 +186     ;;=back. This means data must be converted to key format before it can be
 +187     ;;^DD(1.5218,7,21,4,0)
 +188     ;;=compared to such a key.
 +189     ;;^DD(1.5218,7,"DT")
 +190     ;;=2961014