web stats
Dynamically add images to a PDF - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-18-2013, 10:25 AM
ffowler ffowler is offline
OBX.1 Kenobi
 
Join Date: May 2011
Posts: 50
ffowler is on a distinguished road
Angry Dynamically add images to a PDF

Good day to you all,
I am using Mirth Connect version 2.2.1.5861 and am successfully creating and emailing PDF files constructed from ORU messages. I would like to include an image on the table row if a result is abnormal. I construct the table in a source transformer step (which is below) however, the image never shows up. I see the cell that is created but for some reason, I can not get the image to appear. Any ideas from the code below would be greatly appreciated.

#Code
// Scroll thru all of the OBX segments
for each (resOBX in msg..OBX) {
// Create a new table row
tr = new XML('<tr></tr>');
// Create a new cell in the first position
tr['td'][0] = '';
// If a value is not normal, place a H icon in the first cell
if (resOBX['OBX.8']['OBX.8.1'].toString() != "") {
tr['td'][0]['img']['@src'] = "C:/Mirth/images/HFlag.png";
tr['td'][0]
}
// Create a second cell which holds the Test Name
tr['td'][1] =resOBX['OBX.3']['OBX.3.2'].toString();
// Create a third cell which holds the Result
tr['td'][2] = resOBX['OBX.5']['OBX.5.1'].toString() + " "+ resOBX['OBX.6']['OBX.6.1'].toString();
// Create a fouth cell for the Flag
tr['td'][3] = resOBX['OBX.8']['OBX.8.1'].toString();
// Create a fifth cell for the Reference range
tr['td'][4] = resOBX['OBX.7']['OBX.7.1'].toString() + " " + resOBX['OBX.6']['OBX.6.1'].toString();
// Add the row to the results HTML collection
results[''] += tr;
}
Reply With Quote
  #2  
Old 03-18-2013, 10:58 AM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 459
upstart33 is on a distinguished road
Default

I'm pretty sure that you will have to encode the image using Base64 and then the receiving application would have to decode it.


Quick example:
Code:
var contents = FileUtil.readBytes('C:/HL7DOCS/image.jgg');
var encData=FileUtil.encode(contents);

//remove the newlines to produce valid Base64
var index = encData.indexOf("\r\n");
    while(index != -1){
        encData = encData.replace("\r\n","");
        index = encData.indexOf("\r\n");
    }


tmp['OBX']['OBX.5']['OBX.5.5']=encData;

Last edited by upstart33; 03-18-2013 at 11:03 AM.
Reply With Quote
  #3  
Old 03-18-2013, 12:14 PM
ffowler ffowler is offline
OBX.1 Kenobi
 
Join Date: May 2011
Posts: 50
ffowler is on a distinguished road
Default

Thanks for the reply. I'll give it a go.
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 07:11 AM.


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