Beispiel #1
0
 def map_concept(self, concept):
   r = Concepts()
   db_cursor.execute(self._MAP_QUERY % concept.code)
   for (code,) in db_cursor.fetchall():
     c = self.terminology2.get(code)
     if c: r.add(c)
   return r
Beispiel #2
0
 def map_concepts(self, concepts):
   r = Concepts()
   for concept in concepts:
     db_cursor.execute("SELECT DISTINCT CUI FROM MRCONSO WHERE AUI IN %s"  % concept._sql_uis)
     for (code,) in db_cursor.fetchall():
       concept = self.terminology2.get(code) # get() because it might be a suppressed concept
       if concept: r.add(concept)
   return r
Beispiel #3
0
 def map_concepts(self, concepts):
   r = Concepts()
   for concept in concepts:
     db_cursor.execute(self._MAP_QUERY, (str(concept.code),))
     for (code,) in db_cursor.fetchall():
       concept = self.terminology2.get(code) # get() because it might be a suppressed concept
       if concept: r.add(concept)
   return r
Beispiel #4
0
 def map_concepts(self, concepts):
   r = Concepts()
   for concept in concepts:
     try:
       code = concept.english_code
       if       self.reversed  and (code in _ICD10_CHAPTER_MAPPING_REVERSE): code = _ICD10_CHAPTER_MAPPING_REVERSE[code]
       elif not(self.reversed) and (code in _ICD10_CHAPTER_MAPPING        ): code = _ICD10_CHAPTER_MAPPING        [code]
       elif "-" in code:
         if self.reversed:
           if code.endswith(".9"): code = code[:-2]
         else: code += ".9"
       c = self.terminology2[code]
       r.add(c)
     except ValueError: pass
   return r
Beispiel #5
0
 def first_levels(self):
   source          = tuple(UMLS_SRC["V-%s" % self._original_terminology_name] >> UMLS_CUI)[0]
   sources_in_self = source >> UMLS_AUI >> self
   if sources_in_self: return list(sources_in_self)
   
   roots = Concepts(source.children) >> UMLS_AUI >> self
   return list(root for root in roots if not root.parents)
Beispiel #6
0
 def map_concepts(self, concepts, cumulated_concepts = None):
   r                          = Concepts()
   cumulated_concepts         = cumulated_concepts or set(concepts)
   concepts_partially_matched = Concepts(concepts)
   
   for concept in tuple(concepts_partially_matched):
     r2 = None
     if self._umls_mapping: r2 = self._umls_mapping.map_concept(concept)
     if r2:
       r.update(r2)
       concepts_partially_matched.discard(concept)
     else:
       db_cursor.execute(self._MAP_QUERY % concept._sql_uis)
       for (code,) in db_cursor.fetchall():
         c = self.terminology2.get(code)
         if c:
           r.add(c)
           concepts_partially_matched.discard(concept)
           
   if concepts_partially_matched:
     concepts = Concepts(sum([self._get_concept_parents(concept) for concept in concepts_partially_matched], []))
     
     concepts = concepts - cumulated_concepts
     if concepts:
       cumulated_concepts.update(concepts)
       r.update(self.map_concepts(concepts, cumulated_concepts))
       
   return r
Beispiel #7
0
 def map_concepts(self, concepts, cumulated_concepts = None):
   r                          = Concepts()
   cumulated_concepts         = cumulated_concepts or set(concepts)
   concepts_partially_matched = Concepts(concepts)
   
   for concept in tuple(concepts_partially_matched):
     corresponding_concepts = self.terminology2._concepts_from_cui(concept.code)
     if corresponding_concepts:
       for c in corresponding_concepts: r.add(c)
       concepts_partially_matched.discard(concept)
       
   if concepts_partially_matched:
     concepts = Concepts(sum([self._get_concept_parents(concept) for concept in concepts_partially_matched], []))
     concepts = concepts - cumulated_concepts
     if concepts:
       cumulated_concepts.update(concepts)
       r.update(self.map_concepts(concepts, cumulated_concepts))
   return r
Beispiel #8
0
 def map_concepts(self, concepts):
   return Concepts([self.terminology2[ui] for concept in concepts for ui in concept._uis])