web stats
Transformer Error - TypeError: Cannot read property "IN1.43" from undefined - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2009, 08:52 AM
RHavlick RHavlick is offline
Mirth Newb
 
Join Date: Jan 2009
Posts: 10
RHavlick
Default Transformer Error - TypeError: Cannot read property "IN1.43" from undefined

Hello,

I'm still new to Mirth - trying to learn how it works. I'm just trying to do a real simple interface which pulls in a ADT A28 HL7 file. I mapped each segment from the incoming file to a variable, and then using an insert statement populate a database. When I run it, I get all sorts of transformer errors of: ERROR (transformer:?): TypeError: Cannot read property "IN1.43" from undefined. What's happening is that I am reading in an IN1 segment, but say the patient doesn't have a tertiary insurance, so that variable is blank. I tried setting the Default Value for the variable to "" (double quotes) - Doesn't seem to do much. Is there a way to not have variables mapped if they aren't populated in the incoming message?

Thanks.
Reply With Quote
  #2  
Old 03-31-2009, 11:09 AM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,217
jacobb is an unknown quantity at this point
Default

You can use a JavaScript step and check if that segment != undefined first.
Code:
 if (msg['IN1']['IN1.43']['IN1.43.1'] != undefined) {
    // do mapping
}
Also make sure you're trying to map IN1.43.1 and not just IN1.43.
__________________
Jacob Brauer
Mirth Connect Project Lead
Sr. 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
Reply With Quote
  #3  
Old 03-31-2009, 12:13 PM
RHavlick RHavlick is offline
Mirth Newb
 
Join Date: Jan 2009
Posts: 10
RHavlick
Default

Thanks Jacob - there are a TON of fields, so I'm trying to keep this as much drag and dropping as possible just using Mappers and not Java Script...

Just another thought - could I use the import transformer to import and then set default values or something then have the export transformer be the one where the variables are set at? If so how do I do that, and would that eliminate the warnings?

Thanks.
Reply With Quote
  #4  
Old 03-31-2009, 01:44 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,217
jacobb is an unknown quantity at this point
Default

You can still drag and drop elements from the tree into a JavaScript step, but it is a lot more typing.

Does the message you're trying to process and is failing have an IN1 segment at all?
__________________
Jacob Brauer
Mirth Connect Project Lead
Sr. 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
Reply With Quote
  #5  
Old 03-31-2009, 01:53 PM
RHavlick RHavlick is offline
Mirth Newb
 
Join Date: Jan 2009
Posts: 10
RHavlick
Default

Yeah most have at least 1 insurance (IN1 Segment) but can have up to 3. It then goes into a single record in the database. So it's not adding a record for each insurance, it's just grabbing the first iteration of IN1 and placing in some fields, the second in some others, and the third in some others. So that's why I'm creating a variable for each field in the database and trying to populate.

Thanks Jacob.
Reply With Quote
  #6  
Old 02-24-2011, 08:13 AM
joshillian joshillian is offline
Mirth Newb
 
Join Date: May 2010
Location: Temple, TX
Posts: 8
joshillian is on a distinguished road
Default

This is an old issue, but in case anyone else comes across is it, I thought I'd post an expanded solution based on jacobb's earlier suggestion.

More or less, I created a new step of JavaScript type. The intent is to create channelMap variables for each of the needed insurance fields for each of the possible three IN1 segments regardless of whether the segment is defined. If the segment is not present, that segment's variables are simply set to an empty string. This is useful to me because I use each of these variables in an HTTP Sender to build a JSON request, and need each variable represented regardless. Here's my solution:

