From 1599e48584ec779b4e3c675dcd1107794d35b70c Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 12 May 2025 10:18:44 +0100 Subject: [PATCH] improve finrding --- anatomy/static/js/anatomy.js | 1 - atlas/templates/atlas/case_display_block.html | 21 ++++-- atlas/templates/atlas/series_viewer.html | 71 +++++++++++++++++-- atlas/urls.py | 2 + atlas/views.py | 50 +++++++++++-- rad/static/css/anatomy.css | 11 +++ 6 files changed, 138 insertions(+), 18 deletions(-) diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index c92ef75e..13b414cc 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -210,7 +210,6 @@ function loadDicomViewer(images_to_load, annotations_to_load) { images = JSON.parse(images); } - console.log(images); let annotations = single_dicom.dataset.annotations; if (annotations_to_load != undefined) { diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html index 6ec10389..2b35c3fb 100755 --- a/atlas/templates/atlas/case_display_block.html +++ b/atlas/templates/atlas/case_display_block.html @@ -2,7 +2,7 @@ {% partialdef case-series %} {% for series in case.series.all %} - + Series {{ forloop.counter }}:
@@ -197,9 +197,14 @@ {% if case.series.all %} {% for series in case.series.all %} {% for finding in series.findings.all %} -
+
- Series {{series.pk}}: {{series.get_examination_full}} |  + {% if finding.findings.all %} @@ -331,4 +336,12 @@ // Listen for toggle events on the
element detailsElement.addEventListener("toggle", toggleCheckboxes); }); - \ No newline at end of file + + + \ No newline at end of file diff --git a/atlas/templates/atlas/series_viewer.html b/atlas/templates/atlas/series_viewer.html index 6a8d7581..7fb49f2f 100755 --- a/atlas/templates/atlas/series_viewer.html +++ b/atlas/templates/atlas/series_viewer.html @@ -3,14 +3,41 @@
{{ series.modality}}, {{ series.examination }}, {{ series.plane }}, {{ series.contrast }}
Description: {{series.description}}
-{% if series.case %} - Associated case: + Associated case: {% for case in series.case.all %} + {{case}} - {% endfor %} -{% else %} + {% if can_edit %} + + {% endif %} + + {% empty %} This series is not associated with any cases. -{% endif %} + {% if can_edit %} +
+ Add Series to Case +
+ {% csrf_token %} + + + +
+
+
+ {% endif %} + {% endfor %} {% with image_url_array_and_count=series.get_image_url_array_and_count %}
@@ -44,7 +71,7 @@ {% for finding in series.findings.all %}
- Finding(s): {% for f in finding.findings.all %}{{f.get_link}}{% endfor %}
@@ -155,6 +182,7 @@ {% endif %} + + + \ No newline at end of file diff --git a/atlas/urls.py b/atlas/urls.py index a3c51c7b..b04e2d98 100755 --- a/atlas/urls.py +++ b/atlas/urls.py @@ -264,6 +264,8 @@ urlpatterns = [ views.series_dicom_json, name="series_dicom_json", ), + path('series//add-to-case/', views.add_series_to_case, name='add_series_to_case'), + path('series///remove-from-case/', views.remove_series_from_case, name='remove_series_from_case'), path("uncategorised_dicoms/", views.uncategorised_dicoms, name="uncategorised_dicoms_view"), path("question_schema/", views.QuestionSchemaView.as_view(), name="question_schema_overview"), path("question_schema/", views.question_schema_detail, name="question_schema_detail"), diff --git a/atlas/views.py b/atlas/views.py index a59c326e..0c3cdb5d 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -247,16 +247,21 @@ def series_detail(request, pk, finding_pk=None): else: series_finding_form = SeriesFindingForm(series_id=series.id) - # logging.debug(atlas.subspecialty.first().name.all()) - return render( - request, - "atlas/series.html", - { + context = { "series": series, "series_finding_form": series_finding_form, "editing_finding": editing_finding, "can_edit": can_edit, - }, + } + + if can_edit: + context["available_cases"] = Case.objects.all() # Adjust the queryset as needed + + # logging.debug(atlas.subspecialty.first().name.all()) + return render( + request, + "atlas/series.html", + context, ) @@ -3098,4 +3103,35 @@ def linked_cases_overview(request, case_id): "previous_cases": previous_cases, "next_cases": next_cases, }, - ) \ No newline at end of file + ) + +@login_required +def add_series_to_case(request, series_pk): + if request.method == "POST": + case_id = request.POST.get("case_id") + case = get_object_or_404(Case, pk=case_id) + if not case.check_user_can_edit(request.user): + raise PermissionDenied("You do not have permission to edit this case.") + + series = get_object_or_404(Series, pk=series_pk) + + # Associate the series with the case + series.case.add(case) + + return HttpResponse(f"Series {series_pk} added to case {case.title} ({case_id}).") + return HttpResponse("Invalid request.") + +@login_required +def remove_series_from_case(request, series_pk, case_pk): + if request.method == "POST": + case = get_object_or_404(Case, pk=case_pk) + if not case.check_user_can_edit(request.user): + raise PermissionDenied("You do not have permission to edit this case.") + + series = get_object_or_404(Series, pk=series_pk) + + # Associate the series with the case + series.case.remove(case) + + return HttpResponse(f"Removed") + return HttpResponse("Invalid request.") diff --git a/rad/static/css/anatomy.css b/rad/static/css/anatomy.css index d0a55500..7c58e619 100644 --- a/rad/static/css/anatomy.css +++ b/rad/static/css/anatomy.css @@ -138,6 +138,17 @@ button a { color: inherit; } +.button-unset { + background-color: unset; + color: unset; + border: unset; +} +.button-unset:hover { + background-color: unset; + color: unset; + border: unset; +} + .marking-list pre { display: inline; white-space: pre-wrap;