Sidebar

Can I test a preProcess Script in a Channel with a format of Text?

0 votes
348 views
asked May 19, 2017 by brandon-w-8204 (33,170 points)
edited May 22, 2017 by terrie-g-7436
I want to test my pre-process script. How can I configure a channel with format of text to test these scripts?

1 Answer

0 votes

Here is what you need to configure the variables to test a pre-process script:

// Items to test preprocess in channel script DO NOT INCLUDE IN PREPROCESS SCRIPT ON SOURCE NODE
var bytesOut = null;
var bytesIn = message.getBytes();
var responseBytes = bytesIn;

Here is a sample mapping with a pre-process script and the variables configured:

// Items to test preprocess in channel script DO NOT INCLUDE IN PREPROCESS SCRIPT ON SOURCE NODE
var bytesOut = null;
var bytesIn = message.getBytes();
var responseBytes = bytesIn;

//Preprocess script THIS GOES IN PREPROCSS SCRIPT
var preMessageString = new java.lang.String(bytesIn, 'UTF-8');
qie.debug('preMessageString: ' + preMessageString);
var llError = StringUtils.substringBetween(preMessageString, '/-/', '\\-\\');
qie.debug('llError: '+ llError);
preMessageString = StringUtils.replace(preMessageString, '/-/' + llError + '\\-\\\r', '');
qie.debug('afterProcessing: ' + preMessageString);
try {
   qie.parseHL7String(preMessageString);
   bytesOut = preMessageString.getBytes();
} catch (err) {
   qie.debug('error with parsing hl7 string: ' + err);
}
if (bytesOut === null) {  //When null, the message is discarded and no further processing is done
   //todo: when bytesOut = null, set responseBytes to acknowledge the receipt of discarded messages as needed
   responseBytes = new java.lang.String('Replace with valid acknowledgement').getBytes();
}

 

answered May 19, 2017 by brandon-w-8204 (33,170 points)
edited May 22, 2017 by terrie-g-7436
...