com.mirth.connect.server.userutil
Class DICOMUtil

java.lang.Object
  extended by com.mirth.connect.server.userutil.DICOMUtil

public class DICOMUtil
extends java.lang.Object

Provides DICOM utility methods.


Method Summary
static org.dcm4che2.data.DicomObject byteArrayToDicomObject(byte[] bytes, boolean decodeBase64)
          Converts a byte array into a dcm4che DicomObject.
static java.lang.String convertDICOM(java.lang.String imageType, ImmutableConnectorMessage connectorMessage)
          Converts merged DICOM data associated with a connector message into a specified image format.
static java.lang.String convertDICOM(java.lang.String imageType, ImmutableConnectorMessage connectorMessage, boolean autoThreshold)
          Converts merged DICOM data associated with a connector message into a specified image format.
static java.lang.String convertDICOM(java.lang.String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex)
          Converts merged DICOM data associated with a connector message into a specified image format.
static java.lang.String convertDICOM(java.lang.String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex, boolean autoThreshold)
          Converts merged DICOM data associated with a connector message into a specified image format.
static java.lang.String convertDICOM(java.lang.String imageType, MessageObject messageObject)
          Deprecated. This method is deprecated and will soon be removed. Please use convertDICOM(imageType, connectorMessage) instead.
static java.lang.String convertDICOM(java.lang.String imageType, MessageObject messageObject, boolean autoThreshold)
          Deprecated. This method is deprecated and will soon be removed. Please use convertDICOM(imageType, connectorMessage, autoThreshold) instead.
static byte[] convertDICOMToByteArray(java.lang.String imageType, ImmutableConnectorMessage connectorMessage)
          Converts merged DICOM data associated with a connector message into a specified image format.
static byte[] convertDICOMToByteArray(java.lang.String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex)
          Converts merged DICOM data associated with a connector message into a specified image format.
static byte[] convertDICOMToByteArray(java.lang.String imageType, ImmutableConnectorMessage connectorMessage, int sliceIndex, boolean autoThreshold)
          Converts merged DICOM data associated with a connector message into a specified image format.
static byte[] dicomObjectToByteArray(org.dcm4che2.data.DicomObject dicomObject)
          Converts a dcm4che DicomObject into a byte array.
static byte[] dicomToJpg(int sliceIndex, ImmutableConnectorMessage connectorMessage, boolean autoThreshold)
          Deprecated. This method is deprecated and will soon be removed. Please use convertDICOMToByteArray(imageType, connectorMessage, sliceIndex, autoThreshold) instead.
static byte[] dicomToJpg(int sliceIndex, MessageObject messageObject, boolean autoThreshold)
          Deprecated. This method is deprecated and will soon be removed. Please use convertDICOMToByteArray(imageType, connectorMessage, sliceIndex, autoThreshold) instead.
static byte[] getDICOMMessage(ImmutableConnectorMessage connectorMessage)
          Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.
static byte[] getDICOMMessage(MessageObject messageObject)
          Deprecated. This method is deprecated and will soon be removed. Please use getDICOMMessage(connectorMessage) instead.
static byte[] getDICOMRawBytes(ImmutableConnectorMessage connectorMessage)
          Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.
static java.lang.String getDICOMRawData(ImmutableConnectorMessage connectorMessage)
          Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base64-encoded string.
static java.lang.String getDICOMRawData(MessageObject messageObject)
          Deprecated. This method is deprecated and will soon be removed. Please use getDICOMRawData(connectorMessage) instead.
static java.util.List<Attachment> getMessageAttachments(ImmutableConnectorMessage connectorMessage)
          Deprecated. This method is deprecated and will soon be removed. Please use getAttachments() instead.
static java.util.List<Attachment> getMessageAttachments(MessageObject messageObject)
          Deprecated. This method is deprecated and will soon be removed. Please use getAttachments() instead.
static int getSliceCount(ImmutableConnectorMessage connectorMessage)
          Returns the number of slices in the fully-merged DICOM data associated with a given connector message.
