PipeParser无法解析HL7消息

问题描述

我正在通过TCP套接字监听传入的HL7消息。为了进行调试,我使用工具 7Edit 将HL7消息发送到我的应用程序。

所以我要发送的是此示例消息

MSH|^~\&|KISsystem|ZTM|NIDAklinikserver|HL7Connector|201902271130||ADT^A01|68371142|P|2.3
EVN|A01|201902271130|201902271130
PID|1||677789||Aubertinó^Letizia||19740731|F||
PV1|1|O|||||||||||||||||456456456
IN1|1||999567890|gematik Musterkasse1GKV||||||||||||Prof. Dr.Aubertinó^Letizia||19740731|||||||||||201902271101|||||||X110173919

我的TcpListener实例使用此代码侦听传入的消息

    public async Task Listen()
    {
        try
        {
            while (true)
            {
                TcpClient tcpClient = await tcpListener.AcceptTcpClientAsync();
                
                // fetch message stream
                NetworkStream tcpClientStream = tcpClient.GetStream();
                
                // create reader instance
                using StreamReader streamReader = new StreamReader(tcpClientStream);
                
                // read message stream at once
                string messageText = await streamReader.ReadToEndAsync();
                
                // create new HL7 message parser instance
                PipeParser pipeParser = new PipeParser();
                
                // parse that string to a HL7 message
                IMessage hl7Message = pipeParser.Parse(messageText);
            }
        }
        catch (Exception exception)
        {
            // ... error handling ...
        }
    }

不幸的是,HL7解析器抛出以下异常

无法解析邮件开头 MSH | ^〜&| KISsystem | ZTM | NIDAklinikserver | HL7Connec

enter image description here

向应用程序发送消息时,似乎正确提取了消息,因此messageText保留了消息字符串。

我从Visual Studio Locals 标签获取了值:

"\vMSH|^~\\&|KISsystem|ZTM|NIDAklinikserver|HL7Connector|201902271130||ADT^A01|68371142|P|2.3\rEVN|A01|201902271130|201902271130\rPID|1||677789||Aubertin�^Letizia||19740731|F||\rPV1|1|O|||||||||||||||||456456456\rIN1|1||999567890|gematik Musterkasse1GKV||||||||||||Prof. Dr.Aubertin�^Letizia||19740731|||||||||||201902271101|||||||X110173919\u001c\r"

检查时,您可以看到此

enter image description here

如您所见,该字符串中包含一些无效字符。在检查窗口中,您可以在开头看到一个无效字符。字符串本身包含一些转义字符。我认为这就是pipeParser.Parse(messageText)引发异常的原因。

有人知道这里有什么问题/如何解决吗?

预先感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...