[英]Parsing an HL7 without a priori messageType knowledge
In NHapi, how can we parse a message if we don't know what messageType (MSH#9) it is? 在NHapi中,如果我们不知道它是什么messageType(MSH#9),我们如何解析消息?
var parser = new NHapi.Base.Parser.PipeParser();
IMessage parsedMessage = parser.Parse(SampleMessage);
parsedMessage
is a NHapi.Base.Model.GenericMessage.V25
at runtime and I can't seem to read in the MSH header to read the MessageType field and then re-parse(?) the message as that message type. parsedMessage
在运行时是一个NHapi.Base.Model.GenericMessage.V25
,我似乎无法在MSH头中读取读取MessageType字段,然后将消息重新解析(?)为该消息类型。
I'm frustrated by the lack of documentation and examples. 由于缺乏文档和示例,我感到很沮丧。 Perhaps I'm very far off base.
也许我离基地很远。 I am very new to HL7, but I thought I was doing well understanding the HL7 spec until I tried using NHapi.
我是HL7的新手,但在我尝试使用NHapi之前,我认为我对HL7规范的理解很好。
parsedMessage.GetStructureName()
will give you the message type and trigger event. parsedMessage.GetStructureName()
将为您提供消息类型和触发器事件。 parser.Encode(parsedMessage)
will give you the message back in pipe-delimited format. parser.Encode(parsedMessage)
将以管道分隔格式返回消息。
The following code shows how to get the message type and also how to get the original message in pipe format. 以下代码显示了如何获取消息类型以及如何以管道格式获取原始消息。
public static String ParseMessage(String message)
{
var parser = new NHapi.Base.Parser.PipeParser();
var parsedMessage = parser.Parse(message);
//Get the message type and trigger event
var msgType = parsedMessage.GetStructureName();
//Get the message in raw, pipe-delimited format
var pipeDelimitedMessage = parser.Encode(parsedMessage);
return pipeDelimitedMessage;
}
Some good starter code can be found at the hapi examples site . 一些好的入门代码可以在hapi示例站点找到 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.