From 92fca51b79eebcd073dfd75a47d4d4401d6a2cda Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 13 Feb 2024 22:27:03 +0000 Subject: [PATCH] . --- atlas/models.py | 23 ++++++++++++ atlas/templates/atlas/collection_viva.html | 42 ++++++++++++++++++---- atlas/urls.py | 6 ++++ atlas/views.py | 17 +++++++++ 4 files changed, 82 insertions(+), 6 deletions(-) diff --git a/atlas/models.py b/atlas/models.py index 8b746ab2..e7ce3d89 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -612,6 +612,29 @@ class Series(SeriesBase): return series_json + def get_ohif_dicom_json(self, case_title_as_patient_name = True): + series_json = [] + series_json.append(self.get_series_dicom_json()) + + patient_name = "" + if case_title_as_patient_name: + patient_name = self.title + + return { + "studies": [ + { + "StudyInstanceUID": "1.3.6.1.4.1.14519.5.2.1.6279.6001.298806137288633453246975630178", + "StudyDate": "20000101", + "StudyTime": "", + "PatientName": patient_name, + "PatientID": "LIDC-IDRI-0001", + "AccessionNumber": "", + "PatientAge": "", + "PatientSex": "", + "series": series_json, + } + ] + } class CaseCollection(ExamOrCollectionGenericBase): app_name = "atlas" diff --git a/atlas/templates/atlas/collection_viva.html b/atlas/templates/atlas/collection_viva.html index 27ac6fe8..97786b8d 100644 --- a/atlas/templates/atlas/collection_viva.html +++ b/atlas/templates/atlas/collection_viva.html @@ -2,14 +2,38 @@ {% block content %}

Cases

-
    - {% for case in cases %} -
  1. Case {{forloop.counter}}: {{case.title}}   +
    + Instructions +

    Click on the 'Show' button to view the case in the viewer. Click on the 'Open' button to open the case in a new window.

    +

    Opening a second case will replace the first case in the viewer or window.

    +
    - aoeu - +
      + {% for case in cases %} +
    1. +
      Case {{forloop.counter}}: {{case.title}}   + {% comment %} {% endcomment %} - + +
      +
      Series: + {% for series in case.series.all %} + + + Series {{ forloop.counter }}:
      + {{series.get_block}} + + +
      +
      +
      + {% endfor %} +
      +
    2. {% endfor %} @@ -34,6 +58,12 @@ $('#case-title').text($(this).data('title')); $('#viewer').attr('src', url) }); + $('.show-series').click(function() { + var url = $(this).data('target'); + console.log('clicked', url) + $('#case-title').text("Series: " + $(this).data('title')); + $('#viewer').attr('src', url) + }); $('.open-case').click(function() { var url = $(this).data('target'); bc.postMessage(url); diff --git a/atlas/urls.py b/atlas/urls.py index 10c0cda7..63451025 100755 --- a/atlas/urls.py +++ b/atlas/urls.py @@ -58,6 +58,7 @@ urlpatterns = [ path("collection/", views.collection_detail, name="collection_detail"), path("collection//viva", views.collection_viva, name="collection_viva"), path("collection//viva/", views.collection_viva_case, name="collection_viva_case"), + path("collection//viva/", views.collection_viva_series, name="collection_viva_series"), path( "collection//take", views.collection_take_start, @@ -148,6 +149,11 @@ urlpatterns = [ views.case_dicom_json, name="case_dicom_json", ), + path( + "series//dicom_json", + views.series_dicom_json, + name="series_dicom_json", + ), path("uncategorised_dicoms/", views.uncategorised_dicoms, name="uncategorised_dicoms_view"), path("condition/", views.ConditionView.as_view(), name="condition_view"), diff --git a/atlas/views.py b/atlas/views.py index 54356f2a..1d7bb0dc 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -1363,6 +1363,19 @@ def collection_viva_case(request, pk, case_number): {"collection": collection, "cases": cases, "current_case": current_case}, ) +@user_is_collection_author_or_atlas_editor +def collection_viva_series(request, pk, series_id): + collection = get_object_or_404(CaseCollection, pk=pk) + + series = get_object_or_404(Series, pk=series_id) + + return render( + request, + "atlas/collection_viva_case.html", + {"collection": collection, "current_case": series}, + ) + + @user_is_collection_author_or_atlas_editor def collection_detail(request, pk): collection = get_object_or_404(CaseCollection, pk=pk) @@ -1820,6 +1833,10 @@ def case_dicom_json(request, pk): return JsonResponse(case.get_case_dicom_json()) +def series_dicom_json(request, pk): + series = get_object_or_404(Series, pk=pk) + + return JsonResponse(series.get_ohif_dicom_json()) @user_is_collection_author_or_atlas_editor def delete_collection_cid_answers(request, exam_id, cid):