diff --git a/rapids/templates/rapids/rapid_form.html b/rapids/templates/rapids/rapid_form.html index 84480823..451ee02b 100755 --- a/rapids/templates/rapids/rapid_form.html +++ b/rapids/templates/rapids/rapid_form.html @@ -53,6 +53,7 @@ // Check if we have selected a examination type if (!$("#id_examination_to option").length) { + // Yes we do read the file twice (here and where loading it in the viewer) var reader = new FileReader(); reader.onload = function (file) { console.log("READ EXAMINIANS", file) @@ -389,8 +390,19 @@ // 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'); - console.log("STUDY", study_description) + var study_description = dataSet.string('x00081030').toLowerCase(); + console.log("STUDY", study_description); + + // try to match with a study description + option = $(`#id_examination_from option[title*='${study_description}' i]`); + + if (option.length) { + option.appendTo($("#id_examination_to")); + toastr.success(`Examination set to ${option.attr('title')} from dicom data`); + } else { + toastr.warning(`Unable to set examination ${option.attr('title')} from dicom data (it needs creating)`); + + } } catch (err) {