【发布时间】:2021-01-04 05:08:57
【问题描述】:
我正在通过 TCP 连接接收 HL7 消息。这些消息将始终为 ADT 类型。我正在使用 Kestrel 来侦听这些消息,并使用 NHAPI 包来处理它们。我用David Fowler's Kestrel sample code 设置了一个 TCP 监听器。所以基于这个示例代码
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
}
}
}
我正在使用工具 7Edit 将 HL7 消息发送到我的应用程序。存储库中的回声示例(上面的链接)工作正常。 echo 示例代码会生成这样的日志
但是在使用我的代码时出现此错误
所以我认为我没有正确转换 ACK 消息。任何想法如何解决这个问题?
【问题讨论】:
-
Piped HL7 通常来自血液检测仪等设备。所以 ack 通常只有一个字符(有时带有返回)。因此,您必须阅读设备手册才能了解 ACK 使用什么。您不需要等待,这可能是您的问题。由于您没有发送另一条消息,设备可能会超时。你认为什么会让代码在等待之后继续?示例代码最后没有等待。示例代码等待读取而不是写入。