hl7nhapi

NHapi incomplete messages encoded partially and without error?


In NHapi, I'm attempting to create a pipe-encoded ORM. When I parser.Encode() my populated message, only some of the segments are printed. Notably among the missing segments is MSH!

I don't know for sure, but I believe that the encoder is skipping segments that it considers to be incomplete.

I have given values for the required fields MSH-1, 2, 9, 10, 11, and 12, but I cannot get the MSH segment to encode.

If I am right that the MSH segment's incompleteness is causing this omission: Is there any way to have the PipeEncoder or some other validator throw exceptions if messages are not complete?

And: In any case, why is the MSH segment not encoding?


Solution

  • Perhaps this could help someone, so I won't just close it. I was printing these encoded messages to the Console and seeing only two segments, and jumbled at that, though I wasn't familiar enough with HL7 to realize.

    What was happening was that NHapi's '\r' single newline character (rather than "\r\n") was merely overwriting each line with the next segment. My PID segment was long enough to wrap, getting me to the second line and the two segments.

    That was dumb.