2015-10-29 13:50:28 +01:00
|
|
|
Measurements = new Meteor.Collection(null);
|
2015-11-06 17:35:35 +01:00
|
|
|
Timepoints = new Meteor.Collection(null);
|
2015-10-23 18:21:46 +02:00
|
|
|
|
2015-11-09 14:08:50 +01:00
|
|
|
// When nonTarget lesion is added to image, insert data to lesion table
|
|
|
|
|
function nonTargetToolAdded(e, eventData, lesionData) {
|
2015-11-09 15:38:24 +01:00
|
|
|
|
|
|
|
|
// Set timepointID
|
2015-11-09 14:08:50 +01:00
|
|
|
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);
|
2015-11-09 17:49:31 +01:00
|
|
|
|
2015-11-09 14:08:50 +01:00
|
|
|
$("#selectNonTargetLesionLocation option").each(function()
|
|
|
|
|
{
|
|
|
|
|
if ($(this).text() === locationName) {
|
2015-11-09 17:49:31 +01:00
|
|
|
// Select location in locations dropdown list
|
|
|
|
|
$("#selectNonTargetLesionLocation option").eq($(this).index()).attr("selected", "selected");
|
2015-11-09 14:08:50 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-11-09 15:38:24 +01:00
|
|
|
|
|
|
|
|
$("#selectNonTargetLesionLocation").attr("disabled", "disabled");
|
|
|
|
|
} else{
|
2015-11-09 14:08:50 +01:00
|
|
|
|
2015-11-09 15:38:24 +01:00
|
|
|
// If selectNonTargetLesionLocation is disabled, make it enable
|
|
|
|
|
$("#selectNonTargetLesionLocation").removeAttr("disabled");
|
2015-11-09 14:08:50 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-09 17:49:31 +01:00
|
|
|
// Save lesionData in Session to use after location and response are selected
|
2015-11-09 14:08:50 +01:00
|
|
|
Session.set("nonTargetLesionData", lesionData);
|
|
|
|
|
|
|
|
|
|
var dialogPointsOnPage = eventData.currentPoints.page;
|
|
|
|
|
$("#modal-dialog-container-nonTargetLesion").css({
|
|
|
|
|
"top": dialogPointsOnPage.y,
|
|
|
|
|
"left": dialogPointsOnPage.x
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#nonTargetLesionLocationDialog").modal("show");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
// Activate selected lesions when lesion table row is clicked
|
|
|
|
|
function updateLesions(e) {
|
|
|
|
|
// lesionNumber of measurement = id of row
|
|
|
|
|
var lesionNumber = parseInt($(e.currentTarget).attr("id"), 10);
|
2015-11-09 14:08:50 +01:00
|
|
|
var isTarget = $(e.currentTarget).find('td').eq(2).html().trim() === 'N'?false:true;
|
2015-10-23 18:21:46 +02:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
// Find data for specific lesion
|
|
|
|
|
var measurementData = Measurements.find({
|
2015-11-09 14:08:50 +01:00
|
|
|
lesionNumber: lesionNumber,
|
|
|
|
|
isTarget: isTarget
|
2015-11-06 17:35:35 +01:00
|
|
|
}).fetch()[0];
|
2015-10-31 15:26:57 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
var timepoints = measurementData.timepoints;
|
2015-10-23 18:21:46 +02:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
$(".imageViewerViewport").each(function(index, element) {
|
|
|
|
|
// Get the timepointID related to the image viewer viewport
|
|
|
|
|
// from the DOM itself. This will be changed later when a
|
|
|
|
|
// real association between viewports and timepoints is created.
|
|
|
|
|
var timepointID = $(element).data('timepointID');
|
|
|
|
|
var timepointObject = timepoints[timepointID];
|
2015-10-29 20:40:20 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
// Defines event data
|
|
|
|
|
var eventData = {
|
|
|
|
|
enabledElement: cornerstone.getEnabledElement(element),
|
|
|
|
|
lesionData: {
|
2015-11-09 14:08:50 +01:00
|
|
|
isTarget: isTarget,
|
2015-11-06 17:35:35 +01:00
|
|
|
lesionNumber: lesionNumber,
|
|
|
|
|
imageId: timepointObject.imageId
|
|
|
|
|
},
|
|
|
|
|
type: "active"
|
|
|
|
|
};
|
2015-10-29 20:40:20 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
if (timepointObject.longestDiameter === "") {
|
|
|
|
|
eventData.type = "inactive";
|
|
|
|
|
}
|
2015-10-29 20:40:20 +01:00
|
|
|
|
2015-11-09 21:35:06 +01:00
|
|
|
if (!isTarget) {
|
|
|
|
|
$(element).trigger("NonTargetToolSelected", eventData);
|
|
|
|
|
|
|
|
|
|
// Deactivate lesion tool measurements
|
|
|
|
|
eventData.type = "inactive";
|
|
|
|
|
$(element).trigger("LesionToolSelected", eventData);
|
2015-11-09 17:49:31 +01:00
|
|
|
return;
|
2015-11-09 14:08:50 +01:00
|
|
|
}
|
2015-11-09 21:35:06 +01:00
|
|
|
$(element).trigger("LesionToolSelected", eventData);
|
|
|
|
|
|
|
|
|
|
// Deactivate nonTarget tool measurements
|
|
|
|
|
eventData.type = "inactive";
|
|
|
|
|
$(element).trigger("NonTargetToolSelected", eventData);
|
2015-11-09 14:08:50 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
});
|
|
|
|
|
}
|
2015-10-23 18:21:46 +02:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
Template.lesionTable.onRendered(function() {
|
|
|
|
|
// For the moment we will associate the timepoint
|
|
|
|
|
// with the viewport element by storing the timepointID
|
|
|
|
|
// inside the element's DOM data. This is temporary.
|
|
|
|
|
$(".imageViewerViewport").each(function(index, element) {
|
|
|
|
|
var timepointID = uuid.v4();
|
2015-10-23 18:21:46 +02:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
var timepointName = "Baseline";
|
|
|
|
|
if (index > 0) {
|
|
|
|
|
timepointName = "Current"; //"Follow Up "+i;
|
|
|
|
|
}
|
2015-11-02 00:24:31 +01:00
|
|
|
|
2015-10-31 15:26:57 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
// FUTURE = On load series data into viewport, create a new timepoint
|
|
|
|
|
// unless it already exists
|
|
|
|
|
Timepoints.insert({
|
|
|
|
|
timepointID: timepointID,
|
|
|
|
|
timepointName: timepointName
|
|
|
|
|
});
|
2015-11-02 00:24:31 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
$(element).data('timepointID', timepointID);
|
2015-11-09 14:08:50 +01:00
|
|
|
|
|
|
|
|
// Listen NonTargetToolAdded Event
|
|
|
|
|
$(element).on("NonTargetToolAdded", nonTargetToolAdded);
|
2015-11-06 17:35:35 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-11-09 14:08:50 +01:00
|
|
|
|
2015-11-06 17:35:35 +01:00
|
|
|
Template.lesionTable.helpers({
|
|
|
|
|
'measurement': function() {
|
|
|
|
|
return Measurements.find();
|
|
|
|
|
},
|
|
|
|
|
'timepoints': function() {
|
|
|
|
|
return Timepoints.find();
|
2015-11-02 00:24:31 +01:00
|
|
|
}
|
2015-11-06 17:35:35 +01:00
|
|
|
});
|
2015-10-31 15:26:57 +01:00
|
|
|
|
2015-11-02 00:24:31 +01:00
|
|
|
Template.lesionTable.events({
|
|
|
|
|
'click table#tblLesion tbody tr': function(e) {
|
2015-11-04 01:20:17 +01:00
|
|
|
updateLesions(e);
|
2015-10-31 15:26:57 +01:00
|
|
|
}
|
2015-11-06 17:35:35 +01:00
|
|
|
});
|