Skip to content

Commit

Permalink
Django 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
chimezie committed Dec 21, 2023
1 parent 06bb391 commit f23b7ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"django>=3.2,<4",
"django>=4.2,<5",
]

[build-system]
Expand Down
9 changes: 9 additions & 0 deletions src/snomed_ct/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def get_or_set(self, key, val_func):

cache = PassThruCache()


def print_function_entry_and_exit(decorated_function):
"""
Function decorator logging entry + exit and parameters of functions.
Expand Down Expand Up @@ -145,6 +146,9 @@ def has_icd10_mappings(self):
def has_definitions(self):
return self.filter(text_definitions__isnull=False)

def definitions(self):
return TextDefinition.objects.all(concept__in=self.ids)

def icd10_mappings(self):
return ICD10_Mapping.objects.filter(referenced_component_id__in=self.ids)

Expand Down Expand Up @@ -518,6 +522,7 @@ class Meta:
ASSOCIATED_MORPHOLOGY = 116676008
PART_OF = 123005000


class RelationshipQuerySet(CommonSNOMEDQuerySet):
def sources(self):
return Concept.objects.filter(id__in=self.values_list('source_id', flat='True'))
Expand Down Expand Up @@ -556,6 +561,9 @@ def by_type_id(self, type_id):
def by_type_ids(self, type_ids):
return self.get_queryset().filter(type_id_in=type_ids)

def active(self):
return self.get_queryset().active


ATTRIBUTE_HUMAN_READABLE_NAMES = {
363698007: 'is located in',
Expand Down Expand Up @@ -833,6 +841,7 @@ def by_icd_codes(self, codes):
query = reduce(or_, (Q(map_target__startswith=code, map_rule='TRUE') for code in codes))
return self.get_queryset().filter(query)


class ICD10_Mapping(ExtendedMapRefSet):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
referenced_component = models.ForeignKey(Concept, on_delete=models.PROTECT, related_name='icd10_mappings',
Expand Down

0 comments on commit f23b7ca

Please sign in to comment.