diff --git a/TODO.md b/TODO.md index 8aaf6d6f..d9ef1b52 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,7 @@ ## Top +- Currently when images are received by the DICOMweb API they are temporarily downloaded to the file system before then send back to the requester. Try to pass the dataset directly. - Update documentation - Fix some stuff and use our fork then of DICOMwebClient -- @@ -13,9 +14,9 @@ - Locked info for other apps like batch_transfer_locked.html - Hint when app is locked for admin user - Encrypt data between swarm containers --- --- --- We can also make the network attachable to do the "exec" stuff in tasks.py using one off containers using "run" + -- + -- + -- We can also make the network attachable to do the "exec" stuff in tasks.py using one off containers using "run" ## High Priority diff --git a/adit/core/utils/dicom_dataset.py b/adit/core/utils/dicom_dataset.py index 691c4b92..6b9b5bc5 100644 --- a/adit/core/utils/dicom_dataset.py +++ b/adit/core/utils/dicom_dataset.py @@ -190,7 +190,7 @@ def from_dict(cls, query: dict[str, str], **additional_attributes) -> "QueryData ds = Dataset() for k, v in query.items(): - _set_dataset_value(ds, k, v, ignore_invalid_tags=True, ignore_invalid_values=True) + _set_dataset_value(ds, k, v) for k, v in additional_attributes.items(): _set_dataset_value(ds, k, v) @@ -238,13 +238,9 @@ def __contains__(self, keyword: str) -> bool: return keyword in self._ds -def _set_dataset_value( - ds: Dataset, k: str, v: Any, ignore_invalid_tags=False, ignore_invalid_values=False -) -> None: +def _set_dataset_value(ds: Dataset, k: str, v: Any) -> None: t = datadict.tag_for_keyword(k) if t is None: - if ignore_invalid_tags: - return raise ValueError(f"Unknown DICOM tag with keyword: {k}") vr = datadict.dictionary_VR(t) @@ -265,5 +261,4 @@ def _set_dataset_value( elem = DataElement(t, vr, v, validation_mode=config.RAISE) ds.add(elem) except ValueError as err: - if not ignore_invalid_values: - raise ValueError(f"Invalid value for DICOM tag {t} ({vr}): {v}") from err + raise ValueError(f"Invalid value for DICOM tag '{k}' (VR {vr}): {v} ({str(err)})") from err diff --git a/adit/dicom_web/views.py b/adit/dicom_web/views.py index a8b055e6..a046c383 100644 --- a/adit/dicom_web/views.py +++ b/adit/dicom_web/views.py @@ -62,7 +62,12 @@ async def get( query[key] = value source_server = await self._fetch_dicom_server(request, ae_title, "source") - results = await qido_find(source_server, query, self.level) + + try: + results = await qido_find(source_server, query, self.level) + except ValueError as err: + logger.warn(f"Invalid DICOMweb study query - {err}") + raise ValidationError(str(err)) from err return Response([result.dataset.to_json_dict() for result in results]) @@ -90,7 +95,12 @@ async def get( query["StudyInstanceUID"] = study_uid source_server = await self._fetch_dicom_server(request, ae_title, "source") - results = await qido_find(source_server, query, self.level) + + try: + results = await qido_find(source_server, query, self.level) + except ValueError as err: + logger.warn(f"Invalid DICOMweb series query - {err}") + raise ValidationError(str(err)) from err return Response([result.dataset.to_json_dict() for result in results])