0

After consuming HL7 v2 files I am trying to marshal them into HAPI HL7 objects. The route sample would be:

from("file:C:\\routes\\in").unmarshal(new HL7DataFormat()).log("Success!");

Unfortunately I get the Exception:

ca.uhn.hl7v2.parser.EncodingNotSupportedException: Determine encoding for message. The following is the first 50 chars of the message for reference, although this may not be where the issue is: MSH|^~\&|...

I found that each message whish is parsed has \u000B symbol in the front, this causes the parser fail to find "MSH" header.

Of cource, I can fix it with simple string operation, like:

from("file:C:\\routes\\in")
            .convertBodyTo(String.class)
            .transform().simple("${in.body.trim()}")
            .unmarshal(new HL7DataFormat())
            .log("Success!");

But it seems to me that this is not the best solution. I've found, that if the MLLP protocol is used, the same symbol is in the front of the message, and HL7 codec should handle it. http://camel.apache.org/hl7.html

The question: Is it possible to use something like HL7Codec for File or FTP component to handle conversion to string/parsing?

Dagaz
  • 353
  • 4
  • 15
  • **1** outside ASCII and Linux environments HL7 v2 messages are **binary format** not text format so don't apply text functions on them **2** the MLLP wrapper should be already handled by the network layer. The network layer uses it to determine where messages start and end. So it should be stripped off for your on-disk format already there. If not then fix your network layer – xmojmr Jun 12 '14 at 05:51
  • But I do not use MLLP protocol for transport. I am using File/FTP as a transport protocol. I would like to apply HL7Codec to the File/FTP components. Is this possible? – Dagaz Jun 12 '14 at 07:32
  • **1** There is some on-disk file encoding mentioned in the [HL7 v2 specifications](http://www.hl7.org/implement/standards/product_brief.cfm?product_id=185) but I don't know where. **2** I don't know anything about what Apache Camel can/cannot do. Perhaps official [Camel support forum](http://camel.apache.org/support.html) is better place to ask **3** removing a byte from file before further processing should not be a big engineering problem in any programming language – xmojmr Jun 12 '14 at 09:39
  • Good point. Probably Camel support forum is better place to ask. Thaks! – Dagaz Jun 12 '14 at 10:03

1 Answers1

0

\u000B is the start byte (marker) of the standard HL7 message Minimal Lower Layer Protocol. The message should then normally end with the bytes \u001C and \u000D (end marker).

Although you can discuss the need of MLLP on files, you should be able to get a pure HL7 message string with the HL7MLLPCodec Class according the documentation of Apache Camel

sqlab
  • 6,412
  • 1
  • 14
  • 29