.
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ class ExaminationForm(ModelForm):
|
||||
class SeriesFindingForm(ModelForm):
|
||||
class Meta:
|
||||
model = SeriesFinding
|
||||
exclude = ["series", "annotation_json"]
|
||||
exclude = ["series", "annotation_json", "viewport_json"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if kwargs.get("series_id"):
|
||||
|
||||
@@ -220,6 +220,7 @@ class SeriesFinding(models.Model):
|
||||
)
|
||||
findings = models.ManyToManyField(Finding, blank=True)
|
||||
annotation_json = models.TextField(null=True, blank=True)
|
||||
viewport_json = models.TextField(null=True, blank=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
findings = self.findings.all().values_list("name")
|
||||
|
||||
@@ -44,7 +44,7 @@ This series is not associated with any cases.
|
||||
|
||||
{% for finding in series.findings.all %}
|
||||
<div>
|
||||
<button class="view-finding-button" data-json={{finding.annotation_json}}>Click to view</button>
|
||||
<button class="view-finding-button" data-annotationjson={{finding.annotation_json}} data-viewportjson={{finding.viewport_json}}>Click to view</button>
|
||||
Findings: {{finding.findings.all|join:", "}}<br />
|
||||
Description: {{finding.description}}<br />
|
||||
<a href="{% url 'atlas:delete_finding' pk=finding.pk %}">Delete finding</a>
|
||||
@@ -74,9 +74,12 @@ This series is not associated with any cases.
|
||||
$(".view-finding-button").each((n, el) => {
|
||||
$(el).click((e) => {
|
||||
dicom_element = $(".single-dicom-viewer").get(0);
|
||||
json = JSON.parse(e.currentTarget.dataset.json);
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(json);
|
||||
cornerstone.reset(dicom_element);
|
||||
annotationjson = JSON.parse(e.currentTarget.dataset.annotationjson);
|
||||
viewport = JSON.parse(e.currentTarget.dataset.viewportjson)
|
||||
//cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(json);
|
||||
cornerstone.getEnabledElement(dicom_element).restoreToolState(annotationjson)
|
||||
cornerstone.getEnabledElement(dicom_element).viewport = viewport
|
||||
cornerstone.resize(dicom_element);
|
||||
|
||||
|
||||
});
|
||||
@@ -85,13 +88,17 @@ This series is not associated with any cases.
|
||||
});
|
||||
|
||||
$(document).on('submit', '#series_finding_form', function (e) {
|
||||
dicom_element = $(".single-dicom-viewer").get(0);
|
||||
c = cornerstone.getEnabledElement(dicom_element);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{% url "atlas:add_finding" %}',
|
||||
data: {
|
||||
description: $('#id_description').val(),
|
||||
series: {{series.pk}},
|
||||
annotation_json: JSON.stringify(cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState()),
|
||||
annotation_json: JSON.stringify(c.saveToolState()),
|
||||
viewport_json: JSON.stringify(c.viewport),
|
||||
findings: JSON.stringify($('#finding-form select[name="findings"]').find(":selected").map((i, el) => { return $(el).val() }).toArray()),
|
||||
csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(),
|
||||
action: 'post'
|
||||
|
||||
@@ -541,6 +541,7 @@ def create_series_findings(request):
|
||||
findings_ids = json.loads(request.POST.get("findings"))
|
||||
description = request.POST.get("description")
|
||||
annotation_json = request.POST.get("annotation_json")
|
||||
viewport_json = request.POST.get("viewport_json")
|
||||
|
||||
series = Series.objects.get(pk=series_id)
|
||||
findings = Finding.objects.filter(pk__in=findings_ids)
|
||||
@@ -549,6 +550,7 @@ def create_series_findings(request):
|
||||
series=series,
|
||||
description=description,
|
||||
annotation_json=annotation_json,
|
||||
viewport_json=viewport_json,
|
||||
)
|
||||
sf.findings.set(findings)
|
||||
sf.save()
|
||||
|
||||
Reference in New Issue
Block a user