[Python] pynetdicom send_c_find How to get the output?

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    I am using pynetdicom library to get patient information and Orthanc as pac server

    I have this code

    from pydicom.dataset import Dataset

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

    debug_logger()

    ae = AE()
    ae.add_requested_context(PatientRootQueryRetrieveInformationModelFind)

    # Create our Identifier (query) dataset
    ds = Dataset()
    ds.SOPClassesInStudy = ''
    ds.PatientID = '123'
    ds.PatientName = ''
    ds.StudyInstanceUID = ''
    ds.QueryRetrieveLevel = 'STUDY'
    ds.StudyID= ''
    ds.StudyDate= ''

    # Associate with the peer AE at IP 127.0.0.1 and port 11112
    assoc = ae.associate("127.0.0.1", 4242)
    if assoc.is_established:
    # Send the C-FIND request
    responses = assoc.send_c_find(ds, PatientRootQueryRetrieveInformationModelFind)

    print(ds)
    for (status, dataset) in responses:
    if status:
    print('C-FIND query status: 0x{0:04X}'.format(status.Status))
    else:
    print('Connection timed out, was aborted or received invalid response')

    # Release the association
    assoc.release()
    else:
    print('Association rejected, aborted or never connected')`
    and the output is this:


    : pydicom.read_dataset() TransferSyntax="Little Endian Explicit"
    I:
    I: # Response Identifier
    I: (0008,0005) CS [ISO_IR 100] # 1 SpecificCharacterSet
    I: (0008,0020) DA [20231206] # 1 StudyDate
    I: (0008,0052) CS [STUDY] # 1 QueryRetrieveLevel
    I: (0008,0054) AE [CLLSPS] # 1 RetrieveAETitle
    I: (0008,0062) UI [1.2.840.10008.5.1.4.1.1.3.1] # 1 SOPClassesInStudy
    I: (0010,0010) PN [Andres] # 1 PatientName
    I: (0010,0020) LO [464646] # 1 PatientID
    I: (0020,000D) UI [123213131] # 1 StudyInstanceUID
    I: (0020,0010) SH [20231206151403] # 1 StudyID
    I: `
    I


    only need to be able to save the StudyInstanceUID field, is this possible?

    I tried using dataset but I got no results, I also read that c-find does not return data, but nevertheless I see people who use it and can obtain data

    Continue reading...

Compartilhe esta Página