No announcement yet.

Processing Mirth's output files

  • Filter
  • Time
  • Show
Clear All
new posts

  • Processing Mirth's output files

    I'm fairly new to Mirth. I'm coding an app that will 'listen' for Mirth to deliver a file. When the app detects that a new file is available from Mirth I'm going to process the contents of that file into a DB.
    Currently the design assumes that the name of the file delivered by Mirth will be fixed.
    For example, mirthdata.xml.
    My question is this.
    In the event, presumably common, that Mirth delivers a new file while my app is processing the previous file what options does Mirth have for waiting until that processing finishes to avoid conflicts?
    For background, my 'listening' code is based on Apache Commons VFS. I create a thread that uses this API to detect timestamp changes on a file, and when a change is detected, it calls the DB access code.
    Any ideas appreciated, even better ones. :>)

  • #2
    Re:Processing Mirth's output files

    if the file contains HL7 data, why don't you use Mirth to place the data in the DB?
    Reid Hospital and Healthcare


    • #3
      Re:Processing Mirth's output files

      Thanks for your interesting response. I was unaware that Mirth could directly access a DB. I have written lots of code to handle the DB loading from an XML file that's generated by Mirth. ie; AS400 app exports file to Mirth. Mirth transforms this file into an XML file which I use as input to the DB loading code.
      I know that I can setup Mirth to fire my DB loading code but that code still has to be written - Mirth doesn't know what my DB looks like, or does it?
      Looking forward to reading your response.


      • #4
        Re:Processing Mirth's output files

        There is a sample channel called "Workaround to call a stored procedure from Mirth" that can be found at:

        Mirth doesn't need to know what your database looks like. You control that in the javascript code itself.

        I went off this same sample channel. I have a SQL Server 2005 database that has a stored procedure that will process all my transactions. I have variables that hold the various information, an example below:
           // Patient gender
           if (msg['PID']['PID.8']['PID.8.1'].toString() != null) {   
              tempGender = "'" + msg['PID']['PID.8']['PID.8.1'].toString() + "'";
        Then I take all the variables and send them to the stored procedure:
        var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:«»sqlserver://localhost:1433/Openlink;','java','java1');
        //Get parameters for the stored proc separated by , 
        var spParams = tempMRN  + ', ' + tempPID     + ', ' + 
        	       tempLastName  + ', ' + tempFirstName + ', ' + 
        	       tempMiddleName   + ', ' + tempBirthDate     + ', ' + 
        	       tempGender   + ', ' + tempModifiedSSN + ', ' + 
        	       tempAttendID + ', ' + tempAttendPhy + ', ' + 
                       tempNurseStat     + ', ' + tempRoomNum + ', ' + 
                       tempDischargeDate + ', ' + tempAddress1 + ', ' + 
        	       tempCity       + ', ' + tempState      + ', ' + 
        	       tempZipCode    + ', ' + tempPhone1 + ', ' + 
        	       tempADTCode + ', ' + tempAdmitDate + ', ' + 
        var expression = "EXEC process_adt " + spParams;   
        // Print the SQL statement for debugging purpose
        //'SQL: ' + expression);
        //Execute SQL statement.
        var result = dbConn.executeQuery(expression); 
        You can also change the expression variable to say "insert into (....) values(...)" rather than send information to a stored procedure.
        Reid Hospital and Healthcare


        • #5
          Re:Processing Mirth's output files

          You can also use the DB Writer connector, however you might need to install the AS400 driver into Mirth.
          Chris Lang