DIMSE Messages (dimsemessages)

In this module you can find classes that implements DIMSE-C and DIMSE-N messages as they are described in PS3.7 Sections 9 (DIMSE-C) and 10 (DIMSE-N).

Note

Please note, that in this version of the library message classes does not provide any form of validation for required and conditional fields. If your service class requires such validation you are responsible for implementing one. Service classes implementations provided in Service SOP Classes (sopclass) do not expose messages to the user (aside from C-MOVE SCU, but it only yields received message). With that said if you are using services from this library you should not worry about any kind of message validation.

pynetdicom2.dimsemessages.value_or_none(elem)

Gets element value or returns None, if element is None

Parameters:elem – dataset element or None
Returns:element value or None
pynetdicom2.dimsemessages.chunks(seq, size)

Breaks a sequence of bytes into chunks of provided size

Parameters:
  • seq – sequence of bytes
  • size – chunk size
Returns:

generator that yields tuples of sequence chunk and boolean that indicates if chunk is the last one

pynetdicom2.dimsemessages.fragment(data_set, max_pdu_length, normal, last)

Fragmets dataset byte stream into chunks

Parameters:
  • data_set (bytes) – dataset bytes stream
  • max_pdu_length (int) – maximum PDU length
  • normal (int) – regular chunk code
  • last (int) – last chunk code
Yield:

tuple of bytes: fragment and its code

Return type:

Tuple[bytes,int]

pynetdicom2.dimsemessages.fragment_file(fp, max_pdu_length, normal, last)

Fragmets dataset from a file-like object into chunks

Parameters:
  • f (IO[bytes]) – file-like object
  • max_pdu_length (int) – maximum PDU length
  • normal (int) – regular chunk code
  • last (int) – last chunk code
Yield:

tuple of bytes: fragment and its code

Return type:

Tuple[bytes,int]

pynetdicom2.dimsemessages.dimse_property(tag)

Creates property for DIMSE message using specified attribute tag

Parameters:tag – tuple with group and element numbers
Returns:property that gets/sets value in command dataset
class pynetdicom2.dimsemessages.StatusMixin

Helper mixin that defines common status property in provided DIMSE message class.

This property is usually found in response messages.

class pynetdicom2.dimsemessages.PriorityMixin

Helper mixin that defines common priority property in provided DIMSE message class.

This property is usually found in request messages

class pynetdicom2.dimsemessages.DIMSEMessage(command_set=None)

Base DIMSE message class.

This class is not used directly, rather its subclasses, that represent specific DIMSE messages are used.

data_set

Dataset included with a DIMSE Message

encode(pc_id, max_pdu_length)

Returns the encoded message as a series of P-DATA-TF PDU objects.

Parameters:
  • pc_id (int) – Presentation Context ID
  • max_pdu_length (int) – maximum PDU length
Yield:

P-DATA-TF PDUs

Return type:

pdu.PDataTfPDU

set_length()

Sets DIMSE message length attribute in command dataset

class pynetdicom2.dimsemessages.DIMSERequestMessage(command_set=None)

Base class for all DIMSE request messages

class pynetdicom2.dimsemessages.DIMSEResponseMessage(command_set=None)

Base class for all DIMSE response messages

class pynetdicom2.dimsemessages.CEchoRQMessage(command_set=None)

C-ECHO-RQ Message.

Complete definition can be found in DICOM PS3.7, 9.3.5.1 C-ECHO-RQ

command_field = 48

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0030H for the C-ECHO-RQ Message.

class pynetdicom2.dimsemessages.CEchoRSPMessage(command_set=None)

C-ECHO-RSP Message.

Complete definition can be found in DICOM PS3.7, 9.3.5.5 C-ECHO-RSP

command_field = 32816

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 8030H for the C-ECHO-RSP Message.

class pynetdicom2.dimsemessages.CStoreRQMessage(command_set=None)

C-STORE-RQ Message.

Complete definition can be found in DICOM PS3.7, 9.3.1.1 C-STORE-RQ

command_field = 1

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0001H for the C-STORE-RQ Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance to be stored.

move_originator_aet

Contains the DICOM AE Title of the DICOM AE that invoked the C-MOVE operation from which this C-STORE sub-operation is being performed.

