| 1 | DINIT125 ;SFISC/MKO-SORT TEMPLATE FILE ;1:13 PM  13 Nov 1998
 | 
|---|
| 2 |  ;;22.0;VA FileMan;;Mar 30, 1999
 | 
|---|
| 3 |  ;Per VHA Directive 10-93-142, this routine should not be modified.
 | 
|---|
| 4 |  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
 | 
|---|
| 5 |  G ^DINIT126
 | 
|---|
| 6 | Q Q
 | 
|---|
| 7 |  ;;^DD(.4014,14,21,1,0)
 | 
|---|
| 8 |  ;;=Fields are assigned a probability rating based on the number of hits
 | 
|---|
| 9 |  ;;^DD(.4014,14,21,2,0)
 | 
|---|
| 10 |  ;;=found for the query (or sort) condition.  The probability rating is used
 | 
|---|
| 11 |  ;;^DD(.4014,14,21,3,0)
 | 
|---|
| 12 |  ;;=to determine the order in which query conditions should be executed
 | 
|---|
| 13 |  ;;^DD(.4014,14,21,4,0)
 | 
|---|
| 14 |  ;;=during the sort phase.  Fields with a higher probability rating are
 | 
|---|
| 15 |  ;;^DD(.4014,14,21,5,0)
 | 
|---|
| 16 |  ;;=executed first to most quickly cut down the number of records that have
 | 
|---|
| 17 |  ;;^DD(.4014,14,21,6,0)
 | 
|---|
| 18 |  ;;=to be processed.
 | 
|---|
| 19 |  ;;^DD(.4014,14,23,0)
 | 
|---|
| 20 |  ;;=^^1^1^2930125^
 | 
|---|
| 21 |  ;;^DD(.4014,14,23,1,0)
 | 
|---|
| 22 |  ;;=Calculated by a call to the FileMan Query Optimizer routine ^DIOQ.
 | 
|---|
| 23 |  ;;^DD(.4014,14,"DT")
 | 
|---|
| 24 |  ;;=2930125
 | 
|---|
| 25 |  ;;^DD(.4014,15,0)
 | 
|---|
| 26 |  ;;=DATA TYPE FOR SORTING^P.81'^DI(.81,^0;10^Q
 | 
|---|
| 27 |  ;;^DD(.4014,15,21,0)
 | 
|---|
| 28 |  ;;=^^5^5^2930514^
 | 
|---|
| 29 |  ;;^DD(.4014,15,21,1,0)
 | 
|---|
| 30 |  ;;=This pointer to the FileMan DATA TYPE file is entered automatically by
 | 
|---|
| 31 |  ;;^DD(.4014,15,21,2,0)
 | 
|---|
| 32 |  ;;=FileMan during the sort/print.  Note that if sorting by a pointer or a
 | 
|---|
| 33 |  ;;^DD(.4014,15,21,3,0)
 | 
|---|
| 34 |  ;;=variable pointer, FileMan will follow the pointer chain until it gets to
 | 
|---|
| 35 |  ;;^DD(.4014,15,21,4,0)
 | 
|---|
| 36 |  ;;=one of the other data types, in order to determine how to correctly set up
 | 
|---|
| 37 |  ;;^DD(.4014,15,21,5,0)
 | 
|---|
| 38 |  ;;=the sort logic.
 | 
|---|
| 39 |  ;;^DD(.4014,15,23,0)
 | 
|---|
| 40 |  ;;=^^1^1^2930514^
 | 
|---|
| 41 |  ;;^DD(.4014,15,23,1,0)
 | 
|---|
| 42 |  ;;=Pointer to DATA TYPE file, derived by FileMan in routine DTYP^DIP1.
 | 
|---|
| 43 |  ;;^DD(.4014,15,"DT")
 | 
|---|
| 44 |  ;;=2930514
 | 
|---|
| 45 |  ;;^DD(.4014,16,0)
 | 
|---|
| 46 |  ;;=COMPUTED FIELD CODE^K^^CM;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 | 
|---|
| 47 |  ;;^DD(.4014,16,3)
 | 
