.
This commit is contained in:
@@ -458,6 +458,7 @@ class RapidImage(models.Model):
|
||||
# Try and read the file as a dicom
|
||||
try:
|
||||
# and generate a hash from the pixel data
|
||||
# TODO: improve?
|
||||
dataset = pydicom.dcmread(self.image)
|
||||
print(dataset)
|
||||
flatten = dataset.pixel_array.flatten()
|
||||
|
||||
@@ -446,6 +446,7 @@
|
||||
|
||||
|
||||
ocr2(url, el);
|
||||
checkHash(hash);
|
||||
|
||||
$("#drop-filenames").append(
|
||||
`<span data-input-id='${el.id}'><span>${n}: ${el.files[0].name}</span><img class='uploading${extra_class}' data-input-id='${el.id}' src=${url}></span>`
|
||||
@@ -468,6 +469,7 @@
|
||||
|
||||
let hash = CryptoJS.MD5(pixel_data).toString();
|
||||
console.log(element, "HASH", hash)
|
||||
checkHash(hash);
|
||||
|
||||
});
|
||||
|
||||
@@ -630,6 +632,31 @@
|
||||
|
||||
}
|
||||
|
||||
function checkHash(hash) {
|
||||
$.ajax({
|
||||
url: "{% url 'rapids:rapid_question_by_hash' %}",
|
||||
data: {
|
||||
csrfmiddlewaretoken: csrf,
|
||||
hash: hash
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
})
|
||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||
.done(function (data) {
|
||||
console.log(data);
|
||||
|
||||
if (data.status == "success") {
|
||||
console.log("success");
|
||||
console.log(data.id)
|
||||
toastr.info(f'id {data.id}')
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
}
|
||||
|
||||
function extractDicomStudyDescription(byteArray) {
|
||||
// We need to setup a try/catch block because parseDicom will throw an exception
|
||||
// if you attempt to parse a non dicom part 10 file (or one that is corrupted)
|
||||
|
||||
@@ -12,6 +12,7 @@ urlpatterns = [
|
||||
path("author/<int:pk>/", views.GenericViews.author_detail, name="author_detail"),
|
||||
path("author/", views.GenericViews.author_list, name="author_list"),
|
||||
path("question/", views.RapidView.as_view(), name="rapid_view"),
|
||||
path("question/hash", views.get_question_by_hash, name="rapid_question_by_hash"),
|
||||
# path("unchecked/", views.unchecked_list, name="unchecked_list"),
|
||||
# path("verified/<int:pk>/", views.verified_detail, name="verified_detail"),
|
||||
path(
|
||||
|
||||
@@ -33,6 +33,7 @@ from .forms import (
|
||||
from .models import (
|
||||
Rapid,
|
||||
Abnormality,
|
||||
RapidImage,
|
||||
Region,
|
||||
Examination,
|
||||
Exam,
|
||||
@@ -1105,3 +1106,17 @@ def question_save_annotation(request, pk):
|
||||
class ExamClone(ExamCloneMixin, ExamCreate):
|
||||
"""Clone exam view"""
|
||||
|
||||
|
||||
@login_required
|
||||
def get_question_by_hash(request, pk):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
|
||||
hash = json.loads(request.POST.get("hash"))
|
||||
|
||||
try:
|
||||
question = RapidImage.objects.get(image_md5_hash=hash)
|
||||
data = {"status": "success", "id": question.pk}
|
||||
return JsonResponse(data, status=200)
|
||||
except RapidImage.DoesNotExist:
|
||||
data = {"status": "success", "id": False}
|
||||
return JsonResponse(data, status=200)
|
||||
Reference in New Issue
Block a user