Skip to content

Instantly share code, notes, and snippets.

@pasknel
Created February 22, 2018 14:45
Show Gist options
  • Save pasknel/23228327641e6fcdf1d2fb7279b0a0cc to your computer and use it in GitHub Desktop.
Save pasknel/23228327641e6fcdf1d2fb7279b0a0cc to your computer and use it in GitHub Desktop.
C-FIND request example with pynetdicom3 and pydicom
from pynetdicom3 import AE
from pydicom.dataset import Dataset
from pynetdicom3 import QueryRetrieveSOPClassList
ae = AE(scu_sop_class = QueryRetrieveSOPClassList)
ip = "IP ADDRESS HERE"
port = 104
association = ae.associate(ip, port)
if association.is_established:
print('[+] Association established!')
dataset = Dataset()
dataset.PatientName = '*'
dataset.PatientID = ''
dataset.PatientSex = ''
dataset.PatientBirthDate = ''
dataset.StudyDescription = ''
dataset.QueryRetrieveLevel = "PATIENT"
results = association.send_c_find(dataset, query_model='P')
for (status, dataset) in results:
if status.status_type == 'Pending':
print(dataset)
print('')
association.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment