Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Converting HL7 message to Base64Binary (http://www.mirthcorp.com/community/forums/showthread.php?t=7622)

msoor 09-06-2012 06:30 AM

Converting HL7 message to Base64Binary
 
I am new to Mirth and need some help trying to send HL7 message as Base64Binary to a downstream system using Web service Sender connector type.

I have the data coming from the SQL Server and have applied the transformer to convert it to HL7 format. Now I need to convert the HL7 message and then send it via web service. I have tried but not able to figure out where and how can I convert the message. Any help with this matter will be greatly appreciated.

I am using Mirth Connect Server version 2.2.1.5861 built on Feb 28, 2012.

Thanks,
MSoor

narupley 09-06-2012 07:17 AM

It's interesting that your client would need an HL7 message as Base64, since it already should be encoded as ASCII (and binary chunks within the message itself should already be in Base64), but it's certainly possible to do. The simplest way is to use Velocity. First, you'll need to include some sort of encoder in your context. You can do that in a transformer:

Code:

$co('Base64',org.apache.commons.codec.binary.Base64);
Then, just include your Base64-converted message in your destination template (the SOAP Envelope for a Web Service Sender):

Code:

${Base64.encodeBase64String(${message.encodedData.getBytes()})}
NOTE: No charset handling is done there; I'll leave that up to you if it's necessary.

rav 09-06-2013 08:01 AM

Hi Nick,

How to do the other way round converting base64 to HL7

cwfowers 09-24-2013 11:57 AM

So what I want to do is create an HL7 message, and encode it to base64. How do I get the byte array from the HL7 in a transformer?

narupley 09-24-2013 01:48 PM

Quote:

Originally Posted by cwfowers (Post 34677)
So what I want to do is create an HL7 message, and encode it to base64. How do I get the byte array from the HL7 in a transformer?

To convert a string to a byte array:

Code:

var byteArray = new java.lang.String(yourStringHere).getBytes(charset);


All times are GMT -8. The time now is 02:41 PM.

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