static java.lang.String mergeHeaderAttachments(ImmutableConnectorMessage connectorMessage, java.util.List<Attachment> attachments)
          Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base-64 encoded String.
static java.lang.String mergeHeaderAttachments(MessageObject messageObject, java.util.List<Attachment> attachments)
          Deprecated. This method is deprecated and will soon be removed. Please use mergeHeaderAttachments(connectorMessage, attachments) instead.
static java.lang.String mergeHeaderPixelData(byte[] header, java.util.List<byte[]> images)
          Re-attaches DICOM attachments with the given header data and returns the resulting merged data as a Base-64 encoded String.
static java.lang.String reAttachMessage(ImmutableConnectorMessage connectorMessage)
          Deprecated. This method is deprecated and will soon be removed. Please use AttachmentUtil.reAttachMessage(connectorMessage) instead.
static java.lang.String reAttachMessage(MessageObject messageObject)
          Deprecated. This method is deprecated and will soon be removed. Please use AttachmentUtil.reAttachMessage(connectorMessage) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDICOMRawData

public static java.lang.String getDICOMRawData(MessageObject messageObject)
Deprecated. This method is deprecated and will soon be removed. Please use getDICOMRawData(connectorMessage) instead.

Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base64-encoded string.

Parameters:
messageObject - The connector message to retrieve merged DICOM data for.
Returns:
The merged DICOM data, Base64-encoded.

getDICOMRawData

public static java.lang.String getDICOMRawData(ImmutableConnectorMessage connectorMessage)
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base64-encoded string.

Parameters:
connectorMessage - The connector message to retrieve merged DICOM data for.
Returns:
The merged DICOM data, Base64-encoded.

getDICOMRawBytes

public static byte[] getDICOMRawBytes(ImmutableConnectorMessage connectorMessage)
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.

Parameters:
connectorMessage - The connector message to retrieve merged DICOM data for.
Returns:
The merged DICOM data as a byte array.

getDICOMMessage

public static byte[] getDICOMMessage(MessageObject messageObject)
Deprecated. This method is deprecated and will soon be removed. Please use getDICOMMessage(connectorMessage) instead.

Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.

Parameters:
messageObject - The connector message to retrieve merged DICOM data for.
Returns:
The merged DICOM data as a byte array.

getDICOMMessage

public static byte[] getDICOMMessage(ImmutableConnectorMessage connectorMessage)
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a byte array.

Parameters:
connectorMessage - The connector message to retrieve merged DICOM data for.
Returns:
The merged DICOM data as a byte array.

mergeHeaderAttachments

public static java.lang.String mergeHeaderAttachments(MessageObject messageObject,
                                                      java.util.List<Attachment> attachments)
                                               throws com.mirth.connect.donkey.model.message.XmlSerializerException,
                                                      java.io.IOException
Deprecated. This method is deprecated and will soon be removed. Please use mergeHeaderAttachments(connectorMessage, attachments) instead.

Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base-64 encoded String.

Parameters:
messageObject - The connector message containing header data to merge DICOM attachments with.
attachments - The DICOM attachments to merge with the header data.
Returns:
The merged DICOM data as a Base-64 encoded String.
Throws:
com.mirth.connect.donkey.model.message.XmlSerializerException
java.io.IOException

mergeHeaderAttachments

public static java.lang.String mergeHeaderAttachments(ImmutableConnectorMessage connectorMessage,
                                                      java.util.List<Attachment> attachments)
                                               throws com.mirth.connect.donkey.model.message.XmlSerializerException,
                                                      java.io.IOException
Re-attaches DICOM attachments with the header data in the connector message and returns the resulting merged data as a Base-64 encoded String.

Parameters:
connectorMessage - The connector message containing header data to merge DICOM attachments with.
attachments - The DICOM attachments to merge with the header data.
Returns:
The merged DICOM data as a Base-64 encoded String.
Throws:
com.mirth.connect.donkey.model.message.XmlSerializerException
java.io.IOException

mergeHeaderPixelData

public static java.lang.String mergeHeaderPixelData(byte[] header,
                                                    java.util.List<byte[]> images)
                                             throws java.io.IOException
