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