diff --git a/pyorthanc/orthanc.py b/pyorthanc/orthanc.py index f2892ac6e08bb84f3a46e810f07406dcbacea0c7..2ee931af09340d2ed2111830207d5a712e878088 100644 --- a/pyorthanc/orthanc.py +++ b/pyorthanc/orthanc.py @@ -919,10 +919,17 @@ class Orthanc: >>> o = Orthanc('http://localhost:8080') >>> o.get_instance_content_by_group_element('0040-a730/6/0040-a730/0/0040-a160') """ - return self.get_request( + answer = self.get_request( f'{self._orthanc_url}/instances/{instance_identifier}/content/{group_element}', **kwargs ) + if type(answer) == bytes: + # If answer is a string + return answer.decode("uft-8") + + else: + # If the answer is a int + return answer def export_instance_to_filesystem( self, instance_identifier: str, @@ -2981,13 +2988,13 @@ class Orthanc: return False if False in queries_have_been_deleted else True - def get_query_answers( + def get_query_answer_number_of_results( self, query_identifier: str, params: Dict = None, **kwargs) -> Any: """Get query answers - List all the answers for this C-Find SCU request + List all the indexes of each answer for this C-Find SCU request ("?expand" to show content, "&simplify" to simplify output) Parameters @@ -3000,7 +3007,7 @@ class Orthanc: Returns ------- Any - List all the answers for the specified query. + List all the indexes corresponding to each answers for the specified query. """ return self.get_request( f'{self._orthanc_url}/queries/{query_identifier}/answers', diff --git a/pyorthanc/remote.py b/pyorthanc/remote.py index 8289d1ebb065e66d7ad121c8f45b57cab4dc1ffc..bc7c43b0e323b79297b5b8c9464f7f6188e0554b 100644 --- a/pyorthanc/remote.py +++ b/pyorthanc/remote.py @@ -113,3 +113,45 @@ class RemoteModality: query_identifier, data=cmove_data ) + + def get_query_answer_number_of_results(self, query_identifier: str, + params: Dict = None, + **kwargs) -> list: + """Get all content of specified answer of C-Find + + Parameters + ---------- + query_identifier + Query identifier. + params + GET HTTP request's params. + + Returns + ------- + list + A list of dictionaries corresponding to each answer of the C-find. Empty if no answer found. + """ + return self.orthanc.get_query_answer_number_of_results(query_identifier, params) + + def get_content_of_specified_query_answer( + self, query_identifier: str, + index: str, + params: Dict = None, + **kwargs): + """Get content of specified answer of C-Find + + Parameters + ---------- + query_identifier + Query identifier. + index + Index of wanted answer. + params + GET HTTP request's params. + + Returns + ------- + Any + Specified answer of C-Find SCU operation. + """ + return self.orthanc.get_content_of_specified_query_answer(query_identifier, index, params)