web stats
Guidance on sending to csv file with repeating OBX per OBR - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2016, 06:16 AM
paulstein4123 paulstein4123 is offline
What's HL7?
 
Join Date: Jun 2015
Posts: 2
paulstein4123 is on a distinguished road
Default Guidance on sending to csv file with repeating OBX per OBR

Hello. I have scoured this forum and found tons of useful info however now find myself needing expert guidance on what i am trying to achieve. Some of this is javascript related, and some of this is not knowing how to extract the information. Any help appreciated.

Mirth Connect version: 3.3.2.7911

I am trying to build a compendium file or a channel that writes to a .csv file that will continually append the csv file where each line would look like this:

OBR4.1,OBR4.2,OBX3.1,OBX3.2

I have found that i am probably going to need to iterate since I could have an unknown amount of OBXs for each OBR, and will also have the chance for multi-obr messges. I have found some other methods such as getSegmentsAfter and various other ways people have done something similar. But I am getting stuck due to just not knowing enough. I am assuming this should be a JavaScript Source Transform, but whether or not to use msg.OBX or msg..OBX as well as letting the Javascript write to the file or doing a channel map for a destination template is my confusion.

I haven't yet accounted for the OBRs, just literally trying to see this code work but it isn't. Any help appreciated:

var csv="";
for each(var seg in msg..OBX)
{
csv=csv+=seg['OBX.3']['OBX.3.1'].toString()+','+ seg['OBX.3']['OBX.3.2'].toString() + "\n";
}
//FileUtil.write("C:\Desktop", true, csv);
//channelMap.put('csv',csv);
Reply With Quote
  #2  
Old 04-08-2016, 07:29 AM
mcalKno mcalKno is offline
 
Join Date: Apr 2015
Location: Pennsylvania
Posts: 247
mcalKno is on a distinguished road
Default

This should get you started.

PHP Code:
var csv="";
for 
each(obx in msg.OBX
{
var 
obx obx['OBX.3']['OBX.3.1'].toString()+','obx['OBX.3']['OBX.3.2'].toString() + "\n";
csv += obx;    
}
channelMap.put('csv',csv); 
Reply With Quote
  #3  
Old 04-08-2016, 07:50 AM
paulstein4123 paulstein4123 is offline
What's HL7?
 
Join Date: Jun 2015
Posts: 2
paulstein4123 is on a distinguished road
Default

Thank you mcalKno, that did the trick. I also had to remove strict parsing. Can you explain why you used msg.OBX rather than msg..OBX?
Reply With Quote
Reply

Tags
csv, iterate repeating fields, obx

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 07:16 AM.


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