def get_patient(req, args): pid = args['paths'][0] if pid.endswith('.json') and use_db: pid = pid[:-len('.json')] pid = omop.get_person_id(pid) cache_file = os.path.join(json_dir, pid) p_name = json_dir + pid.strip() if p_name not in patients: patients.add(p_name) save_patients() if pid.endswith('.json'): pid = pid[:-len('.json')] if not os.path.isfile(cache_file) or not use_cache: if use_db: patient = omop.get_patient(pid, dict, line_file, class_file) else: patient = cms_get_patient.process(all_paths, line_file, class_file, pid) build_dictionary.extractEntries(dict, patient) if use_cache: with open(cache_file, 'w') as pf: pf.write(json_dumps(patient)) pf.flush() if use_cache: with open(dictionary_file, 'w') as output: output.write(json_dumps(dict)) output.flush() return patient with open(cache_file, 'r') as pf: return json.loads(pf.read())
def processDict(events, id): if len(events) == 0: return #print("processing {1} with {0} events".format(len(events), id), file=sys.stderr) obj = {"events": events} dict = {} build_dictionary.extractEntries(dict, obj) for group in dict.keys(): cb(id, group, dict[group].keys())
def processDict(events, id): if len(events) == 0: return #print("processing {1} with {0} events".format(len(events), id), file=sys.stderr) obj = { "events": events } dict = {} build_dictionary.extractEntries(dict, obj) for group in dict.keys(): cb(id, group, dict[group].keys())