def get_patient(self, pid, dictionary, line_file, class_file): obj = { "info": [], "events": [], "h_bars": [], "v_bars": [ "auto" ], "v_spans": [], "classes": {} } new_dict_entries = set() util.add_files(obj, line_file, class_file) self.get_info(pid, obj) self.add_info(obj, "pid", "Patient", pid) self.get_info(pid, obj) self.get_diagnoses(pid, obj, dictionary, new_dict_entries) self.get_observations_concept_valued(pid, obj, dictionary, new_dict_entries) self.get_observations_string_valued(pid, obj, dictionary, new_dict_entries) self.get_observations_number_valued(pid, obj, dictionary, new_dict_entries) self.get_procedures(pid, obj, dictionary, new_dict_entries) self.get_drugs(pid, obj, dictionary, new_dict_entries) self.get_measurements(pid, obj, dictionary, new_dict_entries) self.get_visits(pid, obj) min_time = float('inf') max_time = float('-inf') for e in obj["events"]: time = e["time"] if time < min_time: min_time = time if time > max_time: max_time = time obj["start"] = min_time obj["end"] = max_time self.add_info(obj, "event_count", "Events", len(obj["events"])) self.update_hierarchies(dictionary, new_dict_entries) return obj
def process(allPaths, lineFile, classFile, id): obj = { "info": [], "events": [], "h_bars": [], "v_bars": ["auto"], "v_spans": [], "classes": {} } util.add_files(obj, lineFile, classFile) addInfo(obj, "pid", "Patient", id) if len(allPaths) == 0: print('warning: no path given', file=sys.stderr) statusMap = {} for (path, isfile) in allPaths: if isfile: processFile(path, id, obj, statusMap) else: util.process_id_directory( path, id, lambda file, id: processFile(file, id, obj, statusMap)) curInStart = None curInEnd = None curStatus = STATUS_UNKNOWN for k in sorted(statusMap): status = statusMap[k] if status == curStatus: if curInStart is None: curInStart = k curInEnd = k else: if curInStart is not None: if curStatus == STATUS_IN: obj["v_spans"].append({ "from": curInStart, "to": util.nextDay(curInEnd), "class": "in_hospital" }) elif curStatus == STATUS_PROF: obj["v_spans"].append({ "from": curInStart, "to": util.nextDay(curInEnd), "class": "professional" }) curInStart = None curStatus = status min_time = float('inf') max_time = float('-inf') for e in obj["events"]: time = e["time"] if time < min_time: min_time = time if time > max_time: max_time = time obj["start"] = min_time obj["end"] = max_time addInfo(obj, "event_count", "Events", len(obj["events"])) return obj
def process(allPaths, lineFile, classFile, id): obj = { "info": [], "events": [], "h_bars": [], "v_bars": [ "auto" ], "v_spans": [], "classes": {} } util.add_files(obj, lineFile, classFile) addInfo(obj, "pid", "Patient", id) if len(allPaths) == 0: print('warning: no path given', file=sys.stderr) statusMap = {} for (path, isfile) in allPaths: if isfile: processFile(path, id, obj, statusMap) else: util.process_id_directory(path, id, lambda file, id: processFile(file, id, obj, statusMap)) curInStart = None curInEnd = None curStatus = STATUS_UNKNOWN for k in sorted(statusMap): status = statusMap[k] if status == curStatus: if curInStart is None: curInStart = k curInEnd = k else: if curInStart is not None: if curStatus == STATUS_IN: obj["v_spans"].append({ "from": curInStart, "to": util.nextDay(curInEnd), "class": "in_hospital" }) elif curStatus == STATUS_PROF: obj["v_spans"].append({ "from": curInStart, "to": util.nextDay(curInEnd), "class": "professional" }) curInStart = None curStatus = status min_time = float('inf') max_time = float('-inf') for e in obj["events"]: time = e["time"] if time < min_time: min_time = time if time > max_time: max_time = time obj["start"] = min_time obj["end"] = max_time addInfo(obj, "event_count", "Events", len(obj["events"])) return obj