DINIT122 ;SFISC/MKO-SORT TEMPLATE FILE ;1:13 PM  13 Nov 1998
 ;;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 ^DINIT123
Q Q
 ;;^DD(.4011624,3.1,21,3,0)
 ;;=the sort qualifiers for page breaks (#) or rankings (!).  
 ;;^DD(.4011624,3.1,21,4,0)
 ;;= 
 ;;^DD(.4011624,3.1,21,5,0)
 ;;=The # and/or ! are the only qualifiers that can be used.  Others,
 ;;^DD(.4011624,3.1,21,6,0)
 ;;=such as + for subtotals, cannot be used.
 ;;^DD(.4011624,3.1,23,0)
 ;;=^^1^1^2960910^^
 ;;^DD(.4011624,3.1,23,1,0)
 ;;=Equivalent to the 1st piece of DISPAR(0,n) in the EN1^DIP call.
 ;;^DD(.4011624,3.1,"DT")
 ;;=2960910
 ;;^DD(.4011624,3.2,0)
 ;;=DISPAR(0,n) PIECE TWO^FX^^1;2^K:$L(X)>50!($L(X)<1)!'((X[";""")!(X[";L")!(X[";C")!(X[";S")) X
 ;;^DD(.4011624,3.2,3)
 ;;=Answer with qualifiers like ;"" or ;S2;C10;L30;"VALUE: "
 ;;^DD(.4011624,3.2,21,0)
 ;;=^^12^12^2960910^^^
 ;;^DD(.4011624,3.2,21,1,0)
 ;;=As when defining the second piece of DISPAR(0,n) in a programmer
 ;;^DD(.4011624,3.2,21,2,0)
 ;;=call that includes BY(0) when calling EN1^DIP, this field can hold
 ;;^DD(.4011624,3.2,21,3,0)
 ;;=the sort qualifiers that normally appear after a sort-by field in
 ;;^DD(.4011624,3.2,21,4,0)
 ;;=interactive mode.  The ones that can be used are as follows:
 ;;^DD(.4011624,3.2,21,5,0)
 ;;= 
 ;;^DD(.4011624,3.2,21,6,0)
 ;;= ;""         to have the subheader appear
 ;;^DD(.4011624,3.2,21,7,0)
 ;;= ;"caption"  to give the subheader a caption
 ;;^DD(.4011624,3.2,21,8,0)
 ;;= ;Ln         to left-justify the subheader to n characters
 ;;^DD(.4011624,3.2,21,9,0)
 ;;= ;Cn         to start the display in the nth column
 ;;^DD(.4011624,3.2,21,10,0)
 ;;= ;Sn         to skip n lines before each subheader
 ;;^DD(.4011624,3.2,21,11,0)
 ;;= 
 ;;^DD(.4011624,3.2,21,12,0)
 ;;=If this field is null, subheaders are supressed (@ is assumed).
 ;;^DD(.4011624,3.2,23,0)
 ;;=^^3^3^2960910^^^
 ;;^DD(.4011624,3.2,23,1,0)
 ;;=Equivalent to the 2nd piece of DISPAR(0,n) in the EN1^DIP call.
 ;;^DD(.4011624,3.2,23,2,0)
 ;;=Note that if DISPAR(0,n) is defined, subheaders will appear even if
 ;;^DD(.4011624,3.2,23,3,0)
 ;;=used with a print template that normally suppresses subheaders.
 ;;^DD(.4011624,3.2,"DT")
 ;;=2960911
 ;;^DD(.4011624,4,0)
 ;;=DISPAR(0,n,OUT)^K^^2;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 ;;^DD(.4011624,4,3)
 ;;=Enter code to transform subscript.  This is Standard M code.
 ;;^DD(.4011624,4,9)
 ;;=@
 ;;^DD(.4011624,4,21,0)
 ;;=^^7^7^2960829^^^^
 ;;^DD(.4011624,4,21,1,0)
 ;;=As when defining DISPAR(0,n,"OUT") for a call to EN1^DIP that includes
 ;;^DD(.4011624,4,21,2,0)
 ;;=BY(0), enter M code that will transform the sort-by value for this 
 ;;^DD(.4011624,4,21,3,0)
 ;;=subscript (n) when it is output (e.g. printed).  At the time
 ;;^DD(.4011624,4,21,4,0)
 ;;=the code is executed the untransformed value of the subscript will be in
 ;;^DD(.4011624,4,21,5,0)
 ;;=Y.  The code should put the transformed value back into Y.
 ;;^DD(.4011624,4,21,6,0)
 ;;= 
 ;;^DD(.4011624,4,21,7,0)
 ;;=For example, for an inverse date, S:Y Y=99999999-Y S Y=$$FMTE^XLFDT(Y)"
 ;;^DD(.4011624,4,23,0)
 ;;=^^2^2^2960829^^^^
 ;;^DD(.4011624,4,23,1,0)
 ;;=Equivalent to the DISPAR(0,n,"OUT") input variable to the programmer call
 ;;^DD(.4011624,4,23,2,0)
 ;;=EN1^DIP.
 ;;^DD(.4011624,4,"DT")
 ;;=2960829
 ;;^DD(.4012,0)
 ;;=DESCRIPTION SUB-FIELD^^.01^1
 ;;^DD(.4012,0,"NM","DESCRIPTION")
 ;;=
 ;;^DD(.4012,0,"UP")
 ;;=.401
 ;;^DD(.4012,.01,0)
 ;;=DESCRIPTION^W^^0;1^Q
 ;;^DD(.4014,0)
 ;;=SORT FIELD DATA SUB-FIELD^^21^27
 ;;^DD(.4014,0,"DT")
 ;;=2931221
 ;;^DD(.4014,0,"IX","B",.4014,.01)
 ;;=
 ;;^DD(.4014,0,"NM","SORT FIELD DATA")
 ;;=
 ;;^DD(.4014,0,"UP")
 ;;=.401
 ;;^DD(.4014,.01,0)
 ;;=FILE OR SUBFILE NO.^MRNJ13,5^^0;1^K:+X'=X!(X>9999999.99999)!(X<0)!(X?.E1"."6N.N) X
 ;;^DD(.4014,.01,1,0)
 ;;=^.1
 ;;^DD(.4014,.01,1,1,0)
 ;;=.4014^B
 ;;^DD(.4014,.01,1,1,1)
 ;;=S ^DIBT(DA(1),2,"B",$E(X,1,30),DA)=""
 ;;^DD(.4014,.01,1,1,2)
 ;;=K ^DIBT(DA(1),2,"B",$E(X,1,30),DA)
 ;;^DD(.4014,.01,3)
 ;;=Type a Number between 0 and 9999999.99999, 5 Decimal Digits.  File or subfile number on which sort field resides.
 ;;^DD(.4014,.01,21,0)
 ;;=^^3^3^2930125^^
 ;;^DD(.4014,.01,21,1,0)
 ;;=This is the number of the file or subfile on which the sort field
 ;;^DD(.4014,.01,21,2,0)
 ;;=resides.  It is created automatically during the SORT FIELDS dialogue
 ;;^DD(.4014,.01,21,3,0)
 ;;=with the user in the sort/print option.
 ;;^DD(.4014,.01,23,0)
 ;;=^^1^1^2930125^^
 ;;^DD(.4014,.01,23,1,0)
 ;;=This number is automatically assigned by the print routine DIP.
 ;;^DD(.4014,.01,"DT")
 ;;=2930125
 ;;^DD(.4014,2,0)
 ;;=FIELD NO.^NJ13,5^^0;2^K:+X'=X!(X>9999999.99999)!(X<0)!(X?.E1"."6N.N) X
 ;;^DD(.4014,2,3)
 ;;=Type a Number between 0 and 9999999.99999, 5 Decimal Digits.  Sort field number, except for pointers, variable pointers and computed fields.
 ;;^DD(.4014,2,21,0)
 ;;=^^4^4^2930125^
 ;;^DD(.4014,2,21,1,0)
 ;;=On most sort fields, this piece will contain the field number.  If sorting
 ;;^DD(.4014,2,21,2,0)
 ;;=on a pointer, variable pointer or computed field, the piece will be null.
 ;;^DD(.4014,2,21,3,0)
 ;;=If sorting on the record number (NUMBER or .001), the piece will contain
 ;;^DD(.4014,2,21,4,0)
 ;;=a 0.
 ;;^DD(.4014,2,23,0)
 ;;=^^1^1^2930125^
 ;;^DD(.4014,2,23,1,0)
 ;;=Created by FileMan during the print option (in the DIP* routines).
 ;;^DD(.4014,2,"DT")
 ;;=2930125
 ;;^DD(.4014,3,0)
 ;;=FIELD NAME^F^^0;3^K:$L(X)>100!($L(X)<1) X
 ;;^DD(.4014,3,3)
 ;;=Answer must be 1-100 characters in length.
 ;;^DD(.4014,3,21,0)
 ;;=^^2^2^2930125^
 ;;^DD(.4014,3,21,1,0)
 ;;=This piece contains the sort field name, or the user entry if sorting by
 ;;^DD(.4014,3,21,2,0)
 ;;=an on-the-fly computed field.
 ;;^DD(.4014,3,23,0)
 ;;=^^1^1^2930125^
 ;;^DD(.4014,3,23,1,0)
 ;;=Created by FileMan during the print option (DIP* routines).
 ;;^DD(.4014,3,"DT")
 ;;=2930125
 ;;^DD(.4014,4,0)
 ;;=SORT QUALIFIERS BEFORE FIELD^F^^0;4^K:$L(X)>20!($L(X)<1) X
 ;;^DD(.4014,4,3)
 ;;=Answer must be 1-20 characters in length.  Sort qualifiers that normally precede the field number in the user dialogue (like !,@,#,+)
 ;;^DD(.4014,4,21,0)
 ;;=^^5^5^2930125^^^
 ;;^DD(.4014,4,21,1,0)
 ;;=This contains all of the sort qualifiers that normally precede the field
 ;;^DD(.4014,4,21,2,0)
 ;;=number in the user dialogue during the sort option.  It includes things
 ;;^DD(.4014,4,21,3,0)
 ;;=like # (Page break when sort value changes), @ (suppress printing of
 ;;^DD(.4014,4,21,4,0)
 ;;=subheader).  These qualifiers are listed out with no delimiters, as they
 ;;^DD(.4014,4,21,5,0)
 ;;=are found during the user dialogue.  (So you might see something like #@).
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDINIT122   7212     printed  Sep 23, 2025@20:26:45                                                                                                                                                                                                    Page 2
DINIT122  ;SFISC/MKO-SORT TEMPLATE FILE ;1:13 PM  13 Nov 1998
 +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 ^DINIT123
Q          QUIT 
 +1       ;;^DD(.4011624,3.1,21,3,0)
 +2       ;;=the sort qualifiers for page breaks (#) or rankings (!).  
 +3       ;;^DD(.4011624,3.1,21,4,0)
 +4       ;;= 
 +5       ;;^DD(.4011624,3.1,21,5,0)
 +6       ;;=The # and/or ! are the only qualifiers that can be used.  Others,
 +7       ;;^DD(.4011624,3.1,21,6,0)
 +8       ;;=such as + for subtotals, cannot be used.
 +9       ;;^DD(.4011624,3.1,23,0)
 +10      ;;=^^1^1^2960910^^
 +11      ;;^DD(.4011624,3.1,23,1,0)
 +12      ;;=Equivalent to the 1st piece of DISPAR(0,n) in the EN1^DIP call.
 +13      ;;^DD(.4011624,3.1,"DT")
 +14      ;;=2960910
 +15      ;;^DD(.4011624,3.2,0)
 +16      ;;=DISPAR(0,n) PIECE TWO^FX^^1;2^K:$L(X)>50!($L(X)<1)!'((X[";""")!(X[";L")!(X[";C")!(X[";S")) X
 +17      ;;^DD(.4011624,3.2,3)
 +18      ;;=Answer with qualifiers like ;"" or ;S2;C10;L30;"VALUE: "
 +19      ;;^DD(.4011624,3.2,21,0)
 +20      ;;=^^12^12^2960910^^^
 +21      ;;^DD(.4011624,3.2,21,1,0)
 +22      ;;=As when defining the second piece of DISPAR(0,n) in a programmer
 +23      ;;^DD(.4011624,3.2,21,2,0)
 +24      ;;=call that includes BY(0) when calling EN1^DIP, this field can hold
 +25      ;;^DD(.4011624,3.2,21,3,0)
 +26      ;;=the sort qualifiers that normally appear after a sort-by field in
 +27      ;;^DD(.4011624,3.2,21,4,0)
 +28      ;;=interactive mode.  The ones that can be used are as follows:
 +29      ;;^DD(.4011624,3.2,21,5,0)
 +30      ;;= 
 +31      ;;^DD(.4011624,3.2,21,6,0)
 +32      ;;= ;""         to have the subheader appear
 +33      ;;^DD(.4011624,3.2,21,7,0)
 +34      ;;= ;"caption"  to give the subheader a caption
 +35      ;;^DD(.4011624,3.2,21,8,0)
 +36      ;;= ;Ln         to left-justify the subheader to n characters
 +37      ;;^DD(.4011624,3.2,21,9,0)
 +38      ;;= ;Cn         to start the display in the nth column
 +39      ;;^DD(.4011624,3.2,21,10,0)
 +40      ;;= ;Sn         to skip n lines before each subheader
 +41      ;;^DD(.4011624,3.2,21,11,0)
 +42      ;;= 
 +43      ;;^DD(.4011624,3.2,21,12,0)
 +44      ;;=If this field is null, subheaders are supressed (@ is assumed).
 +45      ;;^DD(.4011624,3.2,23,0)
 +46      ;;=^^3^3^2960910^^^
 +47      ;;^DD(.4011624,3.2,23,1,0)
 +48      ;;=Equivalent to the 2nd piece of DISPAR(0,n) in the EN1^DIP call.
 +49      ;;^DD(.4011624,3.2,23,2,0)
 +50      ;;=Note that if DISPAR(0,n) is defined, subheaders will appear even if
 +51      ;;^DD(.4011624,3.2,23,3,0)
 +52      ;;=used with a print template that normally suppresses subheaders.
 +53      ;;^DD(.4011624,3.2,"DT")
 +54      ;;=2960911
 +55      ;;^DD(.4011624,4,0)
 +56      ;;=DISPAR(0,n,OUT)^K^^2;E1,245^K:$L(X)>245 X D:$D(X) ^DIM
 +57      ;;^DD(.4011624,4,3)
 +58      ;;=Enter code to transform subscript.  This is Standard M code.
 +59      ;;^DD(.4011624,4,9)
 +60      ;;=@
 +61      ;;^DD(.4011624,4,21,0)
 +62      ;;=^^7^7^2960829^^^^
 +63      ;;^DD(.4011624,4,21,1,0)
 +64      ;;=As when defining DISPAR(0,n,"OUT") for a call to EN1^DIP that includes
 +65      ;;^DD(.4011624,4,21,2,0)
 +66      ;;=BY(0), enter M code that will transform the sort-by value for this 
 +67      ;;^DD(.4011624,4,21,3,0)
 +68      ;;=subscript (n) when it is output (e.g. printed).  At the time
 +69      ;;^DD(.4011624,4,21,4,0)
 +70      ;;=the code is executed the untransformed value of the subscript will be in
 +71      ;;^DD(.4011624,4,21,5,0)
 +72      ;;=Y.  The code should put the transformed value back into Y.
 +73      ;;^DD(.4011624,4,21,6,0)
 +74      ;;= 
 +75      ;;^DD(.4011624,4,21,7,0)
 +76      ;;=For example, for an inverse date, S:Y Y=99999999-Y S Y=$$FMTE^XLFDT(Y)"
 +77      ;;^DD(.4011624,4,23,0)
 +78      ;;=^^2^2^2960829^^^^
 +79      ;;^DD(.4011624,4,23,1,0)
 +80      ;;=Equivalent to the DISPAR(0,n,"OUT") input variable to the programmer call
 +81      ;;^DD(.4011624,4,23,2,0)
 +82      ;;=EN1^DIP.
 +83      ;;^DD(.4011624,4,"DT")
 +84      ;;=2960829
 +85      ;;^DD(.4012,0)
 +86      ;;=DESCRIPTION SUB-FIELD^^.01^1
 +87      ;;^DD(.4012,0,"NM","DESCRIPTION")
 +88      ;;=
 +89      ;;^DD(.4012,0,"UP")
 +90      ;;=.401
 +91      ;;^DD(.4012,.01,0)
 +92      ;;=DESCRIPTION^W^^0;1^Q
 +93      ;;^DD(.4014,0)
 +94      ;;=SORT FIELD DATA SUB-FIELD^^21^27
 +95      ;;^DD(.4014,0,"DT")
 +96      ;;=2931221
 +97      ;;^DD(.4014,0,"IX","B",.4014,.01)
 +98      ;;=
 +99      ;;^DD(.4014,0,"NM","SORT FIELD DATA")
 +100     ;;=
 +101     ;;^DD(.4014,0,"UP")
 +102     ;;=.401
 +103     ;;^DD(.4014,.01,0)
 +104     ;;=FILE OR SUBFILE NO.^MRNJ13,5^^0;1^K:+X'=X!(X>9999999.99999)!(X<0)!(X?.E1"."6N.N) X
 +105     ;;^DD(.4014,.01,1,0)
 +106     ;;=^.1
 +107     ;;^DD(.4014,.01,1,1,0)
 +108     ;;=.4014^B
 +109     ;;^DD(.4014,.01,1,1,1)
 +110     ;;=S ^DIBT(DA(1),2,"B",$E(X,1,30),DA)=""
 +111     ;;^DD(.4014,.01,1,1,2)
 +112     ;;=K ^DIBT(DA(1),2,"B",$E(X,1,30),DA)
 +113     ;;^DD(.4014,.01,3)
 +114     ;;=Type a Number between 0 and 9999999.99999, 5 Decimal Digits.  File or subfile number on which sort field resides.
 +115     ;;^DD(.4014,.01,21,0)
 +116     ;;=^^3^3^2930125^^
 +117     ;;^DD(.4014,.01,21,1,0)
 +118     ;;=This is the number of the file or subfile on which the sort field
 +119     ;;^DD(.4014,.01,21,2,0)
 +120     ;;=resides.  It is created automatically during the SORT FIELDS dialogue
 +121     ;;^DD(.4014,.01,21,3,0)
 +122     ;;=with the user in the sort/print option.
 +123     ;;^DD(.4014,.01,23,0)
 +124     ;;=^^1^1^2930125^^
 +125     ;;^DD(.4014,.01,23,1,0)
 +126     ;;=This number is automatically assigned by the print routine DIP.
 +127     ;;^DD(.4014,.01,"DT")
 +128     ;;=2930125
 +129     ;;^DD(.4014,2,0)
 +130     ;;=FIELD NO.^NJ13,5^^0;2^K:+X'=X!(X>9999999.99999)!(X<0)!(X?.E1"."6N.N) X
 +131     ;;^DD(.4014,2,3)
 +132     ;;=Type a Number between 0 and 9999999.99999, 5 Decimal Digits.  Sort field number, except for pointers, variable pointers and computed fields.
 +133     ;;^DD(.4014,2,21,0)
 +134     ;;=^^4^4^2930125^
 +135     ;;^DD(.4014,2,21,1,0)
 +136     ;;=On most sort fields, this piece will contain the field number.  If sorting
 +137     ;;^DD(.4014,2,21,2,0)
 +138     ;;=on a pointer, variable pointer or computed field, the piece will be null.
 +139     ;;^DD(.4014,2,21,3,0)
 +140     ;;=If sorting on the record number (NUMBER or .001), the piece will contain
 +141     ;;^DD(.4014,2,21,4,0)
 +142     ;;=a 0.
 +143     ;;^DD(.4014,2,23,0)
 +144     ;;=^^1^1^2930125^
 +145     ;;^DD(.4014,2,23,1,0)
 +146     ;;=Created by FileMan during the print option (in the DIP* routines).
 +147     ;;^DD(.4014,2,"DT")
 +148     ;;=2930125
 +149     ;;^DD(.4014,3,0)
 +150     ;;=FIELD NAME^F^^0;3^K:$L(X)>100!($L(X)<1) X
 +151     ;;^DD(.4014,3,3)
 +152     ;;=Answer must be 1-100 characters in length.
 +153     ;;^DD(.4014,3,21,0)
 +154     ;;=^^2^2^2930125^
 +155     ;;^DD(.4014,3,21,1,0)
 +156     ;;=This piece contains the sort field name, or the user entry if sorting by
 +157     ;;^DD(.4014,3,21,2,0)
 +158     ;;=an on-the-fly computed field.
 +159     ;;^DD(.4014,3,23,0)
 +160     ;;=^^1^1^2930125^
 +161     ;;^DD(.4014,3,23,1,0)
 +162     ;;=Created by FileMan during the print option (DIP* routines).
 +163     ;;^DD(.4014,3,"DT")
 +164     ;;=2930125
 +165     ;;^DD(.4014,4,0)
 +166     ;;=SORT QUALIFIERS BEFORE FIELD^F^^0;4^K:$L(X)>20!($L(X)<1) X
 +167     ;;^DD(.4014,4,3)
 +168     ;;=Answer must be 1-20 characters in length.  Sort qualifiers that normally precede the field number in the user dialogue (like !,@,#,+)
 +169     ;;^DD(.4014,4,21,0)
 +170     ;;=^^5^5^2930125^^^
 +171     ;;^DD(.4014,4,21,1,0)
 +172     ;;=This contains all of the sort qualifiers that normally precede the field
 +173     ;;^DD(.4014,4,21,2,0)
 +174     ;;=number in the user dialogue during the sort option.  It includes things
 +175     ;;^DD(.4014,4,21,3,0)
 +176     ;;=like # (Page break when sort value changes), @ (suppress printing of
 +177     ;;^DD(.4014,4,21,4,0)
 +178     ;;=subheader).  These qualifiers are listed out with no delimiters, as they
 +179     ;;^DD(.4014,4,21,5,0)
 +180     ;;=are found during the user dialogue.  (So you might see something like #@).