0

In regards to HL7 pipe-delimited data, how exactly do the encoding characters (|^~\&) work?

Is the following example of fields, field repetitions, components and their sub-components correct when parsing raw HL7 data?

PID|1||||||||||||1234567890^somedata&moredata^[email protected]~0987654321 Field (|): PID13 = 1234567890^somedata&moredata^[email protected]~0987654321 Field repetition (~): PID13~1 = 1234567890^somedata&moredata^[email protected] PID13~2 = 0987654321 Component (^): PID13.1 = 1234567890 PID13.2 = somedata&moredata PID13.3 = [email protected] Sub-component (&): PID13.2.1 = somedata PID13.2.2 = moredata PID13.3.1 = [email protected] PID13.3.2 = 
7
  • 2
    Would we agree with what? Is what the consensus? This question appears to be polling for opinions. Commented Mar 19, 2018 at 22:17
  • HL7 is considered a standard in the healthcare industry, and yet not everyone follows it to the T. My question is geared towards those with experience with the HL7 standard, where it is known that formats and data is handled differently across different systems. This is not just a matter of opinion, I'm simply asking what have others come across in regards to these separators. What seems to be "standard" for such characters. Commented Mar 20, 2018 at 13:07
  • If every answer is equally valid, then this question is off-topic for Stack Overflow. help center Commented Mar 20, 2018 at 13:12
  • That's not necessarily true though. Some answers would outweigh others based on use-case and frequency used. 90% of the industry might be following one way while 10% do not, that difference if it exists is significant. I believe there is only one standard protocol to follow with field separators but I've heard countering statements and am interested in seeing what the community thinks. Commented Mar 20, 2018 at 13:28
  • 1
    @daveloyall In light that the question was edited so it isn't polling for opinions, I've removed my downvote. My downvote was never about the question not being "legit". Commented May 30, 2018 at 21:22

1 Answer 1

3

Without understanding the left-hand side structure you're trying to assign stuff to, it's impossible to tell you if you're doing it right.

There is however one right way to parse the segment/field in question.

Here's a link to the specs I reference here

From section 2.5.3 of the HL7v2.7 Standard:

Each field is assigned a data type that defines the value domain of the field – the possible values that it may take.

If you pull up section 3.4.2.13 (PID-13) you'll see a breakdown of each component and subcomponent. Technically, the meaning of subcomponents and components can vary by field, but mostly they just vary by data type.

In your example, you don't treat the repetitions as separate instances of XTN data types. I would re-write using array syntax as so:

Field repetition (~): PID13[0] = 1234567890^somedata&moredata^[email protected] PID13[1] = 0987654321 Component (^): PID13[0].1 = 1234567890 PID13[0].2 = somedata&moredata PID13[0].3 = [email protected] Sub-component (&): PID13[0].2.1 = somedata PID13[0].2.2 = moredata 

The psuedo-code in the same specification section 2.6.1 may be helpful as well

foreach occurrence in ( occurrences_of( field ) ) { construct_occurrence( occurrence ); if not last ( populated occurrence ) insert repetition_separator; /* e.g., ~ */ } 

It's important to remember that those different subcomponents have different meaning because PID-13 is a XTN type.

PID-13 is a problematic example because historically, the order of PID-13 mattered. The first repetition was "primary". Over time the field has also become the landing place for e-mail addresses, pager numbers, etc. So good luck trying to make sense out of real-world data.

Sign up to request clarification or add additional context in comments.

1 Comment

This is exactly what I needed, thank you! Left-hand structure I am assigning to in my example is simply for identification purposes, as in identifying each field/component/sub-components and field repeaters. However, your example is much clearer :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.