web stats
Retrieve Segment Value in Preprocessor - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2014, 11:10 AM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default Retrieve Segment Value in Preprocessor

I have a channel with multiple destinations that needs a value from the incoming HL7 message. I've gone through a couple threads and from what I've read it looks like the msg isn't available in the preprocessor.

So I'm wondering how can I get the value from the incoming message? Say like the Control ID from MSH-10.


This is what I have so far in the preprocessor:

Code:
var xmsg = new XML(SerializerFactory.getHL7Serializer().toXML(message));
var msgid = xmsg[MSH][MSH.10][MSH.10.1].toString;
But the validator says I'm missing a bracket (]) in index expression. Not sure what this error means.
Reply With Quote
  #2  
Old 01-22-2014, 12:01 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,115
narupley is on a distinguished road
Default

The msg variable isn't available in the preprocessor because the preprocessor is only meant for string manipulation / replacement, before serialization occurs.

The validator is complaining because your syntax is invalid. It should be something like "xmsg['MSH']['MSH.10']['MSH.10.1'].toString();" instead.
__________________
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 01-22-2014, 12:19 PM
skekasaurus skekasaurus is offline
OBX.3 Kenobi
 
Join Date: Dec 2013
Posts: 145
skekasaurus is on a distinguished road
Default

Yeah I just saw that. Haha.
Now that I've fixed the syntax it validates, however I'm not sure I'm actually capturing the value I want for the other destinations to use.

This is what I have now:
Code:
var xmsg = new XML(SerializerFactory.getHL7Serializer().toXML(message));
var msgid = xmsg['MSH']['MSH.10']['MSH.10.1'].toString;

globalChannelMap.put('MessageID', msgid);

return message;
Would this work?
Reply With Quote
  #4  
Old 01-22-2014, 12:26 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,115
narupley is on a distinguished road
Default

As indicated in the code example in my last post, you need to use "toString()", not "toString".
__________________
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
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 09:29 PM.


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