1.2k questions
1.4k answers
361 comments
339 users
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(); }
//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(); }