web stats
Attachments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2013, 06:39 AM
sandersmr sandersmr is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 71
sandersmr is on a distinguished road
Default Attachments

I'm using Mirth 2.2.3.6825. I'm trying to use attachments for PDF and RTF documents in MDM messages. For the most part, we have it working. In the Pre-processor, we have:

Code:
// Modify the message variable below to pre process data
var hl7XML = new XML(SerializerFactory.getHL7Serializer().toXML(message));

var messagetype = hl7XML['MSH']['MSH.9']['MSH.9.1'].toString();

if (messagetype == "MDM"){

	for(var i = 0; i < hl7XML['OBX'].length(); i++)
	{
		var obx5 = hl7XML['OBX'][i]['OBX.5']['OBX.5.1'].toString();
		if (org.apache.commons.lang.StringUtils.isNotBlank(obx5))
		{
			var attachment;
			if (hl7XML['OBX'][i]['OBX.3']['OBX.3.1'].toString() == "text/rtf")
				attachment = addAttachment(obx5,'text/rtf');
			else
				attachment = addAttachment(obx5,'application/pdf');
			hl7XML['OBX'][i]['OBX.5']['OBX.5.1'] = attachment.getAttachmentId();	
		}
	}

	for(var i = 0; i < hl7XML['ZFT'].length(); i++)
	{
		var zft1 = hl7XML['ZFT'][i]['ZFT.1']['ZFT.1.1'].toString();
		if (org.apache.commons.lang.StringUtils.isNotBlank(zft1))
		{
			var attachment = addAttachment(zft1,'text/rtf');
			hl7XML['ZFT'][i]['ZFT.1']['ZFT.1.1'] = attachment.getAttachmentId();	
		}
	}

}

return SerializerFactory.getHL7Serializer().fromXML(hl7XML);
So it parses out the message, checks whether there's anything in OBX and whether in ZFT (we could potentially receive documents in either one, but only RTFs can appear in the ZFT segment).

Then on the destination, we use the ${MESSAGEATTACH} mapping in the template. This generally works well, except every now and then, we'll get an error where in the HL7 message, we see the attachment id, but when looking at the Attachments tab, there's nothing listed. This causes the message to error out (though it doesn't get marked as Errored). What would be causing this?
Reply With Quote
  #2  
Old 09-24-2013, 07:25 AM
schillert schillert is offline
OBX.1 Kenobi
 
Join Date: Jul 2012
Posts: 31
schillert is on a distinguished road
Default

I also encountered this (or a very similar) problem.

Suppose your attachment doesn't get written into the database.

addAttachment won't throw an exception but just carry on.

When composing the outgoing message ${MESSAGEATTACH} won't find any matching attachment ID since it looks into the database. So nothing will be replaced.

I use getAttachments().isEmpty() to check if the attachment is actually in the DB.
Reply With Quote
  #3  
Old 09-24-2013, 08:04 AM
sandersmr sandersmr is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 71
sandersmr is on a distinguished road
Default

That's what I suspected (not writing to the database), I just didn't understand why it happened.

Do you happen to know how to manually attach attachments? I never could find anything on that. I know of the getAttachments() call, but it returns a list of possible attachments but I don't know what call(s) would be needed to actually attach it.


On another note, do you (or anyone else) know if pruning actually gets rid of the attachment? I assume so, but I want to verify.
Reply With Quote
  #4  
Old 09-26-2013, 06:36 AM
schillert schillert is offline
OBX.1 Kenobi
 
Join Date: Jul 2012
Posts: 31
schillert is on a distinguished road
Default

Failure writing to database: We use MySql. I experienced database locks due to a long running queries that made Mirth give up to try to write an attachment or message.
The pruning process for example sometimes prevents Mirth from writing to the MESSAGE table.

I don't know if I'm getting you wrong but if writing of an attachment fails there is no way to attach it because it isn't in the DB at the time the destination connector wants to pull it.

The getAttachments call returns a list of all attachments (in the DB) related to the messageObject.

The last step of the pruning process gets rid of orphaned attachments by looking for attachments whose MESSAGE_ID isn't an ID in MESSAGE anymore and deleting them.
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 10:37 AM.


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