From 0696ec69cb730495a5d44256b13134ad64be848e Mon Sep 17 00:00:00 2001 From: Jeff VanOss Date: Mon, 29 Aug 2022 22:49:00 -0400 Subject: [PATCH] let dicomweb-client handle pagination --- DICOMwebBrowser/DICOMwebBrowser.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/DICOMwebBrowser/DICOMwebBrowser.py b/DICOMwebBrowser/DICOMwebBrowser.py index aa08ddd..bb245a3 100644 --- a/DICOMwebBrowser/DICOMwebBrowser.py +++ b/DICOMwebBrowser/DICOMwebBrowser.py @@ -79,7 +79,7 @@ def setup(self): # Ensure that correct version of dicomweb-clien Python package is installed needRestart = False needInstall = False - minimumDicomwebClientVersion = "0.51" + minimumDicomwebClientVersion = "0.57" try: import dicomweb_client from packaging import version @@ -573,19 +573,7 @@ def connectToServer(self): else: try: # Get all studies - studies = [] - offset = 0 - - while True: - subset = self.DICOMwebClient.search_for_studies(offset=offset) - if len(subset) == 0: - break - if subset[0] in studies: - # got the same study twice, so probably this server does not respect offset, - # therefore we cannot do paging - break - studies.extend(subset) - offset += len(subset) + studies = self.DICOMwebClient.search_for_studies(get_remaining=True) # Save to cache with open(cacheFile, 'w') as f: @@ -631,7 +619,7 @@ def studySelected(self, row): else: try: - series = self.DICOMwebClient.search_for_series(self.selectedStudyInstanceUID) + series = self.DICOMwebClient.search_for_series(self.selectedStudyInstanceUID, get_remaining=True) # Save to cache with open(cacheFile, 'w') as f: json.dump(series, f) @@ -800,7 +788,8 @@ def downloadSelectedSeries(self): #response = self.DICOMwebClient.get_image(seriesInstanceUid=selectedSeries) instances = self.DICOMwebClient.search_for_instances( study_instance_uid=selectedStudy, - series_instance_uid=selectedSeries + series_instance_uid=selectedSeries, + get_remaining=True ) self.progressMessage = "Retrieving data from server" logging.debug("Retrieving data from server")