web stats
DICOM OB as array of bytes - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2009, 01:12 PM
tmatimar tmatimar is offline
What's HL7?
 
Join Date: Jan 2008
Posts: 5
tmatimar
Default DICOM OB as array of bytes

Hi,

I'm trying to extract a PDF file from a DICOM encapsulated PDF. The PDF file exists in the tag (0042,0011), which is type OB ... effectively a byte array, just like pixel data would be.

However, from javascript, it appears as a backslash-separated list of hex digits like 25\50\44\46\2D\31\... (PDF files always start with %PDF-1). I want to either send the bytes to the channelMap, or write it as a file, either would be fine, but I can't find any way to get it (or convert it) back to native form.

Ideally, depending on the site, I'd either dump it as a PDF file, or I'd convert it to ED and send it in the ORU.

I have attached a sample DICOM encapsulated PDF file.

For testing, I am using storescu.exe from the command line to test sending the DICOM encapsulated PDF.
storescu -aec MIRTH localhost 14104 pdf2.dcm
storescu is part of the OFFIS DCMTK toolkit (http://dicom.offis.de/dcmtk).

And, for reference, I'm also attaching a channel. This is not entirely useful because it doesn't work, but it may serve as a starting point.

Any suggestions?
Thanks,
Ted
Attached Files
File Type: zip pdf2.zip (1.5 KB, 67 views)
File Type: xml DICOM_PDF.xml (16.5 KB, 58 views)

Last edited by tmatimar; 07-08-2009 at 06:16 AM. Reason: attempt at improved formatting
Reply With Quote
  #2  
Old 07-06-2009, 03:38 PM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

You might want to try to convert the hex into decimals and see if that gives you the pdf data. Maybe this would give you some more info: http://mindprod.com/jgloss/hex.html
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #3  
Old 07-07-2009, 05:22 AM
tmatimar tmatimar is offline
What's HL7?
 
Join Date: Jan 2008
Posts: 5
tmatimar
Default

The hex is a hex dump of the byte stream. Converting it to decimals is not the right step. Converting it from hex back to a byte stream would be useful, but I'm not aware of any way to do this in Mirth/Javascript. If it had been a base64 encoding of the same byte stream, there would be a way to convert it.
Reply With Quote
  #4  
Old 07-07-2009, 07:53 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

google gave me this:
http://stackoverflow.com/questions/1...ray-using-java

and

http://forums.sun.com/thread.jspa?threadID=546486
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #5  
Old 07-07-2009, 08:44 AM
tmatimar tmatimar is offline
What's HL7?
 
Join Date: Jan 2008
Posts: 5
tmatimar
Default

Yes, I could certainly do it in Java. But I'm trying to do it in Javascript. If I were doing it in Java, I would access the data directly and not use the Mirth routines at all. This is about using Mirth for what Mirth is meant to be used for.
Reply With Quote
  #6  
Old 07-07-2009, 08:50 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

You can use Java when scripting in Mirth. You just have to use javascript syntax. For example if you wanted to use a Java String object:
Code:
var myString = new java.lang.String();
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #7  
Old 07-07-2009, 09:00 AM
tmatimar tmatimar is offline
What's HL7?
 
Join Date: Jan 2008
Posts: 5
tmatimar
Default

That sounds useful. I'll give it a try later this week and let you know if it works.
Thanks,
Ted
Reply With Quote
  #8  
Old 07-08-2009, 06:15 AM
tmatimar tmatimar is offline
What's HL7?
 
Join Date: Jan 2008
Posts: 5
tmatimar
Default

After some trial and error, I have managed to get this to work.

The trick was that I needed a Javascript array of java.lang.Byte's (which are signed). The root of the fix is the following:
var pdf_str = msg..tag00420011;
var hexarray = pdf_str.split('\\');
var len = hexarray.length;
var bytearray = new Array(len);
for (var ii = 0 ; ii < len ; ii++)
{
var sbyte = java.lang.Integer.parseInt(hexarray[ii], 16);
if (sbyte > 127)
sbyte -= 256;
bytearray[ii] = new java.lang.Byte(sbyte);
}
var b64 = FileUtil.encode(bytearray);

// Put the base64 encoded string in the channel map
channelMap.put('PDFDoc', b64);
// For reference also write out the file
FileUtil.write('C:/test.pdf', false, bytearray);
Attached Files
File Type: xml DICOM_PDF.xml (17.3 KB, 89 views)
Reply With Quote
  #9  
Old 07-08-2009, 08:08 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

Nice! Thanks for posting.
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #10  
Old 06-21-2019, 09:31 AM
hjaffar hjaffar is offline
What's HL7?
 
Join Date: Jun 2019
Posts: 1
hjaffar is on a distinguished road
Default

Is this channel really work for you ? I am using the same channel and I got this error message

Transformer error
ERROR MESSAGE: Error evaluating transformer
java.lang.OutOfMemoryError: Java heap space
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 PM.


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