No announcement yet.

reading in 2.5 msg from DB, populating DB cols with contents

  • Filter
  • Time
  • Show
Clear All
new posts

  • reading in 2.5 msg from DB, populating DB cols with contents

    Mirth Connect Server
    Java version: 1.8.0_40

    I have spent weeks on this and I'm throwing in the towel. I don't think there's a related forum post that I haven't read a dozen times.

    What I'm trying to do:
    In a database, I have a transaction table of all incoming HL7 messages(ORU-R01). I'm particularly interested in the transaction ID and the actual HL7 message.

    For now, I read in some messages, set the "processed" column to 1, and I want to write some of the contents of the HL7 message to another table. When I get this working, I'm going to read in all of the OBX segments and put all of the contents in a name/value pair table (not shown here). Baby steps . . . .

    The results:
    My source database writer seems to work. Right now, I'm just bringing in 10 rows from the DB and I can see them in the source raw message in this form:

    The transformed msg seems to be structured correctly (sans data of course). I was concerned because the raw HL7 msg has "& # 13 ;" (minus spaces) as a segment delimiter, but it seems to work as a carriage return.

    The problem is, I'm not able to extract the contents of the incoming msg correctly. It's there in the raw XML.

    I've tried using a serializer and I've also left it out.

    In an earlier iteration, I had an HL7 msg in the outbound template tree, and MIRTH wrote that to my database correctly--so, that piece works.

    I originally had my code in the source transformer. Then, I moved it to the destination transformer. That didn't matter. I think I've turned every switch on/off out of desperation . . . . Obviously, there's something I'm missing.

    Does anyone have any suggestions? I'm very new to MIRTH, so, please be explicit on where things should go (e.g., db reader javascript vs. source transformer javascript vs. destination javascript).

    Attached Files

  • #2

    I wanted to see if I could at least read in the messages from the database and write out what I was receiving. I was never able to write the actual HL7 message to the logger, so, I wasn't sure if I was reading it in correctly or not.

    So, I wrote another channel with the same Database Reader and a simple File Writer destination (without a transformer).

    Everything worked fine. The messages I read had their status updated and the messages are valid HL7 messages.

    So, the HL7 message is arriving fine. It's pulling out the components and mapping them to the variables that I'm having problems with.

    Also, I keep getting this warning. Can anyone tell me what I need to do to fix it?
    WARN  (org.apache.ibatis.datasource.pooled.PooledDataSource:54): Execution of ping query 'SELECT 1' failed: Syntax error: Encountered "<EOF>" at line 1, column 8.
    Attached Files


    • #3
      Well first, I think you would have a better time if you used the SQL mode of the Database connectors. The JavaScript mode is there for advanced use if you need to do tricky things, but it doesn't seem like you need to use it in this case.

      Second, there are some incorrect things I noticed. First, in your source transformer you're trying to reference "msg['msg_content_blob']", but that won't work since the alias you specify in the reader query is "hl7_msg".

      You can extract the hl7_msg and set it as msg in the source transformer:

      msg = new XML(SerializerFactory.getSerializer('HL7V2').toXML(msg['hl7_msg'].toString()));
      You actually attempted to do this in the destination transformer, but it's incorrect. You're passing the literal string "HL7_msg" in, which won't work.

      I've attached a modified version of the channel to illustrate.
      Attached Files
      Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

      Nicholas Rupley
      Work: 949-237-6069
      Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.

      - How do I foo?
      - You just bar.


      • #4
        Thank you! That was the key. (For future reference: If you have an actual HL7 message that's stored in a database column as text, you have to use the code in the last post to use the msg.

        msg = new XML(SerializerFactory.getSerializer('HL7V2').toXML(msg['hl7_msg'].toString()));
        Taking narupley's other advice, I converted my current database writers to SQL instead of javascript.

        Now, those two destinations ("metadata" and "person") work fine. I'm basically decomposing an HL7 message into its original pieces (e.g., metadata, and PID info).

        My final destination is to insert the contents of each OBX segment into its own table in this form: Col 1 & 2 = IDs, Col 3 = OBX # (OBX-1.1), Col 4 = Question (OBX-3.1), Col 5 = Answer (OBX-5.1). For that, I think I need to use javascript in another destination . . . .

        Let's say a msg with a Transaction ID = 001 and MSH-10.1 = VA12345 had 5 OBX segments, the Metadata table would have 1 row, the Person table would have 1 row, and the Observations table would have 5 rows containing the contents of the OBXs.

        My needs are very similar to this post:

        My issues are that (1) I'm not able to access the 'msg', (2) I'm not sure if I'm doing the looping of the OBX correctly, and (3) I have a variable [obx_n] that I need to convert to numeric for insertion in the DB, but, I'm having no luck converting it with a prepared statement.

        Any advice would be greatly appreciated.

        UPDATE: I fixed it . . . seems to be working now. Attaching channel for anyone looking to do something similar.
        Attached Files
        Last edited by Guit_fishN; 05-11-2015, 07:55 PM. Reason: fixed it!