Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubleshooting Query/Retrieve SCU **Start Here** #419

Closed
scaramallion opened this issue Dec 15, 2019 · 0 comments
Closed

Troubleshooting Query/Retrieve SCU **Start Here** #419

scaramallion opened this issue Dec 15, 2019 · 0 comments

Comments

@scaramallion
Copy link
Member

scaramallion commented Dec 15, 2019

Introduction

The DICOM Query/Retrieve (QR) service allows an SCU (client) to send a service request to an SCP (server). There are three types of requests:

  • C-FIND: Send a query and have the QR SCP reply with matching values to the query keys only.
  • C-MOVE: Send a query and have the QR SCP send matching SOP instances (datasets) to a different Storage SCP over a new association. C-MOVE has good support amongst PACS providers but requires the QR SCP be configured with the details of the Storage SCP.
  • C-GET: Send a query and have the QR SCP send matching SOP instances (datasets) to the SCU over the same association. C-GET has poor support amongst PACS providers but requires no extra configuration of the QR SCP.

Common Problems

All

  • QR SCP responds with Success but no matches: Triple check your Identifier (query) dataset and do print(identifier) to confirm the values are correct. Check the DICOM standard to confirm that your query is valid. Check the QR SCP's DICOM conformance statement to confirm it supports the query keys.

C-MOVE

  • QR SCP responded with 0xA801: 0xA801 is Move Destination Unknown. Check that the QR SCP has been configured with the AE title, IP address and port number of the destination Storage SCP.

Troubleshooting

Before you do anything else, add the following and check the output:

from pynetdicom import debug_logger
debug_logger()

# Rest of your code goes here

Test 1: Confirm that you can associate and echo

from pynetdicom import AE, debug_logger
from pynetdicom.sop_class import VerificationSOPClass

debug_logger()

ae = AE()
ae.add_requested_context(VerificationSOPClass)
# qr_addr: the IP address of the QR SCP, as `str`
# qr_port: the port that the QR SCP is listening on as `int`
assoc = ae.associate(qr_addr, qr_port)
if assoc.is_established:
    status = assoc.send_c_echo()
    assoc.release()

Result

  • Received Echo Response (Status: Success), move on to Test 2.
  • Received Echo Response (Status: 0xXXXX), you have successfully associated with the QR SCP but the C-ECHO request failed. Move on to Test 2.
  • No accepted presentation contexts, you have successfully associated with the QR SCP but the Verification service is not supported. Move on to Test 2.
  • TCP Initialisation Error: Connection refused: check the QR SCPs IP and port are correct and check any firewall settings.
  • Association Rejected (Called AE title not recognised): the QR SCP doesn't recognise your AE title and has rejected the association request. Either configure the QR SCP with your AE title or change your AE title to one that is recognised
  • Association Rejected (other reason): the QR SCP has rejected the association request. You'll need to determine the reason why and fix it before you can continue.

Test 2: Confirm acceptance of the QR presentation contexts

from pynetdicom import AE, debug_logger, QueryRetrievePresentationContexts

debug_logger()

ae = AE()
ae.requested_contexts = QueryRetrievePresentationContexts
assoc = ae.associate(qr_addr, qr_port)
if assoc.is_established:
    assoc.release()

Result
In the A-ASSOCIATE-AC section of the log, look for entries similar to:

  Context ID:        1 (Accepted)
    Abstract Syntax: =PatientRootQueryRetrieveInformationModelFind
    Proposed SCP/SCU Role: Default
    Accepted SCP/SCU Role: Default
    Accepted Transfer Syntax: =LittleEndianImplicit
  • If the result for the context you want to use is Accepted then continue to Test 3.
  • If the result is Rejected - Abstract Syntax Not Supported then check the QR SCPs DICOM conformance statement and see what abstract syntaxes are supported.
  • If the result is Rejected - Transfer Syntax Not Supported then check the QR SCPs DICOM conformance statement and see what transfer syntaxes are supported.

