web stats
Special character issue - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 07-08-2019, 04:42 AM
mmazeemahmad mmazeemahmad is offline
What's HL7?
Join Date: Apr 2019
Posts: 2
mmazeemahmad is on a distinguished road
Post Special character issue


I am receiving an Hl7 message from source, converting to XML from Mirth and storing that xml in a directory, the only problem i am facing is if the HL7 contain the ' character in its segment then its failing to create an XML, i tried to remove the ' character after which it transforms to XML successfully, can you please advise a way to handle this character in HL7 message.

Reply With Quote
Old 07-09-2019, 08:07 AM
f180350 f180350 is offline
What's HL7?
Join Date: May 2015
Posts: 3
f180350 is on a distinguished road

Not to be overly simple. You'd need to remove it with a preprocessor script. An internet search should get you some examples to follow for removing characthers. I found this to get rid of a carriage return within a text field.

// Modify the message variable below to pre process data
// initialize a first_iteration flag.
// we don't want to add a carriage return
// before the MSH segment
var first_iteration = true;

// initialize the new message as an empty string
var new_message = '';

// loop over each line in the message
// by splitting on the hl7 standard carriage return
for each (var line in message.split(/\n/)) {

// if it is a valid hl7 segment, we'll
// append the new line to the new message
if(line.match(/^[a-zA-Z0-9]{3}\|/)) {
// see the first comment
if( ! first_iteration){
new_message += '\r';
new_message += line;
// logger.info(new_message);
} else {
// if it isn't a valid hl7 segment,
// we'll append it to the end of the
// previous segment instead
new_message += ' ' + line;
logger.info('IN Soft ORU: Improper HL7 Format Corrected');

// it will never be the first_iteration again
first_iteration = false;

//send the fixed message to the channel
message = new_message;

return message;
Reply With Quote

character, conversion, hl7, mirth, special

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 08:28 AM.

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