web stats
Delimited File issue - Preprocessor Script Mirth version 3.4.2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2019, 10:57 PM
vijayk333 vijayk333 is offline
Mirth Newb
 
Join Date: Jul 2014
Posts: 25
vijayk333 is on a distinguished road
Default Delimited File issue - Preprocessor Script Mirth version 3.4.2

Dear All,

When I am sending raw data manually then preprocessor script works fine. When I use TCP/IP socket to send data then it is giving following error.
I am attaching channel and raw data file for your reference.
Please let me know what could be the reason for this error:

Preprocessor Script error
ERROR MESSAGE: Error running preprocessor scripts
com.mirth.connect.server.MirthJavascriptTransforme rException:
SOURCE CODE:
48: var splitLength = splitArr.length;
49: const regexdatehm = /h|mn/gmi;
50: const substdatehm = ':';
51: const regexdates = /s/gmi;
52: const regexsubsts = '';
53: const year = splitArr[3].substr(2,2) + '/'+ splitArr[3].substr(5,2)+'/'+ '20' + splitArr[3].substr(8,2)+ '|'+ splitArr[3].substr(11,2) +':' + splitArr[3].substr(14,2)+':' +splitArr[3].substr(18,2);
54: const regedrepl = year;
55: const regexremovechars = /[a-zA-Z]+/gmi;
56: const regexremoverep = '';
57: const header = "Date|ID1|Instrument|ID2|Lot|ID3|Analyte|Resul t"
LINE NUMBER: 53
DETAILS: TypeError: Cannot call method "substr" of undefined
at 61ef9d7c-0376-4c83-8fe4-784b836f8afb_Preprocessor:53 (doScript)
at 61ef9d7c-0376-4c83-8fe4-784b836f8afb_Preprocessor:185
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:527)
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executePreprocessorScripts(JavaScriptUtil.ja va:196)
at com.mirth.connect.server.transformers.JavaScriptPr eprocessor$JavaScriptPreProcessorTask.doCall(JavaS criptPreprocessor.java:103)
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)

Thank you for your help in advance.
Attached Files
File Type: xml ABX.xml (36.8 KB, 3 views)
File Type: txt abx.txt (801 Bytes, 2 views)
Reply With Quote
  #2  
Old 09-17-2019, 09:31 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,282
cory_cole is on a distinguished road
Default

It is this line here...


const year = splitArr[3].substr(2,2) + '/'+ splitArr[3].substr(5,2)+'/'+ '20' + splitArr[3].substr(8,2)+ '|'+ splitArr[3].substr(11,2) +':' + splitArr[3].substr(14,2)+':' +splitArr[3].substr(18,2);

Make sure that your length is 4 as it is 0 based.
Reply With Quote
  #3  
Old 09-17-2019, 04:14 PM
vijayk333 vijayk333 is offline
Mirth Newb
 
Join Date: Jul 2014
Posts: 25
vijayk333 is on a distinguished road
Default

Thank you Cory. Actually, when I use this code in other Javascript IDE then it works very well. Even, when I send raw data manually through Mirth Connect dashboard then it works. But when I use TCP/IP stream then it fail. I am not sure where I am wrong.
Any other hint?

Thanks in Advance.
Reply With Quote
  #4  
Old 09-18-2019, 09:26 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,282
cory_cole is on a distinguished road
Default

Here is your error...

DETAILS: TypeError: Cannot call method "substr" of undefined

it is saying that splitArr[3] is not defined. Which means either splitArr is not defined or this not 4 items.

Add these two lines before the error...
logger.info(splitArr.toString()); //if this line errors then splitArr is undefined.
logger.info(splitArr.length());// not sure if you need the () or not. This will tell you how many items are in the array.

Last edited by cory_cole; 09-18-2019 at 09:46 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:47 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation