web stats
A few Questions on sending PDF over OBX (I did the research) - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-21-2015, 08:20 AM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default A few Questions on sending PDF over OBX (I did the research)

Hi:

I was hoping someone could answer a few questions for me (please)...

Background: I need to take the 'OBX' section of a report (ORU^R01), convert it to a PDF, and send that HL7 message with the OBX section recreated to have the PDF report encapsulated in it.

I have the 'Source' transformer creating the text for the channelMap variable called 'Report', and the Document Writer which creates the PDF file itself. This works, because I can open the file with Adobe reader.
From the research I've done here, it looks like it is possible to create another channel to take the PDF file and send it via an HL7 message. If this is the case, I don't understand how a person would get the information for the (for example) PID,OBR,PV1 records, for that message does not exist in that second channel?

I would imagine the actual 'Destination' would have to be within the same channel as the one that creates the PDF file, so you still have access to the original message, no? Or am I totally missing something?

Can we create another 'Destination' in the channel that creates the PDF file that runs after the PDF was created (Postprocessor maybe?) and replace the original OBX text with the OBX containing the encapsulated PDF and then send the message?

... If I sound confused, it's because I am.
BTW, I'm using Mirth 2.2

Thank you in advance.
Robert

Last edited by RobertD; 10-21-2015 at 09:11 AM.
Reply With Quote
  #2  
Old 10-21-2015, 10:49 AM
bwscheller bwscheller is offline
 
Join Date: Jun 2015
Location: Boise, ID
Posts: 48
bwscheller is on a distinguished road
Default

Hello Robert,

You are on the right track.

You can have an early destination create the PDF and then a later destination embed it into the OBX segment. You would need to store the PDF filename from the early destination in a map variable so that you can retrieve it in the later destination or pull it from the response of the Document Writer.

Then you can use the FileUtil readBytes and encode methods to Base64 encode the PDF file. I would also recommend that you strip out the CR/LF pairs in the string returned from FileUtil.encode(). They are not required and need to either be also encoded or removed. If you remove them it makes it easier on the recipient and they will not have to decode the CR/LF pair, just Base64 decode.

The results of this process can be stored in OBX.5.5. OBX.2 should be "ED" and OBX.5.4 should be "Base64". You should still have the original message as the input to this destination and can embed the PDF in the existing OBX segment or create a new one.

Brian Scheller
Reply With Quote
  #3  
Old 10-21-2015, 02:54 PM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default

Thank you, Brian - I appreciate your reply.

This is the part I'm not too sure of; would it be possible to give an example of the read and encode method? Again, I apologize, and thank you.

Robert
Reply With Quote
  #4  
Old 10-22-2015, 02:26 AM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default

?

Why are there links to sports games in the post above?
Reply With Quote
  #5  
Old 10-22-2015, 04:23 AM
obsessio obsessio is offline
OBX.3 Kenobi
 
Join Date: Mar 2015
Location: Turkey
Posts: 164
obsessio is on a distinguished road
Default

spam.factory (◣_◢)

Quote:
Originally Posted by RobertD View Post
?

Why are there links to sports games in the post above?
Reply With Quote
  #6  
Old 10-22-2015, 07:19 AM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default

Ok - thank you all for your help, but this is getting strange.

In the transformer (in 'Source'), I am creating the report from the OBX.5 fields, with a </br> in between, and assigning it to a channel map variable called 'Report':

Code:
var	pdfTemplate = "";

for each (seg in msg..OBX)
{
	pdfTemplate = pdfTemplate + seg['OBX.5']['OBX.5.1'];// + '\r\n'; 
	pdfTemplate = pdfTemplate + "<br/>";
}

channelMap.put('Report', pdfTemplate);

for each (seg in msg..OBX)
{
	delete msg.OBX;
}
Then, in 'Destination 1', I am creating the PDF document:
Directory - C:/TMP
File Name - FCS_TMP.PDF
Document Type - PDF
Encrypted - No
Template: ${Report}

Then, in 'Destination 2', I create the HL7 message:
Transformer:
Code:
var Accession = msg[0]['OBX']['OBX.3']['OBX.3.1'].toString();
var Path = "C:/TMP/FCS_TMP.PDF";

java.lang.Thread.sleep(5000);

var fileData = FileUtil.readBytes(Path);
var OBXText = FileUtil.encode(fileData).toString().replace('\r','').replace('\n',''); // strip NL/CR combination

var obx = <OBX/>;
obx['OBX.1']['OBX.1.1'] = "1";
obx['OBX.2']['OBX.2.1'] = "ED";
obx['OBX.3']['OBX.3.1'] = Accession;
obx['OBX.4']['OBX.4.1'] = "Base64";
obx['OBX.5']['OBX.5.1'] = OBXText;
obx['OBX.11']['OBX.11.1'] = "";
obx['OBX.14']['OBX.14.1'] = "";

msg.appendChild(obx);

java.lang.Thread.sleep(5000);

var File = java.io.File;
if (FileUtil.deleteFile(new File(Path))) 
{
	logger.error("File successfully deleted.");
}
else
{
	logger.error("File could not be deleted.");
}
Destination:
Directory - C:/TMP
File Name - FCS_${COUNT}.HL7
Template: ${message.encodedData}


Here's the strange problem


The first time I ran this, it created the PDF file correctly, and in turn the HL7 message correctly.
However, every subsequent time I run this, it uses the information from the FIRST message from the FIRST time I ran it. Even though the PDF file was deleted, and the new message contains different information.
I've even dumped the contents of 'Report' to the error log, and it displays the correct info.

Please help, I'm pulling my hair out!
Mirth Connect 2.2

Last edited by RobertD; 10-22-2015 at 07:24 AM.
Reply With Quote
  #7  
Old 10-22-2015, 07:40 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,116
narupley is on a distinguished road
Default

Did you set an outbound template that you're not using?
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #8  
Old 10-22-2015, 08:14 AM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default

I don't believe so. Here is the exported channel.

Thank you again...


BTW, it won't let me add to your reputation, it says that I need to 'spread it around' :?
Attached Files
File Type: xml 5 - Test PDF File Creation.xml (15.9 KB, 69 views)
Reply With Quote
  #9  
Old 10-22-2015, 11:16 AM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default

OK, this is weird. It has to do with the way 'Report' was mapped into the variable.

I created a *different*, new channel from scratch, and it still used the original data.

I then changed the variable name to 'PDFReport', and it seems to work now, testing with two different HL7 messages. I don't get it, and I'm not convinced it won't happen again.
Can anyone tell me what's possibly happening?

Thank you,
Robert

Last edited by RobertD; 10-22-2015 at 11:35 AM.
Reply With Quote
  #10  
Old 10-23-2015, 03:37 AM
RobertD RobertD is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 89
RobertD is on a distinguished road
Default

Anybody? Please?
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 05:11 AM.


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