This commit is contained in:
Ross
2021-10-30 22:36:50 +01:00
parent f4a3cca774
commit d179030881
+56 -25
View File
@@ -38,13 +38,17 @@
$('#id_answers-TOTAL_FORMS').val(parseInt(form_idx) + 1); $('#id_answers-TOTAL_FORMS').val(parseInt(form_idx) + 1);
} }
function input_change () { function input_change(evt) {
$(this).removeClass("image-ident-warning"); $(this).removeClass("image-ident-warning");
$(this).removeClass("image-ident-ok"); $(this).removeClass("image-ident-ok");
updateFileList(); updateFileList();
console.log("input change1"); console.log("input change1", evt);
console.log("input change", this); console.log("input change", this);
ocr(this); ocr(this);
// Check if we have selected a examination type
console.log($("#id_examination_from").val())
} }
@@ -53,11 +57,11 @@
$(".temp-thumb").remove() $(".temp-thumb").remove()
$("#image_form_set input[type=file]").each((n, el) => { $("#image_form_set input[type=file]").each((n, el) => {
console.log(el); console.log(el);
if(el.files.length > 0) { if (el.files.length > 0) {
extra_class = " image-ident-loading"; extra_class = " image-ident-loading";
if($(el).hasClass("image-ident-warning")) { if ($(el).hasClass("image-ident-warning")) {
extra_class = " image-ident-warning" extra_class = " image-ident-warning"
} else if($(el).hasClass("image-ident-ok")) { } else if ($(el).hasClass("image-ident-ok")) {
extra_class = " image-ident-ok" extra_class = " image-ident-ok"
} }
$("#drop-filenames").append( $("#drop-filenames").append(
@@ -112,8 +116,8 @@
input_diff = (evt.dataTransfer.files.length - inputs.length) input_diff = (evt.dataTransfer.files.length - inputs.length)
console.log("diff", input_diff) console.log("diff", input_diff)
if(input_diff > 0) { if (input_diff > 0) {
for(let j = 0; j < input_diff; j++) { for (let j = 0; j < input_diff; j++) {
add_input_form() add_input_form()
} }
@@ -127,14 +131,14 @@
let dT = new DataTransfer(); let dT = new DataTransfer();
dT.clearData(); dT.clearData();
dT.items.add(f); dT.items.add(f);
for(let i = 0; i < inputs.length; i++) { for (let i = 0; i < inputs.length; i++) {
el = inputs.get(i) el = inputs.get(i)
if(el.files.length == 0) { if (el.files.length == 0) {
el.files = dT.files; el.files = dT.files;
ocr(el) ocr(el)
if(evt.target.id == "feedback-drop-target") { if (evt.target.id == "feedback-drop-target") {
arr = el.name.split("-"); arr = el.name.split("-");
arr.splice(2, 1, "feedback_image"); arr.splice(2, 1, "feedback_image");
feedback_el_name = arr.join("-"); feedback_el_name = arr.join("-");
@@ -165,12 +169,12 @@
function ifNormal(){ function ifNormal() {
if (document.getElementById("id_normal").checked){ if (document.getElementById("id_normal").checked) {
$("#answer_form_set textarea").attr("required", false) $("#answer_form_set textarea").attr("required", false)
} else { } else {
$("#answer_form_set textarea").attr("required", true) $("#answer_form_set textarea").attr("required", true)
} }
} }
$("#id_normal").change(() => ifNormal()); $("#id_normal").change(() => ifNormal());
@@ -223,7 +227,7 @@
l = text.toLowerCase(); l = text.toLowerCase();
$(`img[data-input-id='${input.id}'`).removeClass("image-ident-loading"); $(`img[data-input-id='${input.id}'`).removeClass("image-ident-loading");
console.log(l); console.log(l);
if(l.includes("accesion") || l.includes("number") || l.search(/(ref|rk9|rh8|ra9|rbz)\d+/g) > -1) { if (l.includes("accesion") || l.includes("number") || l.search(/(ref|rk9|rh8|ra9|rbz)\d+/g) > -1) {
console.log("SHIT", input); console.log("SHIT", input);
$(input).addClass("image-ident-warning"); $(input).addClass("image-ident-warning");
$(`img[data-input-id='${input.id}'`).addClass("image-ident-warning"); $(`img[data-input-id='${input.id}'`).addClass("image-ident-warning");
@@ -256,7 +260,7 @@
image.title = file.name; image.title = file.name;
image.src = reader.result; image.src = reader.result;
image.className = "temp-thumb"; image.className = "temp-thumb";
console.log("read" ,el); console.log("read", el);
$(el).parent().parent().prepend(image); $(el).parent().parent().prepend(image);
//images.push(reader.result); //images.push(reader.result);
loadViewer(); loadViewer();
@@ -332,6 +336,31 @@
} }
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)
try{
// parse byteArray into a DataSet object using the parseDicom library
var dataSet = dicomParser.parseDicom(byteArray);
// dataSet contains the parsed elements. Each element is available via a property
// in the dataSet.elements object. The property name is based on the elements group
// and element in the following format: xggggeeee where gggg is the group number
// and eeee is the element number with lowercase hex characters.
// To access the data for an element, we need to know its type and its tag.
// We will get the sopInstanceUid from the file which is a string and
// has the tag (0020,000D)
var study_description = dataSet.string('x00081030');
}
catch(err)
{
console.log(err);
}
}
</script> </script>
{{ form.media }} {{ form.media }}
@@ -340,8 +369,10 @@
<h2>Submit Rapid</h2> <h2>Submit Rapid</h2>
<a href="{% url 'rapids:rapid_create_defaults' %}">Edit defaults</a> <a href="{% url 'rapids:rapid_create_defaults' %}">Edit defaults</a>
<p> <p>
<h3>Instructions</h3> <h3>Instructions</h3>
Abnormality, Region and Laterality are used to categorise within the system (they are not used for marking). String answers that match those added below will be used for automatic marking. Multiple images can be added to a question. If the feedback image box is checked they will not be displayed when taking the question. Abnormality, Region and Laterality are used to categorise within the system (they are not used for marking). String
answers that match those added below will be used for automatic marking. Multiple images can be added to a question. If
the feedback image box is checked they will not be displayed when taking the question.
</p> </p>
<form action="" method="post" enctype="multipart/form-data" id="rapid-form"> <form action="" method="post" enctype="multipart/form-data" id="rapid-form">
{% csrf_token %} {% csrf_token %}