git displaysets working in viva view
This commit is contained in:
@@ -1152,6 +1152,11 @@ class CaseDisplaySet(models.Model, AuthorMixin):
|
|||||||
structures = models.ManyToManyField(Structure, blank=True)
|
structures = models.ManyToManyField(Structure, blank=True)
|
||||||
conditions = models.ManyToManyField(Condition, blank=True)
|
conditions = models.ManyToManyField(Condition, blank=True)
|
||||||
|
|
||||||
|
def viewerstate_string(self):
|
||||||
|
return json.dumps(self.viewerstate) if self.viewerstate else "{}"
|
||||||
|
|
||||||
|
def annotations_string(self):
|
||||||
|
return json.dumps(self.annotations) if self.annotations else "{}"
|
||||||
|
|
||||||
|
|
||||||
class CaseDetail(models.Model):
|
class CaseDetail(models.Model):
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-outline-primary btn-sm select-series-btn"
|
class="btn btn-outline-primary btn-sm select-series-btn"
|
||||||
|
style="display: none;"
|
||||||
data-series-id="{{series.pk}}">
|
data-series-id="{{series.pk}}">
|
||||||
Select
|
Select
|
||||||
</button>
|
</button>
|
||||||
@@ -238,56 +239,51 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Series Findings -->
|
<!-- Series Findings -->
|
||||||
<h5>Series Findings</h5>
|
<h5>Series Findings</h5>
|
||||||
{% if case.series.all %}
|
{% if case.ordered_series %}
|
||||||
{% for series in case.get_ordered_series %}
|
{% for series in case.ordered_series %}
|
||||||
{% for finding in series.findings.all %}
|
{% for finding in series.findings.all %}
|
||||||
<div class="finding-box" id="finding-box-{{ finding.pk }}" data-series="{{ series.pk }}"
|
<div class="finding-box" id="finding-box-{{ finding.pk }}" data-series="{{ series.pk }}">
|
||||||
_="on mouseenter
|
<span>
|
||||||
toggle .highlight-series
|
<a href="{{series.get_absolute_url}}?show_finding={{finding.pk}}">
|
||||||
on #series-block-{{ series.pk }}
|
<button class="btn btn-primary btn-sm">View</button>
|
||||||
until mouseleave"
|
</a>
|
||||||
>
|
<button class="btn btn-secondary btn-sm view-finding-modal" data-finding-id="{{ finding.pk }}" data-series-id="{{ series.pk }}">
|
||||||
<span>
|
View in Modal
|
||||||
<a href="{{series.get_absolute_url}}?show_finding={{finding.pk}}">
|
</button>
|
||||||
<button class="btn btn-primary btn-sm">View</button>
|
</span>
|
||||||
</a>
|
{% if finding.findings %}
|
||||||
<button class="btn btn-secondary btn-sm view-finding-modal" data-finding-id="{{ finding.pk }}" data-series-id="{{ series.pk }}">
|
<span>
|
||||||
View in Modal
|
Findings: {% for f in finding.findings.all %}
|
||||||
</button>
|
{{f.get_link}},
|
||||||
</span>
|
{% endfor %}
|
||||||
{% if finding.findings.all %}
|
</span>
|
||||||
<span>
|
{% endif %}
|
||||||
Findings: {% for f in finding.findings.all %}
|
{% if finding.conditions %}
|
||||||
{{f.get_link}},
|
<span>
|
||||||
{% endfor %}
|
Conditions: {% for c in finding.conditions.all %}
|
||||||
</span>
|
{{c.get_link}},
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
{% if finding.conditions.all %}
|
</span>
|
||||||
<span>
|
{% endif %}
|
||||||
Conditions: {% for c in finding.conditions.all %}
|
{% if finding.structures %}
|
||||||
{{c.get_link}},
|
<span>
|
||||||
{% endfor %}
|
Structure: {% for s in finding.structures.all %}
|
||||||
</span>
|
{{s.get_link}},
|
||||||
{% endif %}
|
{% endfor %}
|
||||||
{% if finding.structures.all %}
|
</span>
|
||||||
<span>
|
{% endif %}
|
||||||
Structure: {% for s in finding.structures.all %}
|
{% if finding.description %}
|
||||||
{{s.get_link}},
|
<span>
|
||||||
{% endfor %}
|
Description: {{finding.description}}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if finding.description %}
|
</div>
|
||||||
<span>
|
{% endfor %}
|
||||||
Description: {{finding.description}}
|
{% endfor %}
|
||||||
</span>
|
{% else %}
|
||||||
{% endif %}
|
No series associated with case.
|
||||||
</div>
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
{% else %}
|
|
||||||
No series associated with case.
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!-- Case Display Sets -->
|
<!-- Case Display Sets -->
|
||||||
<h5 class="mt-3">Case Display Sets</h5>
|
<h5 class="mt-3">Case Display Sets</h5>
|
||||||
|
|||||||
@@ -58,7 +58,8 @@
|
|||||||
var form = evt.target;
|
var form = evt.target;
|
||||||
console.log("Form:", form);
|
console.log("Form:", form);
|
||||||
console.log("Form matches:", form.matches("form[hx-post*='{% url 'atlas:case_displaysets_add' case.pk %}']"));
|
console.log("Form matches:", form.matches("form[hx-post*='{% url 'atlas:case_displaysets_add' case.pk %}']"));
|
||||||
if (form && form.matches("form[hx-post*='{% url 'atlas:case_displaysets_add' case.pk %}']")) {
|
console.log("Form matches:", form.matches("form[hx-post*='display_sets/edit']"));
|
||||||
|
if (form && (form.matches("form[hx-post*='{% url 'atlas:case_displaysets_add' case.pk %}']") ||form.matches("form[hx-post*='display_sets/edit']" ))) {
|
||||||
// Set hidden fields from JS functions
|
// Set hidden fields from JS functions
|
||||||
var viewerState = window.exportViewerState_main_viewer ? window.exportViewerState_main_viewer() : "{}";
|
var viewerState = window.exportViewerState_main_viewer ? window.exportViewerState_main_viewer() : "{}";
|
||||||
var annotations = window.exportAnnotations_main_viewer ? window.exportAnnotations_main_viewer() : "{}";
|
var annotations = window.exportAnnotations_main_viewer ? window.exportAnnotations_main_viewer() : "{}";
|
||||||
|
|||||||
@@ -62,6 +62,34 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
{% if case.display_sets.all %}
|
||||||
|
<details class="displayset-detail"><summary>Display Sets:</summary>
|
||||||
|
{% for ds in case.display_sets.all %}
|
||||||
|
<div class="displayset-block">
|
||||||
|
<span>
|
||||||
|
<b>{{ ds.name }}</b>
|
||||||
|
{% if ds.description %}
|
||||||
|
<span class="text-muted">({{ ds.description }})</span>
|
||||||
|
{% endif %}
|
||||||
|
<button class="open-displayset no-padding text-secondary border-secondary"
|
||||||
|
data-type="displayset"
|
||||||
|
data-displayset="{{ ds.pk }}"
|
||||||
|
data-case="{{ case.pk }}"
|
||||||
|
data-title="{{ ds.name }}"
|
||||||
|
data-casejson='{{case.get_viva_details_json}}'
|
||||||
|
data-images='{{case.get_series_images_nested}}'
|
||||||
|
data-viewerstate={{ds.viewerstate_string}}
|
||||||
|
data-annotations='{{ds.annotations_string}}'
|
||||||
|
>
|
||||||
|
Load Display Set
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{% empty %}
|
||||||
|
<span class="text-muted">No display sets for this case.</span>
|
||||||
|
{% endfor %}
|
||||||
|
</details>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
@@ -163,9 +191,30 @@
|
|||||||
$("#current-case-report").html("<span class='title'>Report:</span> "+case_details['report']);
|
$("#current-case-report").html("<span class='title'>Report:</span> "+case_details['report']);
|
||||||
|
|
||||||
bc.postMessage({"type": "open",
|
bc.postMessage({"type": "open",
|
||||||
"case" : c.dataset.case, "images": c.dataset.images,
|
"case" : c.dataset.case, "images": c.dataset.images,
|
||||||
"viewerstate": viewerstate
|
"viewerstate": viewerstate
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
$('.open-displayset').click(function() {
|
||||||
|
let c = this;
|
||||||
|
console.log('clicked local', c)
|
||||||
|
console.log('open local', c.dataset.case)
|
||||||
|
case_details = JSON.parse(c.dataset.casejson);
|
||||||
|
let viewerstate = JSON.parse(c.dataset.viewerstate) || {};
|
||||||
|
let annotations = JSON.parse(c.dataset.annotations) || {};
|
||||||
|
$('#loading-case').show()
|
||||||
|
$("#open-viewer-local").addClass("flash-button");
|
||||||
|
$('#current-case-title').html("<span class='title'>Case:</span> "+c.dataset.title);
|
||||||
|
$("#current-case-history").html("<span class='title'>History:</span> "+case_details['history']);
|
||||||
|
$("#current-case-discussion").html("<span class='title'>Discussion:</span> "+case_details['discussion']);
|
||||||
|
$("#current-case-report").html("<span class='title'>Report:</span> "+case_details['report']);
|
||||||
|
|
||||||
|
bc.postMessage({"type": "open",
|
||||||
|
"case" : c.dataset.case, "images": c.dataset.images,
|
||||||
|
"viewerstate": viewerstate,
|
||||||
|
"annotations": annotations
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
$('.open-series-local').click(function() {
|
$('.open-series-local').click(function() {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<a href="{{ prev_case.get_absolute_url }}">{{ case.title }}</a>
|
<a href="{{ prev_case.get_absolute_url }}">{{ case.title }}</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
{% partial case-series %}
|
{% include "atlas/case_display_block.html#case-series" %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -40,11 +40,8 @@
|
|||||||
console.log(event);
|
console.log(event);
|
||||||
if (event.data.type == "open") {
|
if (event.data.type == "open") {
|
||||||
document.getElementById("awating-load").style.display = "none";
|
document.getElementById("awating-load").style.display = "none";
|
||||||
console.log("open, images: ", event.data.images);
|
|
||||||
document.getElementById("root").dataset.images = event.data.images;
|
document.getElementById("root").dataset.images = event.data.images;
|
||||||
|
|
||||||
console.log("viewerstate: ", event.data.viewerstate);
|
|
||||||
console.log(event.data.viewerstate == {});
|
|
||||||
if (
|
if (
|
||||||
event.data.viewerstate &&
|
event.data.viewerstate &&
|
||||||
Object.keys(event.data.viewerstate).length > 0
|
Object.keys(event.data.viewerstate).length > 0
|
||||||
@@ -53,6 +50,15 @@
|
|||||||
} else {
|
} else {
|
||||||
delete document.getElementById("root").dataset.viewerstate;
|
delete document.getElementById("root").dataset.viewerstate;
|
||||||
}
|
}
|
||||||
|
console.log("Annotations:", event.data.annotations);
|
||||||
|
if (
|
||||||
|
event.data.annotations &&
|
||||||
|
Object.keys(event.data.annotations).length > 0
|
||||||
|
) {
|
||||||
|
document.getElementById("root").dataset.annotationjson = event.data.annotations;
|
||||||
|
} else {
|
||||||
|
delete document.getElementById("root").dataset.annotationjson;
|
||||||
|
}
|
||||||
|
|
||||||
window.mountDicomViewers();
|
window.mountDicomViewers();
|
||||||
bc.postMessage({"type": "open-complete-local"});
|
bc.postMessage({"type": "open-complete-local"});
|
||||||
|
|||||||
+3
-4
@@ -313,15 +313,13 @@ def case_detail(request, pk):
|
|||||||
"series",
|
"series",
|
||||||
queryset=Series.objects.select_related("modality", "examination", "plane", "contrast")
|
queryset=Series.objects.select_related("modality", "examination", "plane", "contrast")
|
||||||
.prefetch_related(
|
.prefetch_related(
|
||||||
Prefetch("images", queryset=SeriesImage.objects.filter(removed=False).order_by("position")),
|
|
||||||
Prefetch(
|
Prefetch(
|
||||||
"findings",
|
"findings",
|
||||||
queryset=SeriesFinding.objects.prefetch_related(
|
queryset=SeriesFinding.objects.prefetch_related(
|
||||||
Prefetch("findings", queryset=Finding.objects.all()),
|
"findings", "conditions", "structures"
|
||||||
Prefetch("conditions", queryset=Condition.objects.all()),
|
|
||||||
Prefetch("structures", queryset=Structure.objects.all()),
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
Prefetch("images", queryset=SeriesImage.objects.filter(removed=False).order_by("position")),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -340,6 +338,7 @@ def case_detail(request, pk):
|
|||||||
)
|
)
|
||||||
.get(pk=pk)
|
.get(pk=pk)
|
||||||
)
|
)
|
||||||
|
case.ordered_series = [sd.series for sd in case.seriesdetail_set.all()]
|
||||||
can_edit = case.check_user_can_edit(request.user)
|
can_edit = case.check_user_can_edit(request.user)
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
|
|||||||
Reference in New Issue
Block a user