move_originator_message_id

Contains the Message ID (0000,0110) of the C-MOVE-RQ Message from which this C-STORE sub-operations is being performed.

class pynetdicom2.dimsemessages.CStoreRSPMessage(command_set=None)

C-STORE-RSP Message.

Complete definition can be found in DICOM PS3.7, 9.3.1.2 C-STORE-RSP

command_field = 32769

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 8001H for the C-STORE-RSP Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance stored.

class pynetdicom2.dimsemessages.CFindRQMessage(command_set=None)

C-FIND-RQ Message.

Complete definition can be found in DICOM PS3.7, 9.3.2.1 C-FIND-RQ

command_field = 32

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0020H for the C-FIND-RQ Message.

class pynetdicom2.dimsemessages.CFindRSPMessage(command_set=None)

C-FIND-RSP Message.

Complete definition can be found in DICOM PS3.7, 9.3.2.2 C-FIND-RSP

command_field = 32800

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 8020H for the C-FIND-RSP Message.

class pynetdicom2.dimsemessages.CGetRQMessage(command_set=None)

C-GET-RQ Message.

Complete definition can be found in DICOM PS3.7, 9.3.3.1 C-GET-RQ

command_field = 16

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0010H for the C-GET-RQ Message.

class pynetdicom2.dimsemessages.CGetRSPMessage(command_set=None)

C-GET-RSP Message.

Complete definition can be found in DICOM PS3.7, 9.3.3.2 C-GET-RSP

command_field = 32784

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0010H for the C-GET-RQ Message.

num_of_remaining_sub_ops

The number of remaining C-STORE sub-operations to be invoked for this C-GET operation.

num_of_completed_sub_ops

The number of C-STORE sub-operations invoked by this C-GET operation that have completed successfully.

num_of_failed_sub_ops

The number of C-STORE sub-operations invoked by this C-GET operation that have failed.

num_of_warning_sub_ops

The number of C-STORE sub-operations invoked by this C-GET operation that generated warning responses.

class pynetdicom2.dimsemessages.CMoveRQMessage(command_set=None)

C-MOVE-RQ Message.

Complete definition can be found in DICOM PS3.7, 9.3.4.1 C-MOVE-RQ

command_field = 33

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0021H for the C-MOVE-RQ Message.

move_destination

Shall be set to the DICOM AE Title of the destination DICOM AE to which the C-STORE sub-operations are being performed.

class pynetdicom2.dimsemessages.CMoveRSPMessage(command_set=None)

C-MOVE-RSP Message.

Complete definition can be found in DICOM PS3.7, 9.3.4.2 C-MOVE-RSP

command_field = 32801

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 8021H for the C-MOVE-RSP Message.

num_of_remaining_sub_ops

The number of remaining sub-operations to be invoked for this C-MOVE operation.

num_of_completed_sub_ops

The number of C-STORE sub-operations invoked by this C-MOVE operation that have completed successfully.

num_of_failed_sub_ops

The number of C-STORE sub-operations invoked by this C-MOVE operation that have failed.

num_of_warning_sub_ops

The number of C-STORE sub-operations invoked by this C-MOVE operation that generated warning responses.

class pynetdicom2.dimsemessages.CCancelRQMessage(command_set=None)

C-CANCEL-FIND-RQ, C-CANCEL-GET-RQ, C-CANCEL-MOVE-RQ Messages.

Complete definition can be found in:

  • DICOM PS3.7, 9.3.2.3 C-CANCEL-FIND-RQ
  • DICOM PS3.7, 9.3.3.3 C-CANCEL-GET-RQ
  • DICOM PS3.7, 9.3.4.3 C-CANCEL-MOVE-RQ
command_field = 4095

This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 0FFFH for the C-CANCEL-MOVE-RQ Message.

class pynetdicom2.dimsemessages.NEventReportRQMessage(command_set=None)

N-EVENT-REPORT-RQ Message.

Complete definition can be found in DICOM PS3.7, 10.3.1.1 N-EVENT-REPORT-RQ

command_field = 256

This field distinguishes the DIMSE-N notification conveyed by this Message. The value of this field shall be set to 0100H for the N-EVENT-REPORT-RQ Message.

event_type_id

Values for this field are application-specific.

