Order Elements Even if They Aren't Present

I've come across the same situation twice, so time to blog about it.  I have an EDI segment that can take 4 line procedure codes.  The back end system contains the 4 procedure codes, but it is not guaranteed which order they will be populated or if they will be populated at all.  For example procedure code 1 could be NULL but 2, 3, and 4 could be present.  The EDI segment requires that procedure codes be populated starting at element 1.

I created an inline C# that would accommodate this scenario.  Throw all your procedure modifiers into the scripting functoid and adjust the int_ProcedureModifierToReturn to the one you're needing and away you go.

public string get_2400_SV101_2(string LINE_PROC_MODIFIER1, string LINE_PROC_MODIFIER2, string LINE_PROC_MODIFIER3, string LINE_PROC_MODIFIER4) { int int_ProcedureModifierToReturn = 0; //All Data will be in the form of example: BH*A2*20041201^BI*A2*20041201-20041215 string[] arry_ProcedureModifiers; string str_ProdedureModifiers = LINE_PROC_MODIFIER1 + "^" + LINE_PROC_MODIFIER2 + "^" + LINE_PROC_MODIFIER3 + "^" + LINE_PROC_MODIFIER4; //Split the LINE_PROC_MODFIERS into an array arry_ProcedureModifiers = str_ProdedureModifiers.Split('^'); //Sort the Array to get like Qualifiers together System.Array.Sort(arry_ProcedureModifiers); //Reverse the array order to get the blank records to the end System.Array.Reverse(arry_ProcedureModifiers); //Return the element if it exists if (arry_ProcedureModifiers[int_ProcedureModifierToReturn].Length > 0) { return arry_ProcedureModifiers[int_ProcedureModifierToReturn]; } else { return ""; } }

posted @ Wednesday, January 28, 2009 11:12 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 8 and 6 and type the answer here:
 

Live Comment Preview:

 
«March»
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910