Incorrect parsing

Feb 2, 2015 at 12:23 PM
Edited Feb 2, 2015 at 12:43 PM
We have decided to use NHapi.Base library for parsing HL7 messages.
I created unitTest and receive strange result:

expected: TST|C1Data&subC1Data&subC1Data2^C2Data
actual: TST|C1Data^C2Data^subC1Data2
        public void PutField()
            string expectedMessage = @"MSH|^~\&|||||||ADT^A31|||2.3||||
            var parser = new PipeParser();
            var message = parser.Parse(expectedMessage);
            var actualMessage = PipeParser.Encode(message,  new EncodingCharacters('|', @"^~\&"));

            Assert.AreEqual(expectedMessage, actualMessage);
Is it bug or I use library incorrectly? Could you give some advise?
Feb 2, 2015 at 11:19 PM
Edited Feb 2, 2015 at 11:20 PM
In the HL7 2.3 standard, the Country code field is actually a non-repeating ID type of length 2.

It looks like you are trying to put more than what that field is specified as, and as such are getting strange results. (i.e. this field doesn't support sub components '&' or repetitions '&')

Can you first try to conform your test data against the HL7 specification, to which this parser is generated from?

Then if there are oddities with the parsing of data we can look into what problem/s there may be.
Feb 3, 2015 at 9:18 AM
Thank you for reply.

Does the lib allow validating input message against the standard? Instead of getting strange results after parsing/building message it would be more convenient to get some kind of validation exception.