pynetdicom.association.ServiceUser

class pynetdicom.association.ServiceUser(assoc: Association, mode: str)[source]

Convenience class for the Association service user.

An Association object has two ServiceUser attributes, one representing the association requestor and the other the association acceptor. Once both have been defined sufficiently to be considered valid then association negotiation can begin. The requestor ServiceUser requires (at a minimum) the following in order to be valid:

  • For association as requestor:

    • AE title (ae_title)

    • Address and port number (address and port)

    • Maximum PDU length (maximum_length)

    • Implementation class UID (implementation_class_uid)

    • At least one presentation context (requested_contexts)

  • For association as acceptor:

    • AE title

    • Address and port number

The acceptor ServiceUser requires (at a minimum) the following in order to be valid:

  • For association as requestor:

    • Address and port number

  • For association as acceptor:

    • AE title

    • Address and port number

    • Maximum PDU length

    • Implementation class UID

address

The TCP/IP address of the AE.

Type:

str

port

The port number of the AE.

Type:

int

primitive

The A-ASSOCIATE primitive (request if mode is 'requestor', accept/reject if mode is 'acceptor') sent or received by the AE during association negotiation.

Type:

None or pdu_primitives.A_ASSOCIATE

__init__(assoc: Association, mode: str) None[source]

Create a new ServiceUser.

Parameters:
  • assoc (association.Association) – The parent association.

  • mode (str) – The operation mode of the AE represented by the ServiceUser, either 'requestor' or 'acceptor'. This is not necessarily the same as the association’s mode.

Methods

__init__(assoc, mode)

Create a new ServiceUser.

add_negotiation_item(item)

Add an extended negotiation item to the user information.

get_contexts(cx_type)

Return a list of PresentationContext items corresponding to cx_type.

remove_negotiation_item(item)

Remove an extended negotiation item from the user information.

reset_negotiation_items()

Remove all extended negotiation items.

Attributes

accepted_common_extended

Return a dict of the accepted SOP Class Common Extended Negotiation.

ae_title

Get or set the AE title.

asynchronous_operations

Return the Asynchronous Operations Window operations numbers.

extended_negotiation

Return a list of Extended Negotiation items.

implementation_class_uid

The Implementation Class UID as a UID.

implementation_version_name

Get or set the Implementation Version Name.

info

Return a dict with information about the ServiceUser.

is_acceptor

Return True if the ServiceUser is the association acceptor.

is_requestor

Return True if the ServiceUser is the association requestor.

maximum_length

The maximum PDV size as int.

mode

Return the mode as str, either 'requestor' or 'acceptor'.

requested_contexts

A list of the requestor's requested presentation contexts.

role_selection

Return any SCP/SCU Role Selection items.

sop_class_common_extended

Return the SOP Class Common Extended items.

sop_class_extended

Return any SOP Class Extended items.

supported_contexts

The supported presentation contexts.

user_identity

Return the User Identity Negotiation Item (if available).

user_information

Returns a list of the User Information items.

writeable

Return True if the current object can be changed.

property accepted_common_extended: dict[UID, tuple[UID, list[UID]]]

Return a dict of the accepted SOP Class Common Extended Negotiation.

Returns:

The {'SOP Class UID' : (Service Class UID, Related General SOP Class Identification)} for the accepted SOP Class Common Extended negotiation items.

Return type:

dict of 2-tuple

Raises:

RuntimeError – If called when the requestor.

add_negotiation_item(item: MaximumLengthNotification | ImplementationClassUIDNotification | ImplementationVersionNameNotification | AsynchronousOperationsWindowNegotiation | SCP_SCU_RoleSelectionNegotiation | SOPClassExtendedNegotiation | SOPClassCommonExtendedNegotiation | UserIdentityNegotiation) None[source]

Add an extended negotiation item to the user information.

Items can only be added prior to starting the association negotiation.

Parameters:

item (pdu_primitives.ServiceParameter) –

An extended negotiation item, one of:

Raises:
  • RuntimeError – If attempting to add an item after association negotiation has started.

  • TypeError – If item it not an extended negotiation item.

property ae_title: str

Get or set the AE title.

Parameters:

value (str) – The AE title as an ASCII string.

Returns:

The AE title as an ASCII string.

Return type:

str

property asynchronous_operations: tuple[int, int]

Return the Asynchronous Operations Window operations numbers.

Returns:

The (Maximum Number of Operations Invoked, Maximum Number of Operations Performed) or (1, 1) if no Asynchronous Operations Window Negotiation item is in the extended negotiation items.

Return type:

2-tuple of int

property extended_negotiation: list[MaximumLengthNotification | ImplementationClassUIDNotification | ImplementationVersionNameNotification | AsynchronousOperationsWindowNegotiation | SCP_SCU_RoleSelectionNegotiation | SOPClassExtendedNegotiation | SOPClassCommonExtendedNegotiation | UserIdentityNegotiation]

Return a list of Extended Negotiation items.

Extended Negotiation items are:

  • SCP/SCU Role Selection Negotiation (0 or more)

  • Asynchronous Operations Window Negotiation (0 or 1)

  • SOP Class Extended Negotiation (0 or more)

  • SOP Class Common Extended Negotiation (0 or more)

  • User Identity Negotiation (0 or 1)

