I'm receiving HL7 messages via TCP connection. Those messages will always be of type ADT. I'm using Kestrel to listen for thise messages and the NHAPI package to deal with them. I took David Fowler's Kestrel sample code to setup a TCP listener. So based on this sample code
internal class HL7Listener : ConnectionHandler
{
public override async Task OnConnectedAsync(ConnectionContext connection)
{
try
{
// handle the incoming message
}
catch (Exception exception)
{
// handle exceptions
}
finally
{
ACK acknowledgement = new ACK(); // create an ACK message
PipeParser pipeParser = new PipeParser();
string ackMessage = pipeParser.Encode(acknowledgement); // produces => MSH|^~\&|||||||ACK|||2.3
byte[] ackMessageBytes = Encoding.UTF8.GetBytes(ackMessage);
await connection.Transport.Output.WriteAsync(ackMessageBytes); // send the ACK
}
}
}
I'm using the tool 7Edit to send HL7 messages to my application. The echo sample from the repository (link above) works fine. The echo sample code produces a log like this
But when using my code I get this error
So I think I don't convert the ACK message correctly. Any ideas how to fix this?