This commit is contained in:
Ross
2021-12-07 11:58:35 +00:00
parent 9ed3e765e1
commit c858e95d7c
6 changed files with 163 additions and 35 deletions
+40 -1
View File
@@ -1,6 +1,6 @@
import django_filters 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 from django.contrib.auth.models import User
@@ -134,3 +134,42 @@ class StructureFilter(django_filters.FilterSet):
data=data, queryset=queryset, prefix=prefix, request=request data=data, queryset=queryset, prefix=prefix, request=request
) )
pass 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
+10 -1
View File
@@ -131,7 +131,7 @@ class Condition(SynMixin, models.Model):
return reverse("atlas:condition_detail", kwargs={"pk": self.pk}) return reverse("atlas:condition_detail", kwargs={"pk": self.pk})
class Presentation(SynMixin, models.Model): class Presentation(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
subspecialty = models.ManyToManyField("subspecialty", blank=True) subspecialty = models.ManyToManyField("subspecialty", blank=True)
@@ -146,6 +146,9 @@ class Presentation(SynMixin, models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse("atlas:presentation_detail", kwargs={"pk": self.pk}) return reverse("atlas:presentation_detail", kwargs={"pk": self.pk})
def get_link(self):
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name)
class Subspecialty(models.Model): class Subspecialty(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
@@ -156,6 +159,9 @@ class Subspecialty(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse("atlas:subspecialty_detail", kwargs={"pk": self.pk}) return reverse("atlas:subspecialty_detail", kwargs={"pk": self.pk})
def get_link(self):
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name)
class PathalogicalProcess(models.Model): class PathalogicalProcess(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
@@ -166,6 +172,9 @@ class PathalogicalProcess(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse("atlas:pathalogical_process_detail", kwargs={"pk": self.pk}) return reverse("atlas:pathalogical_process_detail", kwargs={"pk": self.pk})
def get_link(self):
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name)
class Differential(models.Model): class Differential(models.Model):
condition = models.ForeignKey(Condition, on_delete=models.CASCADE) condition = models.ForeignKey(Condition, on_delete=models.CASCADE)
+46 -1
View File
@@ -1,7 +1,7 @@
import django_tables2 as tables import django_tables2 as tables
from django_tables2.utils import A 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 from django.utils.html import format_html
@@ -226,3 +226,48 @@ class StructureTable(tables.Table):
def render_synonym(self, value, record): def render_synonym(self, value, record):
return format_html(record.get_synonym_link()) 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",)
+17 -2
View File
@@ -9,9 +9,18 @@
<p class="pre-whitespace"><b>Description:</b> {{ case.description }}</p> <p class="pre-whitespace"><b>Description:</b> {{ case.description }}</p>
<p>
Presentation:
<ul>
{% for presentation in case.presentation.all %}
<li>{{presentation.get_link}}</li>
{% endfor %}
</ul>
</p>
<p class="pre-whitespace"><b>History:</b> {{ case.history }}</p> <p class="pre-whitespace"><b>History:</b> {{ case.history }}</p>
<p class="pre-whitespace"><b>History:</b> {{ case.discussion }}</p> <p class="pre-whitespace"><b>Discussion:</b> {{ case.discussion }}</p>
<div class="pre-whitespace multi-image-block"><b>Series:</b> <div class="pre-whitespace multi-image-block"><b>Series:</b>
{% for series in case.series.all %} {% for series in case.series.all %}
@@ -90,7 +99,13 @@
Subspecialty: Subspecialty:
<ul> <ul>
{% for sub in case.subspecialty.all %} {% for sub in case.subspecialty.all %}
<li>{{sub}}</li> <li>{{sub.get_link}}</li>
{% endfor %}
</ul>
Pathological Process:
<ul>
{% for p in case.pathological_process.all %}
<li>{{p.get_link}}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</p> </p>
+4
View File
@@ -138,4 +138,8 @@ urlpatterns = [
views.StructureAutocomplete.as_view(model=Structure, create_field="name"), views.StructureAutocomplete.as_view(model=Structure, create_field="name"),
name="structure-autocomplete", name="structure-autocomplete",
), ),
path("presentation/", views.PresentationView.as_view(), name="presentation_view"),
path("presentation/<int:pk>", views.presentation_detail, name="presentation_detail"),
path("process/", views.PathologicalProcessView.as_view(), name="pathological_process_view"),
path("process/<int:pk>", views.pathological_process_detail, name="pathological_process_detail"),
] ]
+17 -1
View File
@@ -40,6 +40,7 @@ from .forms import (
from .models import ( from .models import (
Case, Case,
Condition, Condition,
PathalogicalProcess,
Presentation, Presentation,
Series, Series,
Examination, Examination,
@@ -49,11 +50,13 @@ from .models import (
SeriesFinding, SeriesFinding,
SeriesImage, SeriesImage,
) )
from .tables import CaseTable, ConditionTable, FindingTable, SeriesTable, StructureTable from .tables import CaseTable, ConditionTable, FindingTable, PathologicalProcessTable, PresentationTable, SeriesTable, StructureTable
from .filters import ( from .filters import (
CaseFilter, CaseFilter,
ConditionFilter, ConditionFilter,
FindingFilter, FindingFilter,
PathologicalProcessFilter,
PresentationFilter,
SeriesFilter, SeriesFilter,
StructureFilter, StructureFilter,
) )
@@ -609,6 +612,19 @@ class ConditionView(LoginRequiredMixin, SingleTableMixin, FilterView):
filterset_class = ConditionFilter 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): class StructureView(LoginRequiredMixin, SingleTableMixin, FilterView):
model = Structure model = Structure