As of version 44 the receivers below have a new feature/section: "Preprocess Received Bytes".
File
FTP
HTTP Listener
Network Share
Web Service
Socket
Secure Socket
This new section can be used to execute a script prior to the message being added to the channels inbound queue.
If an HL7 message has misplaced new lines character in the middle of fields, you can look for a new line that is not followed by a starting segment. These new lines could be be replaced by a space with the following:
bytesOut = new java.lang.String(bytesIn, 'UTF-8').replaceAll('\\n(?![A-Z0-9]{3}\\|)', ' ').getBytes();
Note that in the screenshot above this section has been enabled. In this example the script will ONLY run when the incoming message fails to be parsed into the channels message model type. Alternatively the script can be configured to run for all messages.
The following is a description of the bound variables available in the preprocess script
bytesIn - The original bytes received. Used to access the original bytes modification to this variable will be ignored by the channel.
bytesOut - The modified bytes that will be used by the channel. Note if set to null the message will be discarded. bytesOut can be set to bytesIn if no changes are needed.
responseBytes - Applicable only to receivers that send acknowledgements. Used to send a response to the sending system when bytesOut = null. Otherwise responses are sent based on the channel configuration.
See this question for an example of how to fix HL7 parse exceptions caused when a new line character is embedded in an HL7 field:
See also: