Announcement

Collapse
No announcement yet.

Accept HL7, Read from SQL, Send modified HL7

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

  • Accept HL7, Read from SQL, Send modified HL7

    Hello,

    Up until now, I have been working with Mirth Connect 3.02.7140 to accept HL7 messages and write the data out to SQL.
    I have been tasked with doing something a little different, and after trying many times, I am stuck.

    For certain HL7 messages, I want to forward them on to a new channel so I do not hang up the current writing process.
    After receiving them in a new channel, parse out parts of the HL7 message to create a new message. Then pull some data from SQL to add to custom Z segment, and send the message back out. For right now, I am trying to test using File Writer destination.

    I have created the Channel Writer on the existing Channel.
    I have created a new channel set up as a Channel Reader, and on the Source Transformer, parsed out the data from the message I plan to use in the new message.
    In my first destination, I have a JavaScript SQL query to pull the data.
    var sql = dbConn.executeUpdate("SELECT Hosp, pmort30, PRISMscore, PRISMscoreDt, PRISMscoreExpirationDt from WorstLVPS_90days where MRN = '"+ $('MRN') +"'");
    var results = dbConn.executeUpdate(sql);

    I am having problems figuring out out to get the SQL results to a mapping?

    In the File Writer destination, I have created a template and I am able to pull the mappings from the source transformer. But the SQL results are putting the descriptive name from the destination mapping instead of the actual values from SQL.
    MSH|^~\&|PRISM|2.16.840.1.113883.3.137.3100^2.16.8 40.1.113883.3.137|||${date.get('yyyyMMddHHmmss')}| |ADT^A31|${UUID}|D|2.3||||||||||2.2B
    EVN|A31|${date.get('yyyyMMddHHmmss')}||CPIU|Auto
    PID|0001||${Patient_CKS}||${Patient_LastName}^${Pa tient_FirstName}^${Patient_MiddleName}||${Patient_ DOB}|${Patient_Sex}||${Patient_Race}|^^^^${Patient _Zip}^^^^||||||||${Patient_SSN}||||||||||||||||||| ||||||||||||
    ZPR|0001|PrismActive^^${PRISMscore_LVPS}^${PRISMsc oreDt_LVPS}^Worst PRISM Score with score date within 90 days^enter OID^${PRISMscoreExpirationDt}

    Thanks in advance for any suggestions.
    Attached Files
    Last edited by mkohls; 05-10-2018, 05:22 AM. Reason: Adding Channel

  • #2
    Hello,

    you are doing something wrong when query the DB.
    I uploaded your channel and saw that.
    Please change this into your "SQL_Read" Destination:

    Code:
    var dbConn;
    var result;
    
    try 
    {
        dbConn = dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sqlserver://aasjaptlv152:1433/WA_PredMort','mirthuser','mirth3112');
    
        var query="SELECT Hosp, pmort30, PRISMscore, PRISMscoreDt, PRISMscoreExpirationDt from WorstLVPS_90days where MRN = '"+ $('MRN') +"'";
        
        result = dbConn.executeCachedQuery(query);
    
        while(result.next())
        {
            var hosp = result.getString("Hosp");
            var pmort = result.getString("pmort30");
            var score = result.getString("PRISMscore");
            var core = result.getString("PRISMscoreDt");
            var exp = result.getString("PRISMscoreExpirationDt");
        }
    
        /*
        * Create here your channelMap.put('XXX',...);
        */
    } 
    finally 
    {
        if (dbConn) 
        {
            dbConn.close();
        }
    }
    And on the same Destination transformer, remove the HL7 Outbound Template, leave it blank and change the Data Type to XML.
    Best Regards,
    Alex Neiva

    Comment


    • #3
      Alex,

      That did the trick, thank you very much.

      Michael

      Comment


      • #4
        Hi all,
        I'm trying to do something similar.
        I'am able to read data from SQL, put it into a variabile, but the channel hang when creating the HL7 message.
        My aim is to dispatch HL7 message I received, changing only the ['OBR'][1]['OBR.2.1'] and ['ORC'][1]['ORC.2.1'] with the data I got from SQL.

        Can you help me, please?
        I attached the channel.
        Thank you so much
        Attached Files

        Comment


        • #5
          In your destination, HL7_send, you have an HL7 message in the Outbound Message Template. That is almost never what you want, and will cause the incoming message to not be used, but the output to "start" with what is there. Try removing that and reprocessing?

          If you do and you remove the template, be sure to update:

          Code:
          tmp['ORC'][1]['ORC.2']['ORC.2.1'] = newOrderId;
          tmp['OBR'][1]['OBR.2']['OBR.2.1'] = newOrderId;
          to

          Code:
          msg['ORC'][1]['ORC.2']['ORC.2.1'] = newOrderId;
          msg['OBR'][1]['OBR.2']['OBR.2.1'] = newOrderId;
          I disabled the database lookup, and it processed fine for me. You seem to be doing the lookup and writing to a channelMap just fine...

          Good luck!
          Last edited by jackwhaines; 10-10-2019, 11:57 AM.

          -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
          -= [email protected]
          -= Mirth Connect (Advanced)-certified
          -= Gold member of HL7.org
          -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

          Comment


          • #6
            Thank you jackwhaines for your reply!
            Even if I disabled the SQL destination, removed the outbound message template, the HL7 destination remains in RECEIVED state... and I have to send HALT to channel

            Comment


            • #7
              I did it!
              I was sending encoded data to the same channel that was processing the message... my fault!

              Comment


              • #8
                Nice! It's always nice when it's something simple!

                -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
                -= [email protected]
                -= Mirth Connect (Advanced)-certified
                -= Gold member of HL7.org
                -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

                Comment

                Working...
                X