Code:
channelMap.put( 'in1_companyName','');
channelMap.put( 'in1_planCode','');
channelMap.put( 'in1_policyNumber','');
channelMap.put( 'in1_effectiveDate','');
channelMap.put( 'in1_terminationDate','');
channelMap.put( 'in1_groupName','');
channelMap.put( 'in1_insuredFirstName','');
channelMap.put( 'in1_insuredLastName','');
if(msg['IN1'][0] != undefined){
  channelMap.put('in1_companyName' , msg['IN1'][0]['IN1.4']['IN1.4.1'].toString());
  channelMap.put('in1_planCode' , msg['IN1'][0]['IN1.8']['IN1.8.1'].toString());
  channelMap.put('in1_policyNumber' , msg['IN1'][0]['IN1.36']['IN1.36.1'].toString());
  channelMap.put('in1_effectiveDate' , msg['IN1'][0]['IN1.12']['IN1.12.1'].toString());
  channelMap.put('in1_terminationDate' , msg['IN1'][0]['IN1.13']['IN1.13.1'].toString());
  channelMap.put('in1_groupName' , msg['IN1'][0]['IN1.9']['IN1.9.1'].toString());
  channelMap.put('in1_insuredFirstName' , msg['IN1'][0]['IN1.16']['IN1.16.2'].toString());
  channelMap.put('in1_insuredLastName' , msg['IN1'][0]['IN1.16']['IN1.16.1'].toString());  
}

channelMap.put( 'in2_companyName','');
channelMap.put( 'in2_planCode','');
channelMap.put( 'in2_policyNumber','');
channelMap.put( 'in2_effectiveDate','');
channelMap.put( 'in2_terminationDate','');
channelMap.put( 'in2_groupName','');
channelMap.put( 'in2_insuredFirstName','');
channelMap.put( 'in2_insuredLastName','');
if(msg['IN1'][1] != undefined){
  channelMap.put('in2_companyName' , msg['IN1'][1]['IN1.4']['IN1.4.1'].toString());
  channelMap.put('in2_planCode' , msg['IN1'][1]['IN1.8']['IN1.8.1'].toString());
  channelMap.put('in2_policyNumber' , msg['IN1'][1]['IN1.36']['IN1.36.1'].toString());
  channelMap.put('in2_effectiveDate' , msg['IN1'][1]['IN1.12']['IN1.12.1'].toString());
  channelMap.put('in2_terminationDate' , msg['IN1'][1]['IN1.13']['IN1.13.1'].toString());
  channelMap.put('in2_groupName' , msg['IN1'][1]['IN1.9']['IN1.9.1'].toString());
  channelMap.put('in2_insuredFirstName' , msg['IN1'][1]['IN1.16']['IN1.16.2'].toString());
  channelMap.put('in2_insuredLastName' , msg['IN1'][1]['IN1.16']['IN1.16.1'].toString());  
}

channelMap.put( 'in3_companyName','');
channelMap.put( 'in3_planCode','');
channelMap.put( 'in3_policyNumber','');
channelMap.put( 'in3_effectiveDate','');
channelMap.put( 'in3_terminationDate','');
channelMap.put( 'in3_groupName','');
channelMap.put( 'in3_insuredFirstName','');
channelMap.put( 'in3_insuredLastName','');
if(msg['IN1'][2] != undefined){
  channelMap.put('in3_companyName' , msg['IN1'][2]['IN1.4']['IN1.4.1'].toString());
  channelMap.put('in3_planCode' , msg['IN1'][2]['IN1.8']['IN1.8.1'].toString());
  channelMap.put('in3_policyNumber' , msg['IN1'][2]['IN1.36']['IN1.36.1'].toString());
  channelMap.put('in3_effectiveDate' , msg['IN1'][2]['IN1.12']['IN1.12.1'].toString());
  channelMap.put('in3_terminationDate' , msg['IN1'][2]['IN1.13']['IN1.13.1'].toString());
  channelMap.put('in3_groupName' , msg['IN1'][2]['IN1.9']['IN1.9.1'].toString());
  channelMap.put('in3_insuredFirstName' , msg['IN1'][2]['IN1.16']['IN1.16.2'].toString());
  channelMap.put('in3_insuredLastName' , msg['IN1'][2]['IN1.16']['IN1.16.1'].toString());  
}
--Josh
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 11:33 PM.


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