Sidebar

How can I remove the trailing carriage return from an HL7 Message

0 votes
156 views
asked Dec 7, 2023 by mohammed-j-4610 (140 points)
I am transforming an HL7 Message and the end result looks like this:

<start>

MSH|<data>

PID|<data>

PV1|<data>

<blank line>

<end>

How can I remove the trailing Carriage return so that it looks like:

<start>

MSH|<data>

PID|<data>

PV1|<data> <end>

1 Answer

0 votes
The HL7 message model outputs an eol after every segment and there isn't a way to override it that I'm aware of.  So if you let your HL7 message process through to a destination node (or view it in the test logs and caches) you will see the newline at the end.

So if you really want to get rid of the endline you will have to do it from a mapping node using message.getNode("/") and do whatever you want with it at that point.

So in a mapping node if I output to file the endlines will not be added.

qie.writeFile('/tmp/modified.hl7', message.getNode("/"), true);
answered Dec 9, 2023 by nathan-c-4426 (540 points)
...