Simple and clear, thanks. But, can you make a part 2 in which you decode the encoded pdf? Obviously you need something like var decodedByte = new Array(); decodedByte = FileUtil.decode(strData); return new Packages.java.lang.String(decodedByte); But somehow this does not return a copy of the original.
"But somehow this does not return a copy of the original." This, however, does: //read the path to the pdf from OBX.5.1 and get the encoded contents of this pdf var pdfBytes = FileUtil.readBytes(msg['OBX']['OBX.5']['OBX.5.1'].toString()); var encodedPdfBytes = org.apache.commons.codec.binary.Base64.encodeBase64(pdfBytes); var encodedPdfString = new Packages.java.lang.String(encodedPdfBytes); //apparently newlines must be removed var index = encodedPdfString.indexOf(' '); while(index != -1) { encodedPdfString = encodedPdfString.replace(' ', ''); index = encodedPdfString.indexOf(' '); } //store msg['OBX']['OBX.6']['OBX.6.1'] = encodedPdfString; //retrieve the original pdf as follows: //var decodedPdfBytes = org.apache.commons.codec.binary.Base64.decodeBase64(msg['OBX']['OBX.6']['OBX.6.1'].toString()); //FileUtil.write('C:\\temp\\test_out.pdf', false, decodedPdfBytes);
Nicely explained ... Created Library with new code template for PDF to base64 conversion. Transformation done with sample message using (pdf --> OBX5.1 and base64 --> OBX6.1 Assigned user defined library to channel. Followed same steps for Destination connector with "File" Method BUT constantly getting "error in the form for connector "file writer"". Also I am able to successfully test writer directory. Tried with the same file name "msg.hl7" as demonstrated. Can you please assist for the error code to resolve.
Sure, Can you share me the exact error? Which version of Mirth are you trying with? You mean to say that the conversion to base64 is happening, however, while writing the file to the destination folder throws the error?
@@comptech4us192 I am using Mirth Connect 3.9.0 version and I have noticed it has two additional parameters while configuring destination of the channel. 1. Keep connection open 2. Max Idle time (ms) Error: Error in the form for connector "File Writer"
Man.. you have made it look so simple and easy. Thanks for making this video. Cheers!
Very good explanation!
Thanks a lot with simple demo.
That was helpful. Thank you.
😀 Perfect. Worked second time ! (I had put the the wrong info in the Destination Template. It was supposed to be ${message.rawData})
Great video
Nice explanation
what do you mean by "file path" in OBX segement 5.1 (used as a template)
how to convert from xml with xsl file to proper xml using mirth connect?? Please tell me bro
Simple and clear, thanks.
But, can you make a part 2 in which you decode the encoded pdf? Obviously you need something like
var decodedByte = new Array();
decodedByte = FileUtil.decode(strData);
return new Packages.java.lang.String(decodedByte);
But somehow this does not return a copy of the original.
"But somehow this does not return a copy of the original."
This, however, does:
//read the path to the pdf from OBX.5.1 and get the encoded contents of this pdf
var pdfBytes = FileUtil.readBytes(msg['OBX']['OBX.5']['OBX.5.1'].toString());
var encodedPdfBytes = org.apache.commons.codec.binary.Base64.encodeBase64(pdfBytes);
var encodedPdfString = new Packages.java.lang.String(encodedPdfBytes);
//apparently newlines must be removed
var index = encodedPdfString.indexOf('
');
while(index != -1) {
encodedPdfString = encodedPdfString.replace('
', '');
index = encodedPdfString.indexOf('
');
}
//store
msg['OBX']['OBX.6']['OBX.6.1'] = encodedPdfString;
//retrieve the original pdf as follows:
//var decodedPdfBytes = org.apache.commons.codec.binary.Base64.decodeBase64(msg['OBX']['OBX.6']['OBX.6.1'].toString());
//FileUtil.write('C:\\temp\\test_out.pdf', false, decodedPdfBytes);
is it possible for you to share the xml of the channel ?
Nicely explained ...
Created Library with new code template for PDF to base64 conversion.
Transformation done with sample message using (pdf --> OBX5.1 and base64 --> OBX6.1
Assigned user defined library to channel.
Followed same steps for Destination connector with "File" Method BUT constantly getting "error in the form for connector "file writer"".
Also I am able to successfully test writer directory.
Tried with the same file name "msg.hl7" as demonstrated.
Can you please assist for the error code to resolve.
Sure, Can you share me the exact error? Which version of Mirth are you trying with? You mean to say that the conversion to base64 is happening, however, while writing the file to the destination folder throws the error?
@@comptech4us192 I am using Mirth Connect 3.9.0 version and I have noticed it has two additional parameters while configuring destination of the channel.
1. Keep connection open
2. Max Idle time (ms)
Error: Error in the form for connector "File Writer"
@@ubaidurrehman1594 Ok. Can you export the channel and send it to me. I can have a look into it.
Error: File does not exist
I used directory of pdf in the message template still it can read the pdf