web stats
msg object in JavaScript Writer? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2015, 09:24 AM
jr76 jr76 is offline
What's HL7?
 
Join Date: Mar 2015
Posts: 2
jr76 is on a distinguished road
Default msg object in JavaScript Writer?

Hi,

I'm trying to implement a JavaScript Writer. Most examples on the web seem to be for writing transformers, and there is a "msg" object available, from which you can do things like:

msg['MSH'][...]

How can I get access to this object (or something similar) in the JavaScript Writer context?

Thanks!
Reply With Quote
  #2  
Old 03-25-2015, 09:27 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

The msg/tmp variables are typically E4X XML objects that are created automatically in a transformer. That's what a transformer is supposed to be used for: transforming the message. So that begs the question: Why are you doing something in a JavaScript Writer that should be done in a transformer?

FYI you can manually declare msg in a JavaScript Writer, by using one of the conversion functions. Use the References list / User API / auto-completion menu, that's what they're there for.

Code:
var msg = new XML(SerializerFactory.getSerializer('HL7V2').toXML(connectorMessage.getEncodedData()));
__________________
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
  #3  
Old 03-25-2015, 09:43 AM
jr76 jr76 is offline
What's HL7?
 
Join Date: Mar 2015
Posts: 2
jr76 is on a distinguished road
Default

Hi,

Thanks for your quick reply. Perhaps I'm going about this the wrong way. I'm using a JavaScript Writer because I wish to invoke a REST service and pass it some values extracted from the message. So I suppose my real question is, what is the appropriate way to extract values from a message in my JavaScript Writer code? I assumed that the "msg" object is what I'm looking for, because that's what I've seen around the web.

Thanks.
Reply With Quote
  #4  
Old 03-25-2015, 09:45 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,117
narupley is on a distinguished road
Default

If you've never used Mirth Connect before, this is a good place to start: http://www.mirthcorp.com/webinars/mi...ect-screencast

Also the User Guide: http://info.mirth.com/Connect_Docume..._Download.html
__________________
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
  #5  
Old 05-01-2017, 12:19 PM
soundhar soundhar is offline
What's HL7?
 
Join Date: Jul 2015
Posts: 1
soundhar is on a distinguished road
Default Hl7 to EXCEL

Guys,

I'm new in mirth interface need to Map Hl7 V2 message in Excel sheet.

I don't how to write transformer? Please give me some suggestion.
Reply With Quote
  #6  
Old 05-03-2017, 02:37 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

Sounds like you also need to go through mirth 101 guide.
http://www.mirthcorp.com/community/w...rth/User+Guide
Reply With Quote
Reply

Tags
javascript writer, msg

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


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