web stats
Encode to HL7 escape sequence - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-10-2018, 02:15 AM
fzenha fzenha is offline
What's HL7?
 
Join Date: Mar 2017
Posts: 5
fzenha is on a distinguished road
Default Encode to HL7 escape sequence

Hi,

Is there any option on Mirth to encode/replace special characters to HL7 escape sequence when sending an HL7 message?

I have a channel receiving a XML and transform data to send an HL7 message. This is an example of the OBR produced for the message:
OBR||30381000|142018001804|10740^Braço, duas incidências||20180702163620|20180702163620|2018070 2163620|||||||||||

How could I encode the special characters like 'ê' to send the OBR segment like this:
OBR||30381000|142018001804|10740^Braço, duas incid\XEA\ncias||20180702163620|20180702163620|201 80702163620|||||||||||
Reply With Quote
  #2  
Old 07-10-2018, 04:07 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 821
siddharth is on a distinguished road
Default

The best place to replace them would be in preprocessor, like this fiddle

https://jsfiddle.net/j7ph83vz/1/

But these are acute accent, i noticed that you don't to encode ç, but just ê - Why is that?
__________________
HL7v2.7 Certified Control Specialist!
Reply With Quote
  #3  
Old 07-10-2018, 05:31 AM
fzenha fzenha is offline
What's HL7?
 
Join Date: Mar 2017
Posts: 5
fzenha is on a distinguished road
Default

This was just an example. I want to replace all special characteres on HL7 message with the correspondent hexadecimal.
In the example I've provided it should also encode the 'ç' character.

From the resolution you gave, I must map all special characters and the correspondent hexa value?! This would be a very extensive list!! Isn't there a simpler way?
Reply With Quote
  #4  
Old 07-10-2018, 05:54 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 821
siddharth is on a distinguished road
Default

What problems are you facing with the content, assuming that you don't encode them? Is the message erroring in Mirth?

If that is the case, you might want to switch your encoding scheme on the reader to ISO-8859-1 or Windows-1252.

per wiki pedia, ISO-8859-1 and Windows-1252 character encodings include the letters á, é, í, ó, ú, ý, and their respective capital forms. Dozens more letters with the acute accent are available in Unicode.
__________________
HL7v2.7 Certified Control Specialist!
Reply With Quote
  #5  
Old 07-10-2018, 06:02 AM
fzenha fzenha is offline
What's HL7?
 
Join Date: Mar 2017
Posts: 5
fzenha is on a distinguished road
Default

I'm not getting any errors on Mirth. The problem is that we receive HL7 messages from sender that come with all special characteres encoded in hexa decimals.

When we send other messages to the sender (client), they are expecting that this special characters also to be encoded.

Last edited by fzenha; 07-10-2018 at 06:25 AM.
Reply With Quote
  #6  
Old 07-10-2018, 07:54 AM
AlexNeiva AlexNeiva is offline
Mirth Guru
 
Join Date: Oct 2013
Location: Portugal
Posts: 272
AlexNeiva is on a distinguished road
Post

Hello fzenha,


i have this 2 functions that i put in CodeTemplates and you can invoke both just by doing yourvariable.toString().hexDecode() / .hexEncode()
In this case it will encode/decode all the string.
With some twinks you could probably just encode/decode just the character you need.


Code:
String.prototype.hexEncode = function()
{
    var hex, i;

    var result = "";
    for (i=0; i<this.length; i++) 
    {
        hex = this.charCodeAt(i).toString(16);
        result += ("000"+hex).slice(-4);
    }

    return result;
}

String.prototype.hexDecode = function()
{
    var j;
    var hexes = this.match(/.{1,4}/g) || [];
    var back = "";
    for(j = 0; j<hexes.length; j++) 
    {
        back += String.fromCharCode(parseInt(hexes[j], 16));
    }

    return back;
}


give it a try.
__________________
Best Regards,
Alex Neiva
Reply With Quote
  #7  
Old 07-12-2018, 03:36 AM
fzenha fzenha is offline
What's HL7?
 
Join Date: Mar 2017
Posts: 5
fzenha is on a distinguished road
Default

Thanks AlexNeiva. That did the trick.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation