What kind of validation customers need to care about?

Post author
Omar Salas

I create an invalid EDI x12 file with a functional group for 837p (HC code) and include a 270, but when i call IsValid i would expect 270 file was invalid due to is inside a functional group invalid for it, but nothing happened, is this behavior OK?, how could i check this?

Comments

3 comments

  • Comment author
    Admin

    IsValid validates only the transaction itself and not the transaction as part of a functional group or interchange. BTW the demo does not support validation at all, you need to refer to the SDK for validation with 837P only.

    This type of validation is applied with AckMan when generating 997 or 999 acknowledgments (see Acknowledgment samples in the SDK).

    You can always check if the parsed transaction types are the same:

     var items = new List<EdiMessage>();
    using (var ediReader = new X12Reader(File.OpenRead("yourfile.txt"), LoadFactory))
    {
    while (ediReader.Read())
    {
    if (ediReader.Item is EdiMessage msg)
    items.Add(msg);
    }
    }
    var areAll837P = items.All(t => t.GetType() == typeof(TS837));
    0
  • Comment author
    Omar Salas

    What happend if i have two well defined functional group, one HC (837p) and other for 270, the All query will return False cauze there are 270 EdiMessage

    0
  • Comment author
    Admin
    • Edited

    You can rework it to add items to separate groups and then execute the All query against them rather than all the items, something like this:

     var items = new List<Tuple<GS, EdiMessage>>();
    using (var ediReader = new X12Reader(File.OpenRead("yourfile.txt"), LoadFactory)))
    {
    while(ediReader.Read())
    {
    if (ediReader.Item is EdiMessage msg)
    items.Add(new Tuple<GS, EdiMessage>(ediReader.CurrentGroupHeader, msg));
    }
    }

    var fGroups = items.GroupBy(i => i.Item1.GroupControlNumber_6);
    foreach(var fGroup in fGroups)
    {
    var areAll837P = fGroup.All(t => t.Item2.GetType() == typeof(TS837));
    }
    0

Please sign in to leave a comment.