From ca05c67b8721be2c1024119c346b5b97757fc225 Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 24 Feb 2024 22:39:45 +0000 Subject: [PATCH] update seriesfinding to contain conditions --- atlas/forms.py | 4 ++++ .../0044_seriesfinding_conditions.py | 18 ++++++++++++++++++ atlas/models.py | 3 ++- atlas/templates/atlas/series_viewer.html | 10 +++++++++- atlas/views.py | 3 +++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 atlas/migrations/0044_seriesfinding_conditions.py diff --git a/atlas/forms.py b/atlas/forms.py index d59ec7a9..86838269 100755 --- a/atlas/forms.py +++ b/atlas/forms.py @@ -127,6 +127,10 @@ class SeriesFindingForm(ModelForm): "structures": autocomplete.ModelSelect2Multiple( url="atlas:structure-autocomplete" ), + "conditions": autocomplete.ModelSelect2Multiple( + url="atlas:condition-autocomplete" + ), + } def __init__(self, *args, **kwargs): diff --git a/atlas/migrations/0044_seriesfinding_conditions.py b/atlas/migrations/0044_seriesfinding_conditions.py new file mode 100644 index 00000000..265d6c2f --- /dev/null +++ b/atlas/migrations/0044_seriesfinding_conditions.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-02-24 21:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('atlas', '0043_seriesdetail_feedback'), + ] + + operations = [ + migrations.AddField( + model_name='seriesfinding', + name='conditions', + field=models.ManyToManyField(blank=True, to='atlas.condition'), + ), + ] diff --git a/atlas/models.py b/atlas/models.py index 50aff24b..9eb56f7c 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -514,12 +514,13 @@ class SeriesFinding(models.Model): ) findings = models.ManyToManyField(Finding, blank=True) structures = models.ManyToManyField(Structure, blank=True) + conditions = models.ManyToManyField(Condition, 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") - return f"{self.series.id}/{findings}/{self.description}" + return f"SeriesFinding: {self.series.id}/{findings}/{self.description}" def annotation_as_string(self) -> str: return json.dumps(self.annotation_json) diff --git a/atlas/templates/atlas/series_viewer.html b/atlas/templates/atlas/series_viewer.html index 8c1e77d6..357a6f31 100755 --- a/atlas/templates/atlas/series_viewer.html +++ b/atlas/templates/atlas/series_viewer.html @@ -27,6 +27,7 @@
Description: {{ series_finding_form.description }}
Findings: {{ series_finding_form.findings }}
Structures: {{ series_finding_form.structures }}
+
Conditions: {{ series_finding_form.conditions }}
@@ -48,6 +49,7 @@ Finding(s): {% for f in finding.findings.all %}{{f.get_link}}{% endfor %}
Structure(s): {% for s in finding.structures.all %}{{s.get_link}}{% endfor %}
+ Condition(s): {% for s in finding.conditions.all %}{{s.get_link}}{% endfor %}
Description: {{finding.description}}
Edit @@ -252,7 +254,8 @@ cornerstone.getEnabledElement(dicom_element).viewport = viewport cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState( annotation); - console.log(annotation) + console.log("annotation", annotation) + console.log("viewport", viewport) //cornerstone.getEnabledElement(dicom_element).toolStateManager.restoreToolState(annotationjson) cornerstone.resize(dicom_element); @@ -285,6 +288,11 @@ .map((i, el) => { return $(el).val() }).toArray()), + conditions: JSON.stringify($('#finding-form select[name="conditions"]').find( + ":selected") + .map((i, el) => { + return $(el).val() + }).toArray()), csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), action: 'post' }, diff --git a/atlas/views.py b/atlas/views.py index f37c0283..226e931a 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -1193,6 +1193,7 @@ def create_series_findings(request): series_id = request.POST.get("series") findings_ids = json.loads(request.POST.get("findings")) structure_ids = json.loads(request.POST.get("structures")) + condition_ids = json.loads(request.POST.get("conditions")) description = request.POST.get("description") annotation_json = request.POST.get("annotation_json") viewport_json = request.POST.get("viewport_json") @@ -1200,6 +1201,7 @@ def create_series_findings(request): series = Series.objects.get(pk=series_id) findings = Finding.objects.filter(pk__in=findings_ids) structures = Structure.objects.filter(pk__in=structure_ids) + conditions = Condition.objects.filter(pk__in=condition_ids) if series_finding_id > 0: sf = get_object_or_404(SeriesFinding, pk=series_finding_id) @@ -1217,6 +1219,7 @@ def create_series_findings(request): sf.findings.set(findings) sf.structures.set(structures) + sf.conditions.set(conditions) sf.save() return JsonResponse({"success": True})