web stats
TypeError: Cannot read property "X" from undefined - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2011, 06:10 AM
tahvaki tahvaki is offline
Mirth Newb
 
Join Date: Jun 2010
Posts: 6
tahvaki is on a distinguished road
Default TypeError: Cannot read property "X" from undefined

I'm having little difficulties with my CDA R2 messages.

When I send XML message to my channel it gives me this error:
TypeError: Cannot read property "section" from undefined

Here is the error line:
Code:
 tmp['id']['@root'] = validate(msg['SOAP-ENV:Body']['arb:REFDIS']['ClinicalDocument']['component']['StructuredBody']['component'][0]['section']['component2'][1]['section']['component2'][0]['section']['component1']['Observation']['code']['@code'].toString(), '', new Array());
I've already removed "strip namespaces" option from my source and destination because I was having an SOAP-ENV -error. If I don't do any mapping then the message will go ahead just fine, but that won't help me at all. So what could be answer here?
Reply With Quote
  #2  
Old 01-14-2011, 03:37 AM
asulis asulis is offline
Mirth Guru
 
Join Date: Dec 2006
Location: Cagliari, Sardinia, Italy
Posts: 210
asulis is an unknown quantity at this point
Default

Hi tavaki,
Have you tried to put your incoming message inside your inbound template of your transformer in order to control by drag-and-drop if the msg path you follow in your code is correct?
Reply With Quote
  #3  
Old 01-14-2011, 03:50 AM
tahvaki tahvaki is offline
Mirth Newb
 
Join Date: Jun 2010
Posts: 6
tahvaki is on a distinguished road
Default

That's precisely what I have done. And that is the reason why I am so confused. How it can be "undefined", if I have used the drag-and-drop method? You see I have only used the Message Builder to map my message to other message (well actually there are few steps that are in javascript, but only few).

Last edited by tahvaki; 01-14-2011 at 03:53 AM.
Reply With Quote
  #4  
Old 01-14-2011, 09:21 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

it is a bit tricky to deal with xml with namespaces in e4x/Mirth. I usually use the dot notation and wildcard the namespace:
Code:
// this should work
tmp['id']['@root'] = msg.*::Body.*::REFDIS.*::ClinicalDocument.*::component.*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[0].*::section.*::component1.*::Observation.*::code.@code.toString();
// also this would work
tmp['id']['@root'] = msg..*::ClinicalDocument..*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[0].*::section.*::component1.*::Observation.*::code.@code.toString();
__________________
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
  #5  
Old 01-17-2011, 05:21 AM
tahvaki tahvaki is offline
Mirth Newb
 
Join Date: Jun 2010
Posts: 6
tahvaki is on a distinguished road
Default

That seems to be working. Although now I have to edit all the mappings and it's going to be hard job.

Thank you very much dans!
Reply With Quote
  #6  
Old 02-01-2011, 04:59 AM
tahvaki tahvaki is offline
Mirth Newb
 
Join Date: Jun 2010
Posts: 6
tahvaki is on a distinguished road
Default

Ok, I'm having trouble again with the same message. I did use dot notation and wildcard the namespaces like dans suggested, but that doesn't work with atribute which has a colon in it.

Here is the original, which comes when you use the drag and drop method.
Code:
msg['SOAP-ENV:Body']['arb:REFDIS']['ClinicalDocument']['component']['StructuredBody']['component'][0]['section']['component2'][1]['section']['component2'][1]['section']['component1']['Observation']['value']['@xsi:type'].toString()
And here is the one I used the dot notation and wildcard the namespaces.
Code:
msg.*::Body.*::REFDIS.*::ClinicalDocument.*::component.*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[1].*::section.*::component1.*::Observation.*::value.@xsi:type.toString()
So the problem is that Mirth thinks that @xsi:type starts with the colon but never ends. And that is ofcourse wrong, because it's only name of the atribute. I tested by sending a test message without the colon (and offcourse one transformer which matched the sent message) if I can get the value from xsi:type at all, and it worked. But now I have to figure out how I can get the value from xsi:type, without messing with the name of the attribute.

I also tested with this:
Code:
msg.*::Body.*::REFDIS.*::ClinicalDocument.*::component.*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[1].*::section.*::component1.*::Observation.*::value['xsi:type'].toString()
But it didn't give the value with this either.

So the question is, how I can get the value from the @xsi:type?

Last edited by tahvaki; 02-01-2011 at 05:13 AM.
Reply With Quote
  #7  
Old 02-01-2011, 09:04 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

The attribute does not have a colon on it. That is how you write it with a namespace. You should remove the namespace if you wildcard it:
Code:
msg.*::Body.*::REFDIS.*::ClinicalDocument.*::component.*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[1].*::section.*::component1.*::Observation.*::value.@type.toString()
__________________
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
  #8  
Old 02-01-2011, 11:11 PM
tahvaki tahvaki is offline
Mirth Newb
 
Join Date: Jun 2010
Posts: 6
tahvaki is on a distinguished road
Default

Actually I have already unchecked the "Strip namespaces" option. That's because otherwise Mirth will give me an Soap envelope error.
Code:
TypeError: The prefix "SOAP-ENV" for element "SOAP-ENV:Envelope" is not bound.
dans, what is the meaning of your last example? I don't get it at all, I can't use only @type attribute, because there isn't any attribute named like that, it's @xsi:type.

I really need help this is really starting to tick me off because I don't know what to try anymore.

Edit: Sorry, now I understood what you meant. xsi is the namespace and type is actually the attribute. But still it doesn't work with your example.

Last edited by tahvaki; 02-02-2011 at 02:02 AM.
Reply With Quote
  #9  
Old 02-03-2011, 01:55 AM
tahvaki tahvaki is offline
Mirth Newb
 
Join Date: Jun 2010
Posts: 6
tahvaki is on a distinguished road
Default Solved

I solved this situation, but a bit unusual way.

First I took the whole value tag:
Code:
var test_string = msg.*::Body.*::REFDIS.*::ClinicalDocument.*::component.*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[1].*::section.*::component1.*::Observation.*::value.toString();
Now the value from the whole value tag is the whole value tag on xml:
Code:
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PN" xmlns="urn:hl7-org:v3"><given>George</given><given>Lupin</given><family>Doe</family></value>
Next thing I what did, I used string manipulation and regular expressions.
Code:
//The whole value tag.
var test_string = msg.*::Body.*::REFDIS.*::ClinicalDocument.*::component.*::StructuredBody.*::component[0].*::section.*::component2[1].*::section.*::component2[1].*::section.*::component1.*::Observation.*::value.toString();

//The regular expression for getting value from inside quotes at xsi:type="".
var regExp = /(.*)(xsi:type=)(['"])([^'"]*)(['"])(.*)/;

//And the last thing is to replace test_string with the regular expression value 
var test = test_string.replace(regExp, "$4");
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 -7. The time now is 08:55 PM.


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