Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are segment field idx numbers supposed to match HL7 field seq numbers? #123

Open
Obversity opened this issue Apr 5, 2023 · 3 comments · May be fixed by #141
Open

Are segment field idx numbers supposed to match HL7 field seq numbers? #123

Obversity opened this issue Apr 5, 2023 · 3 comments · May be fixed by #141
Labels

Comments

@Obversity
Copy link

Obversity commented Apr 5, 2023

Hi guys,

Question: does the segment field idx match up to the HL7 spec's field seq numbers? E.g. should MSH-9 (Message Type) be accessible via msg[:MSH][9]?

Background: Trying to build a tool to dynamically extract data from HL7 segments by users specifying the Segment name and the field number.

Problem: I immediately ran into problems doing that, discovering that in the MSH segment, the field with IDX = 9 isn't the Message Type field.

image

All documentation on HL7 MSH segment indicates that the Message Type should be MSH-9.

I figured maybe it was just zero-based indexing and I could offset by one, but that doesn't seem to be the case for other segments, e.g. for this OBR segment, 4 is the correct sequence for the Universal Service Identifier, and that's what's in the file I'm looking at.

image

Some clarification would be great so I can confidently use the library, thanks in advance!

@LucasMontorio
Copy link
Collaborator

LucasMontorio commented Nov 19, 2024

Hi @Obversity ,

Sorry for the late reply (I just started contributing to this repo recently), I hope this still helps.
I believe the issue you are facing here is specific to the MSH segment, on which MSH-1 has not been implemented as a proper field, despite being a required field according to the following documentation: https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.1.
This results in a offset of 1 in all the indexes of the subsequent fields.

I'm not sure of the impact yet but I believe the gem has been formatting MSH segments with this offset from day 1.
Can you confirm that the MSH segments you generated were properly formatted despite the getters behaving this way?

@LucasMontorio
Copy link
Collaborator

According to the doc, the MSH-1 field "contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters".
Hence, the gem does not have a setter for this field, which causes the offset to happen because we expect all fields to be explicitly defined via such a setter. I will fix this case ASAP

@LucasMontorio LucasMontorio linked a pull request Nov 20, 2024 that will close this issue
3 tasks
@LucasMontorio
Copy link
Collaborator

Issue fixed in the following PR: #141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants