web stats
Multiple Base64 decoding - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2019, 09:36 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default Multiple Base64 decoding

I'm trying to decode multiple base64 lines in a single HL7 message into individual files, although I'm only getting the last one. The filename is derived from OBX.3.1 and the report from OBX.5.1

Example:
OBX|1||1.tif||SKFGhGUWEiijiwbie.................
OBX|1||2.tif||SKFGhGUWEiwioae4................
OBX|1||3.tif||SKFGhGUWEieiiwn4.................

The code i'm using:

for each (obx in msg.OBX)
{
var obx31 = obx['OBX.3']['OBX.3.1'].toString();
$gc('fn',obx31);
var obx51 = obx['OBX.5']['OBX.5.1'].toString();
$gc('report',obx51);
}

Any tips on how to accomplish this would be greatly appreciated!

Thank you,
Matt

Last edited by mhaase; 02-20-2019 at 10:10 AM. Reason: typo
Reply With Quote
  #2  
Old 02-20-2019, 09:47 AM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 727
jbartels is on a distinguished road
Default

You're overwriting the report variable every time. Use a different variable for each iteration of the loop
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #3  
Old 02-20-2019, 10:19 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 60
mhaase is on a distinguished road
Default

My initial post of the code had a typo: $gc('report',obx31) --> $gc('fn',obx31)

The issue is that the first two lines don't appear to be processed when a message is received.
Reply With Quote
  #4  
Old 02-20-2019, 06:32 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,000
agermano is on a distinguished road
Default

Like he said, you're using the same globalChannelMap key (which isn't the appropriate map in this case, anyway) on every iteration of the loop. When the loop is finished, the value of the key holds the last thing that was stored to that key.

You're likely going to run into issues once you get your loop figured out. If you are trying to use a File Writer, you can only write one file per message. You'll either want to write the files (using java/javscript) in the same place where your are doing your loop (either a transformer or javascript writer) or route the files as separate message to a second channel that can use a File Writer to write 1 file at a time.

Either way, you shouldn't need to store the pdfs in a mirth Map at all. If writing the files in the loop itself, you don't need to store them. If routing to a second channel, it would be better to store them in attachments in the first channel and pass the extended attachment id to the second channel if you are using mirth 3.5+. Otherwise, the pdf should be the message body. You can include the filename and path as sourceMap variables in the new message.
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 08:35 AM.


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