Skip to content

Commit

Permalink
Added support for end-text matching of Description instances
Browse files Browse the repository at this point in the history
  • Loading branch information
chimezie committed Sep 20, 2024
1 parent d82f826 commit 9ee7199
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/snomed_ct/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ def pretty_print_list(my_list, sep=", ", and_char=", & "):
my_list[0], my_list[1]
) if len(my_list) == 2 else my_list[0]


class TextSearchTypes(Enum):
CASE_INSENSITIVE_CONTAINS = 1
CASE_SENSITIVE_CONTAINS = 2
CASE_SENSITIVE_REGEX = 2
CASE_INSENSITIVE_REGEX = 3
POSTGRES_FULL_TEXT_SEARCH = 4
ENDSWITH_SENSITIVE = 5
ENDSWITH_INSENSITIVE = 5

@classmethod
def get_search_query_suffix(cls, search_type):
Expand All @@ -83,6 +86,8 @@ def GetSearchQuerySuffix(search_type):
'regex' if search_type == TextSearchTypes.CASE_SENSITIVE_REGEX else
'contains' if search_type == TextSearchTypes.CASE_SENSITIVE_CONTAINS else
'icontains' if search_type == TextSearchTypes.CASE_INSENSITIVE_CONTAINS else
'endswith' if search_type == TextSearchTypes.ENDSWITH_SENSITIVE else
'iendswith' if search_type == TextSearchTypes.ENDSWITH_INSENSITIVE else
'search')
return query_suffix

Expand Down Expand Up @@ -168,8 +173,7 @@ def by_fully_specified_name(self, search_string, search_type=TextSearchTypes.CAS
query_suffix = GetSearchQuerySuffix(search_type)
kwargs = {'term__{}'.format(query_suffix): search_string,
'type_id': DESCRIPTION_TYPES['Fully specified name']}
return self.get_queryset().filter(id__in=Description.objects.filter(**kwargs).values_list('concept_id',
flat=True))
return Description.objects.filter(**kwargs).concepts

def mapped(self):
return self.get_queryset().filter(pk__in=ICD10_Mapping.objects.all().values_list('referenced_component__pk',
Expand Down

0 comments on commit 9ee7199

Please sign in to comment.