Re-attaches DICOM attachments with the given header data and returns the resulting merged data as a Base-64 encoded String.

Parameters:
header - The header data to merge DICOM attachments with.
images - The DICOM attachments as byte arrays to merge with the header data.
Returns:
The merged DICOM data as a Base-64 encoded String.
Throws:
java.io.IOException

getMessageAttachments

public static java.util.List<Attachment> getMessageAttachments(MessageObject messageObject)
                                                        throws com.mirth.connect.donkey.model.message.XmlSerializerException
Deprecated. This method is deprecated and will soon be removed. Please use getAttachments() instead.

Retrieves all attachments currently associated with a connector message.

Parameters:
messageObject - The connector message to retrieve associated attachments for.
Returns:
A list of attachments associated with the connector message.
Throws:
com.mirth.connect.donkey.model.message.XmlSerializerException

getMessageAttachments

public static java.util.List<Attachment> getMessageAttachments(ImmutableConnectorMessage connectorMessage)
                                                        throws com.mirth.connect.donkey.model.message.XmlSerializerException
Deprecated. This method is deprecated and will soon be removed. Please use getAttachments() instead.

Retrieves all attachments currently associated with a connector message.

Parameters:
connectorMessage - The connector message to retrieve associated attachments for.
Returns:
A list of attachments associated with the connector message.
Throws:
com.mirth.connect.donkey.model.message.XmlSerializerException

getSliceCount

public static int getSliceCount(ImmutableConnectorMessage connectorMessage)
Returns the number of slices in the fully-merged DICOM data associated with a given connector message.

Parameters:
connectorMessage - The connector message to retrieve DICOM data for.
Returns:
The number of slices in the DICOM data.

convertDICOM

public static java.lang.String convertDICOM(java.lang.String imageType,
                                            MessageObject messageObject,
                                            boolean autoThreshold)
Deprecated. This method is deprecated and will soon be removed. Please use convertDICOM(imageType, connectorMessage, autoThreshold) instead.

Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
messageObject - The connector message to retrieve merged DICOM data for.
autoThreshold - If true, automatically sets the lower and upper threshold levels.
Returns:
The converted image, as a Base64-encoded string.

convertDICOM

public static java.lang.String convertDICOM(java.lang.String imageType,
                                            ImmutableConnectorMessage connectorMessage,
                                            boolean autoThreshold)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
autoThreshold - If true, automatically sets the lower and upper threshold levels.
Returns:
The converted image, as a Base64-encoded string.

convertDICOM

public static java.lang.String convertDICOM(java.lang.String imageType,
                                            MessageObject messageObject)
Deprecated. This method is deprecated and will soon be removed. Please use convertDICOM(imageType, connectorMessage) instead.

Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
messageObject - The connector message to retrieve merged DICOM data for.
Returns:
The converted image, as a Base64-encoded string.

convertDICOM

public static java.lang.String convertDICOM(java.lang.String imageType,
                                            ImmutableConnectorMessage connectorMessage)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
Returns:
The converted image, as a Base64-encoded string.

convertDICOM

public static java.lang.String convertDICOM(java.lang.String imageType,
                                            ImmutableConnectorMessage connectorMessage,
                                            int sliceIndex)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
sliceIndex - If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).
Returns:
The converted image, as a Base64-encoded string.

convertDICOM

public static java.lang.String convertDICOM(java.lang.String imageType,
                                            ImmutableConnectorMessage connectorMessage,
                                            int sliceIndex,
                                            boolean autoThreshold)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
sliceIndex - If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).
autoThreshold - If true, automatically sets the lower and upper threshold levels.
Returns:
The converted image, as a Base64-encoded string.

convertDICOMToByteArray

public static byte[] convertDICOMToByteArray(java.lang.String imageType,
                                             ImmutableConnectorMessage connectorMessage)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
Returns:
The converted image, as a byte array.

convertDICOMToByteArray

public static byte[] convertDICOMToByteArray(java.lang.String imageType,
                                             ImmutableConnectorMessage connectorMessage,
                                             int sliceIndex)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
