web stats
Moving HL7 segments to a external DB - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2019, 06:02 AM
lukejr lukejr is offline
What's HL7?
 
Join Date: Dec 2018
Posts: 2
lukejr is on a distinguished road
Default Moving HL7 segments to a external DB

Hello All,

I am trying to move specific message segments to an external DB. I am using a DB Writer channel on Mirth version 3.7.0, the segments are writing as they should but any segment that may contain sub-segments, the writer writes all of the sub-segments out.

EXAMPLE:

| <PID.5><PID.5.1>LASTNAME</PID.5.1><PID.5.2>FIRSTNAME</PID.5.2><PID.5.3>MIDDLENAME</PID.5.3></PID.5> |

THE DESIRED OUTCOME:

LASTNAME^FIRSTNAME^MIDDLENAME

MY SQL:

INSERT INTO provider (ACC, NAME, ATTEND_P, ORDERING_P, MRN_E, DATE_TIME_E, HOS_ACC) select ${ACC}, ${NAME}, ${ATTEND_P}, ${ORDERING_P}, ${MRN_E}, ${DATE_TIME_E}, ${HOS_ACC} WHERE NOT EXISTS (SELECT 1 FROM provider WHERE acc=${ACC});

SUMMARY -> SET DATA TYPES -> Parse Sub-Components is checked. Thanks in advance for any help/recommendations.
Reply With Quote
  #2  
Old 05-31-2019, 06:52 AM
bhesler bhesler is offline
Mirth Newb
 
Join Date: Jul 2015
Posts: 11
bhesler is on a distinguished road
Default

I think the below should work for you. And you then place the 'NAME' variable in the insert statement. This is assuming that if there are repeating names in PID.5 you only want the first name. Thanks

var lastName = msg['PID']['PID.5'][0]['PID.5.1'].toString();
var firstName = msg['PID']['PID.5'][0]['PID.5.2'].toString();
var middleName = msg['PID']['PID.5'][0]['PID.5.3'].toString();

var NAME = lastName + "^" + firstName + "^" + middleName;
Reply With Quote
Reply

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 02:53 PM.


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