Announcement

Collapse
No announcement yet.

Removing hex characters from flat file to HL7

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing hex characters from flat file to HL7

    Using Mirth 3.9
    I am very new to Mirth. I am transforming flat files to HL7. The notes column of the flat file occasionally has a backspace(note). backspace = hex 08. My transformation is on the Source. My code to remove the backspace isn't working.

    if (row['NTE'].toString() != "")
    {
    var nte = <NTE/>;
    x++
    nte['NTE.1'] = x;
    nte['NTE.3']['NTE.3.1'] = row['NTE'].toString().replace(/\x08/g,'');
    tmp.appendChild(nte);
    }
    }
    }

    Here is the error
    Transformer error
    ERROR MESSAGE: Error evaluating transformer
    com.mirth.connect.server.MirthJavascriptTransforme rException:
    CHANNEL: OTTR Lab_99334307
    CONNECTOR: sourceConnector
    SCRIPT SOURCE:
    SOURCE CODE:
    94: }
    95: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPac kage().getName() + ')');
    96: }
    97: }
    98: function doScript() {
    99: msg = new XML(connectorMessage.getTransformedData());
    100: if (msg.namespace('') != undefined) { default xml namespace = msg.namespace(''); } else { default xml namespace = ''; }
    101: tmp = new XML(template);
    102: function doFilter() { phase[0] = 'filter'; return true; }function doTransform() { phase[0] = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase[0]);
    103:
    LINE NUMBER: 99
    DETAILS: TypeError: An invalid XML character (Unicode: 0x8) was found in the element content of the document.
    at ae7350d8-2700-4263-bfe6-5402f38e76b6:99 (doScript)
    at ae7350d8-2700-4263-bfe6-5402f38e76b6:180
    at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
    at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
    at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    On another post I found to add to the preprocessor
    var newMessage = message.replace(/[\x00-\x08]|[\x0B-\x0C]|[\x0E-\x1F]/g, '');

    I've never worked with the preprocessor. When I added this to the preprocessor I still get the error above.
    Last edited by czoltz; 02-16-2021, 07:20 AM.

  • #2
    I figured this out. I ended up working with just the backspace I knew was a problem. This is what I put in the Preprocessor return message.replace(/\x08/g,''); I will add more characters if necessary.

    Comment


    • #3
      The exact right code, in the exact right place! Great job!

      -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
      -= [email protected]
      -= Mirth Connect (Advanced)-certified
      -= Gold member of HL7.org
      -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

      Comment

      Working...
      X