Search code examples
javahl7hapi

HAPI sorts the segments


We are creating a HL7 XML structure and are using the HAPI Library to output it as a HL7 V2 file. But unfortunately, HAPI is reordering (sorts) the segments.

Because I have MFE and ZBP always repeating:

MSH|...
MFI|...
MFE|...
ZBP|...
MFE|...
ZBP|...
MFE|...
ZBP|...

But HAPI re-orders them to

MSH|...
MFI|...
MFE|...
MFE|...
MFE|...
ZBP|...
ZBP|...
ZBP|...

It hapens also with the HAPI TestPanel. Example:

MSH|^~\&|||||20121011140541.133+0200||MFN^M01|1|T|2.6
MFI|Partners|^Sap|UIZ|||NE
MFE|MUP|||0000040001
ZBP|0000040001|100|Something||||3000|Bern||||
MFE|MUP|||0000040002
ZBP|0000040002|100|Otherthing||||8000|Zurich||||

How can I disable the re-ordering with HAPI?


Solution

  • Changed ADT^01 to the correct MFN^M01 and using the version 2.3 it works (in the tester also):

    MSH|^~\&|||||20121011140541.133+0200||MFN^M01|1|T|2.3
    MFI|Partners|^Sap|UIZ|||NE
    MFE|MUP|||0000040001
    ZBP|0000040001|100|Something||||3000|Bern||||
    MFE|MUP|||0000040002
    ZBP|0000040002|100|Otherthing||||8000|Zurich||||
    

    Strange, but any other version does not work.