X12 HIPAA 999 Specification
X12 999 specification is available at:
X12 HIPAA 999 Sample File
X12 999 sample file is available at:
EDI Tools for .NET C# Examples
The example below is part of the EDI Tools for .NET C# Code Examples.
The code is also available on GitHub
Additional operations for X12 999
- Parse X12 files
- Generate X12 files
- Validate X12 messages
- Generate X12 acknowledgments
- Save X12 files to DB
- Convert between X12 and JSON
- Convert between X12 and XML
How to generate X12 999 with EDI Tools for .NET
var edi = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\X12\PurchaseOrderInvalid.txt");
var processedMessages = new ConcurrentBag();
var settings = new AckSettings
{
AckHandler = (s, a) =>
{
var tsTa1 = a.Message as TSTA1;
var ts997 = a.Message as TS997;
if (tsTa1 != null)
{
// a.Message is TA1
}
if (ts997 != null)
{
var allFailed = ts997.AK2Loop1.Where(f => f.AK5.TransactionSetAcknowledgmentCode_01 == "R").ToList();
var allAccepted = ts997.AK2Loop1.Where(f => f.AK5.TransactionSetAcknowledgmentCode_01 == "A").ToList();
foreach (var failedMessage in allFailed)
{
if (processedMessages.Contains(failedMessage.AK2.TransactionSetControlNumber_02))
{
failedMessage.AK5.TransactionSetAcknowledgmentCode_01 = "E";
}
}
var ack = AckBuilders.BuildAck(a.InterchangeHeader, a.GroupHeader, ts997, AckVersion.X12_997);
Debug.Write(ack);
}
},
MessageHandler = (s, a) =>
{
if (a.ErrorContext.HasErrors)
{
// In case we decide to process the message anyway, preserve the control number
processedMessages.Add(a.Message.ErrorContext.ControlNumber);
// Process the invalid message
// Reject message
// Log/report it
// Inspect MessageErrorContext for the validation errors
var errors = a.ErrorContext.Flatten();
Debug.WriteLine("Message {0} with control number {1} is invalid with errors:", a.ErrorContext.Name, a.ErrorContext.ControlNumber);
foreach (var error in errors)
{
Debug.WriteLine(error);
}
}
},
AckVersion = AckVersion.X12_997,
// Turn off AK2 for valid messages to reduce size
GenerateForValidMessages = false
};
using (var ackMan = new Plugins.Acknowledgments.X12.AckMan(settings))
{
using (var ediReader = new X12Reader(edi, "EdiFabric.Examples.X12.Templates.V4010"))
{
while (ediReader.Read())
ackMan.Publish(ediReader.Item);
}
}
Comments
0 comments
Please sign in to leave a comment.