affected_sop_instance_uid

Contains the UID of the SOP Instance for which this event occurred.

class pynetdicom2.dimsemessages.NEventReportRSPMessage(command_set=None)

N-EVENT-REPORT-RSP Message.

Complete definition can be found in DICOM PS3.7, 10.3.1.2 N-EVENT-REPORT-RSP

command_field = 33024

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 8100H for the N-EVENT-REPORT-RSP Message.

event_type_id

Values for this field are application-specific.

affected_sop_instance_uid

Contains the UID of the SOP Instance for which this event occurred.

class pynetdicom2.dimsemessages.NGetRQMessage(command_set=None)

N-GET-RQ Message.

Complete definition can be found in DICOM PS3.7, 10.3.2.1 N-GET-RQ

command_field = 272

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 0110H for the N-GET-RQ Message.

requested_sop_instance_uid

Contains the UID of the SOP Instance for which Attribute Values are to be retrieved.

attribute_identifier_list

This field contains an Attribute Tag for each of the n Attributes applicable to the N-GET operation.

class pynetdicom2.dimsemessages.NGetRSPMessage(command_set=None)

N-GET-RSP Message.

Complete definition can be found in DICOM PS3.7, 10.3.2.2 N-GET-RSP

command_field = 33040

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 8110H for the N-GET-RSP Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance for which Attribute Values are returned.

class pynetdicom2.dimsemessages.NSetRQMessage(command_set=None)

N-SET-RQ Message.

Complete definition can be found in DICOM PS3.7, 10.3.3.1 N-SET-RQ

command_field = 288

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 0120H for the N-SET-RQ Message.

requested_sop_instance_uid

Contains the UID of the SOP Instance for which Attribute values are to be modified.

class pynetdicom2.dimsemessages.NSetRSPMessage(command_set=None)

N-SET-RSP Message.

Complete definition can be found in DICOM PS3.7, 10.3.3.2 N-SET-RSP

sop_class_uid

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 8120H for the N-SET-RSP Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance for which Attribute Values were modified.

class pynetdicom2.dimsemessages.NActionRQMessage(command_set=None)

N-ACTION-RQ Message.

Complete definition can be found in DICOM PS3.7, 10.3.4.1 N-ACTION-RQ

command_field = 304

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 0130H for the N-ACTION-RQ Message.

requested_sop_instance_uid

Contains the UID of the SOP Instance for which the action is to be performed.

action_type_id

Values for this field are application-specific.

class pynetdicom2.dimsemessages.NActionRSPMessage(command_set=None)

N-ACTION-RSP Message.

Complete definition can be found in DICOM PS3.7, 10.3.4.2 N-ACTION-RSP

command_field = 33072

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 8130H for the N-ACTION-RSP Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance for which the action was performed.

action_type_id

Values for this field are application-specific.

class pynetdicom2.dimsemessages.NCreateRQMessage(command_set=None)

N-CREATE-RQ Message.

Complete definition can be found in DICOM PS3.7, 10.3.5.1 N-CREATE-RQ

command_field = 320

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 0140H for the N-CREATE-RQ Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance to be created.

class pynetdicom2.dimsemessages.NCreateRSPMessage(command_set=None)

N-CREATE-RSP Message.

Complete definition can be found in DICOM PS3.7, 10.3.5.2 N-CREATE-RSP

command_field = 33088

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 8140H for the N-CREATE-RSP Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance that was created.

class pynetdicom2.dimsemessages.NDeleteRQMessage(command_set=None)

N-DELETE-RQ Message.

Complete definition can be found in DICOM PS3.7, 10.3.6.1 N-DELETE-RQ

command_field = 336

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 0150H for the N-DELETE-RQ Message.

requested_sop_instance_uid

Contains the UID of the SOP Instance to be deleted.

class pynetdicom2.dimsemessages.NDeleteRSPMessage(command_set=None)

N-DELETE-RSP Message.

Complete definition can be found in DICOM PS3.7, 10.3.6.2 N-DELETE-RSP

command_field = 33104

This field distinguishes the DIMSE-N operation conveyed by this Message. The value of this field shall be set to 8150H for the N-DELETE-RSP Message.

affected_sop_instance_uid

Contains the UID of the SOP Instance that was deleted.