From c858e95d7c43f9bb4e1d849706eaa942a2c680c3 Mon Sep 17 00:00:00 2001
From: Ross
Date: Tue, 7 Dec 2021 11:58:35 +0000
Subject: [PATCH] .
---
atlas/filters.py | 41 +++++++++-
atlas/models.py | 11 ++-
atlas/tables.py | 49 +++++++++++-
atlas/templates/atlas/case_display_block.html | 75 +++++++++++--------
atlas/urls.py | 4 +
atlas/views.py | 18 ++++-
6 files changed, 163 insertions(+), 35 deletions(-)
diff --git a/atlas/filters.py b/atlas/filters.py
index 267c4e4c..64b51d12 100755
--- a/atlas/filters.py
+++ b/atlas/filters.py
@@ -1,6 +1,6 @@
import django_filters
-from .models import Case, Condition, Finding, Series, Structure
+from .models import Case, Condition, Finding, PathalogicalProcess, Presentation, Series, Structure
from django.contrib.auth.models import User
@@ -134,3 +134,42 @@ class StructureFilter(django_filters.FilterSet):
data=data, queryset=queryset, prefix=prefix, request=request
)
pass
+
+class PresentationFilter(django_filters.FilterSet):
+ class Meta:
+ model = Presentation
+ fields = ("name", "subspecialty")
+
+ def __init__(
+ self,
+ data=None,
+ queryset=None,
+ prefix=None,
+ strict=None,
+ user=None,
+ request=None,
+ ):
+ super(PresentationFilter, self).__init__(
+ data=data, queryset=queryset, prefix=prefix, request=request
+ )
+ pass
+
+
+class PathologicalProcessFilter(django_filters.FilterSet):
+ class Meta:
+ model = PathalogicalProcess
+ fields = ("name")
+
+ def __init__(
+ self,
+ data=None,
+ queryset=None,
+ prefix=None,
+ strict=None,
+ user=None,
+ request=None,
+ ):
+ super(PathologicalProcessFilter, self).__init__(
+ data=data, queryset=queryset, prefix=prefix, request=request
+ )
+ pass
diff --git a/atlas/models.py b/atlas/models.py
index 56e85b9b..1c881951 100644
--- a/atlas/models.py
+++ b/atlas/models.py
@@ -131,7 +131,7 @@ class Condition(SynMixin, models.Model):
return reverse("atlas:condition_detail", kwargs={"pk": self.pk})
-class Presentation(SynMixin, models.Model):
+class Presentation(models.Model):
name = models.CharField(max_length=255)
subspecialty = models.ManyToManyField("subspecialty", blank=True)
@@ -146,6 +146,9 @@ class Presentation(SynMixin, models.Model):
def get_absolute_url(self):
return reverse("atlas:presentation_detail", kwargs={"pk": self.pk})
+ def get_link(self):
+ return format_html("{}", self.get_absolute_url(), self.name)
+
class Subspecialty(models.Model):
name = models.CharField(max_length=255)
@@ -156,6 +159,9 @@ class Subspecialty(models.Model):
def get_absolute_url(self):
return reverse("atlas:subspecialty_detail", kwargs={"pk": self.pk})
+ def get_link(self):
+ return format_html("{}", self.get_absolute_url(), self.name)
+
class PathalogicalProcess(models.Model):
name = models.CharField(max_length=255)
@@ -166,6 +172,9 @@ class PathalogicalProcess(models.Model):
def get_absolute_url(self):
return reverse("atlas:pathalogical_process_detail", kwargs={"pk": self.pk})
+ def get_link(self):
+ return format_html("{}", self.get_absolute_url(), self.name)
+
class Differential(models.Model):
condition = models.ForeignKey(Condition, on_delete=models.CASCADE)
diff --git a/atlas/tables.py b/atlas/tables.py
index 794d6ea8..7d3d5f66 100755
--- a/atlas/tables.py
+++ b/atlas/tables.py
@@ -1,7 +1,7 @@
import django_tables2 as tables
from django_tables2.utils import A
-from .models import Case, Condition, Series, Structure, Finding
+from .models import Case, Condition, PathalogicalProcess, Presentation, Series, Structure, Finding
from django.utils.html import format_html
@@ -225,4 +225,49 @@ class StructureTable(tables.Table):
sequence = ("name",)
def render_synonym(self, value, record):
- return format_html(record.get_synonym_link())
\ No newline at end of file
+ return format_html(record.get_synonym_link())
+
+class PresentationTable(tables.Table):
+ name = tables.Column(
+ linkify=("atlas:condition_detail", {"pk": tables.A("pk")}),
+ verbose_name="Presentation",
+ )
+
+ edit = tables.LinkColumn(
+ "atlas:condition_update", text="Edit", args=[A("pk")], orderable=False
+ )
+ delete = tables.LinkColumn(
+ "atlas:condition_delete", text="Delete", args=[A("pk")], orderable=False
+ )
+ selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
+
+ subspecialty = tables.ManyToManyColumn(verbose_name="Parents")
+
+ class Meta:
+ model = Presentation
+ template_name = "django_tables2/bootstrap4.html"
+ fields = ()
+ sequence = ("name",)
+
+
+class PathologicalProcessTable(tables.Table):
+ name = tables.Column(
+ linkify=("atlas:condition_detail", {"pk": tables.A("pk")}),
+ verbose_name="PathologicalProcess",
+ )
+
+ edit = tables.LinkColumn(
+ "atlas:condition_update", text="Edit", args=[A("pk")], orderable=False
+ )
+ delete = tables.LinkColumn(
+ "atlas:condition_delete", text="Delete", args=[A("pk")], orderable=False
+ )
+ selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
+
+ subspecialty = tables.ManyToManyColumn(verbose_name="Parents")
+
+ class Meta:
+ model = PathalogicalProcess
+ template_name = "django_tables2/bootstrap4.html"
+ fields = ()
+ sequence = ("name",)
\ No newline at end of file
diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html
index da28aaf3..6a5d0da7 100755
--- a/atlas/templates/atlas/case_display_block.html
+++ b/atlas/templates/atlas/case_display_block.html
@@ -9,9 +9,18 @@
Description: {{ case.description }}
+
+ Presentation:
+
+ {% for presentation in case.presentation.all %}
+ - {{presentation.get_link}}
+ {% endfor %}
+
+
+
History: {{ case.history }}
- History: {{ case.discussion }}
+ Discussion: {{ case.discussion }}
Series:
{% for series in case.series.all %}
@@ -42,40 +51,40 @@
Findings
- {% if case.series.all %}
- See individual series for more details.
- {% for series in case.series.all %}
- {% for finding in series.findings.all %}
-
+ {% if case.series.all %}
+ See individual series for more details.
+ {% for series in case.series.all %}
+ {% for finding in series.findings.all %}
+
Series {{series.pk}}: {{series.get_examination_full}} |
- {% if finding.findings.all %}
-
- Findings: {% for f in finding.findings.all %}
- {{f.get_link}},
- {% endfor %}
-
- {% endif %}
- {% if finding.structures.all %}
-
- Structure: {% for s in finding.structures.all %}
- {{s.get_link}},
- {% endfor %}
-
- {% endif %}
- {% if finding.description %}
-
- Description: {{finding.description}}
-
- {% endif %}
-
+ {% if finding.findings.all %}
+
+ Findings: {% for f in finding.findings.all %}
+ {{f.get_link}},
+ {% endfor %}
+
+ {% endif %}
+ {% if finding.structures.all %}
+
+ Structure: {% for s in finding.structures.all %}
+ {{s.get_link}},
+ {% endfor %}
+
+ {% endif %}
+ {% if finding.description %}
+
+ Description: {{finding.description}}
+
+ {% endif %}
+
+ {% endfor %}
{% endfor %}
- {% endfor %}
{% else %}
- No findings associated with case.
- {% endif %}
+ No findings associated with case.
+ {% endif %}
Differentials
@@ -90,7 +99,13 @@
Subspecialty:
{% for sub in case.subspecialty.all %}
- - {{sub}}
+ - {{sub.get_link}}
+ {% endfor %}
+
+ Pathological Process:
+
+ {% for p in case.pathological_process.all %}
+ - {{p.get_link}}
{% endfor %}
diff --git a/atlas/urls.py b/atlas/urls.py
index f6396467..9a7114e6 100755
--- a/atlas/urls.py
+++ b/atlas/urls.py
@@ -138,4 +138,8 @@ urlpatterns = [
views.StructureAutocomplete.as_view(model=Structure, create_field="name"),
name="structure-autocomplete",
),
+ path("presentation/", views.PresentationView.as_view(), name="presentation_view"),
+ path("presentation/", views.presentation_detail, name="presentation_detail"),
+ path("process/", views.PathologicalProcessView.as_view(), name="pathological_process_view"),
+ path("process/", views.pathological_process_detail, name="pathological_process_detail"),
]
diff --git a/atlas/views.py b/atlas/views.py
index edadb89b..372f7672 100755
--- a/atlas/views.py
+++ b/atlas/views.py
@@ -40,6 +40,7 @@ from .forms import (
from .models import (
Case,
Condition,
+ PathalogicalProcess,
Presentation,
Series,
Examination,
@@ -49,11 +50,13 @@ from .models import (
SeriesFinding,
SeriesImage,
)
-from .tables import CaseTable, ConditionTable, FindingTable, SeriesTable, StructureTable
+from .tables import CaseTable, ConditionTable, FindingTable, PathologicalProcessTable, PresentationTable, SeriesTable, StructureTable
from .filters import (
CaseFilter,
ConditionFilter,
FindingFilter,
+ PathologicalProcessFilter,
+ PresentationFilter,
SeriesFilter,
StructureFilter,
)
@@ -609,6 +612,19 @@ class ConditionView(LoginRequiredMixin, SingleTableMixin, FilterView):
filterset_class = ConditionFilter
+class PresentationView(LoginRequiredMixin, SingleTableMixin, FilterView):
+ model = Presentation
+ table_class = PresentationTable
+ template_name = "atlas/view.html"
+
+ filterset_class = PresentationFilter
+
+class PathologicalProcessView(LoginRequiredMixin, SingleTableMixin, FilterView):
+ model = PathalogicalProcess
+ table_class = PathologicalProcessTable
+ template_name = "atlas/view.html"
+
+ filterset_class = PathologicalProcessFilter
class StructureView(LoginRequiredMixin, SingleTableMixin, FilterView):
model = Structure