NonTarget Tool refactoring
NonTarget Tool is using callback function to set lesion number, Unused function-nonTargetToolAdded is removed from lesionTable.js
This commit is contained in:
parent
a205727c27
commit
37c3eb4c71
@ -4,38 +4,42 @@
|
|||||||
|
|
||||||
var toolType = 'nonTarget';
|
var toolType = 'nonTarget';
|
||||||
|
|
||||||
// Define a callback to get your text annotation
|
|
||||||
// This could be used, e.g. to open a modal
|
|
||||||
function getTextCallback(doneChangingTextCallback) {
|
|
||||||
doneChangingTextCallback(prompt('Enter your annotation:'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeTextCallback(data, doneChangingTextCallback) {
|
|
||||||
doneChangingTextCallback(prompt('Change your annotation:'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var configuration = {
|
var configuration = {
|
||||||
getTextCallback: getTextCallback,
|
setLesionNumberCallback: setLesionNumberCallback,
|
||||||
changeTextCallback: changeTextCallback,
|
getNonTargetLesionLocationCallback: getNonTargetLesionLocationCallback,
|
||||||
|
changeNonTargetLesionLocationCallback: changeNonTargetLesionLocationCallback,
|
||||||
drawHandles: false,
|
drawHandles: false,
|
||||||
drawHandlesOnHover: true,
|
drawHandlesOnHover: true,
|
||||||
arrowFirst: true
|
arrowFirst: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set lesion number
|
||||||
|
// Get Non-Target lesions on image
|
||||||
|
function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||||
|
var lesionNumber = 1;
|
||||||
|
doneCallback(lesionNumber);
|
||||||
|
}
|
||||||
|
// Define a callback to get your text annotation
|
||||||
|
// This could be used, e.g. to open a modal
|
||||||
|
function getNonTargetLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||||
|
doneCallback(prompt('Enter your lesion location:'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeNonTargetLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||||
|
doneCallback(prompt('Change your lesion location:'));
|
||||||
|
}
|
||||||
|
|
||||||
/// --- Mouse Tool --- ///
|
/// --- Mouse Tool --- ///
|
||||||
///////// BEGIN ACTIVE TOOL ///////
|
///////// BEGIN ACTIVE TOOL ///////
|
||||||
function addNewMeasurement(mouseEventData) {
|
function addNewMeasurement(mouseEventData) {
|
||||||
|
|
||||||
function doneChangingTextCallback(text) {
|
var element = mouseEventData.element;
|
||||||
if (text !== null) {
|
|
||||||
measurementData.text = text;
|
|
||||||
} else {
|
|
||||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
|
||||||
}
|
|
||||||
|
|
||||||
measurementData.active = false;
|
function doneCallback(lesionNumber) {
|
||||||
cornerstone.updateImage(mouseEventData.element);
|
measurementData.lesionName = "Non-Target "+lesionNumber;
|
||||||
|
measurementData.lesionNumber = lesionNumber;
|
||||||
|
measurementData.active = true;
|
||||||
|
cornerstone.updateImage(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
var measurementData = createNewMeasurement(mouseEventData);
|
var measurementData = createNewMeasurement(mouseEventData);
|
||||||
@ -53,21 +57,24 @@
|
|||||||
$(mouseEventData.element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
$(mouseEventData.element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||||
$(mouseEventData.element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
$(mouseEventData.element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||||
|
|
||||||
cornerstone.updateImage(mouseEventData.element);
|
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||||
|
|
||||||
|
// Set lesion number and lesion name
|
||||||
|
if (measurementData.lesionName === undefined) {
|
||||||
|
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
cornerstone.updateImage(element);
|
||||||
|
|
||||||
cornerstoneTools.moveNewHandle(mouseEventData, measurementData.handles.end, function() {
|
cornerstoneTools.moveNewHandle(mouseEventData, measurementData.handles.end, function() {
|
||||||
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||||
// delete the measurement
|
// delete the measurement
|
||||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
config.getNonTargetLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||||
if (measurementData.text === undefined) {
|
|
||||||
config.getTextCallback(doneChangingTextCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(mouseEventData.element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
$(mouseEventData.element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||||
|
|
||||||
// CornerstoneToolsMouseDown Event
|
|
||||||
$(mouseEventData.element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
$(mouseEventData.element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||||
$(mouseEventData.element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
$(mouseEventData.element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||||
|
|
||||||
@ -77,17 +84,6 @@
|
|||||||
|
|
||||||
function createNewMeasurement(mouseEventData) {
|
function createNewMeasurement(mouseEventData) {
|
||||||
// create the measurement data for this tool with the end handle activated
|
// create the measurement data for this tool with the end handle activated
|
||||||
// TODO: Get text from measurements collection
|
|
||||||
// Subscribe CornerstoneMouseup event, when mouse is up, call lesionDialog
|
|
||||||
$(mouseEventData.element).on("CornerstoneToolsMouseUp", function (e) {
|
|
||||||
// Unsubscribe CornerstoneToolsMouseUp event
|
|
||||||
$(mouseEventData.element).off("CornerstoneToolsMouseUp");
|
|
||||||
$(mouseEventData.element).trigger("NonTargetToolAdded", [e, measurementData]);
|
|
||||||
|
|
||||||
});
|
|
||||||
var timepointID = $(mouseEventData.element).data('timepointID');
|
|
||||||
var lesionNumber = measurementManagerDAL.getNewLesionNumber(timepointID, false);
|
|
||||||
|
|
||||||
var measurementData = {
|
var measurementData = {
|
||||||
visible: true,
|
visible: true,
|
||||||
active: true,
|
active: true,
|
||||||
@ -114,9 +110,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
imageId: mouseEventData.image.imageId,
|
imageId: mouseEventData.image.imageId,
|
||||||
lesionNumber: lesionNumber,
|
measurementText: '',
|
||||||
text: "Non-Target " + lesionNumber,
|
isTarget: false,
|
||||||
isTarget: false
|
uid: uuid.v4()
|
||||||
};
|
};
|
||||||
|
|
||||||
return measurementData;
|
return measurementData;
|
||||||
@ -271,9 +267,9 @@
|
|||||||
|
|
||||||
|
|
||||||
// Draw the text
|
// Draw the text
|
||||||
if (lesion.text && lesion.text !== '') {
|
if (lesion.lesionName && lesion.lesionName !== '') {
|
||||||
context.font = font;
|
context.font = font;
|
||||||
var boundingBox = cornerstoneTools.drawTextBox(context, lesion.text, canvasTextLocation.x, canvasTextLocation.y, color);
|
var boundingBox = cornerstoneTools.drawTextBox(context, lesion.lesionName, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||||
lesion.handles.textBox.boundingBox = boundingBox;
|
lesion.handles.textBox.boundingBox = boundingBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,47 +1,6 @@
|
|||||||
Measurements = new Meteor.Collection(null);
|
Measurements = new Meteor.Collection(null);
|
||||||
Timepoints = new Meteor.Collection(null);
|
Timepoints = new Meteor.Collection(null);
|
||||||
|
|
||||||
// When nonTarget lesion is added to image, insert data to lesion table
|
|
||||||
function nonTargetToolAdded(e, eventData, lesionData) {
|
|
||||||
|
|
||||||
// Set timepointID
|
|
||||||
lesionData.timepointID = $(e.currentTarget).data('timepointID');
|
|
||||||
|
|
||||||
var locationUID = measurementManagerDAL.isLesionNumberAdded(lesionData);
|
|
||||||
if (locationUID) {
|
|
||||||
// location is selected and disable select location in dialog
|
|
||||||
lesionData.locationUID = locationUID;
|
|
||||||
var locationName = measurementManagerDAL.getLocationName(locationUID);
|
|
||||||
|
|
||||||
$("#selectNonTargetLesionLocation option").each(function()
|
|
||||||
{
|
|
||||||
if ($(this).text() === locationName) {
|
|
||||||
// Select location in locations dropdown list
|
|
||||||
$("#selectNonTargetLesionLocation option").eq($(this).index()).attr("selected", "selected");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#selectNonTargetLesionLocation").attr("disabled", "disabled");
|
|
||||||
} else{
|
|
||||||
|
|
||||||
// If selectNonTargetLesionLocation is disabled, make it enable
|
|
||||||
$("#selectNonTargetLesionLocation").removeAttr("disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save lesionData in Session to use after location and response are selected
|
|
||||||
Session.set("nonTargetLesionData", lesionData);
|
|
||||||
|
|
||||||
var dialogPointsOnPage = eventData.currentPoints.page;
|
|
||||||
$("#modal-dialog-container-nonTargetLesion").css({
|
|
||||||
"top": dialogPointsOnPage.y,
|
|
||||||
"left": dialogPointsOnPage.x
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#nonTargetLesionLocationDialog").modal("show");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activate selected lesions when lesion table row is clicked
|
// Activate selected lesions when lesion table row is clicked
|
||||||
function updateLesions(e) {
|
function updateLesions(e) {
|
||||||
// lesionNumber of measurement = id of row
|
// lesionNumber of measurement = id of row
|
||||||
@ -116,9 +75,6 @@ Template.lesionTable.onRendered(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(element).data('timepointID', timepointID);
|
$(element).data('timepointID', timepointID);
|
||||||
|
|
||||||
// Listen NonTargetToolAdded Event
|
|
||||||
$(element).on("NonTargetToolAdded", nonTargetToolAdded);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,16 @@
|
|||||||
#nonTargetLesionLocationDialog {
|
#nonTargetLesionLocationDialog {
|
||||||
background: transparent;
|
display: none;
|
||||||
}
|
|
||||||
|
|
||||||
#modal-dialog-container-nonTargetLesion {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border: none;
|
z-index: 100;
|
||||||
}
|
background: white;
|
||||||
|
padding: 10px 20px 10px 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
|
||||||
|
|
||||||
#btnCloseNonTargetLesionPopup {
|
|
||||||
outline: 0;
|
|
||||||
border: none;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#selectNonTargetLesionLocation, #selectNonTargetLesionLocationResponse {
|
#selectNonTargetLesionLocation, #selectNonTargetLesionLocationResponse {
|
||||||
width: 80%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialogContent, .lesionLocation, .locationResponse {
|
.dialogContent, .lesionLocation, .locationResponse {
|
||||||
|
|||||||
@ -1,40 +1,43 @@
|
|||||||
<template name="nonTargetLesionDialog">
|
<template name="nonTargetLesionDialog">
|
||||||
<div class="modal fade" id="nonTargetLesionLocationDialog">
|
<div id="nonTargetLesionLocationDialog">
|
||||||
<div id="modal-dialog-container-nonTargetLesion" class="modal-dialog modal-sm">
|
<div class="dialogHeader">
|
||||||
<div class="modal-content" style="padding: 10px;">
|
<div class="dialogHeader">
|
||||||
<div class="dialogHeader">
|
<div><h4>Select Lesion Location</h4></div>
|
||||||
<div style="float:left;"><h4>Select Lesion Location</h4></div>
|
</div>
|
||||||
<div style="float:right;"><button class="btn" id="btnCloseNonTargetLesionPopup"><i class="fa fa-close"></i></button></div>
|
</div>
|
||||||
|
<div class="dialogContent">
|
||||||
|
<div class="lesionLocation">
|
||||||
|
<div class="elementContainer">
|
||||||
|
<label>Lesion Location</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialogContent">
|
<div class="elementContainer">
|
||||||
|
<select id="selectNonTargetLesionLocation">
|
||||||
<div class="lesionLocation">
|
<option value="-1"></option>
|
||||||
<div class="elementContainer">
|
{{ #each lesionLocations}}
|
||||||
<label>Lesion Location</label>
|
<option value='{{_id}}'>{{location}}</option>
|
||||||
</div>
|
{{ /each}}
|
||||||
<div class="elementContainer">
|
</select>
|
||||||
<select id="selectNonTargetLesionLocation">
|
|
||||||
<option value="-1"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="locationResponse">
|
|
||||||
<div class="elementContainer">
|
|
||||||
<label>Response</label>
|
|
||||||
</div>
|
|
||||||
<div class="elementContainer">
|
|
||||||
<select id="selectNonTargetLesionLocationResponse">
|
|
||||||
<option value="-1"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="locationOK">
|
|
||||||
<button class="btn" id="nonTargetLesionOK">OK</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="locationResponse">
|
||||||
|
<div class="elementContainer">
|
||||||
|
<label>Response</label>
|
||||||
|
</div>
|
||||||
|
<div class="elementContainer">
|
||||||
|
<select id="selectNonTargetLesionLocationResponse">
|
||||||
|
<option value="-1"></option>
|
||||||
|
{{ #each locationResponses}}
|
||||||
|
<option value='{{code}}'>{{text}}</option>
|
||||||
|
{{ /each}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="locationOK">
|
||||||
|
<button class="btn" id="nonTargetLesionOK">OK</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@ -1,135 +1,231 @@
|
|||||||
//fill selectLesionLocation element
|
// This event sets lesion number for new lesion
|
||||||
var lesionLocationsArray = [{
|
|
||||||
location: "Brain Brainstem",
|
|
||||||
hasDescription: false,
|
|
||||||
description: ""
|
|
||||||
}, {
|
|
||||||
location: "Brain Cerebellum Left",
|
|
||||||
hasDescription: false,
|
|
||||||
description: ""
|
|
||||||
}, {
|
|
||||||
location: "Brain Cerebrum Left",
|
|
||||||
hasDescription: false,
|
|
||||||
description: ""
|
|
||||||
}, {
|
|
||||||
location: "Brain Cerebrum Right",
|
|
||||||
hasDescription: false,
|
|
||||||
description: ""
|
|
||||||
}, {
|
|
||||||
location: "Brain Multiple Sites",
|
|
||||||
hasDescription: false,
|
|
||||||
description: ""
|
|
||||||
}];
|
|
||||||
|
|
||||||
var lesionLocationsResponseArray = [
|
function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||||
|
|
||||||
|
measurementData.timepointID = $(eventData.element).data('timepointID');
|
||||||
|
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||||
|
// exists at a different timepoint
|
||||||
|
var lesionNumber = measurementManagerDAL.getNewLesionNumber(measurementData.timepointID, isTarget=false);
|
||||||
|
measurementData.lesionNumber = lesionNumber;
|
||||||
|
|
||||||
|
// Set lesion number
|
||||||
|
doneCallback(lesionNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This event determines whether or not to show the Non-Target lesion dialog
|
||||||
|
// If there already exists a lesion with this specific lesion number,
|
||||||
|
// related to the chosen location.
|
||||||
|
|
||||||
|
function getNonTargetLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||||
|
|
||||||
|
// Get the non-target lesion location dialog
|
||||||
|
var nonTargetlesionDialog = $("#nonTargetLesionLocationDialog");
|
||||||
|
|
||||||
|
// Find the select option box
|
||||||
|
var selectorLocation = nonTargetlesionDialog.find("select#selectNonTargetLesionLocation");
|
||||||
|
var selectorResponse = nonTargetlesionDialog.find("select#selectNonTargetLesionLocationResponse");
|
||||||
|
|
||||||
|
// OK button
|
||||||
|
var btnOK = nonTargetlesionDialog.find("button#nonTargetLesionOK");
|
||||||
|
|
||||||
|
|
||||||
|
// If selector location is disabled, make it enable
|
||||||
|
enableLocationSelection();
|
||||||
|
|
||||||
|
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||||
|
// If it is, disable selector location
|
||||||
|
var locationUID = measurementManagerDAL.lesionNumberExists(measurementData);
|
||||||
|
if (locationUID) {
|
||||||
|
measurementData.locationUID = locationUID;
|
||||||
|
// Disable the selection of a new location
|
||||||
|
disableLocationSelection(measurementData.locationUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable selector location to prevent selecting a new location
|
||||||
|
function disableLocationSelection(locationUID) {
|
||||||
|
var locationName = measurementManagerDAL.getLocationName(locationUID);
|
||||||
|
selectorLocation.find('option').each(function()
|
||||||
|
{
|
||||||
|
if ($(this).text().trim() === locationName.trim()) {
|
||||||
|
// Select location in locations dropdown list
|
||||||
|
selectorLocation.find('option').eq($(this).index()).attr("selected", "selected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
selectorLocation.attr("disabled", "disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable selector location
|
||||||
|
function enableLocationSelection() {
|
||||||
|
selectorLocation.removeAttr("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeHandler() {
|
||||||
|
|
||||||
|
// Hide the lesion dialog
|
||||||
|
nonTargetlesionDialog.css('display', 'none');
|
||||||
|
// Enable selector location
|
||||||
|
enableLocationSelection();
|
||||||
|
|
||||||
|
// Get the current value of the select option box
|
||||||
|
selectorLocation.find("option:first").prop("selected", "selected");
|
||||||
|
selectorResponse.find("option:first").prop("selected", "selected");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach keypress handlers so the user can close with the Enter button
|
||||||
|
nonTargetlesionDialog.off("keypress");
|
||||||
|
nonTargetlesionDialog.on('keypress', keyPressHandler);
|
||||||
|
|
||||||
|
// This is the keypress callback function
|
||||||
|
function keyPressHandler(e) {
|
||||||
|
// If Enter is pressed, close the dialog
|
||||||
|
if (e.which === 13) {
|
||||||
|
closeHandler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the lesion location dialog above
|
||||||
|
nonTargetlesionDialog.css({
|
||||||
|
top: eventData.currentPoints.page.y,
|
||||||
|
left: eventData.currentPoints.page.x,
|
||||||
|
display: 'block'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click OK button
|
||||||
|
// Add lesion to lesion table
|
||||||
|
btnOK.off('click');
|
||||||
|
btnOK.on('click', function(e) {
|
||||||
|
// Get the current value of the selector
|
||||||
|
var selectedOptionId = selectorLocation.find("option:selected").val();
|
||||||
|
var responseOptionCode = nonTargetlesionDialog.find("select#selectNonTargetLesionLocationResponse option:selected").val();
|
||||||
|
|
||||||
|
// If the selected option is still the default (-1)
|
||||||
|
// then stop here
|
||||||
|
if (selectedOptionId < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the selected response option is still the default (-1)
|
||||||
|
// then stop here
|
||||||
|
if (responseOptionCode < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get selected location data
|
||||||
|
var locationObj = LesionLocations.findOne({_id: selectedOptionId});
|
||||||
|
|
||||||
|
var id;
|
||||||
|
var existingLocation = PatientLocations.findOne({location: locationObj.location});
|
||||||
|
if (existingLocation) {
|
||||||
|
id = existingLocation._id;
|
||||||
|
} else {
|
||||||
|
// Adds location data to PatientLocation and retrieve the location ID
|
||||||
|
id = PatientLocations.insert({location: locationObj.location});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link locationUID with active lesion measurementData
|
||||||
|
measurementData.locationUID = id;
|
||||||
|
|
||||||
|
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||||
|
measurementData.isTarget = false;
|
||||||
|
|
||||||
|
// measurementText is set from location response list
|
||||||
|
measurementData.measurementText = responseOptionCode;
|
||||||
|
|
||||||
|
// Adds lesion data to timepoints array
|
||||||
|
measurementManagerDAL.addLesionData(measurementData);
|
||||||
|
|
||||||
|
// Close the dialog
|
||||||
|
closeHandler();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeNonTargetLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||||
|
doneCallback(prompt('Change your lesion location:'));
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
setLesionNumberCallback: setLesionNumberCallback,
|
||||||
|
getNonTargetLesionLocationCallback: getNonTargetLesionLocationCallback,
|
||||||
|
changeNonTargetLesionLocationCallback: changeNonTargetLesionLocationCallback
|
||||||
|
};
|
||||||
|
|
||||||
|
cornerstoneTools.nonTarget.setConfiguration(config);
|
||||||
|
|
||||||
|
|
||||||
|
LocationResponses = new Meteor.Collection(null);
|
||||||
|
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Complete response",
|
text: "Complete response",
|
||||||
code: "CR",
|
code: "CR",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Progressive disease",
|
text: "Progressive disease",
|
||||||
code: "PD",
|
code: "PD",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
|
{
|
||||||
|
text: "Complete response",
|
||||||
|
code: "CR",
|
||||||
|
description: ""
|
||||||
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Stable disease",
|
text: "Stable disease",
|
||||||
code: "SD",
|
code: "SD",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Non-measurable",
|
text: "Non-measurable",
|
||||||
code: "NM",
|
code: "NM",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Unknown",
|
text: "Unknown",
|
||||||
code: "UN",
|
code: "UN",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Not Evaluable",
|
text: "Not Evaluable",
|
||||||
code: "NE",
|
code: "NE",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Non-CR/Non-PD",
|
text: "Non-CR/Non-PD",
|
||||||
code: "NN",
|
code: "NN",
|
||||||
description: ""
|
description: ""
|
||||||
},
|
}
|
||||||
|
);
|
||||||
|
LocationResponses.insert(
|
||||||
{
|
{
|
||||||
text: "Excluded",
|
text: "Excluded",
|
||||||
code: "EX",
|
code: "EX",
|
||||||
description: ""
|
description: ""
|
||||||
}
|
}
|
||||||
];
|
);
|
||||||
|
|
||||||
Template.nonTargetLesionDialog.onRendered(function() {
|
Template.nonTargetLesionDialog.helpers({
|
||||||
|
'lesionLocations': function() {
|
||||||
function fillSelectLesionLocation() {
|
return LesionLocations.find();
|
||||||
var el = $("#selectNonTargetLesionLocation");
|
|
||||||
el.find('option:not(:first)').remove();
|
|
||||||
$.each(lesionLocationsArray, function(key, value) {
|
|
||||||
el.append("<option value='" + key + "'>" + value.location + "</option>");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillResponses() {
|
|
||||||
var el = $("#selectNonTargetLesionLocationResponse");
|
|
||||||
el.find('option:not(:first)').remove();
|
|
||||||
$.each(lesionLocationsResponseArray, function(key, value) {
|
|
||||||
el.append("<option value='" + value.code + "'>" + value.code +" - "+value.text + "</option>");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill dropdown
|
|
||||||
fillSelectLesionLocation();
|
|
||||||
|
|
||||||
// Fill location responses
|
|
||||||
fillResponses();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Template.nonTargetLesionDialog.events({
|
|
||||||
'click button#btnCloseNonTargetLesionPopup': function(e) {
|
|
||||||
$("#nonTargetLesionLocationDialog").modal("hide");
|
|
||||||
},
|
},
|
||||||
|
'locationResponses': function() {
|
||||||
'click button#nonTargetLesionOK': function() {
|
return LocationResponses.find();
|
||||||
|
|
||||||
var lesionData = Session.get("nonTargetLesionData");
|
|
||||||
// Get selected location data
|
|
||||||
var selectedLocationIndex = $("#selectNonTargetLesionLocation").val();
|
|
||||||
if (selectedLocationIndex < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get selected location data
|
|
||||||
var locationObj = lesionLocationsArray[selectedLocationIndex];
|
|
||||||
lesionData.location = $("#selectNonTargetLesionLocation :selected").text();
|
|
||||||
|
|
||||||
var response = $("#selectNonTargetLesionLocationResponse").val();
|
|
||||||
if(response === "-1") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$("#nonTargetLesionLocationDialog").modal("hide");
|
|
||||||
lesionData.measurementText = response;
|
|
||||||
|
|
||||||
// Select first option
|
|
||||||
$("#selectNonTargetLesionLocation").val($("#selectNonTargetLesionLocation option:first").val());
|
|
||||||
$("#selectNonTargetLesionLocationResponse").val($("#selectNonTargetLesionLocationResponse option:first").val());
|
|
||||||
|
|
||||||
if (typeof lesionData.locationUID !== 'undefined') {
|
|
||||||
measurementManagerDAL.updateTimepointData(lesionData);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds location data to trialPatientLocations array and returns locationUID
|
|
||||||
var locationUID = measurementManagerDAL.addNewLocation(locationObj);
|
|
||||||
// Link locationUID with activeLesionMeasurementData
|
|
||||||
lesionData.locationUID = locationUID;
|
|
||||||
measurementManagerDAL.addLesionData(lesionData);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user