|---|
| 48 |  ;;=This is Standard MUMPS code, generated for sorting by computed fields or pointer fields.
 | 
|---|
| 49 |  ;;^DD(.4014,16,9)
 | 
|---|
| 50 |  ;;=@
 | 
|---|
| 51 |  ;;^DD(.4014,16,21,0)
 | 
|---|
| 52 |  ;;=^^3^3^2930201^
 | 
|---|
| 53 |  ;;^DD(.4014,16,21,1,0)
 | 
|---|
| 54 |  ;;=This field contains MUMPS code used to find the actual value of a field
 | 
|---|
| 55 |  ;;^DD(.4014,16,21,2,0)
 | 
|---|
| 56 |  ;;=that is computed or a pointer.  The code is generated by DICOMP.  This
 | 
|---|
| 57 |  ;;^DD(.4014,16,21,3,0)
 | 
|---|
| 58 |  ;;=code may execute code in OVERFLOW nodes as well.
 | 
|---|
| 59 |  ;;^DD(.4014,16,23,0)
 | 
|---|
| 60 |  ;;=^^1^1^2930201^
 | 
|---|
| 61 |  ;;^DD(.4014,16,23,1,0)
 | 
|---|
| 62 |  ;;=Generated by DICOMP.  Put into the DPP array in C^DIP0.
 | 
|---|
| 63 |  ;;^DD(.4014,16,"DT")
 | 
|---|
| 64 |  ;;=2930201
 | 
|---|
| 65 |  ;;^DD(.4014,17,0)
 | 
|---|
| 66 |  ;;=MULTIPLE FIELD DATA^.40141^^1;0
 | 
|---|
| 67 |  ;;^DD(.4014,18,0)
 | 
|---|
| 68 |  ;;=RELATIONAL JUMP FIELD DATA^.401418^^2;0
 | 
|---|
| 69 |  ;;^DD(.4014,19,0)
 | 
|---|
| 70 |  ;;=OVERFLOW DATA^.401419^^3;0
 | 
|---|
| 71 |  ;;^DD(.4014,19,21,0)
 | 
|---|
| 72 |  ;;=^^5^5^2930201^
 | 
|---|
| 73 |  ;;^DD(.4014,19,21,1,0)
 | 
|---|
| 74 |  ;;=This field contains the first subscript from the part of the DPP array
 | 
|---|
| 75 |  ;;^DD(.4014,19,21,2,0)
 | 
|---|
| 76 |  ;;=that contains overflow code executed when sorting by a field that is
 | 
|---|
| 77 |  ;;^DD(.4014,19,21,3,0)
 | 
|---|
| 78 |  ;;=gotten to relationally or a computed field.  Overflow code is generated
 | 
|---|
| 79 |  ;;^DD(.4014,19,21,4,0)
 | 
|---|
| 80 |  ;;=when needed by DICOMP.  This field will typically look something like
 | 
|---|
| 81 |  ;;^DD(.4014,19,21,5,0)
 | 
|---|
| 82 |  ;;="OVF0".
 | 
|---|
| 83 |  ;;^DD(.4014,19,23,0)
 | 
|---|
| 84 |  ;;=^^1^1^2930201^
 | 
|---|
| 85 |  ;;^DD(.4014,19,23,1,0)
 | 
|---|
| 86 |  ;;=Generated by DICOMP from DIP0 during the sort/print option.
 | 
|---|
| 87 |  ;;^DD(.4014,19,"DT")
 | 
|---|
| 88 |  ;;=2930201
 | 
|---|
| 89 |  ;;^DD(.4014,20,0)
 | 
|---|
| 90 |  ;;=SUBHEADER OUTPUT TRANSFORM^K^^OUT;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 | 
|---|
| 91 |  ;;^DD(.4014,20,3)
 | 
|---|
| 92 |  ;;=This is Standard MUMPS code.  This is used only when sorting by a user-specified cross-reference in input variable BY(0).
 | 
