try adding series data to case table

This commit is contained in:
Ross
2025-04-25 18:28:40 +01:00
parent f584ea07a3
commit 405b17776f
3 changed files with 28 additions and 8 deletions
+2
View File
@@ -49,6 +49,8 @@ def get_series(request):
else:
queryset = Series.objects.all()
queryset = queryset.prefetch_related("examination", "plane")
return queryset
+13
View File
@@ -516,6 +516,14 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
def get_series(self):
return self.series.all().prefetch_related("images", "examination", "plane")
def get_series_modalities(self) -> set:
"""Returns a list of the modalities of the series in the case"""
series = self.series.all()
modalities = [s.modality.short_code for s in series if s.modality is not None]
return set(modalities)
def get_total_series_images_size(self, refresh=False):
if self.total_images_series_size is not None and not refresh:
return self.total_images_series_size
@@ -656,6 +664,11 @@ class Series(SeriesBase):
series_instance_uid = models.CharField(max_length=255, blank=True, null=True)
# findings = models.TextField(null=True, blank=True, help_text="Findings on the series / stack")
def __str__(self) -> str:
if self.description:
return self.description
else:
return f"{self.examination} ({self.plane})"
def get_full_str(self):
if self.case:
+13 -8
View File
@@ -27,6 +27,19 @@ from easy_thumbnails.exceptions import InvalidImageFormatError
class CaseTable(tables.Table):
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
"author", # Many-to-many or reverse relationship
"series", # Many-to-many relationship
"series__examination", # ForeignKey in the related model
"series__plane", # ForeignKey in the related model
"series__images", # Reverse relationship
),
*args,
**kwargs,
)
def get_view_cell(record):
if record.open_access:
return format_html(f"""<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-opencollective" viewBox="0 0 16 16">
@@ -68,14 +81,6 @@ class CaseTable(tables.Table):
sequence = ("view", )#, "series")
order_by = "-created_date"
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
"author", "series",#"condition", "condition__synonym"
),
*args,
**kwargs,
)
class PopupLinkColumn(tables.Column):
def render(self, value):