Beispiel #1
0
def test_find_studies(monkeypatch):
    qr = DICOMQR(host="host", port=123)
    qr.send_c_find = Mock(
        return_value=create_c_find_image_response(
            study_instance_uid="Study1",
            series_instance_uids=["Series1"],
            sop_class_uids=[f"Instance{i}" for i in range(1, 10)],
        )
    )

    studies = qr.find_studies(query=None)
    assert len(studies) == 1
    assert studies[0].uid == "Study1"
    assert len(studies[0].series[0].instances) == 9
Beispiel #2
0
from dicomtrolley.dicom_qr import DICOMQR, DICOMQuery, QueryRetrieveLevels

print("Setting up DICOM query-retrieve")
dicom_qr = DICOMQR(
    host=environ["HOST"],
    port=int(environ["PORT"]),
    aet=environ["AET"],
    aec=environ["AEC"],
)

print("Perform a search")
studies = dicom_qr.find_studies(
    DICOMQuery(
        PatientName="BAL*",
        ProtocolName="Thorax",
        minStudyDate=datetime(year=2015, month=3, day=1),
        maxStudyDate=datetime(year=2015, month=4, day=1),
        includeFields=[
            "PatientBirthDate",
            "SOPClassesInStudy",
            "Modality",
            "StudyDescription",
            "SeriesDescription",
            "ProtocolName",
        ],
        QueryRetrieveLevel=QueryRetrieveLevels.SERIES,
    ))

print(f"Found {len(studies)} studies")