sliceIndex - If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).
Returns:
The converted image, as a byte array.

convertDICOMToByteArray

public static byte[] convertDICOMToByteArray(java.lang.String imageType,
                                             ImmutableConnectorMessage connectorMessage,
                                             int sliceIndex,
                                             boolean autoThreshold)
Converts merged DICOM data associated with a connector message into a specified image format.

Parameters:
imageType - The image format to convert the DICOM data to (e.g. "jpg").
connectorMessage - The connector message to retrieve merged DICOM data for.
sliceIndex - If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).
autoThreshold - If true, automatically sets the lower and upper threshold levels.
Returns:
The converted image, as a byte array.

reAttachMessage

public static java.lang.String reAttachMessage(MessageObject messageObject)
Deprecated. This method is deprecated and will soon be removed. Please use AttachmentUtil.reAttachMessage(connectorMessage) instead.

Replaces any unique attachment tokens (e.g. "${ATTACH:id}") with the corresponding attachment content, and returns the full post-replacement message.

Parameters:
messageObject - The connector message associated with the attachments. The encoded data will be used as the raw message string to re-attach attachments to, if it exists. Otherwise, the connector message's raw data will be used.
Returns:
The resulting message with all applicable attachment content re-inserted.

reAttachMessage

public static java.lang.String reAttachMessage(ImmutableConnectorMessage connectorMessage)
Deprecated. This method is deprecated and will soon be removed. Please use AttachmentUtil.reAttachMessage(connectorMessage) instead.

Replaces any unique attachment tokens (e.g. "${ATTACH:id}") with the corresponding attachment content, and returns the full post-replacement message.

Parameters:
connectorMessage - The connector message associated with the attachments. The encoded data will be used as the raw message string to re-attach attachments to, if it exists. Otherwise, the connector message's raw data will be used.
Returns:
The resulting message with all applicable attachment content re-inserted.

dicomToJpg

public static byte[] dicomToJpg(int sliceIndex,
                                MessageObject messageObject,
                                boolean autoThreshold)
Deprecated. This method is deprecated and will soon be removed. Please use convertDICOMToByteArray(imageType, connectorMessage, sliceIndex, autoThreshold) instead.

Converts merged DICOM data associated with a connector message into a JPEG image.

Parameters:
sliceIndex - If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).
messageObject - The connector message to retrieve merged DICOM data for.
autoThreshold - If true, automatically sets the lower and upper threshold levels.
Returns:
The converted JPEG image, as a byte array.

dicomToJpg

public static byte[] dicomToJpg(int sliceIndex,
                                ImmutableConnectorMessage connectorMessage,
                                boolean autoThreshold)
Deprecated. This method is deprecated and will soon be removed. Please use convertDICOMToByteArray(imageType, connectorMessage, sliceIndex, autoThreshold) instead.

Converts merged DICOM data associated with a connector message into a JPEG image.

Parameters:
sliceIndex - If there are multiple slices in the DICOM data, this indicates which one to use (the first slice has an index of 1).
connectorMessage - The connector message to retrieve merged DICOM data for.
autoThreshold - If true, automatically sets the lower and upper threshold levels.
Returns:
The converted JPEG image, as a byte array.

byteArrayToDicomObject

public static org.dcm4che2.data.DicomObject byteArrayToDicomObject(byte[] bytes,
                                                                   boolean decodeBase64)
                                                            throws java.io.IOException
Converts a byte array into a dcm4che DicomObject.

Parameters:
bytes - The binary data to convert.
decodeBase64 - If true, the data is assumed to be Base64-encoded.
Returns:
The converted DicomObject.
Throws:
java.io.IOException

dicomObjectToByteArray

public static byte[] dicomObjectToByteArray(org.dcm4che2.data.DicomObject dicomObject)
                                     throws java.io.IOException
Converts a dcm4che DicomObject into a byte array.

Parameters:
dicomObject - The DicomObject to convert.
Returns:
The converted byte array.
Throws:
java.io.IOException