web stats
Does anyone have a simple example of referencing a translation table in a .csv file? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2018, 05:12 AM
J R J R is offline
Mirth Newb
 
Join Date: Nov 2017
Posts: 14
J R is on a distinguished road
Default Does anyone have a simple example of referencing a translation table in a .csv file?

I am still pretty new to MIRTH and have not implemented one of these before, nor do I have a working example of one at any of my current sites.

I have a two column .CSV file that is meant to provide a translation from a mnemonic in MSH.4 to a full facility name.

I tried to use a method I dug up in a search where I put the file in the startup script then reference it from a transformer.

Here is my startup script:
Code:
// Load the Facility Mapping Table
$gc('HIEFacilities',{});
for each (pair in org.apache.commons.io.FileUtils.readFileToString(new java.io.File('E:/Interfaces/MirthMaps/HIEFacilityMap.csv')).split('\r\n|\r|\n'))
	$gc('facilityCodes')[pair.split(',')[1]] = pair.split(',')[0];

return;
Here is the transformer step:
Code:
var msh4 = msg['MSH']['MSH.4']['MSH.4.1'].toString().toUpperCase();
var facility = '';

if ($gc('facilityCodes')[msh4]){
facility = $gc('HIEFacilities')[msh4];}


var srcfac = '';
srcfac += "Source Facility: ";
srcfac += facility
I can't get the channel to deploy to even determine if I am setting the variables correctly.

I get the following error. The value it is erroring on is the first value in the whole table, so I am hoping I just have some kind of syntax error in the Script.

Quote:
125:
$gc('facilityCodes')[pair.split(',')[1]] = pair.split(',')[0];
126:
127: return;
128: }
LINE NUMBER:
125
DETAILS:
TypeError: Cannot set property "HIEACH" of null to "ALLMAN CHILDREN’S HOSPITAL"

at ab8e59a0-3dc0-4357-8807-2f061300461f_Deploy:125 (doScript)

at ab8e59a0-3dc0-4357-8807-2f061300461f_Deploy:129

at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:547)

at com.mirth.connect.server.util.javascript.JavaScrip tUtil$2.doCall(JavaScriptUtil.java:379)

at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
I want to figure out how to do this for the customer, but also because translation tables in general are a basic functionality I should know how to implement.

Is this approach even the right one to take?
Reply With Quote
  #2  
Old 05-17-2018, 05:23 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 533
kirbykn2 is on a distinguished road
Default

The simplest way is a mapper step. Populate your translation values in the the string replacement area.
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.10.4
Mirth Connect Version 3.5.0.8232
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_79-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.4.5
Reply With Quote
  #3  
Old 05-17-2018, 06:36 AM
J R J R is offline
Mirth Newb
 
Join Date: Nov 2017
Posts: 14
J R is on a distinguished road
Default

I have quite an extensive list. Do they have to be manually added or is there an import method I can utilize?
Reply With Quote
  #4  
Old 05-17-2018, 06:56 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 533
kirbykn2 is on a distinguished road
Default

http://www.mirthproject.org/communit...ht=file+lookup
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.10.4
Mirth Connect Version 3.5.0.8232
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_79-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.4.5
Reply With Quote
  #5  
Old 05-17-2018, 06:58 AM
J R J R is offline
Mirth Newb
 
Join Date: Nov 2017
Posts: 14
J R is on a distinguished road
Default

I believe that's the thread where I found the code I tried to use above. I will take another look, maybe I missed something simple.
Reply With Quote
  #6  
Old 05-17-2018, 07:21 AM
J R J R is offline
Mirth Newb
 
Join Date: Nov 2017
Posts: 14
J R is on a distinguished road
Default

I found an issue with the variable name in the script, so now I can at least deploy it, I will see if I have any luck with the transformer now.
Reply With Quote
  #7  
Old 05-17-2018, 10:36 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 213
agermano is on a distinguished road
Default

I thought this post looked familiar...

https://www.mirthcorp.com/community/...d.php?t=218218
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 PM.


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