web stats
How to wirte outbound message at destination - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-19-2019, 09:54 PM
Saqib Javaid Saqib Javaid is offline
What's HL7?
 
Join Date: Mar 2019
Posts: 1
Saqib Javaid is on a distinguished road
Red face How to wirte outbound message at destination

Hello!

I am newbie to Mirth Connect. I have successfully created Inbound channel where Source is TCP/File Reader and creates Acknowledgments at destination.But, now I have been assigned a task to create a channel for Outboundmessage. Where I have to read from Database (Source) and Write outbound message in Destination. Source part was easy i.e Read from database. But when I just write outbound file it writes with column names too in destination file like

result|receivingapplication|LABADTsecurity|Psendin gapplication|ADT1datetimeofmessage|2019-03-20sendingfacility|MCMmessagecontrolid|MSGAbCdrecei vingfacility|MCM

which is wrong. Any hint, please.

Thanks in advance
Reply With Quote
  #2  
Old 03-27-2019, 10:53 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 388
rutledj is on a distinguished road
Default

Perhaps posting your channel would help us more understand what you are doing.
Reply With Quote
  #3  
Old 04-15-2019, 11:23 PM
schillert schillert is offline
OBX.1 Kenobi
 
Join Date: Jul 2012
Posts: 29
schillert is on a distinguished road
Default

I guess the result of your database query looks like this

Code:
<result>
	<receivingapplication>LABADT</receivingapplication>
	<security>P</security>
	<sendingapplication>ADT1</sendingapplication>
	<datetimeofmessage>2019-03-20</datetimeofmessage>
	<sendingfacility>MCM</sendingfacility>
	<messagecontrolid>MSGAbCd</messagecontrolid>
	<receivingfacility>MCM</receivingfacility>
	
	...
</result>
The inbound datatype of the source connector should be XML and
the outbound datatype should be HL7V2

You have to add a transformer step and change it's type to javascript.
Then you start building your HL7 message - segment by segment and field by field
in the correct syntactical and numerical order.

The information you provided would be a part of the MSH-segment of the message.
The javascript would look like that

Code:
tmp=new XML("<HL7Message>");
tmp["MSH.1"]="|";
tmp["MSH.2"]="^~\\&";
tmp["MSH.3"]["MSH.3.1"]=msg["sendingapplication"].toString();
tmp["MSH.4"]["MSH.4.1"]=msg["sendingfacility"].toString();
tmp["MSH.5"]["MSH.5.1"]=msg["receivingapplication"].toString();
tmp["MSH.6"]["MSH.6.1"]=msg["receivingfacility"].toString();
tmp["MSH.7"]["MSH.7.1"]=DateUtil.convertDate("yyyy-MM-dd", yyyyMMdd, msg["datetimeofmessage"].toString());
tmp["MSH.8"]["MSH.8.1"]=msg["security"].toString();
tmp["MSH.9"]["MSH.9.1"]="ADT"; // The message type you want
tmp["MSH.9"]["MSH.9.2"]="A01"; // The event you want
tmp["MSH.10"]["MSH.10.1"]=msg["messagecontrolid"].toString();

....

further fields and segments

....

msg=tmp.copy();
Reply With Quote
Reply

Tags
destination template, destinations, file writer, outbound

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 10:38 AM.


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