def merge_pacs_ris(pacs): """ Insert ris report into converted pacs json file""" config = load_config() uses_basis_auth = bool(config["REPORT_USES_BASIC_AUTH"]) use_reports = bool(config["REPORT_USE"]) user = config["REPORT_USER"] pwd = config["REPORT_PWD"] my_dict = [] print(f"Getting RisReport for {len(pacs)} studies") for entry in pacs: dic = {} dic = entry.copy() if not use_reports: dic["RisReport"] = "" my_dict.append(dic) elif "AccessionNumber" in entry: aNum = str(entry["AccessionNumber"]) url = get_report_show_url(config) + aNum + "&output=text" if uses_basis_auth: response = get(url, auth=HTTPBasicAuth(user, pwd)) else: response = get(url) response.raise_for_status() data = response.text dic["RisReport"] = data my_dict.append(dic) return my_dict
def run(self): config = load_config() results = query_study_description( config, self.study_description, self.from_date, self.to_date ) with self.output().open('w') as outfile: w.write_file(results, outfile)
def requires(self): config = load_config() results = query_day_accs(config, self.day) logging.debug( f"Got {len(results)} accession number for day: {self.day}") for i in results: if "AccessionNumber" in i: yield DailyUpConvertedMerged({"acc": i["AccessionNumber"]})
def run(self): config = load_config() study_uids = [] with self.input().open("r") as f: for line in f: study_uids.append(line.strip()) results = [] for study_uid in study_uids: results.append(query_accession_number(config, study_uid)) flat = [item for sublist in results for item in sublist] with self.output().open("w") as outfile: w.write_file(flat, outfile)
def run(self): config = load_config() upload_url = get_solr_upload_url(config) logging.debug("Uploading to url %s", upload_url) with self.input().open("r") as in_file: file = {"file": (in_file.name, in_file, "application/json")} update_response = requests.post( url=upload_url, files=file, params={"commit": "true"} ) if not update_response.ok: update_response.raise_for_status() else: with self.output().open("w") as my_file: my_file.write("Upload successful")
def run(self): config = load_config() post_url = config.get("CDWH_STORE_URL", "") if not post_url: print( "No CDWH_STORE_ULR configured in instance/config.cfg, exiting." ) exit(1) with self.input().open("r") as daily: json_in = json.load(daily) r = requests.post(post_url, json=json_in) r.raise_for_status() with self.output().open("w") as o: o.write("done")