def get_ingredients(self): if self.has_ingredients: return self.dictionaries['ING'].get_med_list() elif self.valid and self.has_ingredients is None: self.dictionaries['ING'] = md.MedicationDictionary(dict_src='RXNORM_ING', dict_id=self.cui) if self.has_hist: cui_list = self.api.get_historical_info(self.cui, 'bossConcept') if cui_list and 'baseRxcui' in cui_list[0].keys(): for i in cui_list: _rxc = get_rxcui(i['baseRxcui']) self.dictionaries['ING'].add_med_with_id(_rxc, _rxc.cui) self.has_ingredients = True else: self.has_ingredients = False else: cui_list = self.api.get_rxcui_ingredients(self.cui) if len(cui_list) > 0: for tty, i in cui_list.items(): for cui in i: _rxc = get_rxcui(cui['rxcui']) self.dictionaries['ING'].add_med_with_id(_rxc, _rxc.cui) self.has_ingredients = True else: self.has_ingredients = False self.ing_checked = True return self.dictionaries['ING'].get_med_list() else: return None
def __init__(self, in_file, file_delim=','): self.path = in_file self.file_name = util.get_filename(in_file) self.delim = file_delim self.file_lines = self.get_file_lines() self.c_records = 0 self.records = {} self.headers = util.read_config_value('INFILE_KEYS') self.trackers = {} self.cui_types = [] self.m_dict = md.MedicationDictionary(self.file_name, link=self) MedKit.med_kits[self.file_name] = self m.Medication.med_id_list[self.file_name] = {} self.med_list = m.Medication.med_id_list[self.file_name]
def add_dict(self, src, id): self.dictionaries[src] = md.MedicationDictionary(src, id)