Announcement

Collapse
No announcement yet.

Delimited File issue - Preprocessor Script Mirth version 3.4.2

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

  • 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

  • #2
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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, 09:46 AM.

        Comment

        Working...
        X