nHapiNET / nHapi

nHapi is the .Net port of the original Java project HAPI.
Mozilla Public License 2.0
277 stars 156 forks source link

HL7 2.5 QBP^Q22^QBP_Q21 maximum repetitions is only 1 reps for Segment QPD #276

Closed giannisptr closed 2 years ago

giannisptr commented 2 years ago

When sending an ITI-21 PDQ message with multiple query parameters in QPD-3 field i receive the following exception when parsing the message: Can't get repetition 2 from field 3 - maximum repetitions is only 1 reps.: Segment: QPD (rep 0) Field #3

Base on PDQ definition this should be allowed

Sample code

PipeParser parserWithoutValidation = new PipeParser();
IMessage hl7Message = parserWithoutValidation.Parse(message);

Sample HL7

MSH|^~\&|PatientManager|IHE|ICS|FORTH|20220215130712||QBP^Q22^QBP_Q21|5b2e49550924456db9e0844e35348144|P|2.5||||||UNICODE UTF-8
QPD|IHE PDQ Query|20220215130712|@PID.5.2^fname~@PID.7.1^20220202~@PID.8^M|||||^^^IHEFACILITY&1.3.6.1.4.1.21367.3000.1.6&ISO~^^^IHEBLUE&1.3.6.1.4.1.21367.13.20.3000&ISO
RCP|I

Versions nHapi version: v2.5.0.6 NHapiTools version: v1.11.0.5

How can i solve this problem?

milkshakeuk commented 2 years ago

@giannisptr having had a quick look at the hl7 V2.5 specification QPD-3 is not repeatable.

milkshakeuk commented 2 years ago

@giannisptr you can have multiple QPD segments though, have you tried that?

milkshakeuk commented 2 years ago

@giannisptr this could still be a valid issue, the hapi test panel seems to parse the message correctly.

milkshakeuk commented 2 years ago

@giannisptr looks like this is the line causing your issue: https://github.com/nHapiNET/nHapi/blob/fc250def8435142d9e79043c47faaa090b7c4018/src/NHapi.Base/Model/AbstractSegment.cs#L170

seems that hapi doesn't do this max repetition check, I tested removing this check in nHapi and it seemed to work fine.

Looks like hapi had the max repetition check in the code base but commented out until this commit on 6 Aug 2012 when they just removed the commented out max repetition check altogether.

milkshakeuk commented 2 years ago

@giannisptr this can be fixed but will require a new version of nhapi which will require you to update past v2.5.0.6.

giannisptr commented 2 years ago

Yes no problem i can go to the lattest version. So are you going to provide an updated version? I will get it from nuget?

milkshakeuk commented 2 years ago

@giannisptr before I go ahead with this, I am going to do some more digging around QPD-3 as I'm still not convinced its repeatable.

giannisptr commented 2 years ago

Based on the IHE TF (https://www.ihe.net/uploadedFiles/Documents/ITI/IHE_ITI_TF_Rev10.0_Vol2a_FT_2013-09-27.pdf) it should be. It defines for ITI-21 transaction that: "Field QPD-3-Demographics Fields consists of one or more repetitions, each of which contains two components that together contain the name and value of a distinct parameter to the query. "

milkshakeuk commented 2 years ago

@giannisptr I have included a unit test in the PR, I may still go ahead just to be in line with hapi, but I'm just reaching out to some people to see if according to the hl7 v2.5 specification its repeatable.

I checked the specification pdf but it's not clear.

milkshakeuk commented 2 years ago

@giannisptr in case you're interested on the outcome of my digging you should be able to see it here: https://chat.fhir.org/#narrow/stream/229447-V2

giannisptr commented 2 years ago

I have evaluated this also with IHE tools and it is successful with repeatable QPD-3 as you can see here: https://gazelle.ihe.net/EVSClient/hl7v2Result.seam?&oid=1.3.6.1.4.1.12559.11.1.2.1.4.1664549

milkshakeuk commented 2 years ago

@giannisptr I have published the changes in nuget package v3.1.1, when you update you might have to fix some namespaces specifically the validation namespace which has been case corrected.

There is a newer version of nhapitools also which supports nhapi v3.X.

https://www.nuget.org/packages/nhapi/3.1.1

giannisptr commented 2 years ago

ok thank you very much