diff --git a/base_client.py b/base_client.py index 57887ee..a259303 100644 --- a/base_client.py +++ b/base_client.py @@ -10,7 +10,7 @@ def pacs_pull(self): pass @abstractmethod - def anonymize(self, dicom_dir: str, params: str, pv_id: int): + def anonymize(self, dicom_dir: str, params: str, send_params: dict, pv_id: int): pass @abstractmethod diff --git a/chrisClient.py b/chrisClient.py index 724e415..3445dd0 100644 --- a/chrisClient.py +++ b/chrisClient.py @@ -38,7 +38,7 @@ def pacs_pull(self): def pacs_push(self): pass - def anonymize(self, dicom_dir: str, tag_struct: str, pv_id: int): + def anonymize(self, dicom_dir: str, tag_struct: str, send_params: dict, pv_id: int): pl_id = self.__get_plugin_id({"name": "pl-dsdircopy", "version": "1.0.2"}) pl_sub_id = self.__get_plugin_id({"name": "pl-pfdicom_tagsub", "version": "3.3.4"}) @@ -59,10 +59,10 @@ def anonymize(self, dicom_dir: str, tag_struct: str, pv_id: int): dir_send_data = { "previous_id": tag_sub_id, 'inputFileFilter': "**/*dcm", - "orthancUrl": params["push"]["url"], - "username":params["push"]["username"], - "password": params["push"]["password"], - "pushToRemote": params["push"]["aec"] + "orthancUrl": send_params["url"], + "username": send_params["username"], + "password": send_params["password"], + "pushToRemote": send_params["aec"] } pl_inst_id = self.__create_feed(pl_dcm_id, dir_send_data) diff --git a/reg_chxr.py b/reg_chxr.py index a96fa13..d986125 100644 --- a/reg_chxr.py +++ b/reg_chxr.py @@ -24,7 +24,7 @@ logger.remove() logger.add(sys.stderr, format=logger_format) -__version__ = '1.0.5' +__version__ = '1.0.6' DISPLAY_TITLE = r""" _ _ @@ -72,6 +72,37 @@ type=str, help='directive to use to anonymize DICOMs' ) +parser.add_argument( + '--orthancUrl', '-o', + dest='orthancUrl', + type=str, + help='Orthanc server url', + default='http://0.0.0.0:8042' +) + +parser.add_argument( + '--orthancUsername', '-u', + dest='username', + type=str, + help='Orthanc server username', + default='orthanc' +) + +parser.add_argument( + '--orthancPassword', '-p', + dest='password', + type=str, + help='Orthanc server password', + default='orthanc' +) + +parser.add_argument( + '--pushToRemote', '-r', + dest='pushToRemote', + type=str, + help='Remote modality', + default='' +) parser.add_argument('-V', '--version', action='version', version=f'%(prog)s {__version__}') @@ -125,6 +156,7 @@ def main(options: Namespace, inputdir: Path, outputdir: Path): # for each individual series, check if total file count matches total file registered for series in data: pacs_search_params = sanitize_for_cube(series) + file_count = int(series["NumberOfSeriesRelatedInstances"]) registered_file_count = cube_cl.get_pacs_registered(pacs_search_params) # poll CUBE at regular interval for the status of file registration @@ -135,17 +167,23 @@ def main(options: Namespace, inputdir: Path, outputdir: Path): poll_count += 1 time.sleep(wait_poll) registered_file_count = cube_cl.get_pacs_registered(pacs_search_params) - LOG(f"Registered file count is {registered_file_count}") + LOG(f"{registered_file_count} series found in CUBE.") # check if polling timed out before registration is finished if registered_file_count == 0: raise Exception(f"PACS file registration unsuccessful. Please try again.") - LOG(f"{registered_file_count} files were successfully registered to CUBE.") + LOG(f"{file_count} files successfully registered to CUBE.") + send_params = { + "url": options.orthancUrl, + "username": options.username, + "password": options.password, + "aec": options.pushToRemote + } dicom_dir = cube_cl.get_pacs_files(pacs_search_params) # create connection object cube_con = ChrisClient(options.CUBEurl, options.CUBEuser, options.CUBEpassword) - cube_con.anonymize(dicom_dir, options.tagStruct, options.pluginInstanceID) + cube_con.anonymize(dicom_dir, options.tagStruct,send_params, options.pluginInstanceID) def sanitize_for_cube(series: dict) -> dict: