How to split edi message properly when the splitted parts lose (null) other segments distinct of loops.

Comments

5 comments

  • Avatar
    Admin

    Splitting is the process of breaking the original EDI document into repeating ranges of segments. This way you are able to translate EDI files of any size. Each part (IsPart =true) is that same range you need splitting by. 

    When splitting, the last EdiMessage contains all of the original segments but the repeating loops that you split by. Each repetition of the loops is returned as a new EdiMessage with only the current loop populated.

    AckMan allows message parts to be published to it, just like any other transaction sequence, and it will correctly assemble the parts and validate them as a whole. AckMan will raise a 997 or 999 for the whole message, and not the individual parts. You can then inspect the relevant segment and determine if it was valid or not.

    Admin

    0
    Comment actions Permalink
  • Avatar
    Omar Salas

    Thanks for clarification, but the fact is how could i split by loop and create the complete message by myself including ISA and other require Segments, because when i get the splitted group as you said the other component is null even when AckMan has the power of validating as a whole it could be good treating the message as a valid message on itself.

    0
    Comment actions Permalink
  • Avatar
    Admin

    Well, if you need the message as a whole then why do you split it ? Splitting and then reconstructing defies the purpose of spitting in the first place.

    As I said, if you need to validate the different parts then publish them to AckMan - it will correctly validate the message as a whole.

    If, for whatever reason, you need to split a message and then reconstruct it, the problem can be paraphrased as - How to merge multiple instances of the same class into one instance ? I'm sure there are hundreds of examples if you google it. The nice thing here is that there is a single collection that is being broken down and you know exactly which one. A pseudo code for this:

     List<EdiItem> ediItems =new List<EdiItem>();
    using (var ediReader = new X12Reader(ediStream, HipaaFactory))
    {
    var loops = new List<Loop_2000A>();
    while (ediReader.Read())
    {
    var msg = ediReader.Item as TS837;
    if (msg != null)
    {
    if (msg.IsPart)
    {
    // Aggregate all parts
    loops.AddRange(msg.Loop_2000A);
    }
    else
    {
    // Reapply all parts to the original message
    msg.Loop_2000A.AddRange(loops);
    ediItems.Add(msg);
    loops.Clear();
    }
    }
    else
    {
    // Add ISA, GS, etc.
    ediItems.Add(ediReader.Item);
    }
    }
    }
    // Here ediItems contains all headers\trailers and the combined messages
    0
    Comment actions Permalink
  • Avatar
    Omar Salas

    Thanks for your quick answer but the case, is i have batch Claims and want to split on files only one claim per st and generate a valid EDI file, and have no mandatory data on splitting by loops.

    0
    Comment actions Permalink
  • Avatar
    Admin

    Well, this is a similar approach and because outside of the 2000 loop there are only 4 other properties. You just assign them to each part from the last:

     List<EdiItem> ediItems = new List<EdiItem>();
    using (var ediReader = new X12Reader(ediStream, HipaaFactory))
    {
    var parts = new List<TS837>();
    while (ediReader.Read())
    {
    var msg = ediReader.Item as TS837;
    if (msg != null)
    {
    if (msg.IsPart)
    {
    parts.Add(msg);
    }
    else
    {
    foreach(var part in parts)
    {
    part.All_NM1 = msg.All_NM1;
    part.BHT_BeginningofHierarchicalTransaction = msg.BHT_BeginningofHierarchicalTransaction;
    part.SE = msg.SE;
    part.ST = msg.ST;
    part.ST.TransactionSetControlNumber_02 = "assign new control number";

    ediItems.Add(part);
    }

    ediItems.Add(msg);
    parts.Clear();
    }
    }
    else
    {
    // Add ISA, GS, etc.
    ediItems.Add(ediReader.Item);
    }
    }
    }
    0
    Comment actions Permalink

Please sign in to leave a comment.