In NHapi, how can we parse a message if we don't know what messageType (MSH#9) it is?
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.
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.
parsedMessage.GetStructureName()
will give you the message type and trigger event.parser.Encode(parsedMessage)
will give you the message back in pipe-delimited format.The following code shows how to get the message type and also how to get the original message in pipe format.
Some good starter code can be found at the hapi examples site.