|---|
| 93 |  ;;^DD(.4014,20,9)
 | 
|---|
| 94 |  ;;=@
 | 
|---|
| 95 |  ;;^DD(.4014,20,21,0)
 | 
|---|
| 96 |  ;;=^^6^6^2930204^
 | 
|---|
| 97 |  ;;^DD(.4014,20,21,1,0)
 | 
|---|
| 98 |  ;;=Defined only when using the BY(0) input variable to the FileMan print,
 | 
|---|
| 99 |  ;;^DD(.4014,20,21,2,0)
 | 
|---|
| 100 |  ;;=EN1^DIP, which allows the user to specify a cross-reference to sort on.
 | 
|---|
| 101 |  ;;^DD(.4014,20,21,3,0)
 | 
|---|
| 102 |  ;;=The user is allowed to specify MUMPS code that can be used as an output
 | 
|---|
| 103 |  ;;^DD(.4014,20,21,4,0)
 | 
|---|
| 104 |  ;;=transform for any of the subheaders (i.e., subscripts in the
 | 
|---|
| 105 |  ;;^DD(.4014,20,21,5,0)
 | 
|---|
| 106 |  ;;=cross-reference) in the S input array.  This output transform code is
 | 
|---|
| 107 |  ;;^DD(.4014,20,21,6,0)
 | 
|---|
| 108 |  ;;=stored in this field.
 | 
|---|
| 109 |  ;;^DD(.4014,20,23,0)
 | 
|---|
| 110 |  ;;=^^4^4^2930204^
 | 
|---|
| 111 |  ;;^DD(.4014,20,23,1,0)
 | 
|---|
| 112 |  ;;=Stores output transform code from the third piece of S(0,N) where N is
 | 
|---|
| 113 |  ;;^DD(.4014,20,23,2,0)
 | 
|---|
| 114 |  ;;=the sort level.  This is an input array used in conjunction with BY(0)
 | 
|---|
| 115 |  ;;^DD(.4014,20,23,3,0)
 | 
|---|
| 116 |  ;;=when user specifies a specific cross-reference to use for the sort, in
 | 
|---|
| 117 |  ;;^DD(.4014,20,23,4,0)
 | 
|---|
| 118 |  ;;=in the FileMan print routine EN1^DIP.
 | 
|---|
| 119 |  ;;^DD(.4014,20,"DT")
 | 
|---|
| 120 |  ;;=2930204
 | 
|---|
| 121 |  ;;^DD(.4014,21,0)
 | 
|---|
| 122 |  ;;=TEXT SORT FLAG^S^SORT:SORT LIKE TEXT;RANGE:TREAT RANGE LIKE TEXT;^SRTTXT;1^Q
 | 
|---|
| 123 |  ;;^DD(.4014,21,21,0)
 | 
|---|
| 124 |  ;;=^^12^12^2931221^
 | 
|---|
| 125 |  ;;^DD(.4014,21,21,1,0)
 | 
|---|
| 126 |  ;;=This flag will be set in one of two cases.
 | 
|---|
| 127 |  ;;^DD(.4014,21,21,2,0)
 | 
|---|
| 128 |  ;;= 1) If the user entered the ;TXT qualifier, the flag will be set to
 | 
|---|
| 129 |  ;;^DD(.4014,21,21,3,0)
 | 
|---|
| 130 |  ;;="SORT", and will cause a space to be inserted at the beginning of each
 | 
|---|
| 131 |  ;;^DD(.4014,21,21,4,0)
 | 
|---|
| 132 |  ;;=sort value, causing even numeric fields to be sorted as if they were text.
 | 
|---|
| 133 |  ;;^DD(.4014,21,21,5,0)
 | 
|---|
| 134 |  ;;= 2) If the user entered a FROM or TO value that is a non-canonic number,
 | 
|---|
| 135 |  ;;^DD(.4014,21,21,6,0)
 | 
|---|
| 136 |  ;;=the flag will be set to RANGE, and will cause sort values that are numeric
 | 
