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.NO_DATASET = 257¶
Command Data Set Type value indicating that no dataset follows the command.
- pynetdicom2.dimsemessages.HAS_DATASET = 1¶
Command Data Set Type value indicating that a dataset follows the command.
- pynetdicom2.dimsemessages.PDV_HEADER_LENGTH = 6¶
Number of bytes consumed by the P-DATA-TF PDU/PDV header. A single PDV item carries this much framing overhead, so fragments must leave room for it.
- pynetdicom2.dimsemessages.COMMAND_FRAGMENT = 1¶
Message Control Header bit values for a PDV fragment (PS3.8 E.2). Bit 0 distinguishes command (1) from data set (0); bit 1 marks the last fragment.
- pynetdicom2.dimsemessages.COMMAND_GROUP_LENGTH_TAG = (0, 0)¶
Command Group Length element tag (0000,0000).
- pynetdicom2.dimsemessages.value_or_none(elem: DataElement | RawDataElement) Any | None¶
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: bytes, size: int) Iterator[tuple[bytes, bool]]¶
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: bytes, max_pdu_length: int, normal: int, last: int) Iterator[tuple[bytes, int]]¶
Fragmets dataset byte stream into chunks
- Parameters:
data_set – dataset bytes stream
max_pdu_length – maximum PDU length
normal – regular chunk code
last – last chunk code
- Yield:
tuple of bytes: fragment and its code
- pynetdicom2.dimsemessages.fragment_file(fp: BinaryIO, max_pdu_length: int, normal: int, last: int) Iterator[tuple[bytes, int]]¶
Fragmets dataset from a file-like object into chunks
- Parameters:
f – file-like object
max_pdu_length – maximum PDU length
normal – regular chunk code
last – last chunk code
- Yield:
tuple of bytes: fragment and its code
- pynetdicom2.dimsemessages.dimse_property(tag: tuple[int, int]) property¶
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.PriorityMixin¶
Helper mixin that defines common priority property in provided DIMSE message class.
This property is usually found in request messages
- class pynetdicom2.dimsemessages.SubOpsCountMixin¶
Helper mixin that defines the sub-operation counter properties shared by C-GET-RSP and C-MOVE-RSP messages (PS3.7 9.3.3.2 / 9.3.4.2).
- property num_of_remaining_sub_ops¶
The number of remaining C-STORE sub-operations to be invoked.
- property num_of_completed_sub_ops¶
The number of C-STORE sub-operations that completed successfully.
- property num_of_failed_sub_ops¶
The number of C-STORE sub-operations that failed.
- property num_of_warning_sub_ops¶
The number of C-STORE sub-operations that generated warnings.
- class pynetdicom2.dimsemessages.DIMSEMessage(command_set: Dataset | None = None)¶
Base DIMSE message class.
This class is not used directly, rather its subclasses, that represent specific DIMSE messages are used.
- property data_set: BinaryIO | bytes | None¶
Dataset included with a DIMSE Message
- encode(pc_id: int, max_pdu_length: int) Iterator[PDataTfPDU]¶
Returns the encoded message as a series of P-DATA-TF PDU objects.
- Parameters:
pc_id – Presentation Context ID
max_pdu_length – maximum PDU length
- Yield:
P-DATA-TF PDUs
- set_length() None¶
Sets DIMSE message length attribute in command dataset.
The Command Group Length element (0000,0000) itself is excluded from the sum. The element is identified explicitly by its tag rather than by position so the computation does not depend on element ordering.
- class pynetdicom2.dimsemessages.DIMSERequestMessage(command_set: Dataset | None = None)¶
Base class for all DIMSE request messages
- class pynetdicom2.dimsemessages.DIMSEResponseMessage(command_set: Dataset | None = None)¶
Base class for all DIMSE response messages
- class pynetdicom2.dimsemessages.CEchoRQMessage(command_set: Dataset | None = None)¶
C-ECHO-RQ Message.
Complete definition can be found in DICOM PS3.7, 9.3.5.1 C-ECHO-RQ
- command_field: ClassVar[int] = 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: Dataset | None = None)¶
C-ECHO-RSP Message.
Complete definition can be found in DICOM PS3.7, 9.3.5.5 C-ECHO-RSP
- command_field: ClassVar[int] = 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: Dataset | None = None)¶
C-STORE-RQ Message.
Complete definition can be found in DICOM PS3.7, 9.3.1.1 C-STORE-RQ
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance to be stored.
- property 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.
- property 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: Dataset | None = None)¶
C-STORE-RSP Message.
Complete definition can be found in DICOM PS3.7, 9.3.1.2 C-STORE-RSP
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance stored.
- class pynetdicom2.dimsemessages.CFindRQMessage(command_set: Dataset | None = None)¶
C-FIND-RQ Message.
Complete definition can be found in DICOM PS3.7, 9.3.2.1 C-FIND-RQ
- command_field: ClassVar[int] = 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: Dataset | None = None)¶
C-FIND-RSP Message.
Complete definition can be found in DICOM PS3.7, 9.3.2.2 C-FIND-RSP
- command_field: ClassVar[int] = 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: Dataset | None = None)¶
C-GET-RQ Message.
Complete definition can be found in DICOM PS3.7, 9.3.3.1 C-GET-RQ
- command_field: ClassVar[int] = 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: Dataset | None = None)¶
C-GET-RSP Message.
Complete definition can be found in DICOM PS3.7, 9.3.3.2 C-GET-RSP
- command_field: ClassVar[int] = 32784¶
This field distinguishes the DIMSE-C operation conveyed by this Message. The value of this field shall be set to 8010H for the C-GET-RSP Message.
- class pynetdicom2.dimsemessages.CMoveRQMessage(command_set: Dataset | None = None)¶
C-MOVE-RQ Message.
Complete definition can be found in DICOM PS3.7, 9.3.4.1 C-MOVE-RQ
- command_field: ClassVar[int] = 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.
- property 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: Dataset | None = None)¶
C-MOVE-RSP Message.
Complete definition can be found in DICOM PS3.7, 9.3.4.2 C-MOVE-RSP
- command_field: ClassVar[int] = 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.
- class pynetdicom2.dimsemessages.CCancelRQMessage(command_set: Dataset | None = 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: ClassVar[int] = 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: Dataset | None = 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: ClassVar[int] = 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.
- property event_type_id¶
Values for this field are application-specific.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance for which this event occurred.
- class pynetdicom2.dimsemessages.NEventReportRSPMessage(command_set: Dataset | None = 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: ClassVar[int] = 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.
- property event_type_id¶
Values for this field are application-specific.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance for which this event occurred.
- class pynetdicom2.dimsemessages.NGetRQMessage(command_set: Dataset | None = None)¶
N-GET-RQ Message.
Complete definition can be found in DICOM PS3.7, 10.3.2.1 N-GET-RQ
- command_field: ClassVar[int] = 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.
- property requested_sop_instance_uid¶
Contains the UID of the SOP Instance for which Attribute Values are to be retrieved.
- property 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: Dataset | None = None)¶
N-GET-RSP Message.
Complete definition can be found in DICOM PS3.7, 10.3.2.2 N-GET-RSP
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance for which Attribute Values are returned.
- class pynetdicom2.dimsemessages.NSetRQMessage(command_set: Dataset | None = None)¶
N-SET-RQ Message.
Complete definition can be found in DICOM PS3.7, 10.3.3.1 N-SET-RQ
- command_field: ClassVar[int] = 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.
- property 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: Dataset | None = None)¶
N-SET-RSP Message.
Complete definition can be found in DICOM PS3.7, 10.3.3.2 N-SET-RSP
- property sop_class_uid¶
Affected SOP Class UID: the SOP Class of the SOP Instance for which Attribute Values were modified.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance for which Attribute Values were modified.
- class pynetdicom2.dimsemessages.NActionRQMessage(command_set: Dataset | None = None)¶
N-ACTION-RQ Message.
Complete definition can be found in DICOM PS3.7, 10.3.4.1 N-ACTION-RQ
- command_field: ClassVar[int] = 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.
- property requested_sop_instance_uid¶
Contains the UID of the SOP Instance for which the action is to be performed.
- property action_type_id¶
Values for this field are application-specific.
- class pynetdicom2.dimsemessages.NActionRSPMessage(command_set: Dataset | None = None)¶
N-ACTION-RSP Message.
Complete definition can be found in DICOM PS3.7, 10.3.4.2 N-ACTION-RSP
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance for which the action was performed.
- property action_type_id¶
Values for this field are application-specific.
- class pynetdicom2.dimsemessages.NCreateRQMessage(command_set: Dataset | None = None)¶
N-CREATE-RQ Message.
Complete definition can be found in DICOM PS3.7, 10.3.5.1 N-CREATE-RQ
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance to be created.
- class pynetdicom2.dimsemessages.NCreateRSPMessage(command_set: Dataset | None = None)¶
N-CREATE-RSP Message.
Complete definition can be found in DICOM PS3.7, 10.3.5.2 N-CREATE-RSP
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance that was created.
- class pynetdicom2.dimsemessages.NDeleteRQMessage(command_set: Dataset | None = None)¶
N-DELETE-RQ Message.
Complete definition can be found in DICOM PS3.7, 10.3.6.1 N-DELETE-RQ
- command_field: ClassVar[int] = 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.
- property requested_sop_instance_uid¶
Contains the UID of the SOP Instance to be deleted.
- class pynetdicom2.dimsemessages.NDeleteRSPMessage(command_set: Dataset | None = None)¶
N-DELETE-RSP Message.
Complete definition can be found in DICOM PS3.7, 10.3.6.2 N-DELETE-RSP
- command_field: ClassVar[int] = 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.
- property affected_sop_instance_uid¶
Contains the UID of the SOP Instance that was deleted.