Skip to content

message.getDICOMBytes

Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.getDICOMBytes.

Signature: message.getDICOMBytes(nodePath, instance*)

Returns: byte[] bytes - the first node that matches the nodePath and instance

Get the DICOM bytes as a byte array of the first node that matches the nodePath.

Note

When the optional instance value is specified, the nodePath should not include an instance identifier.

Parameters

Type Name Description Default
String nodePath the DICOM node path
Integer instance* (optional) the match instance to return. Use 1 for the first instance. 1

Example

// assumes `message` is a DICOM message model object

// Retrieve the raw byte array for a specific DICOM tag
var patientNameBytes = message.getDICOMBytes("0010,0010"); // Patient Name

// Retrieve the raw byte array for a specific instance of a tag
// Useful when the tag appears multiple times (e.g. within sequences)
//
// (0020,0032) Image Position (Patient) — second instance
var imagePositionBytes = message.getDICOMBytes(
    "0020,0032",
    2 // instance (1 = first instance)
);

// Result:
// - patientNameBytes and imagePositionBytes are byte[]
// - The returned bytes represent the raw encoded value
//   of the requested DICOM element