Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Dec 17, 2024
1 parent 7d85a5b commit 3aae819
Showing 1 changed file with 1 addition and 66 deletions.
67 changes: 1 addition & 66 deletions chrisClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,69 +63,4 @@ def anonymize(self, params: dict, pv_id: int):
"pushToRemote": params["push"]["aec"]
}
}
pipe.workflow_schedule(pv_id,"PACS query, retrieve, and registration verification in CUBE 20241217",plugin_params)
# workflow = pipe.pipelineWithName_getNodes("PACS query, retrieve, and registration verification in CUBE 20241217",{})
def anonymize_(self, params: dict, pv_id: int):
prefix = "dynanon"
pl_px_qy_id = self.__get_plugin_id({"name": "pl-pacs_query", "version": "1.0.3"})
pl_px_rt_id = self.__get_plugin_id({"name": "pl-pacs_retrieve", "version": "1.0.2"})
pl_rg_ch_id = self.__get_plugin_id({"name": "pl-reg_chxr", "version": "1.0.7"})

# 1) Run PACS query
px_qy_params = {"PACSurl": params["pull"]["url"],
"PACSname": params["pull"]["pacs"],
"PACSdirective": json.dumps(params["search"]),
"previous_id" : pv_id
}
px_qy_inst_id = self.__create_feed(pl_px_qy_id, px_qy_params)

# 2) Run PACS retrieve
px_rt_params = {"PACSurl": params["pull"]["url"],
"PACSname": params["pull"]["pacs"],
"inputJSONfile": "search_results.json",
"copyInputFile": True,
"previous_id": px_qy_inst_id
}
px_rt_inst_id = self.__create_feed(pl_px_rt_id, px_rt_params)

# 3) Verify registration and run anonymize and push
anon_params = json.dumps(params["anon"])
rg_ch_params = {"CUBEurl": self.cl.url,
"CUBEuser": self.cl.username,
"CUBEpassword": self.cl.password,
"inputJSONfile": "search_results.json",
"tagStruct": anon_params,
"orthancUrl": params["push"]["url"],
"username": params["push"]["username"],
"password": params["push"]["password"],
"pushToRemote": params["push"]["aec"],
"previous_id": px_rt_inst_id}
rg_ch_inst_id = self.__create_feed(pl_rg_ch_id, rg_ch_params)

def __wait_for_node(self,pl_inst_id):
"""
Wait for a node to transition to a finishedState
"""
response = self.cl.get_plugin_instance_by_id(pl_inst_id)
poll_count = 0
total_polls = 50
wait_poll = 5
while 'finished' not in response['status'] and poll_count <= total_polls:
response = self.cl.get_plugin_instance_by_id(pl_inst_id)
time.sleep(wait_poll)
poll_count += 1

def __create_feed(self, plugin_id: str,params: dict):
response = self.cl.create_plugin_instance(plugin_id, params)
return response['id']

def __get_plugin_id(self, params: dict):
response = self.cl.get_plugins(params)
if response['total'] > 0:
return response['data'][0]['id']
raise Exception(f"No plugin found with matching search criteria {params}")





pipe.workflow_schedule(pv_id,"PACS query, retrieve, and registration verification in CUBE 20241217",plugin_params)

0 comments on commit 3aae819

Please sign in to comment.