diff --git a/atlas/models.py b/atlas/models.py index 2d0ef81e..7d72474f 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -821,6 +821,39 @@ class CaseCollection(ExamOrCollectionGenericBase): kwargs={"pk": self.pk, "case_number": cases.index(case)}, ) + def get_ohif_dicom_json(self, case_title_as_patient_name = True): + studies = [] + for n, case in enumerate(self.cases.all()): + series_json = [] + for series in case.series.all(): + series_json.append(series.get_series_dicom_json()) + + patient_name = "" + if case_title_as_patient_name: + patient_name = case.title + + studies.append( + + { + "StudyInstanceUID": f"1.3.6.1.4.1.14519.5.2.1.6279.6001.{n}", + "StudyDate": "20000101", + "StudyTime": "", + "PatientName": patient_name, + "PatientID": f"ID{n}", + "AccessionNumber": "", + "PatientAge": "", + "PatientSex": "", + "series": series_json, + } + ) + + + + return { + "studies": studies + } + + class CaseDetail(models.Model): case = models.ForeignKey(Case, on_delete=models.CASCADE) diff --git a/atlas/templates/atlas/collection_viva.html b/atlas/templates/atlas/collection_viva.html index 6bcf849f..23eec14d 100644 --- a/atlas/templates/atlas/collection_viva.html +++ b/atlas/templates/atlas/collection_viva.html @@ -7,6 +7,7 @@

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.

+
    {% for case in cases %} @@ -55,6 +56,12 @@ $(document).ready(function() { const bc = new BroadcastChannel("test_channel"); console.log('ready') + $('.show-collection').click(function() { + var url = $(this).data('target'); + console.log('clicked', url) + $('#case-title').text($(this).data('title')); + $('#viewer').attr('src', url) + }); $('.show-case').click(function() { var url = $(this).data('target'); console.log('clicked', url) diff --git a/atlas/urls.py b/atlas/urls.py index 63451025..500360e8 100755 --- a/atlas/urls.py +++ b/atlas/urls.py @@ -144,6 +144,11 @@ urlpatterns = [ views.GenericExamViews.exam_json_edit, name="exam_json_edit", ), + path( + "collection//dicom_json", + views.collection_dicom_json, + name="collection_dicom_json", + ), path( "case//dicom_json", views.case_dicom_json, diff --git a/atlas/views.py b/atlas/views.py index 1d7bb0dc..fc383613 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -1827,6 +1827,10 @@ def collection_case_view(request, pk, case_number): }, ) +def collection_dicom_json(request, pk): + collection = get_object_or_404(CaseCollection, pk=pk) + + return JsonResponse(collection.get_case_dicom_json()) def case_dicom_json(request, pk): case = get_object_or_404(Case, pk=pk)