improve dicom uploading

This commit is contained in:
Ross
2023-10-23 13:36:41 +01:00
parent c786019af1
commit 0f3bc68de6
28 changed files with 464 additions and 172 deletions
+9 -3
View File
@@ -811,9 +811,11 @@ class UncategorisedDicom(models.Model):
)
series = models.ForeignKey(
"Series", related_name="imported_dicoms", on_delete=models.SET_NULL, null=True
"Series", related_name="imported_dicoms", on_delete=models.SET_NULL, null=True, blank=True
)
series_instance_uid = models.CharField(max_length=255, blank=True, null=True)
image_md5_hash = models.CharField(max_length=32, null=True, blank=True)
def check_for_duplicates(self, image_hash):
@@ -833,10 +835,14 @@ class UncategorisedDicom(models.Model):
def save(self, *args, **kwargs):
"""Override save method to add image hash"""
if self.image:
ds = self.get_dicom_info()
self.series_instance_uid = ds["SeriesInstanceUID"].value
# if self.check_for_duplicates():
# return DuplicateDicom
image_hash = get_image_dicom_hash(self.image)
image_hash = get_image_dicom_hash(None, dataset=ds)
self.image_md5_hash = image_hash