web stats
Help in setting outbound message "tmp" from a text file. - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-17-2011, 11:49 AM
TDS TDS is offline
Mirth Newb
 
Join Date: Aug 2010
Posts: 17
TDS is on a distinguished road
Red face Help in setting outbound message "tmp" from a text file.

I have the following code in my transformer:

var contents = FileUtil.read('Response.hl7') + "";
tmp = SerializerFactory.getHL7Serializer(false, false, true).toXML(contents).toString();

tmp['MSH']['MSH.7']['MSH.7.1'] = DateUtil.getCurrentDate("yyyyMMddhhmmss");

The assignment for tmp['MSH']... fails?

What am I doing wrong?

The reason I am reading from a file is that I want this to be dynamic (i.e. the contents of the file can be changed to provide a different response).
Reply With Quote
  #2  
Old 03-17-2011, 11:56 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default

You need to put a template message in the outbound message template.
Reply With Quote
  #3  
Old 03-17-2011, 11:59 AM
TDS TDS is offline
Mirth Newb
 
Join Date: Aug 2010
Posts: 17
TDS is on a distinguished road
Default

Quote:
Originally Posted by StefanScholte View Post
You need to put a template message in the outbound message template.
Stefan,

Thanks for the quick response. I do have the template message and that works fine.

However, in this case I want to be able to replace the template message with a completely new message that is read from a file.
Reply With Quote
  #4  
Old 03-21-2011, 12:06 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default

Well Here's what I have done recently with an query response channel.

in the outbound template I put only the MSH segment (and only the pipes)
Then when you turn to the tab and drag a field onto the javascript it looks like this:

tmp['MSH']['MSH.7']['TS.1'] (nothing fancy)

but when you want to use the PID segment or other then you need to use
tmp['ADR_A19.QUERY_RESPONSE']['PID']['PID.3']['CX.4']['HD.1']
in my case it is tmp['ADR_A19.QUERY_RESPONSE']
I don't know what type of message you want to generate.

I developed this message using an outbound template. and when finished I deleted the entire message except for the MSH segment.
I hope this will point you in the right direction.

kind regards.
Reply With Quote
  #5  
Old 03-21-2011, 05:27 AM
TDS TDS is offline
Mirth Newb
 
Join Date: Aug 2010
Posts: 17
TDS is on a distinguished road
Default

Quote:
Originally Posted by StefanScholte View Post
Well Here's what I have done recently with an query response channel.

in the outbound template I put only the MSH segment (and only the pipes)
Then when you turn to the tab and drag a field onto the javascript it looks like this:

tmp['MSH']['MSH.7']['TS.1'] (nothing fancy)

but when you want to use the PID segment or other then you need to use
tmp['ADR_A19.QUERY_RESPONSE']['PID']['PID.3']['CX.4']['HD.1']
in my case it is tmp['ADR_A19.QUERY_RESPONSE']
I don't know what type of message you want to generate.

I developed this message using an outbound template. and when finished I deleted the entire message except for the MSH segment.
I hope this will point you in the right direction.

kind regards.
Thanks much Stefan for the response. Since I wanted the tmp variable to be completely dynamic, I cannot use this as I cannot figure out how to perform a complete substitution of tmp from the HL7 in the read file.

I changed my logic to require me to just update for the fields I need changing. i.e. using your approach of setting the relevant tmp fields. This worked and so I have what I need.

Thanks again for taking the time to respond.
Reply With Quote
  #6  
Old 03-21-2011, 12:01 PM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

you should be able to replace tmp but you need to do it with an XML object
Code:
// something like this:
tmp = new XML(SerializerFactory.getHL7Serializer(false, false, true).toXML(contents));
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #7  
Old 03-21-2011, 12:05 PM
TDS TDS is offline
Mirth Newb
 
Join Date: Aug 2010
Posts: 17
TDS is on a distinguished road
Default

Dan,

Thanks much. This is exactly what I was looking for.

Kind regards.
Reply With Quote
  #8  
Old 08-05-2011, 03:59 PM
Chuck Chuck is offline
Mirth Newb
 
Join Date: Jul 2011
Location: Seattle
Posts: 7
Chuck is on a distinguished road
Default

Quote:
Originally Posted by dans View Post
you should be able to replace tmp but you need to do it with an XML object
Code:
// something like this:
tmp = new XML(SerializerFactory.getHL7Serializer(false, false, true).toXML(contents));


What if the outbound message template is X12 and not XML?
Reply With Quote
  #9  
Old 08-08-2011, 03:25 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default

If you look under the reference tab you will notice a conversion method
called: "Convert X12 to XML" and "Convert XML to X12"

Those should suit your needs.

Kind regards
Stefan Scholte
Reply With Quote
Reply

Tags
file, message, outbound, read, tmp

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:04 PM.


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