-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathDicom.py
34 lines (23 loc) · 846 Bytes
/
Dicom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pynetdicom import AE
from pynetdicom.sop_class import PatientRootQueryRetrieveInformationModelFind
from pydicom import Dataset
ae = AE()
ae.add_requested_context(PatientRootQueryRetrieveInformationModelFind)
ip = "127.0.0.1"
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=PatientRootQueryRetrieveInformationModelFind)
for (status, dataset) in results:
if status.Status in (0xFF00, 0xFF01):
print(dataset)
print('')
association.release()