web stats
mirth map .csv to multiple ORC & OBX segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-26-2018, 03:36 AM
Mark Sull Mark Sull is offline
Mirth Newb
 
Join Date: Apr 2018
Location: Ireland
Posts: 24
Mark Sull is on a distinguished road
Default mirth map .csv to multiple ORC & OBX segments

Hi,

I have built a route to convert a .csv(file reader) to a .hl7(tcp sender) where I have inputted the below java script to map to .csv columns to respective HL7 fields based on an outbound message template in the source transformer.

The .csv has 7 columns in total where 4 columns contain an old order/observation ID and new order/observation ID. The route works fine up until I reference the repeating ORC and OBX segments. I get the below error, which I assume means that mirth cant figure out which ORC/OBX segment to place the data in.

Code:
//save metadata info
channelMap.put('phys_id1', msg['row']['ID1'].toString());
channelMap.put('phys_id2', msg['row']['ID2'].toString());

//generate unique filename to be used in the filewriter
var filename = ('0000000000' + connectorMessage.getMessageId()).slice(-10) + '.hl7';
channelMap.put('uniqueFileName', filename);

	tmp['PID']['PID.3']['PID.5.1'] = msg['row']['ID1'].toString();
	tmp['PID']['PID.3']['PID.3.4'] = msg['row']['Assigningauthority1'].toString();
	tmp['PID']['PID.3']['PID.3.5'] = msg['row']['Identifiertypecode1'].toString();

//OLD ORC/OBR
	tmp['ORC']['ORC.2']['ORC.2.1'] = msg['row']['OLDORDER'].toString();
	tmp['OBR']['OBR.3']['OBR.3.1'] = msg['row']['OLDOBS'].toString();

	
//NEW ORC/OBR - when added to the java script it fails and provides an error
	tmp['ORC']['ORC.2']['ORC.2.1'] = msg['row']['NEWORDER'].toString();
	tmp['OBR']['OBR.3']['OBR.3.1'] = msg['row']['NEWOBS'].toString();

Quote:
Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransforme rException:
CHANNEL: G2SPeech_CSV-TO-HL7_ORM_Replacement_MSU
CONNECTOR: sourceConnector
SCRIPT SOURCE: TRANSFORMER
SOURCE CODE:
66: tmp['PID']['PID.3']['PID.5.1'] = msg['row']['ID1'].toString();
67: tmp['PID']['PID.3']['PID.3.4'] = msg['row']['Assigningauthority1'].toString();
68: tmp['PID']['PID.3']['PID.3.5'] = msg['row']['Identifiertypecode1'].toString();
69:
70: //OLD ORC/OBR
71: tmp['ORC']['ORC.2']['ORC.2.1'] = msg['row']['OLDORDER'].toString();
72: tmp['OBR']['OBR.3']['OBR.3.1'] = msg['row']['OLDOBS'].toString();
73:
74:
75: //NEW ORC/OBR
LINE NUMBER: 71
DETAILS: TypeError: Assignment to lists with more than one item is not supported
at d2d7fced-c5ec-4dd6-8546-b72e188a7c3f:71 (doTransform)
at d2d7fced-c5ec-4dd6-8546-b72e188a7c3f:99 (doScript)
at d2d7fced-c5ec-4dd6-8546-b72e188a7c3f:101
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)

Is there a method to call a repeating segment in java script? maybe a prefix at the start of the script (i.e. [1] ['ORC']['ORC.2']['ORC.2.1'], [2]['ORC']['ORC.2']['ORC.2.1'] ? not sure what the solution is.

I've attached the a sample .csv and the xml mirth route.
Attached Files
File Type: xml G2SPeech_CSV-TO-HL7_ORM_Replacement_MSU.xml (25.1 KB, 1 views)
File Type: txt orm.txt (49 Bytes, 3 views)
Reply With Quote
  #2  
Old 09-26-2018, 05:32 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

tmp['ORC'] returns an XMLList of all ORC segments in the tmp object. They are 0 indexed.

Code:
tmp['ORC'][0]['ORC.2']['ORC.2.1'] = msg['row']['OLDORDER'].toString(); // the first ORC in tmp
tmp['ORC'][1]['ORC.2']['ORC.2.1'] = msg['row']['NEWORDER'].toString(); // the second ORC in tmp
Reply With Quote
  #3  
Old 09-26-2018, 05:34 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,176
agermano is on a distinguished road
Default

If your outbound template has two ORC segments, it should put the index values in for you, if you were to drag-and-drop map from your inbound message to your outbound message (it will create Message Builder steps for you in this case.)
Reply With Quote
  #4  
Old 09-27-2018, 05:10 AM
Mark Sull Mark Sull is offline
Mirth Newb
 
Join Date: Apr 2018
Location: Ireland
Posts: 24
Mark Sull is on a distinguished road
Default Correct :)

Worked a treat, thanks as always Agermano
Reply With Quote
Reply

Tags
.csv, hl7

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 01:53 PM.


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