web stats
Does e4x filtering based on child node values work at all? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-18-2018, 06:50 AM
jonathanlent jonathanlent is offline
OBX.1 Kenobi
 
Join Date: Aug 2014
Location: Denton, TX
Posts: 41
jonathanlent is on a distinguished road
Thumbs down Does e4x filtering based on child node values work at all?

I gather that the version of Rhino in Connect has some issues, but I wanted to ask this to see if anyone had a definitive answer.

Is it possible to use e4x filtering in Mirth 3.5.x to query a node or nodes based on the value in a child node? For example, syntactically I should be able to get the PV1 segment with a set ID of '3' using the following:

msg.PV1.(['PV1.1']['PV1.1.1'] == '3')

Any transformer/filter code with this in it, however, fails to return a value. It seems that this works for non-HL7v2 messages, but the need to use the bracket-and-quote syntax appears to break the filter.

Is there a workaround (use valueOf() here, toString() there, etc.) that will make this work -- or should I just stop trying at this point?

Thanks for the feedback, folks!
Reply With Quote
  #2  
Old 07-18-2018, 02:44 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 800
agermano is on a distinguished road
Default

Code:
msg.PV1.(function() { return new XML(this)['PV1.1']['PV1.1.1'] == '3' }())
The problem is with e4x, not Rhino. e4x doesn't actually define how to access a property using bracket notation in a filter.
Reply With Quote
  #3  
Old 07-19-2018, 05:17 AM
jonathanlent jonathanlent is offline
OBX.1 Kenobi
 
Join Date: Aug 2014
Location: Denton, TX
Posts: 41
jonathanlent is on a distinguished road
Default

I'll take what I can get. Thank you for providing the workaround!
Reply With Quote
  #4  
Old 10-26-2018, 04:26 AM
akathol akathol is offline
Mirth Newb
 
Join Date: Sep 2014
Location: OR, USA
Posts: 10
akathol is on a distinguished road
Default

This is great. Thanks for asking the question I was going to 3 months before I decided to ask it.

Why oh why did they not just use underscores (or any other delimiter that is not an e4x reserved operator)?!
Reply With Quote
  #5  
Old 10-26-2018, 09:41 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 800
agermano is on a distinguished road
Default

I've asked the question several times myself. I think it's because the HL7 specification uses periods (even though though the default parser doesn't produce actual HL7 xml. The strict parser does.)

You could use the function below to convert them if you need to do a lot of filters.

Code:
// start of transformer
replaceInAllDescendantNames(msg, /\./g, '_');

msg.PV1.(PV1_1.PV1_1_1 == '3');

// end of transformer
replaceInAllDescendantNames(msg, /_/g, '.');


function replaceInAllDescendantNames(xml, pattern, replacement) {
    for each (var node in xml.descendants()) {
        if (node.nodeKind() == 'element') {
            node.setLocalName(node.localName().replace(pattern, replacement));
        }
    }
}
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 04:36 PM.


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