Announcement

Collapse
No announcement yet.

How to wirte outbound message at destination

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

  • 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

  • #2
    Perhaps posting your channel would help us more understand what you are doing.

    Comment


    • #3
      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();

      Comment

      Working...
      X