Skip to content

Commit 4acd90d

Browse files
committed
Fixes bug in QIDO-RS relational Serie-level query
1 parent 23ba5ae commit 4acd90d

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

dicomtrolley/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def init_from_query(
556556
f"parameters. You are probably converting between incompatible "
557557
f"query subtypes. Use a basic Query instance to avoid this error. "
558558
f"See ValidationError for details on which parameter is causing "
559-
f"the problem"
559+
f"the problem. Original error: {str(e)}"
560560
) from e
561561

562562
@staticmethod

dicomtrolley/qido_rs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def uri_base(self) -> str:
322322
if self.query_level == QueryLevels.STUDY:
323323
raise ValueError(STUDY_VALUE_ERROR_TEXT)
324324
elif self.query_level == QueryLevels.SERIES:
325-
return "/studies"
325+
return "/series"
326326
elif self.query_level == QueryLevels.INSTANCE:
327327
if self.StudyInstanceUID:
328328
# all instances for this study
@@ -399,10 +399,11 @@ def ensure_query_type(cls, query: Query) -> QidoRSQueryBase:
399399
"to HierarchicalQuery"
400400
)
401401
return HierarchicalQuery.init_from_query(query)
402-
except UnSupportedParameterError:
402+
except UnSupportedParameterError as e:
403403
logger.debug(
404404
"Converting to HierarchicalQuery did not work. "
405-
"Trying slower but less stringent RelationalQuery"
405+
"Trying slower but less stringent RelationalQuery. Error was: "
406+
f"{str(e)}"
406407
)
407408
return RelationalQuery.init_from_query(query)
408409
else:

tests/test_qido_rs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from dicomtrolley.core import QueryLevels
5+
from dicomtrolley.core import Query, QueryLevels
66
from dicomtrolley.qido_rs import HierarchicalQuery, QidoRS, RelationalQuery
77
from tests.conftest import set_mock_response
88
from tests.mock_responses import (
@@ -158,3 +158,11 @@ def test_qido_searcher_204(requests_mock, a_qido):
158158
set_mock_response(requests_mock, QIDO_RS_204_NO_RESULTS)
159159
result = a_qido.find_studies(HierarchicalQuery())
160160
assert len(result) == 0
161+
162+
163+
def test_ensure_query_type(a_qido):
164+
"""Exposes bug where Series level Relational query calles a study url"""
165+
ensured = a_qido.ensure_query_type(
166+
Query(AccessionNumber="123", query_level=QueryLevels.SERIES)
167+
)
168+
assert ensured.uri_base() == "/series"

0 commit comments

Comments
 (0)