web stats
How to map from a list - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #11  
Old 01-03-2013, 07:43 AM
nhaerich nhaerich is offline
OBX.2 Kenobi
 
Join Date: Oct 2010
Posts: 97
nhaerich is on a distinguished road
Default

Before I could deploy this, the receiving vendor made some changes to their request. Here is the scenario: Instead of just a single list lookup like I thought I would have, I now have a conversion list for allergies that I need to take into account. This new list has a "was" column and an "is" column like this:

apple, fruit
bread, wheat
cheese, milk product

What I need to do is read the first column of this for each instance of the
A1-3-2 segment (everything left of the comma in the text file). If I have an allergy that is in the list, I need to replace what is in AL1-3-2 with the corresponding item in column 2, if however, the item is NOT on the list, I have to dump that particular allergy from the message.

I ran the code as listed above, and the item "peanut" is the first item that that is on the allergy list, however, I received the error message:

DETAILS: TypeError: Cannot read property "peanut" from null

Any help would be greatly appreciated.
Thanks

Last edited by nhaerich; 01-03-2013 at 08:24 AM.
Reply With Quote
  #12  
Old 01-03-2013, 08:31 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

What code are you using, and what CSV are you using (a small sample is fine)?
__________________
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
  #13  
Old 01-03-2013, 09:26 AM
nhaerich nhaerich is offline
OBX.2 Kenobi
 
Join Date: Oct 2010
Posts: 97
nhaerich is on a distinguished road
Default

The code is

for each (al1 in msg.AL1)
if ($gc('allergyCodes')[al1['AL1.3']['AL1.3.2'].toString()])
al1['AL1.3']['AL1.3.1'] = $gc('allergyCodes')[al1['AL1.3']['AL1.3.2'].toString()];

The txt file (not csv if that makes a difference) looks like this:

Pea,Pea
Pea Flour,Flour
Peach,Fruit
peanut,peanut
Pecan,Pecan
Pine Nut,Pine Nut
Pineapple,Fruit
Pinto Bean,Bean
Pistachio,Pistachio
Plum,Fruit

Thanks
Reply With Quote
  #14  
Old 01-03-2013, 09:33 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Are you sure you have a deploy script that is creating the global channel map variable in the first place?
__________________
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
  #15  
Old 01-03-2013, 09:45 AM
nhaerich nhaerich is offline
OBX.2 Kenobi
 
Join Date: Oct 2010
Posts: 97
nhaerich is on a distinguished road
Default

This is the script that I have listed in the Scripts section of hte ADT feed. Is this what you are talking about?

$gc('allergyCodes',{});
for each (pair in org.apache.commons.io.FileUtils.readFileToString(n ew
java.io.File('/opt/scripts/conversion.txt')).split('\r\n|\r|\n'))
$gc('allergyCodes')[pair.split(',')[1]] = pair.split(',')[0];
return;
Reply With Quote
  #16  
Old 01-03-2013, 09:48 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Quote:
Originally Posted by nhaerich View Post
This is the script that I have listed in the Scripts section of hte ADT feed. Is this what you are talking about?

$gc('allergyCodes',{});
for each (pair in org.apache.commons.io.FileUtils.readFileToString(n ew
java.io.File('/opt/scripts/conversion.txt')).split('\r\n|\r|\n'))
$gc('allergyCodes')[pair.split(',')[1]] = pair.split(',')[0];
return;
Yep; that's listed in the Deploy script right? Also, if you need to map from column 1 to column 2, the "[1]" and "[0]" will have to be switched around.
__________________
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
  #17  
Old 01-03-2013, 11:24 AM
nhaerich nhaerich is offline
OBX.2 Kenobi
 
Join Date: Oct 2010
Posts: 97
nhaerich is on a distinguished road
Default

I verified that this is in the Script section & it is set to Deploy. I changed around the script so it would convert column 1 to 0, & re-processed the interface message. I still receive an error message:

DETAILS: TypeError: Cannot read property "peanut" from null

What else can I look at to fix this?

Thanks
Reply With Quote
  #18  
Old 01-03-2013, 11:25 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Quote:
Originally Posted by nhaerich View Post
I verified that this is in the Script section & it is set to Deploy. I changed around the script so it would convert column 1 to 0, & re-processed the interface message. I still receive an error message:

DETAILS: TypeError: Cannot read property "peanut" from null

What else can I look at to fix this?

Thanks
Can you post the channel you're using?
__________________
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
  #19  
Old 01-03-2013, 11:45 AM
nhaerich nhaerich is offline
OBX.2 Kenobi
 
Join Date: Oct 2010
Posts: 97
nhaerich is on a distinguished road
Default

The interface in question is labeled Computrition. If it's worth anything, I have also tried sending across an ADT message that did not have any AL1 data that would have qualified & I got the same error message, so it is like the translation isn't reading the file or isn't processing the script correctly.

Thanks for the help on this issue!
Attached Files
File Type: xml HMC TEST ADT FEED.xml (145.1 KB, 6 views)
Reply With Quote
  #20  
Old 01-03-2013, 11:50 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Quote:
Originally Posted by nhaerich View Post
The interface in question is labeled Computrition. If it's worth anything, I have also tried sending across an ADT message that did not have any AL1 data that would have qualified & I got the same error message, so it is like the translation isn't reading the file or isn't processing the script correctly.

Thanks for the help on this issue!
The code you have in the deploy script is not:

Code:
$gc('allergyCodes',{});
for each (pair in org.apache.commons.io.FileUtils.readFileToString(new 
java.io.File('/Users/nickr/Desktop/conversion.txt')).split('\r\n|\r|\n'))
	$gc('allergyCodes')[pair.split(',')[0]] = pair.split(',')[1];
return;
Rather it is this:

Code:
return;

$gc('allergyCodes',{});
for each (pair in org.apache.commons.io.FileUtils.readFileToString(new 
java.io.File('/Users/nickr/Desktop/conversion.txt')).split('\r\n|\r|\n'))
	$gc('allergyCodes')[pair.split(',')[0]] = pair.split(',')[1];
return;
Because it's returning right away the global channel map variable never gets initialized. Remove that first "return;" and it should work.
__________________
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 10:27 AM.


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