Dimse.Command (Dimse v0.8.7)

Copy Markdown View Source

DIMSE command set encoding and decoding.

Command sets are the control headers of DIMSE messages, always encoded in Implicit VR Little Endian regardless of the negotiated transfer syntax (PS3.7 Section 6.3.1). All elements belong to group 0000.

Wire Format (Implicit VR Little Endian)

Each data element: <<group::16-little, element::16-little, length::32-little, value::binary>>

No VR field — the VR is determined from the tag via the DICOM dictionary.

Command Set Elements (PS3.7 Section 6.3)

TagNameVRDescription
(0000,0000)CommandGroupLengthULByte count of remaining command
(0000,0002)AffectedSOPClassUIDUISOP Class being operated on
(0000,0100)CommandFieldUSWhich DIMSE operation
(0000,0110)MessageIDUSUnique ID for request/response pairing
(0000,0120)MessageIDBeingRespondedToUSOriginal request's MessageID
(0000,0800)CommandDataSetTypeUS0x0101 = no data set follows
(0000,0900)StatusUSOperation result code

See Dimse.Command.Fields for command field constants and Dimse.Command.Status for status code definitions.

Summary

Functions

Returns the Affected SOP Class UID from a command set.

Returns the command field value from a command set.

Decodes an Implicit VR Little Endian binary into a command set map.

Encodes a command set map into Implicit VR Little Endian binary.

Returns the message ID from a command set.

Returns true if the command set indicates no data set follows.

Returns the status from a command set.

Functions

affected_sop_class_uid(command_set)

@spec affected_sop_class_uid(map()) :: String.t() | nil

Returns the Affected SOP Class UID from a command set.

command_field(command_set)

@spec command_field(map()) :: integer() | nil

Returns the command field value from a command set.

decode(binary)

@spec decode(binary()) :: {:ok, map()} | {:error, term()}

Decodes an Implicit VR Little Endian binary into a command set map.

Returns {:ok, map} where keys are {group, element} tuples and values are decoded Elixir values.

encode(command_set)

@spec encode(map()) :: {:ok, binary()} | {:error, term()}

Encodes a command set map into Implicit VR Little Endian binary.

The map keys are DICOM tags {group, element} and values are the raw Elixir values to encode. The CommandGroupLength (0000,0000) is computed automatically and should not be included in the input map.

Example

{:ok, binary} = Dimse.Command.encode(%{
  {0x0000, 0x0002} => "1.2.840.10008.1.1",
  {0x0000, 0x0100} => 0x0030,
  {0x0000, 0x0110} => 1,
  {0x0000, 0x0800} => 0x0101
})

message_id(command_set)

@spec message_id(map()) :: integer() | nil

Returns the message ID from a command set.

no_data_set?(command_set)

@spec no_data_set?(map()) :: boolean()

Returns true if the command set indicates no data set follows.

status(command_set)

@spec status(map()) :: integer() | nil

Returns the status from a command set.