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\sitehopital.org\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?
Faithfully,
Thomas
set remove="\E"
set hl7="OBX|1|RP|ECG||CARDIO ECG^APPLICATION^PDF^^\E\\E\sitehopital.org\E\files\E\cardio\E\022018\E\GE274583.PDF|"
set clean=$replace(hl7,remove,"")
write clean
OBX|1|RP|ECG||CARDIO ECG^APPLICATION^PDF^^\\sitehopital.org\files\cardio\022018\GE274583.PDF|
if \E is just a synonym for <ESC> than use instead
set remove=$c(27)
Thanks @Jeffrey Drumm !
I always distrusted HL7 separators and ESC chars. when I first met them ages back as they carry the same limit as $PIECE() with them:
!
"There is always somewhere some odd case where your separator turns up as content. "
Praise $LB()
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.
Faithfully,
Thomas
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 ... \\sitehopital.org\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\sitehopital.org\E\files\E\cardio\E\022018\E\GE274583.PDF" set fixed = $REPLACE(str,"\E\","\") w fixed \\sitehopital.org\files\cardio\022018\GE274583.PDF