python-hl7 icon indicating copy to clipboard operation
python-hl7 copied to clipboard

Defaulting to standard delimiters is surprising

Open kvudata opened this issue 1 year ago • 1 comments

https://github.com/johnpaulett/python-hl7/blob/6d85f25d678e366d2617690d4ee1216bb8027db1/hl7/parser.py#L351-LL370

  • The current parser behavior is to fill in any missing MSH-2 delimiters with the standard ones

According to the HL7 2.3 spec though

At any given site, the subset of the possible delimiters may be limited by negotiations between applications. This implies that the receiving applications will use the agreed upon delimiters, as they appear in the Message Header segment (MSH), to parse the message.

So it should be valid to use less delimiters. The issue is that by assuming the standard delimiters, python-hl7 will incorrectly split fields when parsing if a standard delimiter character (such as "&") is used in the content.

kvudata avatar May 17 '24 16:05 kvudata

I think the ideal behavior would be to raise an error if there aren't 4 delimiters, and provide a way for callers to specify the delimiters to fallback to (so they can opt in to the existing behavior if they want).

kvudata avatar May 17 '24 16:05 kvudata