diff --git a/atlas/migrations/0038_casecollection_viewer_mode.py b/atlas/migrations/0038_casecollection_viewer_mode.py new file mode 100644 index 00000000..6bb42d5f --- /dev/null +++ b/atlas/migrations/0038_casecollection_viewer_mode.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.4 on 2024-02-12 12:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('atlas', '0037_alter_seriesimage_image_blake3_hash'), + ] + + operations = [ + migrations.AddField( + model_name='casecollection', + name='viewer_mode', + field=models.CharField(choices=[('BUILT_IN', 'Built in viewer'), ('OHIF', 'OHIF Viewer'), ('BUILT_IN_WITH_OHIF', 'Built in viewer with OHIF Viewer option')], default='BUILT_IN', max_length=100), + ), + ] diff --git a/atlas/models.py b/atlas/models.py index a67bb3d9..85f512a6 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -699,6 +699,26 @@ class CaseCollection(ExamOrCollectionGenericBase): default=COLLECTION_TYPE_CHOICES.REPORT, ) + class VIEWER_MODE_CHOICES(models.TextChoices): + BUILT_IN = ( + "BUILT_IN", + _("Built in viewer"), + ) + OHIF = ( + "OHIF", + _("OHIF Viewer"), + ) + BUILT_IN_WITH_OHIF = ( + "BUILT_IN_WITH_OHIF", + _("Built in viewer with OHIF Viewer option"), + ) + + viewer_mode = models.CharField( + max_length=100, + choices=VIEWER_MODE_CHOICES.choices, + default=VIEWER_MODE_CHOICES.BUILT_IN, + ) + def get_absolute_url(self): return reverse("atlas:collection_detail", kwargs={"pk": self.pk}) @@ -708,6 +728,18 @@ class CaseCollection(ExamOrCollectionGenericBase): def __str__(self) -> str: return self.name + def show_built_in_viewer(self) -> bool: + return self.viewer_mode in ( + self.VIEWER_MODE_CHOICES.BUILT_IN, + self.VIEWER_MODE_CHOICES.BUILT_IN_WITH_OHIF, + ) + + def show_ohif_viewer_link(self) -> bool: + return self.viewer_mode in ( + self.VIEWER_MODE_CHOICES.OHIF, + self.VIEWER_MODE_CHOICES.BUILT_IN_WITH_OHIF, + ) + def review_only(self) -> bool: """Returns True if a users cannot submit responses @@ -719,6 +751,17 @@ class CaseCollection(ExamOrCollectionGenericBase): return False + def in_review_mode(self) -> bool: + return self.review_only() or self.publish_results + + # def can_answer(self) -> bool: + # """Returns true if the user is able to answer questions in a collection + # (independent of current collection state (e.g. published / not published))""" + # if self.collection_type == self.COLLECTION_TYPE_CHOICES.REPORT: + # return True + + # return False + def get_case_by_index( self, case_index: int, case_count=False ) -> Case | Tuple[Case, int]: @@ -892,8 +935,10 @@ class UncategorisedDicom(models.Model): def check_for_duplicates(self, image_hash): duplicate = None - if obj := UncategorisedDicom.objects.filter(image_blake3_hash=image_hash).first(): - #duplicate = obj + if obj := UncategorisedDicom.objects.filter( + image_blake3_hash=image_hash + ).first(): + # duplicate = obj return obj print(image_hash) @@ -912,7 +957,9 @@ class UncategorisedDicom(models.Model): # if self.check_for_duplicates(): # return DuplicateDicom - image_blake3_hash = get_image_dicom_hash(None, dataset=ds, hash_type="blake3", direct_pixel_data=True) + image_blake3_hash = get_image_dicom_hash( + None, dataset=ds, hash_type="blake3", direct_pixel_data=True + ) self.image_blake3_hash = image_blake3_hash diff --git a/atlas/templates/atlas/add_case_to_collection.html b/atlas/templates/atlas/add_case_to_collection.html new file mode 100644 index 00000000..eab95ab0 --- /dev/null +++ b/atlas/templates/atlas/add_case_to_collection.html @@ -0,0 +1,13 @@ + + +Creating a case in the collection: {{form.collection.name}} +