No announcement yet.

Special character issue

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.


  • #2
    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;
    } else {
    // if it isn't a valid hl7 segment,
    // we'll append it to the end of the
    // previous segment instead
    new_message += ' ' + line;'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;