nHapiNET/nHapi

HL7 2.5.1: Failure to parse ORDER group repetitions in OML_O33

Opened this issue · 5 comments

Describe the bug
When using the PipeParser to parse an OML_O33 message with ORDER group repetitions, the repetitions are not in the parsed message structure. Only the first ORDER group is present.

To Reproduce

var parser = new PipeParser();
var parsedMessage = parser.Parse( /* sample message below */ ) as NHapi.Model.V251.Message.OML_O33;
var orderReps = orderMessage.SPECIMENs.ElementAt(0).ORDERRepetitionsUsed;

Expected behaviour
Expect that orderReps is 2, and that both ORC and OBR segments can be queried.

Actual behaviour
orderReps is 1, and only the first ORC and OBR segments exist.

Sample HL7

MSH|^~\&|||||20210921154451+1000||OML^O33^OML_O33|20210921154451|P|2.5.1|||NE|AL||UNICODE UTF-8|||LAB-28^IHE
SPM|1|||SER^Serum^HL70487|||||||P^Patient^HL70369
SAC|||Found_TT1_TT2_SER_098
ORC|NW||||||||20210921154451
OBR|1|AWOS_ID_Found_TT1_TT2_SER_098_0||TT1^Test Type 1^99000
ORC|NW||||||||20210921154451
OBR|2|AWOS_ID_Found_TT1_TT2_SER_098_1||TT2^Test Type 2^99000

Environmental Details (please complete the following information):

  • OS: Windows 10.0.19043
  • Target Framework: netcoreapp3.1
  • HL7 Version: 2.5.1
  • nHapi Version: 3.0.4

Additional context
It looks like this problem also existed for the Java implementation (https://sourceforge.net/p/nhapi/discussion/569648/thread/3e0c39b1/).

@iangralinski-invetech thank you for this, I will look into this as soon as I can.

@iangralinski-invetech I think this and #65 are related.

It seems that this is due to the message structure and ambiguous choice of where nhapi should put a segment, the java hapi library uses a configuration option NonGreedyMode to deal with these messages which have ambiguous message structures.

See hapi docs here.

We could look to bring that configuration into hapi. I don't suppose you are interested or have time to contribute to nhapi and maybe pick this feature up?

@milkshakeuk I may have some time to pick this feature up in November, but may get delayed until December/January.

@milkshakeuk I have started looking into fixing this issue.

Do I need permissions to be able to push changes to this repo? Or is there a different process for creating pull requests?

@iangralinski-invetech hi, same process as most repos i.e. fork the repo then create a pull request.

I think we should follow the pattern of newtonsoft or the new System.Text.JSON as an example in terms of how nhapi should do "settings" or "options".

Then over time we can add more options nhapi doesn't have which hapi does.

There can be global (default) settings and ones you choose at Parse time for circumstances like the one you mentioned.