start adding uncat dicom

This commit is contained in:
Ross
2023-08-14 10:15:56 +01:00
parent c3a735fa52
commit 9ae1874073
8 changed files with 196 additions and 42 deletions
+16 -1
View File
@@ -26,7 +26,7 @@ from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from helpers.images import pretty_print_dicom
from helpers.images import get_image_hash, pretty_print_dicom
from rad.settings import REMOTE_URL
from django.utils.html import format_html
@@ -187,6 +187,9 @@ class SeriesImageBase(models.Model):
)
dicom_tags_ohif = models.JSONField(help_text="Holds the dicom tags required for the OHIF viewer", blank=True, null=True)
image_md5_hash = models.CharField(max_length=32, null=True, blank=True)
is_dicom = models.BooleanField(default=False)
class Meta:
ordering = ["position"]
abstract = True
@@ -198,6 +201,18 @@ class SeriesImageBase(models.Model):
info = "File is not a dicom."
return info
def save(self, *args, **kwargs):
"""Override save method to add image hash"""
if self.image:
image_hash, is_dicom = get_image_hash(self.image)
self.is_dicom = is_dicom
self.image_md5_hash = image_hash
# Hack for tests
if image_hash != "12345ABCD":
super().save(*args, **kwargs) # Call the "real" save() method.
class SeriesBase(models.Model):
info = models.TextField(