Announcement

Collapse
No announcement yet.

channel map value not able to fetch from transformer when queue message : Always

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

  • channel map value not able to fetch from transformer when queue message : Always

    Hello ,

    I am facing some weird issue when I enable queue message : Always . There is no issue with option queue message : Never or On faliure . This channel perform result fetch from MLLP and Write to DB .

    Error I am getting when I make queue message : Always

    JavaScript Writer error
    ERROR MESSAGE: Error evaluating JavaScript Writer
    com.mirth.connect.server.MirthJavascriptTransforme rException:
    CHANNEL: WelchAllyn_Vital device_ORU
    CONNECTOR: Inserto_Gen_Pat_Report
    SCRIPT SOURCE: JavaScript Writer
    SOURCE CODE:
    121: params.set(5,$('MessageControlId'));
    122:
    123: logger.info("sIZE OF THE OBSERVATION");
    124: for each (observation in $('observations'))
    125: {
    126: params.set(6,observation.Id);
    127: params.set(7,observation.ObservationValue);
    128: params.set(8,observation.UnitsIdentifier);
    129: params.set(9, observation.send);
    130: dbConn.executeUpdate(insertQuery, params);
    LINE NUMBER: 126
    DETAILS: Java class "[B" has no public instance field or method named "Id".
    at 9a556f1b-ca74-4fa6-baca-cbe18ff836b2:126 (doScript)
    at 9a556f1b-ca74-4fa6-baca-cbe18ff836b2:143
    at com.mirth.connect.connectors.js.JavaScriptDispatch er$JavaScriptDispatcherTask.doCall(JavaScriptDispa tcher.java:184)
    at com.mirth.connect.connectors.js.JavaScriptDispatch er$JavaScriptDispatcherTask.doCall(JavaScriptDispa tcher.java:122)
    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


    -------------------------My source transformer code -------------------------
    var field1,field2;
    $c('MessageControlId',msg['MSH']['MSH.10']['MSH.10.1'].toString());
    $c('PatientId',msg['PID']['PID.3']['PID.3.1'].toString());
    $c('PatientVisitId',msg['PV1']['PV1.1']['PV1.1.1'].toString());
    $c('observations',[]);
    var sql="select FIELD1,FIELD2,FIELD3,FIELD4 from gen_lookup where lookup_type='HL7_SETTING' and LOOKUP_VALUE='VITALS MAPPING'";
    var gen_lookup= Fun_Select(sql);
    var gen_lookup2= Fun_Select(sql);
    for each (obx in msg.OBX)
    {
    var observation = {};
    observation.Id = obx['OBX.3']['OBX.3.1'].toString();
    observation.send=obx['OBX.3']['OBX.3.1'].toString();
    field1=checkfield(gen_lookup,observation.Id);
    observation.Id = field1;
    observation.UnitsIdentifier = obx['OBX.6']['OBX.6.1'].toString();

    field2=checkfield2(gen_lookup2,observation.UnitsId entifier);
    observation.UnitsIdentifier=field2;
    observation.ObservationValue = obx['OBX.5']['OBX.5.1'].toString();
    $c('observations').push(observation);
    }

    function checkfield(gen_lookup,observationId)
    {
    try
    {
    var value1,value2;
    while(gen_lookup.next())
    {
    value1=gen_lookup.getString('FIELD1');
    value2=gen_lookup.getString('FIELD2');
    if(value1==observationId)
    {
    gen_lookup.first();
    return value2;
    }
    }
    }
    catch(e)
    {
    logger.info("Catch error"+e);
    }

    }

    function checkfield2( gen_lookup2,observationDet)
    {
    try
    {
    var value1,value2;

    while(gen_lookup2.next())
    {
    value1=gen_lookup2.getString('FIELD3');
    value2=gen_lookup2.getString('FIELD4');
    if(value1==observationDet)
    {
    return value2;
    }
    }
    }
    catch(e)
    {
    logger.info("Catch error"+e);
    }
    }
    ------------------My destination transformer code ----------------------

    //try

    importPackage(java.sql);
    var CurDate = DateUtil.getCurrentDate("dd-MM-yy");
    var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('oracle.jdbc.driver.OracleDriver','jdbcracle:thin:@XXXXX:XXXX','XXXX','XXXX');
    var insertQuery="insert into GEN_PAT_REPORT(GEN_PAT_REPORT_ID,MRNO,VISIT_NO,REP ORT_DATE,ENTRY_DATE,REPORT_TYPE,MESSAGE_CONTROL_ID ,FIELD1,FIELD2,FIELD3,FIELD4) VALUES(SEQ_GEN_PAT_REPORT.nextval,?,?,?,?,?,?,?,?, ?,?)";
    var params = new java.util.ArrayList([$('PatientId'),$('PatientVisitId'), null,null, null, null,null, null, null,null]);
    params.set(2,CurDate);
    params.set(3,CurDate);
    params.set(4,'7');
    params.set(5,$('MessageControlId'));

    logger.info("sIZE OF THE OBSERVATION");
    for each (observation in $('observations'))
    {
    params.set(6,observation.Id);
    params.set(7,observation.ObservationValue);
    params.set(8,observation.UnitsIdentifier);
    params.set(9, observation.send);
    dbConn.executeUpdate(insertQuery, params);
    }
    logger.info("New Row's are inserted to GEN_PAT_REPORT");
    dbConn.close();

    /*finally
    {
    if(dbConn)
    {
    dbConn.close();
    }
    }*/

  • #2
    It has to do with the way the channelMap variables must be serialized and retrieved from the db in order to process a queued message. Your javascript array is getting converted to a java byte[].You probably would have the same issue with queuing on failure if a message were ever actually queued.

    At the end of your source transformer:

    Code:
    $c('observations',JSON.stringify($c('observations')));
    In your destination transformer:

    Code:
    for each (observation in JSON.parse($('observations')))
    Converting your object to and from JSON in the channelMap should preserve your values.

    Comment

    Working...
    X