This commit is contained in:
Ross
2021-11-29 21:16:04 +00:00
parent c447bd9371
commit 0a793e4b65
4 changed files with 16 additions and 6 deletions
+1 -1
View File
@@ -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"):
+1
View File
@@ -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")
+12 -5
View File
@@ -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'
+2
View File
@@ -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()