Merge branch 'master' of ssh://git.xkjq.uk:30001/ross/rad
This commit is contained in:
@@ -5,16 +5,43 @@
|
||||
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
let normal = false;
|
||||
let monitor_directory_handler = false;
|
||||
let monitor_interval_id = false;
|
||||
|
||||
// set to hold the files that are still being processed
|
||||
let active_file_inputs = new Set()
|
||||
|
||||
async function listAllFilesAndDirs(dirHandle) {
|
||||
const files = [];
|
||||
for await (let [name, handle] of dirHandle) {
|
||||
const {
|
||||
kind
|
||||
} = handle;
|
||||
if (handle.kind === 'directory') {
|
||||
files.push({
|
||||
name,
|
||||
handle,
|
||||
kind
|
||||
});
|
||||
files.push(...await listAllFilesAndDirs(handle));
|
||||
} else {
|
||||
files.push({
|
||||
name,
|
||||
handle,
|
||||
kind
|
||||
});
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
function showEditPopup(url) {
|
||||
var win = window.open(url, "Edit",
|
||||
'height=500,width=800,resizable=yes,scrollbars=yes');
|
||||
return false;
|
||||
}
|
||||
|
||||
function showAddPopup(triggeringLink) {
|
||||
var name = triggeringLink.id.replace(/^add_/, '');
|
||||
href = triggeringLink.href;
|
||||
@@ -22,13 +49,16 @@
|
||||
win.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
function closePopup(win, newID, newRepr, id) {
|
||||
console.log(id)
|
||||
$(id + "_to").append('<option value=' + newID + ' title=' + newRepr + ' >' + newRepr + '</option>')
|
||||
win.close();
|
||||
}
|
||||
|
||||
document.addEventListener('drop', function (e) { e.preventDefault(); }, false);
|
||||
document.addEventListener('drop', function (e) {
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
function getUnusedInputs(inputs) {
|
||||
new_inputs = [];
|
||||
@@ -69,7 +99,8 @@
|
||||
|
||||
function add_input_form() {
|
||||
var form_idx = $('#id_images-TOTAL_FORMS').val();
|
||||
$('#image_form_set').append($($('#empty_form').html().replace(/__prefix__/g, form_idx)).on("change", input_change));
|
||||
$('#image_form_set').append($($('#empty_form').html().replace(/__prefix__/g, form_idx)).on("change",
|
||||
input_change));
|
||||
$('#id_images-TOTAL_FORMS').val(parseInt(form_idx) + 1);
|
||||
}
|
||||
|
||||
@@ -131,6 +162,32 @@
|
||||
|
||||
}
|
||||
|
||||
function addFile(f, feedback) {
|
||||
let dT = new DataTransfer();
|
||||
dT.clearData();
|
||||
dT.items.add(f);
|
||||
for (let i = 0; i < inputs.length; i++) {
|
||||
el = inputs.get(i);
|
||||
|
||||
if (el.files.length == 0) {
|
||||
el.files = dT.files;
|
||||
//ocr(el)
|
||||
$(el).change();
|
||||
|
||||
if(feedback) {
|
||||
arr = el.name.split("-");
|
||||
arr.splice(2, 1, "feedback_image");
|
||||
feedback_el_name = arr.join("-");
|
||||
|
||||
$(`[name=${feedback_el_name}]`).prop("checked", true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#add_abnormality").appendTo($("label[for='id_abnormality']"));
|
||||
@@ -165,10 +222,6 @@
|
||||
$(evt.target).removeClass("drop-target-active");
|
||||
|
||||
file_drop_number = evt.dataTransfer.files.length;
|
||||
// Get all input elements
|
||||
inputs = extendInputs(file_drop_number);
|
||||
|
||||
console.log("drop inputs", inputs, evt);
|
||||
|
||||
if (file_drop_number < 1) {
|
||||
toastr.warning(`Drop failed (no files), try again.`);
|
||||
@@ -176,32 +229,20 @@
|
||||
toastr.info(`Loading ${file_drop_number} dropped image(s).`);
|
||||
}
|
||||
|
||||
// Get all input elements
|
||||
inputs = extendInputs(file_drop_number);
|
||||
|
||||
console.log("drop inputs", inputs, evt);
|
||||
|
||||
|
||||
// Loop through each dropped file and try to assign to an
|
||||
// input element
|
||||
[...evt.dataTransfer.files].forEach((f) => {
|
||||
let dT = new DataTransfer();
|
||||
dT.clearData();
|
||||
dT.items.add(f);
|
||||
for (let i = 0; i < inputs.length; i++) {
|
||||
el = inputs.get(i);
|
||||
console.log("drop el", el);
|
||||
|
||||
if (el.files.length == 0) {
|
||||
el.files = dT.files;
|
||||
//ocr(el)
|
||||
$(el).change();
|
||||
console.log("drop change")
|
||||
|
||||
feedback = false;
|
||||
if (evt.target.id == "feedback-drop-target") {
|
||||
arr = el.name.split("-");
|
||||
arr.splice(2, 1, "feedback_image");
|
||||
feedback_el_name = arr.join("-");
|
||||
|
||||
$(`[name=${feedback_el_name}]`).prop("checked", true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
feedback = true;
|
||||
}
|
||||
addFile(f, feedback)
|
||||
})
|
||||
|
||||
// // If you want to use some of the dropped files
|
||||
@@ -215,8 +256,34 @@
|
||||
};
|
||||
|
||||
|
||||
$('#add_more_images').click(() => { add_input_form() });
|
||||
$('#add_more_answers').click(() => { add_answers_input_form() });
|
||||
$('#directory-picker-button').click(() => {
|
||||
window.showDirectoryPicker().then((handler) => {
|
||||
monitor_directory_handler = handler;
|
||||
monitor_interval_id = setInterval(function () {
|
||||
listAllFilesAndDirs(monitor_directory_handler).then((items) => {
|
||||
console.log(items);
|
||||
});
|
||||
}, 5000);
|
||||
$("#directory-picker-display").text(monitor_directory_handler.name).after(
|
||||
$(
|
||||
" <span>[clear]</span>").click((evt) => {
|
||||
$(evt.target).remove();
|
||||
$("#directory-picker-display").text("");
|
||||
monitor_directory_handler = false;
|
||||
clearInterval(monitor_interval_id);
|
||||
//const files = await listAllFilesAndDirs(directoryHandle);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#add_more_images').click(() => {
|
||||
add_input_form()
|
||||
});
|
||||
$('#add_more_answers').click(() => {
|
||||
add_answers_input_form()
|
||||
});
|
||||
|
||||
$("input[type=file]").on('change', input_change);
|
||||
|
||||
@@ -282,6 +349,7 @@
|
||||
|
||||
|
||||
});
|
||||
|
||||
function ocr(input) {
|
||||
// Tesseract.recognize(f, "eng",{ logger: m => console.log(m) }
|
||||
// ).then(({ data: { text } }) => {
|
||||
@@ -319,12 +387,17 @@
|
||||
await worker.loadLanguage('eng');
|
||||
await worker.initialize('eng');
|
||||
// const { data: { text } } = await worker.recognize(input.files[0], { rectangle });
|
||||
const { data: { text } } = await worker.recognize(input.files[0]);
|
||||
const {
|
||||
data: {
|
||||
text
|
||||
}
|
||||
} = await worker.recognize(input.files[0]);
|
||||
//console.log(text);
|
||||
l = text.toLowerCase();
|
||||
$(`img[data-input-id='${input.id}'`).removeClass("image-ident-loading");
|
||||
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);
|
||||
$(input).addClass("image-ident-warning");
|
||||
$(`img[data-input-id='${input.id}'`).addClass("image-ident-warning");
|
||||
@@ -350,6 +423,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Add file to the process list
|
||||
active_file_inputs.add(el)
|
||||
const readFile = (file, el) => {
|
||||
reader(file).then(reader => {
|
||||
@@ -375,6 +449,7 @@
|
||||
|
||||
|
||||
active_file_inputs.delete(el)
|
||||
// Only load once all queued files have been processed
|
||||
if (active_file_inputs.size < 1) {
|
||||
loadViewer();
|
||||
}
|
||||
@@ -391,6 +466,7 @@
|
||||
console.log(el);
|
||||
if (el.files.length > 0) {
|
||||
filename = el.files[0].name;
|
||||
// Probably no need to await here anymore
|
||||
await readFile(el.files[0], el);
|
||||
}
|
||||
})
|
||||
@@ -414,7 +490,9 @@
|
||||
|
||||
image_set = $("#image_form_set img");
|
||||
if (n == image_set.length) {
|
||||
const event = new CustomEvent('loadDicomViewer', { "detail": image_set });
|
||||
const event = new CustomEvent('loadDicomViewer', {
|
||||
"detail": image_set
|
||||
});
|
||||
|
||||
window.dispatchEvent(event);
|
||||
sortable('.sortable');
|
||||
@@ -476,17 +554,16 @@
|
||||
option.appendTo($("#id_examination_to"));
|
||||
toastr.success(`Examination set to ${option.attr('title')} from dicom data`);
|
||||
} else {
|
||||
toastr.warning(`Unable to set examination ${study_description} from dicom data (it needs creating)`);
|
||||
toastr.warning(
|
||||
`Unable to set examination ${study_description} from dicom data (it needs creating)`);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{{ form.media }}
|
||||
@@ -495,11 +572,17 @@
|
||||
<h2>Submit Rapid</h2>
|
||||
<a href="{% url 'rapids:rapid_create_defaults' %}">Edit defaults</a>
|
||||
<p>
|
||||
<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.
|
||||
<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.
|
||||
</p>
|
||||
<div>
|
||||
To monitor a directory select it here.<br />
|
||||
<button id="directory-picker-button">Pick a directory</button>
|
||||
<span id="directory-picker-display">No directory monitored</span>
|
||||
</div>
|
||||
<form action="" method="post" enctype="multipart/form-data" id="rapid-form">
|
||||
{% csrf_token %}
|
||||
<a href="/rapids/abnormality/create" id="add_abnormality" class="add-popup"
|
||||
|
||||
Reference in New Issue
Block a user