numerous updates to case collections

This commit is contained in:
Ross
2024-02-12 13:05:26 +00:00
parent c3f7913402
commit b9cdbb98ef
10 changed files with 158 additions and 29 deletions
+50 -3
View File
@@ -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