Returns:

If mode() is 'requestor' then returns a list of the proposed extended negotiation items, otherwise returns a list of the extended negotiation item responses.

Return type:

list

get_contexts(cx_type: str) list[PresentationContext][source]

Return a list of PresentationContext items corresponding to cx_type.

Parameters:

cx_type (str) –

The type of contexts to return, if mode is 'requestor':

  • If the association has not yet been negotiated then 'requested'.

  • If the association has been negotiated then 'requested' or 'pcdl'.

If mode is 'acceptor':

  • If the association has not yet been negotiated then 'supported'.

  • If the association has been negotiated then 'supported' or 'pcdrl'.

Returns:

A list of presentations contexts, if cx_type is 'requested' then the requested presentation contexts, if 'pcdl' then the presentation contexts from the A-ASSOCIATE (request) primitive’s Presentation Context Definition List parameter. If 'supported' then the supported presentation contexts, if 'pcdrl' then the presentation contexts from the A-ASSOCIATE (accept) primitive’s Presentation Context Definition Results List parameter.

Return type:

list of presentation.PresentationContext

property implementation_class_uid: UID | None

The Implementation Class UID as a UID.

Returns:

Returns the Implementation Class UID if the requestor or if the acceptor and they have accepted the negotiation. Returns None if the acceptor and they have rejected the negotiation.

Return type:

pydicom.uid.UID or None

property implementation_version_name: str | None

Get or set the Implementation Version Name.

Parameters:

value (str or None) – The value to use for the Implementation Version Name, or None if no Implementation Version Name Notification item is to be included in the association negotiation. Can only be set prior to association negotiation.

Returns:

Returns None if the acceptor and they have rejected the negotiation or if no Implementation Version Name Notification item has been included in the association negotiation. Otherwise returns the Implementation Version Name.

Return type:

str or None

property info: dict[str, Any]

Return a dict with information about the ServiceUser.

property is_acceptor: bool

Return True if the ServiceUser is the association acceptor.

property is_requestor: bool

Return True if the ServiceUser is the association requestor.

property maximum_length: int | None

The maximum PDV size as int.

Returns:

Returns the Maximum Received Length if the requestor or if the acceptor and they have accepted the negotiation. Returns None if the acceptor and they have rejected the negotiation.

Return type:

int or None

property mode: str

Return the mode as str, either 'requestor' or 'acceptor'.

remove_negotiation_item(item: MaximumLengthNotification | ImplementationClassUIDNotification | ImplementationVersionNameNotification | AsynchronousOperationsWindowNegotiation | SCP_SCU_RoleSelectionNegotiation | SOPClassExtendedNegotiation | SOPClassCommonExtendedNegotiation | UserIdentityNegotiation) None[source]

Remove an extended negotiation item from the user information.

Items can only be removed prior to starting the association negotiation.

Parameters:

item (pdu_primitives.ServiceParameter) –

An extended negotiation item, one of:

Raises:
  • RuntimeError – If attempting to remove an item after association negotiation has started.

  • TypeError – If item it not an extended negotiation item.

property requested_contexts: list[PresentationContext]

A list of the requestor’s requested presentation contexts.

reset_negotiation_items() None[source]

Remove all extended negotiation items.

Items can only be removed prior to starting the association negotiation.

Raises:

RuntimeError – If attempting to clear the extended negotiation items after association negotiation has started.

property role_selection: dict[UID, SCP_SCU_RoleSelectionNegotiation]

Return any SCP/SCU Role Selection items.

Returns:

The SCP/SCU Role Selection items as {'SOP Class UID' : SCP_SCU_RoleSelectionNegotiation}.

Return type:

dict

property sop_class_common_extended: dict[UID, SOPClassCommonExtendedNegotiation]

Return the SOP Class Common Extended items.

If the ServiceUser is the association acceptor then no SOP Class Common Extended items will be present in the User Information.

Returns:

The SOP Class Common Extended items as {'SOP Class UID' : item}.

Return type:

dict

property sop_class_extended: dict[UID, bytes]

Return any SOP Class Extended items.

Returns:

The SOP Class Extended items as {'SOP Class UID' : Service Class Application Information}.

Return type:

dict

property supported_contexts: list[PresentationContext]

The supported presentation contexts.

Returns:

The supported presentation contexts when acting as an acceptor.

Return type:

list of presentation.PresentationContext

property user_identity: UserIdentityNegotiation | None

Return the User Identity Negotiation Item (if available).

Returns:

Returns the User Identity item if one is available, otherwise None.

Return type:

pdu_primitives.UserIdentityNegotiation or None

property user_information: list[MaximumLengthNotification | ImplementationClassUIDNotification | ImplementationVersionNameNotification | AsynchronousOperationsWindowNegotiation | SCP_SCU_RoleSelectionNegotiation | SOPClassExtendedNegotiation | SOPClassCommonExtendedNegotiation | UserIdentityNegotiation]

Returns a list of the User Information items.

property writeable: bool

Return True if the current object can be changed.