start integrating cimar

This commit is contained in:
Ross
2025-02-24 11:53:36 +00:00
parent 249bc656c8
commit a0960c9b7c
21 changed files with 826 additions and 8 deletions
+17
View File
@@ -67,6 +67,9 @@ from atlas.helpers import get_cases_available_to_user
from typing import Any
from helpers.cimar import CimarAPI, NotFoundError
from rad.settings import CIMAR_USERNAME, CIMAR_PASSWORD
class CaseSelect(Select):
template_name = "atlas/case_select_widget.html"
@@ -363,6 +366,7 @@ class CaseForm(ModelForm):
"open_access",
"previous_case",
"diagnostic_certainty",
"cimar_uuid"
),
)
@@ -396,6 +400,7 @@ class CaseForm(ModelForm):
"open_access",
"previous_case",
"diagnostic_certainty",
"cimar_uuid"
]
# fields = ['question', 'findings', 'subspecialty', 'references']
widgets = {
@@ -417,6 +422,18 @@ class CaseForm(ModelForm):
"pathological_process": CheckboxSelectMultiple(),
"previous_case": CaseSelect(),
}
def clean_cimar_uuid(self):
cimar_uuid = self.cleaned_data["cimar_uuid"]
if cimar_uuid:
with CimarAPI(username=CIMAR_USERNAME, password=CIMAR_PASSWORD) as api:
try:
study = api.get_study_by_uuid(cimar_uuid)
except NotFoundError:
raise ValidationError("Study not found in CIMAR")
return cimar_uuid
def save(self, commit=True):
# Get the unsaved Case instance