Test 3: Check your Identifier query dataset

The test below is for C-FIND but can be C-MOVE or C-GET instead. You may need to use a different SOP Class than PatientRootQueryRetrieveInformationModelFind

from pydicom.dataset import Dataset
from pynetdicom import AE, debug_logger, QueryRetrievePresentationContexts
from pynetdicom.sop_class import PatientRootQueryRetrieveInformationModelFind

debug_logger()

identifier = Dataset()
# patient_id: the Patient ID as `str`
identifier.PatientID = patient_id
identifier.QueryRetrieveLevel = 'PATIENT'

print(identifier)

ae = AE()
ae.requested_contexts = QueryRetrievePresentationContexts
assoc = ae.associate(qr_addr, qr_port)
if assoc.is_established:
    for (status, ds) in assoc.send_c_find(identifier, PatientRootQueryRetrieveInformationModelFind):
        pass
    assoc.release()

Result

  • If you received an 0x0000 status and no 0xFF00 statuses then the QR SCP has received your query but found no matches. Triple check that your identifier dataset contains correct values and types and doesn't contain extra characters. Always do print(identifier) to confirm the query.
  • C-MOVE only: If you received an 0xA801 status then the QR SCP needs to be configured with the AE title, IP address and port of the Storage SCP.
  • If you received an 0x0000 status and one or more 0xFF00 status values then the QR SCP has received your query and found matches.
    • If your problem is with C-FIND and still occurs then create a new issue.
    • If your problem is with C-MOVE or C-GET, move on to Test 4.

Test 4a: (C-MOVE) Confirm the Storage SCP is available

Ensure the destination Storage SCP (either your own or a third party SCP) is up and running and then attempt to associate with it:

from pynetdicom import AE, debug_logger, StoragePresentationContexts
from pynetdicom.sop_class import VerificationSOPClass

debug_logger()

ae = AE()
ae.requested_contexts = StoragePresentationContexts[:127]
ae.add_requested_context(VerificationSOPClass)
# storage_addr: the IP address of the Storage SCP as `str`
# storage_port: the port of the Storage SCP as `int`
assoc = ae.associate(storage_addr, storage_port)
if assoc.is_established:
    assoc.send_c_echo()
    assoc.release()

Result

  • Similar to those in Test 1, only with the Storage SCP instead of the QR SCP.
  • Confirm that the presentation contexts have been accepted for the storage SOP classes you want to transfer. If they're accepted then create a new issue.

Test 4b: (C-GET) Confirm the role selection for the storage presentation contexts

from pynetdicom import AE, debug_logger, build_role, StoragePresentationContexts
from pynetdicom.sop_class import PatientRootQueryRetrieveInformationModelGet

debug_logger()

roles = []
for cx in StoragePresentationContexts[:127]:
    roles.append(build_role(cx.abstract_syntax, scp_role=True))

ae = AE()
ae.requested_contexts = StoragePresentationContexts[:127]
ae.add_requested_context(PatientRootQueryRetrieveInformationModelGet)
assoc = ae.associate(qr_addr, qr_port, ext_neg=roles)
if assoc.is_established:
    responses = assoc.send_c_get(identifier, PatientRootQueryRetrieveInformationModelGet)
    for (status, ds) in responses:
        pass
    assoc.release()

Result

  • If the Accepted SCP/SCU Role: is SCP for the storage context you're interested in then create a new issue.
  • Otherwise check the QR SCPs DICOM conformance statement to confirm that it supports that presentation context.
@scaramallion scaramallion pinned this issue Dec 15, 2019
@pydicom pydicom locked as resolved and limited conversation to collaborators Dec 15, 2019
@scaramallion scaramallion changed the title Troubleshooting Query/Retrieve SCU - **Start Here** Troubleshooting Query/Retrieve SCU **Start Here** Dec 15, 2019
@scaramallion scaramallion unpinned this issue Nov 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant