web stats
reading in 2.5 msg from DB, populating DB cols with contents - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-05-2015, 10:56 AM
Guit_fishN Guit_fishN is offline
Mirth Newb
 
Join Date: Apr 2015
Posts: 7
Guit_fishN is on a distinguished road
Default reading in 2.5 msg from DB, populating DB cols with contents

Mirth Connect Server 3.2.1.7650
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:

Code:
<result>
    <hl7_msg>MSH|^~\&amp;|^2.16.840.1.114222.4.1.144.2^ISO|^2.16.
    <mr_msg_uid>41331506</mr_msg_uid>
</result>
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.

Code:
<HL7Message>
    <MSH>
        <MSH.1>|</MSH.1>
        <MSH.2>^~\&amp;</MSH.2>
        <MSH.3/>
        <MSH.4/>
        <MSH.5/>
        <MSH.6/>
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).

Thanks.
Attached Files
File Type: xml Get_Msgs18.xml (30.5 KB, 10 views)
Reply With Quote
  #2  
Old 05-05-2015, 06:13 PM
Guit_fishN Guit_fishN is offline
Mirth Newb
 
Join Date: Apr 2015
Posts: 7
Guit_fishN is on a distinguished road
Default

UPDATE:

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?
Code:
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
File Type: xml Write_file.xml (22.7 KB, 13 views)
Reply With Quote
  #3  
Old 05-07-2015, 02:03 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

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:

Code:
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
File Type: xml Get_Msgs18 v2.xml (27.6 KB, 24 views)
__________________
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.
Reply With Quote
  #4  
Old 05-11-2015, 01:58 PM
Guit_fishN Guit_fishN is offline
Mirth Newb
 
Join Date: Apr 2015
Posts: 7
Guit_fishN is on a distinguished road
Default

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.

Code:
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: http://www.mirthcorp.com/community/f...ead.php?t=8503

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
File Type: xml Get_Msgs24.xml (60.3 KB, 29 views)

Last edited by Guit_fishN; 05-11-2015 at 07:55 PM. Reason: fixed it!
Reply With Quote
Reply

Tags
database reader, database writer, serializer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:02 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation