This commit is contained in:
Ross
2024-02-13 22:42:36 +00:00
parent 862755179a
commit bf09390160
4 changed files with 49 additions and 0 deletions
+33
View File
@@ -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)
@@ -7,6 +7,7 @@
<p>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.</p>
<p>Opening a second case will replace the first case in the viewer or window.</p>
</details>
<button class="show-collection no-padding" data-title="{{case.title}}" data-target="/ohif/viewer/dicomjson?url=https://www.penracourses.org.uk{% url 'atlas:collection_dicom_json' collection.pk %}">Show Collection</button>
<ol id="" class="sortable">
{% 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)
+5
View File
@@ -144,6 +144,11 @@ urlpatterns = [
views.GenericExamViews.exam_json_edit,
name="exam_json_edit",
),
path(
"collection/<int:pk>/dicom_json",
views.collection_dicom_json,
name="collection_dicom_json",
),
path(
"case/<int:pk>/dicom_json",
views.case_dicom_json,
+4
View File
@@ -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)