diff --git a/atlas/api.py b/atlas/api.py index 95b99f7a..afc7a583 100644 --- a/atlas/api.py +++ b/atlas/api.py @@ -154,7 +154,12 @@ def import_dicoms_helper(request, case_id: int | None = None): series_list = [] for series_uid in data: - modality = get_object_or_404(Modality, short_code=tags["Modality"]) + try: + modality = Modality.objects.get(short_code=tags["Modality"]) + except Modality.DoesNotExist: + modality = Modality.objects.create(short_code=tags["Modality"], modality=tags["Modality"]) + + tags = data[series_uid][0][1] # Check if series with the id already exists (in which case we just add to htat) diff --git a/atlas/models.py b/atlas/models.py index 80adf126..ec5db7c4 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -1378,6 +1378,11 @@ class UncategorisedDicom(models.Model): def get_series(self): return self.series + def get_dicom_url(self): + return f"{REMOTE_URL}self.image.url" + + + class DuplicateDicom(Exception): def __init__(self, duplicate): diff --git a/atlas/templates/atlas/user_upload_viewer.html b/atlas/templates/atlas/user_upload_viewer.html index 0c89ef79..57ba0075 100755 --- a/atlas/templates/atlas/user_upload_viewer.html +++ b/atlas/templates/atlas/user_upload_viewer.html @@ -5,7 +5,7 @@