|---|
| 137 |  ;;^DD(.4014,21,21,7,0)
 | 
|---|
| 138 |  ;;=to be treated as if they were text, when seeing whether they fall within
 | 
|---|
| 139 |  ;;^DD(.4014,21,21,8,0)
 | 
|---|
| 140 |  ;;=the from/to range.  However, they will still sort like numbers (MUMPS sort
 | 
|---|
| 141 |  ;;^DD(.4014,21,21,9,0)
 | 
|---|
| 142 |  ;;=sequence).
 | 
|---|
| 143 |  ;;^DD(.4014,21,21,10,0)
 | 
|---|
| 144 |  ;;= 
 | 
|---|
| 145 |  ;;^DD(.4014,21,21,11,0)
 | 
|---|
| 146 |  ;;=The flag is set automatically when the user is entering the sort fields in
 | 
|---|
| 147 |  ;;^DD(.4014,21,21,12,0)
 | 
|---|
| 148 |  ;;=^DIP, and the from/to values in ^DIP1.
 | 
|---|
| 149 |  ;;^DD(.4014,21,"DT")
 | 
|---|
| 150 |  ;;=2931221
 | 
|---|
| 151 |  ;;^DD(.40141,0)
 | 
|---|
| 152 |  ;;=MULTIPLE FIELD DATA SUB-FIELD^^1^2
 | 
|---|
| 153 |  ;;^DD(.40141,0,"DT")
 | 
|---|
| 154 |  ;;=2930201
 | 
|---|
| 155 |  ;;^DD(.40141,0,"IX","B",.40141,.01)
 | 
|---|
| 156 |  ;;=
 | 
|---|
| 157 |  ;;^DD(.40141,0,"NM","MULTIPLE FIELD DATA")
 | 
|---|
| 158 |  ;;=
 | 
|---|
| 159 |  ;;^DD(.40141,0,"UP")
 | 
|---|
| 160 |  ;;=.4014
 | 
|---|
| 161 |  ;;^DD(.40141,.01,0)
 | 
|---|
| 162 |  ;;=MULT.FILE OR SUBFILE NO.^MNJ13,5^^0;1^K:+X'=X!(X>9999999.99999)!(X<0)!(X?.E1"."6N.N) X
 | 
|---|
| 163 |  ;;^DD(.40141,.01,1,0)
 | 
|---|
| 164 |  ;;=^.1
 | 
|---|
| 165 |  ;;^DD(.40141,.01,1,1,0)
 | 
|---|
| 166 |  ;;=.40141^B
 | 
|---|
| 167 |  ;;^DD(.40141,.01,1,1,1)
 | 
|---|
| 168 |  ;;=S ^DIBT(DA(2),2,DA(1),1,"B",$E(X,1,30),DA)=""
 | 
|---|
| 169 |  ;;^DD(.40141,.01,1,1,2)
 | 
|---|
| 170 |  ;;=K ^DIBT(DA(2),2,DA(1),1,"B",$E(X,1,30),DA)
 | 
|---|
| 171 |  ;;^DD(.40141,.01,3)
 | 
|---|
| 172 |  ;;=Type a Number between 0 and 9999999.99999, 5 Decimal Digits.  This is the file/subfile number when sorting by a multiple field.
 | 
|---|
| 173 |  ;;^DD(.40141,.01,21,0)
 | 
|---|
| 174 |  ;;=^^4^4^2930201^
 | 
|---|
| 175 |  ;;^DD(.40141,.01,21,1,0)
 | 
|---|
| 176 |  ;;=All files or subfiles needed to get back up to the top level from a
 | 
|---|
| 177 |  ;;^DD(.40141,.01,21,2,0)
 | 
|---|
| 178 |  ;;=multiple field will be represented by an entry in this field.  The
 | 
|---|
| 179 |  ;;^DD(.40141,.01,21,3,0)
 | 
|---|
| 180 |  ;;=file or subfile number will be used as a subscript in the DPP array
 | 
|---|