Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Transformed Data variable

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

  • Transformed Data variable

    I'm evaluating Mirth and because of how I have to access my database I'm having to use JavaScript (new to JavaScript as well). My problem is I don't seem to be able to use the standard variables in the JavaScript and get any data out of them. I've tried using
    $(message.transformedData) but I get nothing in my output. I have defined a source as a file reader and my destination is SQL Server. I'm trying to transform standard HL7 2.3 into a custom XML format. I've defined several transform statements in my destination and I can see the results of this in the "Channel Messages" tabs "Transform Message" and "Encoded Message".

    Can someone give me code examples of how I can get the transformed message in a JavaScript? Here is my destination script.

    var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sql server://sqlserver:1433/Database','dbuser','dbpwd');
    var result = dbConn.executeCachedQuery('SELECT MAX(MSG_ID) FROM DATABASETABLE');
    result.next();
    var msgid = result.getInt(1) + 1;

    var sqlInsert = "INSERT IGNORE INTO DATABASETABLE (MSG_ID, STATUS, MSG_TYPE, HL7STR, XMLSTR, RECV_DATE, RECV_TIME, SOURCE, IDENTIFIER, CLIENT_ID) ";
    sqlInsert = sqlInsert + "VALUES (" + msgid.toString() + ", 'X', '";
    sqlInsert = sqlInsert + channelMap.get('MessageType').toString() + "', '";
    sqlInsert = sqlInsert + channelMap.get('HL7Message').toString() + "', '";
    sqlInsert = sqlInsert + $(message.transformedData) + "', '";
    sqlInsert = sqlInsert + DateUtil.getCurrentDate('yyyyMMdd') + "', '";
    sqlInsert = sqlInsert + DateUtil.getCurrentDate('HHmmss') + "', '";
    sqlInsert = sqlInsert + channelMap.get('Source').toString() + "', '";

    var filename = channelMap.get('originalFilename');
    sqlInsert = sqlInsert + filename.substring(0,filename.length()-4) + "', '";

    sqlInsert = sqlInsert + 'C8' + "')";

    var result = dbConn.executeUpdate(sqlInsert);

    Any and all help is much appreciated!

  • #2
    Re:Transformed Data variable

    Use: messageObject.getTransformedData()

    (Yes, it is confusing and we are working to make things a bit more consistent across the UI)
    Chris Lang

    Comment

    Working...
    X