As the existing GETTCP/ListenTCP NiFi processors are not supporting of Receiving and acknowlidging HL7 messages, I have created NiFi custom processor for receiving MLLP based HL7 message and sending acknowledgement. The custom processor works fine(output flow file has the same HL7 message which I sent from simulator) but when I send the received HL7 message to ExtractHL7Attributes processor I am getting error "ca.uhn.hl7v2.parser.EncodingNotSupportedException: Determine encoding for message."
From the detailed error message below I thought that the MLLP Protocol's special characters (VT and FS) wrapping the HL7 message are causing the error So I replaced those from the code with the empty value. Then sent the flow through replace text for replacing the CR carriage return with \r\n and then the flow was sent to ExtractHL7Attributes processor. Here I am getting the same error which I mentioned below, except those special characters.
I am using the Sample HL7 message for testing my custom processor I am using iNTERFACEHL7 simulator (also tried with 7Edit trial version). But the same HL7, which I sent through generate flow file is always working fine. Its extract the HL7 attributes and values.
Even after removing the special characters and set the encoding character set to UTF-8 I am getting the below error. Can someone help me on what could be the issue?
Uploaded my custom processor code and Flow:
ERROR [Timer-Driven Process Thread-4] o.a.n.p.hl7.ExtractHL7Attributes ExtractHL7Attributes[id=cd04bcf2-0166-1000-bdf4-f8edf35f2ee0] Failed to extract attributes from StandardFlowFileRecord[uuid=20c6a503-b2f8-4fe0-944c-aea8cf5be0ac,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1541774898083-1, container=default, section=1], offset=10240, length=10456],offset=0,name=45793985248400,size=10456] due to 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|^~\&|XXXX^XXXX^EUI-: 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|^~\&XXXX^XXXXEUI- 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|^~\&|XXXX^XXXX^EUI- at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:201) at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:1018) at org.apache.nifi.processors.hl7.ExtractHL7Attributes.onTrigger(ExtractHL7Attributes.java:199) at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1165) at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:203) at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.runAndReset(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
Tried the below links. But no luck.
I have removed the special characters from the starting of the message and end of the messages. But at the end of message I am getting one extra space/line. Will that cause the issue when the ExtractHL7 attribute processor process HL7?
Have you been able to solve the issue? 50% of my real HL7 messages failed by nifi's HL7 processor.
I solved most of my issues in the following two ways:
1. HAPI 2.3 doesn't handle Z segments. I found out by coping my message to HAPI test panel application https://hapifhir.github.io/hapi-hl7v2/hapi-testpanel/ and gradually remove segments from the bottom until my message becomes valid. So if your task can omit the Z-segments, you can just use a replaceText to get rid of them.
2. OBX segment 2 can't be empty. This is a common issue documented in HAPI here: