· Feb 25, 2019

How to remove the escape character of HL7 message?

Hello Gentlemen,


As you can read on the title, my question is to know how to retranslate the hl7 message into a string and so to remove the '\E' that are inside. A example/picture worth more than a thousand word.

OBX|1|RP|ECG||CARDIO ECG^APPLICATION^PDF^^\E\\E\\E\files\E\cardio\E\022018\E\GE274583.PDF|


As you can see, the escape character \E is used by hl7 message in the purpose to authorize a character '\' just but I don't want it in my program... Is there any function that retranslates this format into a "normal" format?





Discussion (5)1
Log in or sign up to continue

Thanks Robert for taking time to respond me but neither your first or your second response works in my case.
The first isn't generic because imagine that  there is a real folder that starts with 'E', it's going to be erased.
For the second,it's not a synonym for <ESC>, this is the environment of HL7 that transform automatically a \ in a \E\ to be sure it's well read. I have already found a response that works but that's hardcoding and my boss is not happy about that, he would prefer to use a proper way such as if a method already exists or a derivated way.



Any application that supports HL7 messages should recognize and translate that value your showing in OBX:5.5 to the appropriate character string. It's a UNC path ... \\\files\cardio\022018\GE274583.PDF.

Technically it's \E\, not \E that represents the HL7 escape character (the 3rd character in MSH:2).

If you wish the backslash character to be interpreted literally in the HL7 message, the escape character in MSH:2 should be substituted with some other character. I often use the backtick character (`). That will prevent a conformant application from trying to do something special with the backslash. And in making that change, an actual backtick character that should be displayed as such in the destination application would be represented as `E` ...

As Robert pointed out,  the $REPLACE() function can be used for the substitution:

set str = "\E\\E\\E\files\E\cardio\E\022018\E\GE274583.PDF"

set fixed = $REPLACE(str,"\E\","\")

w  fixed