start integrating cimar
This commit is contained in:
+64
-1
@@ -48,6 +48,7 @@ from anatomy.models import AnatomyQuestion
|
||||
from anatomy.models import Answer as AnatomyAnswer
|
||||
from rad.filters import UserListFilter
|
||||
|
||||
from helpers.cimar import CimarAPI, InvalidCredentials, NoSession
|
||||
from rapids.models import UserAnswer as RapidsUserAnswer
|
||||
from rapids.models import Exam as RapidsExam
|
||||
from rapids.models import Rapid
|
||||
@@ -65,7 +66,7 @@ from rapids.views import GenericExamViews as RapidsExamsViews
|
||||
from longs.views import GenericExamViews as LongsExamViews
|
||||
|
||||
from generic.forms import QuestionNoteForm
|
||||
from generic.models import CidUser, ExamCollection, QuestionNote, Supervisor, UserGrades, UserProfile
|
||||
from generic.models import CidUser, CimarCase, ExamCollection, QuestionNote, Supervisor, UserGrades, UserProfile
|
||||
|
||||
from django_filters.views import FilterView
|
||||
|
||||
@@ -919,3 +920,65 @@ def request_cid_details(request):
|
||||
return HttpResponse(
|
||||
f"Candidate details will be sent to the requested email (if it is found in the system). If you have not received an email after a few minutes you may need to contact <a href='mailto:{settings.CONTACT_EMAIL}'>{settings.CONTACT_EMAIL}</a>"
|
||||
)
|
||||
|
||||
|
||||
def cimar_study_dicom_json(request, uuid="c9417b53-87aa-4c40-aca0-3fa34c225536"):
|
||||
with CimarAPI(request.user.userprofile.cimar_sid) as api:
|
||||
print(api.sid)
|
||||
#studies = api.list_studies()
|
||||
#test_study = studies["studies"][0]
|
||||
|
||||
#schema = api.get_study_schema(test_study)
|
||||
|
||||
schema = api.get_study_schema_by_uuid("c9417b53-87aa-4c40-aca0-3fa34c225536")
|
||||
|
||||
return JsonResponse(api.get_study_dicom_json(schema))
|
||||
|
||||
def cimar_study_viewer(request, uuid="c9417b53-87aa-4c40-aca0-3fa34c225536"):
|
||||
|
||||
case = get_object_or_404(CimarCase, uuid=uuid)
|
||||
|
||||
viewer_link = case.viewer_link + f"?sid={request.user.userprofile.cimar_sid}"
|
||||
return render(request, "cimar_embed.html", {"viewer_link": viewer_link})
|
||||
|
||||
def cimar_study_viewer_embed(request, uuid="c9417b53-87aa-4c40-aca0-3fa34c225536"):
|
||||
|
||||
case = get_object_or_404(CimarCase, uuid=uuid)
|
||||
|
||||
viewer_link = case.viewer_link + f"?sid={request.user.userprofile.cimar_sid}"
|
||||
return render(request, "cimar_embed.html#embed", {"viewer_link": viewer_link})
|
||||
|
||||
def cimar_study_series_block(request, uuid):
|
||||
|
||||
case = get_object_or_404(CimarCase, uuid=uuid)
|
||||
|
||||
return render(request, "cimar_series.html", {"series_data": case.series_data["series"], "cimar_sid": request.user.userprofile.cimar_sid})
|
||||
|
||||
def cimar_login(request):
|
||||
|
||||
if request.htmx:
|
||||
username = request.POST.get("username")
|
||||
password = request.POST.get("password")
|
||||
|
||||
|
||||
|
||||
if not username and not password:
|
||||
return HttpResponse("Please fill in login details")
|
||||
|
||||
try:
|
||||
sid = CimarAPI().login(username, password)
|
||||
|
||||
request.user.userprofile.cimar_sid = sid
|
||||
request.user.userprofile.save()
|
||||
except InvalidCredentials:
|
||||
return HttpResponse("Invalid login details")
|
||||
|
||||
|
||||
return HttpResponse("Logged in")
|
||||
|
||||
else:
|
||||
try:
|
||||
login_status = CimarAPI(request.user.userprofile.cimar_sid).check_login_status()
|
||||
except NoSession:
|
||||
login_status = False
|
||||
return render(request, "cimar_login.html", {"login_status": login_status, "cimar_sid": request.user.userprofile.cimar_sid})
|
||||
Reference in New Issue
Block a user