Announcement

Collapse
No announcement yet.

Wrapped java.lang.ArrayIndexOutOfBoundsException error on database writer

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

  • Wrapped java.lang.ArrayIndexOutOfBoundsException error on database writer

    I am trying to parse data and writing to a database but I keep getting the following error using Javascript database writer pane. The same query is able to the database using the SQL pane. My channel definition is attached. It is intended to process multiple OBX segments though I have suppressed the loop for now. I would appreciate any assistance.

    This is my code:

    var dbConn;

    try {
    dbConn = DatabaseConnectionFactory.createDatabaseConnection ('org.postgresql.Driver','jdbcostgresql://localhost:5435/funsoft_demo','postgres','afrisystems..');
    //logger.
    var _patient_no = $('patient_no');
    logger.debug("This is patient no. : "+ _patient_no);
    var _surname = $('surname');
    var _middle_name = $('middle_name');
    var _gender = $('gender');
    var _point_of_care = $('point_of_care');
    var _request_no = $('request_no');
    var _test_code = $('test_code');
    var _test_description = $('test_description');
    var _type_of_test = $('type_of_test');
    var _age = 10;

    var i = 0;

    //while($('results')[i] != null) {

    var _parameter = $('parameter');
    var _units = $('units');
    var _upper_limit = $('upper_limit');
    var _lower_limit = $('lower_limit');
    var _results = $('results');
    var _outcome = $('outcome');
    var _pathologist = $('pathologist');
    //console.log(_pathologist);
    //var message = msg.copy();
    logger.debug("Pathologist : "+_pathologist);
    var expression = "INSERT INTO public.hp_lab_results( patient_no, patient_name, lab_no, age, gender, typeof_test, parameter, date, input_date, upper_limit, lower_limit, result, out_come, lab_manager, user_name, doctor ) VALUES ( '" +_patient_no+ "', '"+ _surname||' '||_middle_name+ "', '"+_request_no+ "','"+ _age +"', '"+_gender+ "', '"+_type_of_test+ "', '"+_parameter+ "', current_date, current_date, 0.00, 0.00, 0.00, '"+_outcome+"','',current_user,'postgres', '"+_pathologist+"')";
    dbConn.executeUpdate(expression);
    i = i + 1;
    //}
    } finally {
    if (dbConn) {
    dbConn.close();
    }
    }

    ERROR RETURNED:

    [2020-05-23 02:26:43,535] ERROR (com.mirth.connect.connectors.jdbc.DatabaseDispatc herScript:152): Error evaluating Database Writer (Database Writer "Destination 4" on channel 83a94d27-db66-4dfa-90d3-21b0c422e13e).
    com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
    funsoft test channelCONNECTOR:
    Destination 4SOURCE CODE:
    127: var _pathologist = $('pathologist');128: //console.log(_pathologist);129: //var message = msg.copy();130: logger.debug("Pathologist : "+_pathologist);131: var expression = "INSERT INTO public.hp_lab_results( patient_no, patient_name, lab_no, age, gender, typeof_test, parameter, date, input_date, upper_limit, lower_limit, result, out_come, lab_manager, user_name, doctor ) VALUES ( '" +_patient_no+ "', '"+ _surname||' '||_middle_name+ "', '"+_request_no+ "','"+ _age +"', '"+_gender+ "', '"+_type_of_test+ "', '"+_parameter+ "', current_date, current_date, 0.00, 0.00, 0.00, '"+_outcome+"','',current_user,'postgres', '"+_pathologist+"')";132: dbConn.executeUpdate(expression);133: i = i + 1;134: //}135: } finally {136:
    if (dbConn) { LINE NUMBER:
    132DETAILS:
    Wrapped java.lang.ArrayIndexOutOfBoundsException
    at 9e1c6bc2-a6db-4083-8596-50680f7ad63f:132 (doScript)
    at 9e1c6bc2-a6db-4083-8596-50680f7ad63f:141
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:547)
    at com.mirth.connect.connectors.jdbc.DatabaseDispatch erScript$DatabaseDispatcherTask.doCall(DatabaseDis patcherScript.java:120)
    at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)Caused by: java.lang.ArrayIndexOutOfBoundsException
    at java.lang.AbstractStringBuilder.append(AbstractStr ingBuilder.java:597)
    at java.lang.StringBuilder.append(StringBuilder.java: 190)
    at org.postgresql.core.Parser.parseSql(Parser.java:10 26)
    at org.postgresql.core.Parser.replaceProcessing(Parse r.java:972)
    at org.postgresql.core.CachedQueryCreateAction.create (CachedQueryCreateAction.java:41)
    at org.postgresql.core.QueryExecutorBase.createQueryB yKey(QueryExecutorBase.java:309)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(P gStatement.java:281)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(P gStatement.java:266)
    at org.postgresql.jdbc.PgStatement.execute(PgStatemen t.java:262)
    at com.mirth.connect.server.userutil.DatabaseConnecti on.executeUpdate(DatabaseConnection.java:155)
    at sun.reflect.GeneratedMethodAccessor184.invoke(Unkn own Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:126)
    at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:225)
    at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1479)
    at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
    at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
    at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:405)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3508)
    at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
    at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:150)
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:542)
    ... 6 more
    Attached Files
    Last edited by [email protected]; 05-23-2020, 04:56 AM.

  • #2
    This one has been resolved and closed.

    Comment

    Working...
    X