rbeckman-nextgen / test-mc

test-migration
1 stars 0 forks source link

PreProcessor is not able to extract message line by line #3206

Open rbeckman-nextgen opened 4 years ago

rbeckman-nextgen commented 4 years ago

I use the following code in my PreProcessor under a Mirth Connect Channel:

// 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(/\r/)) {

// if it is a valid hl7 segment, we'll // append the new line to the new message logger.error(line);

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;

}

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

logger.error(new_message);

new_message = new_message.replace(/[']{1}/gi,"''"); new_message = new_message.replace(/[\x08]{1}/gi,""); //Look for the Backspace character

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

return message;

I GET THE FOLLOWING ERROR MESSAGE:

Preprocessor Script error ERROR MESSAGE: Error running preprocessor scripts com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE:
36: 37: // if it is a valid hl7 segment, we'll 38: // append the new line to the new message 39: logger.error(line); 40: 41: if(line.match(/^[a-zA-Z0-9]{3}|/)) { 42: // see the first comment 43: if( ! first_iteration){ 44: new_message += '\r'; 45: } LINE NUMBER: 41 DETAILS: TypeError: Cannot find function match in object function $(val) {...}. at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:41 (doScript) at 77bdf932-8ebc-4990-b234-b04b9fd89f75_Preprocessor:72 at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:490) at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePreprocessorScripts(JavaScriptUtil.java:184) at com.mirth.connect.server.transformers.JavaScriptPreprocessor$JavaScriptPreProcessorTask.call(JavaScriptPreprocessor.java:57) 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)

Imported Issue. Original Details: Reporter: ivanox Created: 2014-04-30T06:04:21.000-0700

rbeckman-nextgen commented 4 years ago

I'm not able to reproduce this; it works perfectly for me on 3.0.2. Can you export and attach the channel you're using, as well as your global scripts and any code templates?

Imported Comment. Original Details: Author: narupley Created: 2014-04-30T06:29:23.000-0700

rbeckman-nextgen commented 4 years ago

Hi Nick,

This is the channel I use. Let me know if you need anything else.

-- Sincerely,

Ivan Olmos | Interface Developer - My Vision Express 877.882.7456 ext 720 | www.MyVisionExpress.comhttp://www.myvisionexpress.com/

By the way, we're hiring http://www.myvisionexpress.com/careers/...

Imported Comment. Original Details: Author: ivanox Created: 2014-04-30T07:47:43.000-0700

rbeckman-nextgen commented 4 years ago

Well as I said in my last comment, your global scripts and any code templates would be helpful as well. Also, post a sample inbound message (without PHI) that you can reproduce the issue with.

I tried out that channel and the preprocessor works fine for me, no errors.

Imported Comment. Original Details: Author: narupley Created: 2014-04-30T07:56:13.000-0700

rbeckman-nextgen commented 4 years ago

Hi Nick,

I have no global scripts or code templates. I am using the latest Java 7 update 55. I will attached a message you can use.

On Wed, Apr 30, 2014 at 10:58 AM, Nick Rupley (JIRA)

-- Sincerely,

Ivan Olmos | Interface Developer - My Vision Express 877.882.7456 ext 720 | www.MyVisionExpress.comhttp://www.myvisionexpress.com/

By the way, we're hiring http://www.myvisionexpress.com/careers/...

Imported Comment. Original Details: Author: ivanox Created: 2014-04-30T08:32:18.000-0700