Work on refactoring measurements out of Lesion Tracker package
- Removed AssociatedStudies Collection - Measurement API is generated from configuration files - Data exchange methods are defined in configuration
This commit is contained in:
1 parent
c511edd419
commit
ab4d4c9008
537 files changed
+5122
-3545
No files matched your search
@@ -0,0 +1,86 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/measurements';
|
||||
|
||||
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
|
||||
|
||||
const BidirectionalHandlesSchema = new SimpleSchema({
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
perpendicularStart: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Perpendicular Start'
|
||||
},
|
||||
perpendicularEnd: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Perpendicular End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
},
|
||||
});
|
||||
|
||||
const BidirectionalSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
|
||||
handles: {
|
||||
type: BidirectionalHandlesSchema,
|
||||
label: 'Handles'
|
||||
},
|
||||
longestDiameter: {
|
||||
type: Number,
|
||||
label: 'Longest Diameter',
|
||||
decimal: true
|
||||
},
|
||||
shortestDiameter: {
|
||||
type: Number,
|
||||
label: 'Shortest Diameter',
|
||||
decimal: true
|
||||
},
|
||||
locationUid: {
|
||||
type: String,
|
||||
label: 'Location UID',
|
||||
optional: true // Optional because it is added after initial drawing, via a callback
|
||||
}
|
||||
}]);
|
||||
|
||||
function displayFunction(data) {
|
||||
// Check whether this is a Nodal or Extranodal Measurement
|
||||
const targetType = 'target';
|
||||
const nodalType = data.isNodal ? 'nodal' : 'extraNodal';
|
||||
|
||||
// Get criteria types
|
||||
const criteriaTypes = TrialCriteriaTypes.find({
|
||||
selected: true
|
||||
}).map(criteria => {
|
||||
return criteria.id;
|
||||
});
|
||||
|
||||
const currentConstraints = getTrialCriteriaConstraints(criteriaTypes, data.imageId);
|
||||
|
||||
if (data.shortestDiameter) {
|
||||
// TODO: Make this check criteria again to see if we should display
|
||||
// shortest x longest
|
||||
return data.longestDiameter + ' x ' + data.shortestDiameter;
|
||||
}
|
||||
|
||||
return data.longestDiameter;
|
||||
}
|
||||
|
||||
export const bidirectional = {
|
||||
id: 'targets',
|
||||
name: 'Targets',
|
||||
cornerstoneToolType: 'bidirectional',
|
||||
schema: BidirectionalSchema,
|
||||
options: {
|
||||
showInMeasurementTable: true,
|
||||
measurementTableOptions: {
|
||||
displayFunction: displayFunction
|
||||
},
|
||||
includeInCaseProgress: true,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { measurementTools } from './measurementTools';
|
||||
import { retrieveMeasurements, storeMeasurements, retrieveTimepoints, storeTimepoints } from './dataExchange';
|
||||
import { validateMeasurements } from './dataValidation';
|
||||
|
||||
import { MeasurementsConfiguration } from 'meteor/ohif:measurements/both/configuration/measurements';
|
||||
import { TimepointsConfiguration } from 'meteor/ohif:measurements/both/configuration/timepoints';
|
||||
|
||||
console.log('OHIF-LesionTracker: Defining Configuration for Measurements');
|
||||
|
||||
const newMeasurementTool = {
|
||||
id: 'newLesions',
|
||||
name: 'New Lesions'
|
||||
};
|
||||
|
||||
MeasurementsConfiguration.setConfiguration({
|
||||
measurementTools: measurementTools,
|
||||
newMeasurementTool: newMeasurementTool,
|
||||
dataExchange: {
|
||||
retrieve: retrieveMeasurements,
|
||||
store: storeMeasurements
|
||||
},
|
||||
dataValidation: {
|
||||
validation: validateMeasurements
|
||||
}
|
||||
});
|
||||
|
||||
TimepointsConfiguration.setConfiguration({
|
||||
dataExchange: {
|
||||
retrieve: retrieveTimepoints,
|
||||
store: storeTimepoints
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import { measurementTools } from './measurementTools';
|
||||
|
||||
export const retrieveMeasurements = () => {
|
||||
console.log('retrieveMeasurements');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call("retrieveMeasurements", (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
console.log(response);
|
||||
|
||||
/*measurementTools.forEach(tool => {
|
||||
console.log('Retrieving tool: ' + tool.id);
|
||||
});*/
|
||||
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const storeMeasurements = (measurementData) => {
|
||||
console.log('storeMeasurements');
|
||||
|
||||
// Here is where we should do any required data transformation and API calls
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call("storeMeasurements", measurementData, (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const retrieveTimepoints = () => {
|
||||
console.log('retrieveTimepoints');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call("retrieveTimepoints", (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const storeTimepoints = (timepointData) => {
|
||||
console.log('storeTimepoints');
|
||||
console.log(timepointData);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Meteor.call("storeTimepoints", timepointData, (error, response) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { bidirectional } from './bidirectional';
|
||||
import { nonTarget } from './nonTarget';
|
||||
import { length } from './length';
|
||||
import { ellipse } from './ellipse';
|
||||
|
||||
export const validateMeasurements = () => {
|
||||
console.log('validateMeasurements');
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/measurements';
|
||||
|
||||
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
|
||||
|
||||
const EllipseHandlesSchema = new SimpleSchema({
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
},
|
||||
});
|
||||
|
||||
const EllipseSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
|
||||
handles: {
|
||||
type: EllipseHandlesSchema,
|
||||
label: 'Handles'
|
||||
}
|
||||
}]);
|
||||
|
||||
export const ellipse = {
|
||||
id: 'ellipse',
|
||||
name: 'Ellipse',
|
||||
cornerstoneToolType: 'ellipticalRoi',
|
||||
schema: EllipseSchema
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/measurements';
|
||||
|
||||
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
|
||||
|
||||
const LengthHandlesSchema = new SimpleSchema({
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
},
|
||||
});
|
||||
|
||||
const LengthSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
|
||||
handles: {
|
||||
type: LengthHandlesSchema,
|
||||
label: 'Handles'
|
||||
}
|
||||
}]);
|
||||
|
||||
export const length = {
|
||||
id: 'length',
|
||||
name: 'Length',
|
||||
cornerstoneToolType: 'length',
|
||||
schema: LengthSchema
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { bidirectional } from './bidirectional';
|
||||
import { nonTarget } from './nonTarget';
|
||||
import { length } from './length';
|
||||
import { ellipse } from './ellipse';
|
||||
|
||||
export const measurementTools = [
|
||||
bidirectional,
|
||||
nonTarget,
|
||||
length,
|
||||
ellipse
|
||||
];
|
||||
@@ -0,0 +1,55 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/measurements';
|
||||
|
||||
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
|
||||
|
||||
const NonTargetHandlesSchema = new SimpleSchema({
|
||||
start: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Start'
|
||||
},
|
||||
end: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'End'
|
||||
},
|
||||
textBox: {
|
||||
type: CornerstoneHandleSchema,
|
||||
label: 'Text Box'
|
||||
}
|
||||
});
|
||||
|
||||
const NonTargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
|
||||
handles: {
|
||||
type: NonTargetHandlesSchema,
|
||||
label: 'Handles'
|
||||
},
|
||||
response: {
|
||||
type: String,
|
||||
label: 'Response',
|
||||
optional: true // Optional because it is added after initial drawing, via a callback
|
||||
},
|
||||
locationUid: {
|
||||
type: String,
|
||||
label: 'Location UID',
|
||||
optional: true // Optional because it is added after initial drawing, via a callback
|
||||
}
|
||||
}]);
|
||||
|
||||
function displayFunction(data) {
|
||||
return data.response;
|
||||
}
|
||||
|
||||
export const nonTarget = {
|
||||
id: 'nonTargets',
|
||||
name: 'Non-Targets',
|
||||
cornerstoneToolType: 'nonTarget',
|
||||
schema: NonTargetSchema,
|
||||
displayFunction: displayFunction,
|
||||
options: {
|
||||
showInMeasurementTable: true,
|
||||
measurementTableOptions: {
|
||||
displayFunction: displayFunction
|
||||
},
|
||||
includeInCaseProgress: true,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
const LocationSchema = new SimpleSchema({
|
||||
id: {
|
||||
type: String,
|
||||
label: 'Location ID'
|
||||
},
|
||||
location: {
|
||||
type: String,
|
||||
label: 'Location Name'
|
||||
},
|
||||
selected: {
|
||||
type: Boolean,
|
||||
label: 'Selected',
|
||||
defaultValue: false
|
||||
},
|
||||
isNodal: {
|
||||
type: Boolean,
|
||||
label: 'Nodal Location',
|
||||
defaultValue: false
|
||||
}
|
||||
});
|
||||
|
||||
LesionLocations = new Meteor.Collection(null);
|
||||
LesionLocations.attachSchema(LocationSchema);
|
||||
LesionLocations._debugName = 'LesionLocations';
|
||||
|
||||
var organGroups = [
|
||||
'Abdominal/Chest Wall',
|
||||
'Adrenal',
|
||||
'Bladder',
|
||||
'Bone',
|
||||
'Brain',
|
||||
'Breast',
|
||||
'Colon',
|
||||
'Esophagus',
|
||||
'Extremities',
|
||||
'Gallbladder',
|
||||
'Kidney',
|
||||
'Liver',
|
||||
'Lung',
|
||||
'Lymph Node',
|
||||
'Mediastinum/Hilum',
|
||||
'Muscle',
|
||||
'Neck',
|
||||
'Other: Soft Tissue',
|
||||
'Ovary',
|
||||
'Pancreas',
|
||||
'Pelvis',
|
||||
'Peritoneum/Omentum',
|
||||
'Prostate',
|
||||
'Retroperitoneum',
|
||||
'Small Bowel',
|
||||
'Spleen',
|
||||
'Stomach',
|
||||
'Subcutaneous'];
|
||||
|
||||
function nameToID(name) {
|
||||
// http://stackoverflow.com/questions/29258016/remove-special-symbols-and-extra-spaces-and-make-it-camel-case-javascript
|
||||
return name
|
||||
.trim() //might need polyfill if you need to support older browsers
|
||||
.toLowerCase() //lower case everything
|
||||
.replace(/([^A-Z0-9]+)(.)/ig, //match multiple non-letter/numbers followed by any character
|
||||
function(match) {
|
||||
return arguments[2].toUpperCase(); //3rd index is the character we need to transform uppercase
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
organGroups.forEach(function(organGroup) {
|
||||
const id = nameToID(organGroup);
|
||||
|
||||
// Check if the name has 'node' in it, if so, it is nodal
|
||||
let isNodal = false;
|
||||
if (id.toLowerCase().indexOf('node') > -1) {
|
||||
isNodal = true;
|
||||
}
|
||||
|
||||
LesionLocations.insert({
|
||||
id: id,
|
||||
location: organGroup,
|
||||
selected: false,
|
||||
isNodal: isNodal
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
const ResponseSchema = new SimpleSchema({
|
||||
text: {
|
||||
type: String,
|
||||
label: 'Text'
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
label: 'Code'
|
||||
},
|
||||
selected: {
|
||||
type: Boolean,
|
||||
label: 'Selected',
|
||||
defaultValue: false
|
||||
}
|
||||
});
|
||||
|
||||
LocationResponses = new Meteor.Collection(null);
|
||||
LocationResponses.attachSchema(ResponseSchema);
|
||||
LocationResponses._debugName = 'LocationResponses';
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Complete response',
|
||||
code: 'CR'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Progressive disease',
|
||||
code: 'PD'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Stable disease',
|
||||
code: 'SD'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Present',
|
||||
code: 'Present'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Not Evaluable',
|
||||
code: 'NE'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Non-CR/Non-PD',
|
||||
code: 'NN'
|
||||
});
|
||||
|
||||
LocationResponses.insert({
|
||||
text: 'Excluded from Assessment',
|
||||
code: 'EX'
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,105 @@
|
||||
(function(cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||
var keys = {
|
||||
D: 68,
|
||||
DELETE: 46
|
||||
};
|
||||
|
||||
function removeMeasurementTimepoint(data, index, toolType, element) {
|
||||
var imageId = data.imageId;
|
||||
if (!imageId) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
imageId = enabledElement.image.imageId;
|
||||
}
|
||||
|
||||
var enabledElements = cornerstone.getEnabledElementsByImageId(imageId);
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
var element = enabledElement.element;
|
||||
|
||||
// The HandleMeasurementRemoved handler should do the rest
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
|
||||
//Update element
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO = Check if we have the same function already in Cornerstone Tools
|
||||
function getNearbyToolData(element, coords, toolTypes) {
|
||||
var allTools = toolManager.getTools();
|
||||
var pointNearTool = false;
|
||||
var touchDevice = isTouchDevice();
|
||||
var nearbyTool,
|
||||
nearbyToolIndex,
|
||||
nearbyToolType;
|
||||
|
||||
toolTypes.forEach(function(toolType) {
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
var toolInterface;
|
||||
if (touchDevice) {
|
||||
toolInterface = allTools[toolType].touch;
|
||||
} else {
|
||||
toolInterface = allTools[toolType].mouse;
|
||||
}
|
||||
|
||||
if (toolInterface.pointNearTool(element, data, coords)) {
|
||||
pointNearTool = true;
|
||||
nearbyTool = data;
|
||||
nearbyToolIndex = i;
|
||||
nearbyToolType = toolType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pointNearTool === true) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (pointNearTool === true) {
|
||||
return {
|
||||
nearbyTool: nearbyTool,
|
||||
nearbyToolIndex: nearbyToolIndex,
|
||||
nearbyToolType: nearbyToolType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function keyDownCallback(e, eventData) {
|
||||
var keyCode = eventData.which;
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||
|
||||
var toolTypes = [ 'bidirectional', 'nonTarget', 'length', 'crTool', 'unTool', 'exTool'];
|
||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||
|
||||
if (!nearbyToolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO= Refactor this so the confirmation dialog is an
|
||||
// optional settable callback in the tool's configuration
|
||||
showConfirmDialog(function() {
|
||||
removeMeasurementTimepoint(nearbyToolData.nearbyTool,
|
||||
nearbyToolData.nearbyToolIndex,
|
||||
nearbyToolData.nearbyToolType,
|
||||
eventData.element
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// module/private exports
|
||||
cornerstoneTools.deleteLesionKeyboardTool = cornerstoneTools.keyboardTool(keyDownCallback);
|
||||
|
||||
})(cornerstoneTools);
|
||||
@@ -0,0 +1,361 @@
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var toolType = 'nonTarget';
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: true,
|
||||
arrowFirst: true
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// 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 getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: '',
|
||||
isTarget: false,
|
||||
toolType: 'nonTarget'
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var font = cornerstoneTools.textStyle.getFont();
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
context.font = font;
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
cornerstoneTools.drawArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ lesion.handles.start ], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ lesion.handles.end ], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.lesionNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([ 2, 3 ]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.lesionNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeLesionLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cornerstoneTools.nonTarget = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(configuration);
|
||||
|
||||
cornerstoneTools.nonTargetTouch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
@@ -0,0 +1,436 @@
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
var responseByToolType = [{
|
||||
"toolType": "crTool",
|
||||
"toolResponse": "CR"
|
||||
}, {
|
||||
"toolType": "unTool",
|
||||
"toolResponse": "UN"
|
||||
}, {
|
||||
"toolType": "exTool",
|
||||
"toolResponse": "EX"
|
||||
}];
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: false,
|
||||
arrowFirst: true
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// 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 getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
|
||||
function createQualitativeTargetTool(toolType) {
|
||||
var toolInterface = {
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
var response;
|
||||
|
||||
responseByToolType.forEach(function(tool) {
|
||||
if (tool.toolType === toolInterface.toolType) {
|
||||
response = tool.toolResponse;
|
||||
}
|
||||
});
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: response,
|
||||
isTarget: true,
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
function drawDottedArrow(context, start, end, color, lineWidth) {
|
||||
//variables to be used when creating the arrow
|
||||
var headLength = 10;
|
||||
|
||||
var angle = Math.atan2(end.y - start.y, end.x - start.x);
|
||||
|
||||
//starting path of the arrow from the start square to the end square and drawing the stroke
|
||||
context.beginPath();
|
||||
context.moveTo(start.x, start.y);
|
||||
context.lineTo(end.x, end.y);
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
//context.setLineDash([ 2, 3 ]);
|
||||
context.stroke();
|
||||
|
||||
//starting a new path from the head of the arrow to one of the sides of the point
|
||||
context.beginPath();
|
||||
context.moveTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//path from the side point of the arrow, to the other side point
|
||||
context.lineTo(end.x - headLength * Math.cos(angle + Math.PI / 7), end.y - headLength * Math.sin(angle + Math.PI / 7));
|
||||
|
||||
//path from the side point back to the tip of the arrow, and then again to the opposite side point
|
||||
context.lineTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//draws the paths created above
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.stroke();
|
||||
context.fillStyle = color;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var font = cornerstoneTools.textStyle.getFont();
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
context.font = font;
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
drawDottedArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.start], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.end], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.lesionNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, "Target " + +data.lesionNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeLesionLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toolInterface.mouse = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
toolInterface.touch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
return toolInterface;
|
||||
}
|
||||
|
||||
var crToolInterface = createQualitativeTargetTool('crTool');
|
||||
cornerstoneTools.crTool = crToolInterface.mouse;
|
||||
cornerstoneTools.crTool.setConfiguration(configuration);
|
||||
cornerstoneTools.crToolTouch = crToolInterface.touch;
|
||||
|
||||
var unToolInterface = createQualitativeTargetTool('unTool');
|
||||
cornerstoneTools.unTool = unToolInterface.mouse;
|
||||
cornerstoneTools.unTool.setConfiguration(configuration);
|
||||
cornerstoneTools.unToolTouch = unToolInterface.touch;
|
||||
|
||||
var exToolInterface = createQualitativeTargetTool('exTool');
|
||||
cornerstoneTools.exTool = exToolInterface.mouse;
|
||||
cornerstoneTools.exTool.setConfiguration(configuration);
|
||||
cornerstoneTools.exToolTouch = exToolInterface.touch;
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
@@ -0,0 +1,254 @@
|
||||
|
||||
(function($, cornerstone, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Draw Intervals
|
||||
function drawIntervals (context, config) {
|
||||
|
||||
var i = 0;
|
||||
|
||||
while (config.verticalLine.start.y + i * config.verticalMinorTick <= config.vscaleBounds.bottomRight.y) {
|
||||
|
||||
var startPoint = {
|
||||
x: config.verticalLine.start.x,
|
||||
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||
};
|
||||
|
||||
var endPoint = {
|
||||
x: 0,
|
||||
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||
};
|
||||
if (i% 5 === 0) {
|
||||
|
||||
endPoint.x = config.verticalLine.start.x - config.majorTickLength;
|
||||
} else {
|
||||
|
||||
endPoint.x = config.verticalLine.start.x - config.minorTickLength;
|
||||
}
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.bottomRight.x) {
|
||||
|
||||
startPoint = {
|
||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||
y: config.horizontalLine.start.y
|
||||
};
|
||||
|
||||
endPoint = {
|
||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||
y: 0
|
||||
};
|
||||
|
||||
if (i% 5 === 0) {
|
||||
endPoint.y = config.horizontalLine.start.y - config.majorTickLength;
|
||||
} else {
|
||||
endPoint.y = config.horizontalLine.start.y - config.minorTickLength;
|
||||
}
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Draws long horizontal and vertical lines
|
||||
function drawFrameLines(context, config){
|
||||
|
||||
// Vertical Line
|
||||
var startPoint = {
|
||||
x: config.verticalLine.start.x,
|
||||
y: config.verticalLine.start.y
|
||||
};
|
||||
var endPoint = {
|
||||
x: config.verticalLine.end.x,
|
||||
y: config.verticalLine.end.y
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
// Horizontal line
|
||||
startPoint = {
|
||||
x: config.horizontalLine.start.x ,
|
||||
y: config.horizontalLine.start.y
|
||||
};
|
||||
endPoint = {
|
||||
x: config.horizontalLine.end.x,
|
||||
y: config.horizontalLine.end.y
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
// Draw intervals
|
||||
drawIntervals(context, config);
|
||||
|
||||
}
|
||||
|
||||
// Computes the max bound for scales on the image
|
||||
function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReduction, verticalReduction) {
|
||||
|
||||
var canvasBounds = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: canvasSize.width,
|
||||
height: canvasSize.height
|
||||
};
|
||||
|
||||
var hReduction = horizontalReduction * Math.min(1000, canvasSize.width);
|
||||
var vReduction = verticalReduction * Math.min(1000, canvasSize.height);
|
||||
canvasBounds = {
|
||||
left: canvasBounds.left + hReduction,
|
||||
top: canvasBounds.top + vReduction,
|
||||
width: canvasBounds.width - 2 * hReduction,
|
||||
height: canvasBounds.height - 2 * vReduction
|
||||
};
|
||||
|
||||
var startPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
var startPointImageBounds = {
|
||||
x: startPoint.x,
|
||||
y: startPoint.y
|
||||
};
|
||||
var endPointImageBounds = {
|
||||
x: startPoint.x + imageSize.width,
|
||||
y: startPoint.y + imageSize.height
|
||||
};
|
||||
|
||||
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
|
||||
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
|
||||
|
||||
var imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
|
||||
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
|
||||
|
||||
hReduction = horizontalReduction * imageBoundsWidth;
|
||||
vReduction = verticalReduction * imageBoundsHeight;
|
||||
|
||||
var imageBounds = {
|
||||
left: startPointCanvasImageBounds.x + hReduction,
|
||||
top: startPointCanvasImageBounds.y + vReduction,
|
||||
width: imageBoundsWidth - 2 * hReduction,
|
||||
height: imageBoundsHeight - 2 * vReduction
|
||||
};
|
||||
|
||||
return cornerstoneMath.rect.getIntersectionRect(canvasBounds, imageBounds);
|
||||
|
||||
}
|
||||
|
||||
function onImageRendered(e, eventData) {
|
||||
|
||||
// Check whether pixel spacing is defined
|
||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||
return;
|
||||
}
|
||||
|
||||
var viewport = cornerstone.getViewport(eventData.enabledElement.element);
|
||||
if (!viewport) {
|
||||
return;
|
||||
}
|
||||
|
||||
var canvasSize = {
|
||||
width: eventData.enabledElement.canvas.width,
|
||||
height: eventData.enabledElement.canvas.height
|
||||
};
|
||||
var imageSize = {
|
||||
width: eventData.enabledElement.image.width ,
|
||||
height: eventData.enabledElement.image.height
|
||||
};
|
||||
|
||||
// Distance between intervals is 10mm
|
||||
var verticalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||
var horizontalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||
|
||||
// 0.1 and 0.05 gives margin to horizontal and vertical lines
|
||||
var hscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.1, 0.05);
|
||||
var vscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.05, 0.1);
|
||||
|
||||
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height || !hscaleBounds || !vscaleBounds) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = {
|
||||
hscaleBounds: hscaleBounds,
|
||||
vscaleBounds: vscaleBounds,
|
||||
verticalMinorTick: verticalIntervalScale,
|
||||
horizontalMinorTick: horizontalIntervalScale,
|
||||
minorTickLength: 12.5,
|
||||
majorTickLength: 25,
|
||||
verticalLine: {
|
||||
start: {
|
||||
x: vscaleBounds.bottomRight.x,
|
||||
y: vscaleBounds.topLeft.y
|
||||
},
|
||||
end: {
|
||||
x: vscaleBounds.bottomRight.x,
|
||||
y: vscaleBounds.bottomRight.y
|
||||
}
|
||||
},
|
||||
horizontalLine: {
|
||||
start: {
|
||||
x: hscaleBounds.topLeft.x,
|
||||
y: hscaleBounds.bottomRight.y
|
||||
},
|
||||
end: {
|
||||
x: hscaleBounds.bottomRight.x,
|
||||
y: hscaleBounds.bottomRight.y
|
||||
}
|
||||
},
|
||||
color: 'white', // TODO: fix this later
|
||||
lineWidth: cornerstoneTools.toolStyle.getToolWidth()
|
||||
};
|
||||
|
||||
var context = eventData.enabledElement.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
context.save();
|
||||
|
||||
// Draw frame lines
|
||||
drawFrameLines(context, config);
|
||||
|
||||
context.restore();
|
||||
|
||||
}
|
||||
|
||||
///////// END IMAGE RENDERING ///////
|
||||
|
||||
function disable(element) {
|
||||
// TODO: displayTool does not have cornerstone.updateImage(element) method to hide tool
|
||||
$(element).off('CornerstoneImageRendered', onImageRendered);
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
// module exports
|
||||
cornerstoneTools.scaleOverlayTool = cornerstoneTools.displayTool(onImageRendered);
|
||||
cornerstoneTools.scaleOverlayTool.disable = disable;
|
||||
|
||||
})($, cornerstone, cornerstoneTools);
|
||||
@@ -0,0 +1,28 @@
|
||||
<template name="measureFlow">
|
||||
<div class="measure-flow {{#if this.treeColumns}}tree-columns{{/if}} {{instance.state.get}}" style="position:fixed; top:200px; left:400px">
|
||||
<button class="btn-add">Add label</button>
|
||||
{{#if eq instance.state.get 'selected'}}
|
||||
<div class="tree-leaf">
|
||||
<i class="icon-check"></i>
|
||||
<span>{{instance.value.label}}</span>
|
||||
{{#if instance.descriptionEdit.get}}
|
||||
<div class="description clearfix">
|
||||
<textarea
|
||||
class="pull-left"
|
||||
rows="1"
|
||||
style="{{#unless instance.description.get}}height:0{{/unless}}"
|
||||
>{{instance.description.get}}</textarea>
|
||||
</div>
|
||||
{{else}}
|
||||
{{#if instance.description.get}}
|
||||
<div class="descriptionText">{{instance.description.get}}</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<div class="actions clearfix">
|
||||
<button class="pull-left btn-rename">Rename</button>
|
||||
<button class="pull-right btn-description">{{valueIf instance.description.get 'Edit' 'Add'}} description</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,254 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { $ } from 'meteor/jquery';
|
||||
|
||||
Template.measureFlow.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.state = new ReactiveVar('closed');
|
||||
instance.description = new ReactiveVar('');
|
||||
instance.descriptionEdit = new ReactiveVar(false);
|
||||
|
||||
instance.items = [{
|
||||
label: 'Category 1',
|
||||
value: 'Category 1',
|
||||
items: [{
|
||||
label: 'Subcategory 1.1',
|
||||
value: 'Subcategory 1.1'
|
||||
}, {
|
||||
label: 'Subcategory 1.2',
|
||||
value: 'Subcategory 1.2',
|
||||
items: [{
|
||||
label: 'Subcategory 1.2.1',
|
||||
value: 'Subcategory 1.2.1'
|
||||
}, {
|
||||
label: 'Subcategory 1.2.2',
|
||||
value: 'Subcategory 1.2.2',
|
||||
items: [{
|
||||
label: 'Subcategory 1.2.2.1',
|
||||
value: 'Subcategory 1.2.2.1'
|
||||
}, {
|
||||
label: 'Subcategory 1.2.2.2',
|
||||
value: 'Subcategory 1.2.2.2'
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
label: 'Category 2',
|
||||
value: 'Category 2',
|
||||
items: [{
|
||||
label: 'Subcategory 2.1',
|
||||
value: 'Subcategory 2.1'
|
||||
}, {
|
||||
label: 'Subcategory 2.2',
|
||||
value: 'Subcategory 2.2'
|
||||
}, {
|
||||
label: 'Subcategory 2.3',
|
||||
value: 'Subcategory 2.3'
|
||||
}]
|
||||
}, {
|
||||
label: 'Category 3',
|
||||
value: 'Category 3'
|
||||
}];
|
||||
|
||||
const items = [
|
||||
'Abdomen/Chest Wall',
|
||||
'Adrenal',
|
||||
'Bladder',
|
||||
'Bone',
|
||||
'Brain',
|
||||
'Breast',
|
||||
'Colon',
|
||||
'Esophagus',
|
||||
'Extremities',
|
||||
'Gallbladder',
|
||||
'Kidney',
|
||||
'Liver',
|
||||
'Lung',
|
||||
'Lymph Node',
|
||||
'Mediastinum/Hilum',
|
||||
'Muscle',
|
||||
'Neck',
|
||||
'Other Soft Tissue',
|
||||
'Ovary',
|
||||
'Pancreas',
|
||||
'Pelvis',
|
||||
'Peritoneum/Omentum',
|
||||
'Prostate',
|
||||
'Retroperitoneum',
|
||||
'Small Bowel',
|
||||
'Spleen',
|
||||
'Stomach',
|
||||
'Subcutaneous'
|
||||
];
|
||||
|
||||
instance.items = [];
|
||||
_.each(items, item => {
|
||||
instance.items.push({
|
||||
label: item,
|
||||
value: item
|
||||
});
|
||||
});
|
||||
|
||||
const commonItems = [
|
||||
'Abdomen/Chest Wall',
|
||||
'Lung',
|
||||
'Lymph Node',
|
||||
'Liver',
|
||||
'Mediastinum/Hilum',
|
||||
'Pelvis',
|
||||
'Peritoneum/Omentum',
|
||||
'Retroperitoneum'
|
||||
];
|
||||
|
||||
instance.commonItems = [];
|
||||
_.each(commonItems, item => {
|
||||
instance.commonItems.push({
|
||||
label: item,
|
||||
value: item
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Template.measureFlow.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
// Make the measure flow bounded by the window borders
|
||||
instance.$('.measure-flow').bounded();
|
||||
});
|
||||
|
||||
Template.measureFlow.events({
|
||||
'click .measure-flow .btn-add, click .measure-flow .btn-rename'(event, instance) {
|
||||
// Set the open state for the component
|
||||
instance.state.set('open');
|
||||
|
||||
// Wait template rerender before rendering the selectTree
|
||||
Tracker.afterFlush(() => {
|
||||
// Get the click position
|
||||
const position = {
|
||||
left: event.clientX,
|
||||
top: event.clientY,
|
||||
};
|
||||
|
||||
// Define the data for selectTreeComponent
|
||||
const data = {
|
||||
key: 'label',
|
||||
items: instance.items,
|
||||
commonItems: instance.commonItems,
|
||||
hideCommon: instance.data.hideCommon,
|
||||
label: 'Assign label',
|
||||
searchPlaceholder: 'Search labels',
|
||||
storageKey: 'measureLabelCommon',
|
||||
treeColumns: instance.data.treeColumns,
|
||||
position
|
||||
};
|
||||
|
||||
// Define in which element the selectTree will be rendered in
|
||||
const parentElement = instance.$('.measure-flow')[0];
|
||||
|
||||
// Render the selectTree element
|
||||
instance.selectTreeView = Blaze.renderWithData(Template.selectTree, data, parentElement);
|
||||
});
|
||||
},
|
||||
|
||||
'click .measure-flow .btn-description'(event, instance) {
|
||||
// Fade out the action buttons
|
||||
instance.$('.measure-flow .actions').addClass('fadeOut');
|
||||
|
||||
// Set the description edit mode
|
||||
instance.descriptionEdit.set(true);
|
||||
|
||||
// Wait for DOM re-rendering, resize and focus the description textarea
|
||||
Tracker.afterFlush(() => {
|
||||
const $textarea = instance.$('textarea');
|
||||
$textarea.trigger('input').focus();
|
||||
});
|
||||
},
|
||||
|
||||
'input textarea, change textarea'(event, instance) {
|
||||
const element = event.currentTarget;
|
||||
const $element = $(element);
|
||||
|
||||
// Resize the textarea based on its content length
|
||||
$element.css('max-height', 0);
|
||||
$element.height(element.scrollHeight);
|
||||
$element.css('max-height', '');
|
||||
|
||||
// Reposition the measure flow if needed
|
||||
const $measureFlow = instance.$('.measure-flow');
|
||||
$element.one('transitionend', () => $measureFlow.trigger('spatialChanged'));
|
||||
},
|
||||
|
||||
'keydown textarea'(event, instance) {
|
||||
// Unset the description edit mode if ENTER or ESC was pressed
|
||||
if (event.which === 13 || event.which === 27) {
|
||||
instance.$('.measure-flow .actions').removeClass('fadeOut');
|
||||
instance.descriptionEdit.set(false);
|
||||
}
|
||||
|
||||
// Keep the current description if ENTER was pressed
|
||||
if (event.which === 13) {
|
||||
instance.description.set($(event.currentTarget).val());
|
||||
}
|
||||
},
|
||||
|
||||
'click .select-tree-common label'(event, instance) {
|
||||
// Set the common section clicked flag
|
||||
instance.commonClicked = true;
|
||||
},
|
||||
|
||||
'change .select-tree-root'(event, instance) {
|
||||
// Stop here if it's an inner input event
|
||||
if (event.target !== event.currentTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the selectTree component value before it's removed from DOM
|
||||
const $treeRoot = $(event.currentTarget);
|
||||
instance.value = $treeRoot.data('component').value();
|
||||
},
|
||||
|
||||
'click .tree-leaf input'(event, instance) {
|
||||
const $target = $(event.currentTarget);
|
||||
const $label = $target.closest('label');
|
||||
const $treeRoot = $label.closest('.select-tree-root');
|
||||
const $container = $treeRoot.find('.tree-options:first');
|
||||
|
||||
// Check if the targe click was a label inside common section
|
||||
if (instance.commonClicked) {
|
||||
const labelTop = $label.position().top;
|
||||
const containerCenter = Math.round($container.height() / 2);
|
||||
const labelCenter = Math.round($label.height() / 2);
|
||||
|
||||
// Scroll the options container to make the target input visible
|
||||
$container.scrollTop(labelTop - containerCenter + labelCenter);
|
||||
}
|
||||
|
||||
// Change the measure flow state to selected
|
||||
instance.state.set('selected');
|
||||
|
||||
// Get the clicked label window offset
|
||||
const labelOffset = $label.offset();
|
||||
|
||||
// Wait for the DOM re-rendering
|
||||
Tracker.afterFlush(() => {
|
||||
// Get the measure flow div
|
||||
const $measureFlow = instance.$('.measure-flow');
|
||||
|
||||
// Subtract the label box shadow height from the label's position
|
||||
labelOffset.top -= 10;
|
||||
|
||||
// Reposition the measure flow based on the clicked label position
|
||||
$measureFlow.css(labelOffset);
|
||||
|
||||
// Resize the copied label with same width of the clicked one
|
||||
$measureFlow.children('.tree-leaf').width($label.outerWidth());
|
||||
});
|
||||
|
||||
// Wait the fade-out transition and remove the selectTree component
|
||||
$container.one('transitionend', event => Blaze.remove(instance.selectTreeView));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,187 @@
|
||||
@import "{design}/app"
|
||||
|
||||
.measure-flow
|
||||
position: relative
|
||||
|
||||
&.open,
|
||||
&.selected
|
||||
|
||||
.btn-add
|
||||
opacity: 0
|
||||
|
||||
.btn-add
|
||||
theme('color', '$textColorActive')
|
||||
theme('background-color', '$activeColor')
|
||||
theme('border', '2px solid $uiBorderColor')
|
||||
border-radius: 14px
|
||||
cursor: pointer
|
||||
font-weight: bold
|
||||
height: 24px
|
||||
left: 0
|
||||
line-height: 24px
|
||||
opacity: 1
|
||||
position: absolute
|
||||
padding: 0 14px
|
||||
top: 0
|
||||
transition(opacity 0.3s ease)
|
||||
white-space: nowrap
|
||||
|
||||
// / {selector()}
|
||||
// color: $themes['tide']['uiYellow'] !important
|
||||
|
||||
.select-tree-root>.tree-content
|
||||
width: 213px
|
||||
|
||||
&>.tree-options
|
||||
position: relative
|
||||
z-index: 2
|
||||
|
||||
.tree-inputs
|
||||
position: relative
|
||||
|
||||
&>.tree-leaf
|
||||
position: relative
|
||||
|
||||
.icon-check
|
||||
theme('background-color', '$activeColor')
|
||||
left: -46px
|
||||
position: absolute
|
||||
top: 3px
|
||||
|
||||
span
|
||||
background: white
|
||||
font-weight: normal
|
||||
height: 46px
|
||||
line-height: 46px
|
||||
padding: 0 12px
|
||||
|
||||
input, span
|
||||
display: none
|
||||
|
||||
.actions
|
||||
margin-top: 16px
|
||||
opacity: 0
|
||||
|
||||
&:not(.fadeOut)
|
||||
animateFadeIn()
|
||||
animation-delay: 0.3s
|
||||
|
||||
&.fadeOut
|
||||
animateFadeOut()
|
||||
|
||||
button
|
||||
theme('border', '1px solid $uiBorderColor')
|
||||
theme('color', '$textPrimaryColor')
|
||||
background-color: transparent
|
||||
border-radius: 16px
|
||||
font-weight: normal
|
||||
height: 31px
|
||||
line-height: 31px
|
||||
padding: 0 12px
|
||||
text-align: center
|
||||
|
||||
.description
|
||||
margin-top: -10px
|
||||
margin-bottom: 26px
|
||||
|
||||
textarea
|
||||
background-color: white
|
||||
box-shadow: 0 10px white
|
||||
border: 0
|
||||
line-height: 20px
|
||||
outline: none
|
||||
overflow: hidden
|
||||
padding: 0 12px
|
||||
resize: none
|
||||
transition(height 0.3s ease)
|
||||
width: 100%
|
||||
|
||||
.descriptionText
|
||||
background-color: white
|
||||
box-shadow: 0 10px white
|
||||
line-height: 20px
|
||||
margin-bottom: 26px
|
||||
margin-top: -10px
|
||||
padding: 0 12px
|
||||
|
||||
&.selected>.tree-leaf
|
||||
|
||||
span
|
||||
display: block
|
||||
|
||||
&.tree-columns
|
||||
|
||||
.select-tree-root
|
||||
|
||||
&.interacted .select-tree-common .content
|
||||
animation-name: none
|
||||
|
||||
&.selected .select-tree-common .content
|
||||
animation-name: selectTreeCommonCloseLeft
|
||||
|
||||
.tree-search
|
||||
input, i
|
||||
display: none
|
||||
|
||||
.select-tree-common
|
||||
padding-left: 0
|
||||
padding-right: 6px
|
||||
right: auto
|
||||
left: 0
|
||||
width: 33.333333333333%
|
||||
|
||||
&>.tree-content
|
||||
transform-origin(0% 50%)
|
||||
width: 426px
|
||||
|
||||
.select-tree-common .content
|
||||
right: -100%
|
||||
|
||||
&.started .select-tree-common .content
|
||||
right: 6px
|
||||
|
||||
&.interacted .select-tree-common .content
|
||||
animation-name: selectTreeCommonCloseRight
|
||||
|
||||
.tree-inputs>label
|
||||
float: left
|
||||
width: 50%
|
||||
|
||||
@keyframes selectTreeCommonCloseRight {
|
||||
from {
|
||||
height: 37px
|
||||
display: table
|
||||
right: 6px
|
||||
opacity: 1
|
||||
visibility: visible
|
||||
}
|
||||
to {
|
||||
height: 100%
|
||||
right: -100%
|
||||
opacity: 0
|
||||
visibility: hidden
|
||||
width: calc(100% - 6px)
|
||||
}
|
||||
}
|
||||
|
||||
.icon-check
|
||||
background-color: white
|
||||
border-radius: 20px
|
||||
display: block
|
||||
height: 40px
|
||||
overflow: hidden
|
||||
position: relative
|
||||
width: 40px
|
||||
|
||||
&:before
|
||||
border: 2px solid black
|
||||
border-left-width: 0
|
||||
border-top-width: 0
|
||||
content: ''
|
||||
display: block
|
||||
height: 18px
|
||||
left: 15px
|
||||
position: absolute
|
||||
top: 9px
|
||||
transform(rotate(45deg))
|
||||
width: 9px
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<template name="measurementLocationDialog">
|
||||
<div id="measurementLocationDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Select Location</h4>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="measurementLocation">
|
||||
<label>Location</label>
|
||||
<select class="selectMeasurementLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each measurementLocations}}
|
||||
<option value='{{_id}}'>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="measurementLocationRelabelDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Change Location</h4>
|
||||
</div>
|
||||
<a></a>
|
||||
<div class="dialogContent">
|
||||
<div class="measurementLocation">
|
||||
<label>Location</label>
|
||||
<select class="selectMeasurementLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each measurementLocations}}
|
||||
<option value='{{_id}}' selected={{selected}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<button id="removeLesion" class="btn btn-link">Remove</button>
|
||||
<button id="convertToNonTarget" class="btn btn-link">Convert to Non-Target</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
||||
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
// This event sets lesion number for new lesion
|
||||
|
||||
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
||||
return (measurementData, eventData, doneCallback) => {
|
||||
// Get the current element's timepointId from the study date metadata
|
||||
var element = eventData.element;
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
if (!timepointApi) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the relevant timepoint given the current study
|
||||
var timepoint = timepointApi.study(study.studyInstanceUid)[0];
|
||||
if (!timepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
// exists at a different timepoint
|
||||
const timepointId = timepoint.timepointId;
|
||||
const collection = measurementApi[measurementTypeId];
|
||||
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
|
||||
// Set lesion number
|
||||
doneCallback(measurementNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// This event determines whether or not to show the lesion dialog
|
||||
// If there already exists a lesion with this specific lesion number,
|
||||
// related to the chosen location.
|
||||
function getLesionLocationCallback(measurementData, eventData) {
|
||||
return;
|
||||
Template.measurementLocationDialog.measurementData = measurementData;
|
||||
|
||||
// Reset the doneCallback saved in the template so we don't call the change event's done callback
|
||||
Template.measurementLocationDialog.doneCallback = undefined;
|
||||
|
||||
// Get the lesion location dialog
|
||||
var dialog = $('#measurementLocationDialog');
|
||||
Template.measurementLocationDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
});
|
||||
|
||||
// Select the first option for now
|
||||
var selector = dialog.find('select.selectMeasurementLocation');
|
||||
selector.find('option:first').prop('selected', true);
|
||||
|
||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||
// If it is, stop here because we don't need the dialog.
|
||||
var locationUID = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||
if (locationUID) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationUID = locationUID;
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
closeHandler();
|
||||
return;
|
||||
}
|
||||
// If it isn't, continue to open the dialog and have the user choose a lesion location
|
||||
|
||||
// Show the lesion location dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
}
|
||||
|
||||
changeLesionLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
return;
|
||||
Template.measurementLocationDialog.measurementData = measurementData;
|
||||
Template.measurementLocationDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the lesion location dialog
|
||||
var dialog = $('#measurementLocationRelabelDialog');
|
||||
|
||||
// Show/Hide Convert To NonTarget option in measurementLocationRelabelDialog
|
||||
if (measurementData.toolType === 'bidirectional') {
|
||||
dialog.find("#convertToNonTarget").css("visibility", "visible");
|
||||
} else {
|
||||
dialog.find("#convertToNonTarget").css("visibility", "hidden");
|
||||
}
|
||||
|
||||
Template.measurementLocationDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
});
|
||||
|
||||
// Show the lesion location dialog above
|
||||
var dialogProperty = {
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update({},
|
||||
{
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
var currentLocation = LesionLocations.findOne({
|
||||
id: measurement.locationId
|
||||
});
|
||||
|
||||
if (!currentLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update(currentLocation._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Template.measurementLocationDialog.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementTypeId = 'targets';
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
const config = {
|
||||
setLesionNumberCallback: getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
};
|
||||
|
||||
cornerstoneTools.bidirectional.setConfiguration(config);
|
||||
|
||||
// Set CR-Tool, UN-Tool, EX-Tool configurations
|
||||
cornerstoneTools.crTool.setConfiguration(config);
|
||||
cornerstoneTools.exTool.setConfiguration(config);
|
||||
cornerstoneTools.unTool.setConfiguration(config);
|
||||
|
||||
});
|
||||
|
||||
Template.measurementLocationDialog.events({
|
||||
'change .selectMeasurementLocation': function(e) {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
// Get the current value of the selector
|
||||
var selectedOptionId = e.currentTarget.value;
|
||||
|
||||
// If the selected option is still the default (-1)
|
||||
// then stop here
|
||||
if (selectedOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected location data
|
||||
var locationObj = LesionLocations.findOne({
|
||||
_id: selectedOptionId
|
||||
});
|
||||
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
locationId: locationObj.id,
|
||||
}
|
||||
});
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback(measurementData);
|
||||
}
|
||||
},
|
||||
'click #removeLesion': function() {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
var options = {
|
||||
keyPressAllowed: false,
|
||||
title: 'Remove measurement?',
|
||||
text: 'Are you sure you would like to remove the entire measurement?'
|
||||
};
|
||||
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
}, options);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #convertToNonTarget': function() {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
const instance = Template.instance()
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
convertToNonTarget(measurementApi, measurementData);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseLesionPopup': function() {
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keydown #measurementLocationDialog, keydown #measurementLocationRelabelDialog': function(e) {
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.measurementLocationDialog.helpers({
|
||||
measurementLocations: function() {
|
||||
return LesionLocations.find();
|
||||
}
|
||||
});
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#measurementLocationDialog, #measurementLocationRelabelDialog
|
||||
display: none
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: 130px
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
outline: none
|
||||
|
||||
#closeLesionPopup
|
||||
outline: none
|
||||
border: none
|
||||
background-color: transparent
|
||||
|
||||
#selectMeasurementLocation
|
||||
margin-top: 5px
|
||||
|
||||
.dialogContent
|
||||
margin-bottom: 10px
|
||||
|
||||
#removeLesion
|
||||
outline: none
|
||||
text-decoration: none
|
||||
|
||||
#measurementLocationDialog
|
||||
height: 110px
|
||||
|
||||
#measurementLocationRelabelDialog
|
||||
height: 125px
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<template name="nonTargetLesionDialog">
|
||||
<div id="nonTargetLesionLocationDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Select Lesion Location</h4>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="lesionLocation">
|
||||
<label>Lesion Location</label>
|
||||
<select id="selectNonTargetLesionLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each lesionLocations}}
|
||||
<option value={{_id}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationResponse">
|
||||
<label>Response</label>
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1" selected="true"></option>
|
||||
{{ #each locationResponses}}
|
||||
{{ #if code }}
|
||||
<option value={{code}} selected={{selected}}>{{code}} - {{text}}
|
||||
</option>
|
||||
{{ else }}
|
||||
<option value={{text}} selected={{selected}}>{{text}}
|
||||
</option>
|
||||
{{ /if }}
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationOK">
|
||||
<button class="btn btn-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="nonTargetLesionRelabelDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h4>Select Lesion Location</h4>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="lesionLocation">
|
||||
<label>Lesion Location</label>
|
||||
<select id="selectNonTargetLesionLocation">
|
||||
<option value="-1"></option>
|
||||
{{ #each lesionLocations}}
|
||||
<option value='{{_id}}' selected={{selected}}>{{location}}</option>
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationResponse">
|
||||
<label>Response</label>
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1" selected="true"></option>
|
||||
{{ #each locationResponses}}
|
||||
{{ #if code }}
|
||||
<option value={{code}} selected={{selected}}>{{code}} - {{text}}</option>
|
||||
{{ else }}
|
||||
<option value={{text}} selected={{selected}}>{{text}}</option>
|
||||
{{ /if }}
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationOK">
|
||||
<button class="btn btn-link" id="removeLesion">Remove</button>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-link dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Convert
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
{{ #each conversionOptions }}
|
||||
<a class="btn btn-link dropdown-item convertNonTarget" data-type="{{id}}">{{name}}</a>
|
||||
{{ /each }}
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+372
@@ -0,0 +1,372 @@
|
||||
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
|
||||
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
// This event sets lesion number for new lesion
|
||||
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
||||
return (measurementData, eventData, doneCallback) => {
|
||||
// Get the current element's timepointId from the study date metadata
|
||||
var element = eventData.element;
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
|
||||
// Find the relevant timepoint given the current study
|
||||
var timepoint = timepointApi.study(study.studyInstanceUid)[0];
|
||||
if (!timepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
// exists at a different timepoint
|
||||
const timepointId = timepoint.timepointId;
|
||||
const collection = measurementApi[measurementTypeId];
|
||||
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
|
||||
// Set lesion number
|
||||
doneCallback(measurementNumber);
|
||||
}
|
||||
}
|
||||
|
||||
function selectNonTargetResponse(responseCode) {
|
||||
// First, disable all other responses
|
||||
LocationResponses.update({}, {
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
// If no response code is specified, leave them all disabled
|
||||
if (!responseCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the specified response by code and set it as selected
|
||||
LocationResponses.update({
|
||||
code: responseCode
|
||||
}, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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 getLesionLocationCallback(measurementData, eventData) {
|
||||
return 'Test Location';
|
||||
Template.nonTargetLesionDialog.measurementData = measurementData;
|
||||
|
||||
// Get the non-target lesion location dialog
|
||||
var dialog = $('#nonTargetLesionLocationDialog');
|
||||
Template.nonTargetLesionDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
});
|
||||
|
||||
// Find the select option box
|
||||
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||
|
||||
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||
|
||||
// LT-112 "Non-target response shall default to non-measurable on baseline, present on follow-up"
|
||||
var timepoint = Timepoints.findOne({
|
||||
timepointId: measurementData.timepointId
|
||||
});
|
||||
|
||||
if (timepoint && timepoint.timepointType === 'baseline') {
|
||||
selectNonTargetResponse('Present');
|
||||
} else {
|
||||
selectNonTargetResponse();
|
||||
}
|
||||
|
||||
// Allow location selection
|
||||
selectorLocation.removeAttr('disabled');
|
||||
|
||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||
// If it is, disable selector location
|
||||
var locationId = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||
if (locationId) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationId = locationId;
|
||||
|
||||
// Disable the selection of a new location
|
||||
disableLocationSelection(measurementData.locationId);
|
||||
}
|
||||
|
||||
// Disable selector location to prevent selecting a new location
|
||||
function disableLocationSelection(locationId) {
|
||||
var locationObject = LesionLocations.findOne({
|
||||
id: locationId
|
||||
});
|
||||
|
||||
if (!locationObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
selectorLocation.find('option[value="' + locationObject._id + '"]').prop('selected', true);
|
||||
selectorLocation.prop('disabled', true);
|
||||
}
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
dialogProperty.margin = 'auto';
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
}
|
||||
|
||||
changeNonTargetLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
Template.nonTargetLesionDialog.measurementData = measurementData;
|
||||
Template.nonTargetLesionDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the non-target lesion location dialog
|
||||
var dialog = $('#nonTargetLesionRelabelDialog');
|
||||
Template.nonTargetLesionDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
});
|
||||
|
||||
// Find the select option box
|
||||
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||
|
||||
selectorLocation.find('option:first').prop('selected', 'selected');
|
||||
selectorResponse.find('option:first').prop('selected', 'selected');
|
||||
|
||||
// Allow location selection
|
||||
selectorLocation.removeAttr('disabled');
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update({}, {
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
var currentLocation = LesionLocations.findOne({
|
||||
id: measurement.locationId
|
||||
});
|
||||
|
||||
if (!currentLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
LesionLocations.update(currentLocation._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
|
||||
var response = measurement.timepoints[measurementData.timepointId].response;
|
||||
selectNonTargetResponse(response);
|
||||
};
|
||||
|
||||
|
||||
Template.nonTargetLesionDialog.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementTypeId = 'nonTargets';
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
const config = {
|
||||
setLesionNumberCallback: getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
};
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(config);
|
||||
});
|
||||
|
||||
Template.nonTargetLesionDialog.events({
|
||||
'change #selectNonTargetLesionLocationResponse': function(e) {
|
||||
var responseCode = $(e.currentTarget).val();
|
||||
selectNonTargetResponse(responseCode);
|
||||
},
|
||||
'click #nonTargetLesionOK': function() {
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||
|
||||
// Find the select option box
|
||||
var selectorLocation = dialog.find('select#selectNonTargetLesionLocation');
|
||||
|
||||
// Get the current value of the selector
|
||||
var selectedOptionId = selectorLocation.find('option:selected').val();
|
||||
|
||||
// If the selected option is still the default (-1)
|
||||
// then stop here
|
||||
if (selectedOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected location data
|
||||
var locationObj = LesionLocations.findOne({
|
||||
_id: selectedOptionId
|
||||
});
|
||||
|
||||
if (measurementData.id) {
|
||||
// Update the location data
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
location: locationObj.location,
|
||||
locationId: locationObj.id
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
}
|
||||
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// Response is set from location response list
|
||||
measurementData.response = LocationResponses.findOne({selected: true}).code;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #removeLesion': function() {
|
||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||
var doneCallback = Template.nonTargetLesionDialog.doneCallback;
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseLesionPopup': function() {
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click a.convertNonTarget': function(evt) {
|
||||
var measurementData = Template.nonTargetLesionDialog.measurementData;
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
var button = $(evt.currentTarget);
|
||||
var toolType = button.data('type');
|
||||
|
||||
convertNonTarget(measurementData, toolType);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keydown #lesionLocationDialog, keydown #lesionLocationRelabelDialog': function(e) {
|
||||
var dialog = Template.nonTargetLesionDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var conversionOptions = [{
|
||||
id: 'bidirectional',
|
||||
name: 'Measurable Target'
|
||||
}, {
|
||||
id: 'crTool',
|
||||
name: 'Complete Response (CR)'
|
||||
}, {
|
||||
id: 'unTool',
|
||||
name: 'Not Evaluable (NE)'
|
||||
}, {
|
||||
id: 'exTool',
|
||||
name: 'Excluded (EX)'
|
||||
}];
|
||||
|
||||
Template.nonTargetLesionDialog.helpers({
|
||||
lesionLocations: function() {
|
||||
return LesionLocations.find();
|
||||
},
|
||||
locationResponses: function() {
|
||||
return LocationResponses.find();
|
||||
},
|
||||
conversionOptions: function() {
|
||||
return conversionOptions;
|
||||
}
|
||||
});
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#nonTargetLesionLocationDialog, #nonTargetLesionRelabelDialog
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: 230px
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: white
|
||||
outline: none
|
||||
|
||||
#selectNonTargetLesionLocation, #selectNonTargetLesionLocationResponse
|
||||
width: 100%
|
||||
|
||||
.dialogContent, .lesionLocation, .locationResponse
|
||||
margin-bottom: 20px
|
||||
|
||||
.locationOK
|
||||
text-align: center
|
||||
|
||||
/* dialogMobile is added to #nonTargetLesionLocationDialog when touchDevices is detected */
|
||||
.dialogMobile
|
||||
margin: auto
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<template name="nonTargetResponseDialog">
|
||||
<div id="nonTargetResponseDialog" class="dialog-animated" tabindex="0">
|
||||
<div class="dialogHeader">
|
||||
<h5>Select Response</h5>
|
||||
</div>
|
||||
<div class="dialogContent">
|
||||
<div class="locationResponse">
|
||||
<label>Response</label>
|
||||
<select id="selectNonTargetLesionLocationResponse">
|
||||
<option value="-1"></option>
|
||||
{{ #each locationResponses}}
|
||||
{{ #if code }}
|
||||
<option value={{code}} selected={{selected}}>{{code}} - {{text}}</option>
|
||||
{{ else }}
|
||||
<option value={{text}} selected={{selected}}>{{text}}</option>
|
||||
{{ /if }}
|
||||
{{ /each}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="locationOK">
|
||||
<button class="btn btn-link" id="removeLesion">Remove</button>
|
||||
<button class="btn btn-primary" id="nonTargetLesionOK">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
function closeHandler(dialog) {
|
||||
// Hide the lesion dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
changeNonTargetResponse = function(measurementData, eventData, doneCallback) {
|
||||
Template.nonTargetResponseDialog.measurementData = measurementData;
|
||||
Template.nonTargetResponseDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the non-target lesion location dialog
|
||||
var dialog = $('#nonTargetResponseDialog');
|
||||
Template.nonTargetResponseDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
// Show the nonTargetLesion dialog above
|
||||
var dialogProperty = {
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
var response = measurement.timepoints[measurementData.timepointId].response;
|
||||
|
||||
// TODO = Standardize this. Searching by code probably isn't the best, we should use
|
||||
// some sort of UID
|
||||
var currentResponse = LocationResponses.findOne({
|
||||
code: response
|
||||
});
|
||||
|
||||
if (!currentResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocationResponses.update(currentResponse._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Template.nonTargetResponseDialog.events({
|
||||
'click #nonTargetLesionOK': function() {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
var measurementData = Template.nonTargetResponseDialog.measurementData;
|
||||
|
||||
// Find the select option box
|
||||
var selectorResponse = dialog.find('select#selectNonTargetLesionLocationResponse');
|
||||
|
||||
// Get the current value of the selector
|
||||
var responseOptionId = selectorResponse.find('option:selected').val();
|
||||
|
||||
// If the selected response option is still the default (-1)
|
||||
// then stop here
|
||||
if (responseOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!measurementData.id) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
}
|
||||
|
||||
/// Set the isTarget value to true, since this is the target-lesion dialog callback
|
||||
measurementData.isTarget = false;
|
||||
|
||||
// Response is set from location response list
|
||||
measurementData.response = responseOptionId;
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
LesionManager.updateLesionData(measurementData);
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #removeLesion': function() {
|
||||
var measurementData = Template.nonTargetResponseDialog.measurementData;
|
||||
var doneCallback = Template.nonTargetResponseDialog.doneCallback;
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
|
||||
showConfirmDialog(function() {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
var deleteTool = true;
|
||||
doneCallback(measurementData, deleteTool);
|
||||
}
|
||||
});
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseLesionPopup': function() {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keydown #nonTargetResponseDialog': function(e) {
|
||||
var dialog = Template.nonTargetResponseDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.nonTargetResponseDialog.helpers({
|
||||
locationResponses: function() {
|
||||
return LocationResponses.find();
|
||||
}
|
||||
});
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#nonTargetResponseDialog
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
z-index: 100
|
||||
width: 300px
|
||||
height: 150px
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
outline: none
|
||||
|
||||
#selectNonTargetLesionLocationResponse
|
||||
width: 100%
|
||||
|
||||
.dialogContent, .locationResponse
|
||||
margin-bottom: 20px
|
||||
|
||||
.locationOK
|
||||
text-align: center
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<template name="irRCDescription">
|
||||
<h4>irRC</h4>
|
||||
<h5>Baseline Checks</h5>
|
||||
<ul>
|
||||
<li>Target lesions must be >= 10 X 10 mm AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Up to a max of 5 target lesions per organ</li>
|
||||
<li>Up to a max of 10 target lesions total</li>
|
||||
<li>Non-targets can only be assessed as 'present'</li>
|
||||
<li>Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)</li>
|
||||
</ul>
|
||||
<h5>New Lesion Checks for Follow-ups</h5>
|
||||
<ul>
|
||||
<li>New target lesions must be >= 5 X 5 mm AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Up to a max of 5 target lesions per organ</li>
|
||||
<li>Up to a max of 10 target lesions total</li>
|
||||
</ul>
|
||||
<!--Time Point Measurement Total = SPD target lesions + SPD new lesions (SPD = sum of product of long axis and short axis diameters)-->
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
<template name="optionsModal">
|
||||
<div class="modal fade" id="optionsModal" tabindex="-1" role="dialog" aria-labelledby="optionsModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="optionsModalLabel">Clinical Trial Options</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3>Select one or more Trial Criteria types:</h3>
|
||||
{{ #each trialCriteriaTypes}}
|
||||
<label for="{{id}}Criteria" class="trialCriteriaLabel">
|
||||
<!-- TODO: Change to checkbox for multiple criteria !-->
|
||||
<input type="radio" name="trialCriteria" id="{{id}}Criteria" value='{{id}}' class="trialCriteria" checked={{selected}}>
|
||||
{{name}}
|
||||
</label>
|
||||
{{ /each }}
|
||||
<div>
|
||||
<h3>Selected Trial Criteria:</h3>
|
||||
{{ #each trialCriteriaTypes}}
|
||||
{{ #if selected }}
|
||||
<div class="trialCriteriaPanel panel fade in" id="{{id}}Description">
|
||||
{{> Template.dynamic template=descriptionTemplate }}
|
||||
</div>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4>Additional Options</h4>
|
||||
<a type="button" class="btn btn-danger clearAllStudyTimepointAssociations">
|
||||
<i class="fa fa-trash"></i> Clear All Study/Timepoint Associations
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,61 @@
|
||||
TrialCriteriaTypes = new Meteor.Collection(null);
|
||||
|
||||
TrialCriteriaTypes.insert({
|
||||
id: 'RECIST',
|
||||
name: 'RECIST 1.1',
|
||||
descriptionTemplate: 'recistDescription',
|
||||
selected: true
|
||||
});
|
||||
|
||||
TrialCriteriaTypes.insert({
|
||||
id: 'irRC',
|
||||
name: 'irRC',
|
||||
descriptionTemplate: 'irRCDescription',
|
||||
selected: false
|
||||
});
|
||||
|
||||
Template.optionsModal.helpers({
|
||||
trialCriteriaTypes: function() {
|
||||
return TrialCriteriaTypes.find();
|
||||
}
|
||||
});
|
||||
|
||||
Template.optionsModal.events({
|
||||
/**
|
||||
* When the trial criteria radio buttons are changed, change the
|
||||
* trial assessment criteria for the Lesion Tracker
|
||||
*
|
||||
* @param e The 'change' event on the selected radio button
|
||||
*/
|
||||
'change input.trialCriteria': function(e) {
|
||||
var isChecked = e.currentTarget.checked;
|
||||
|
||||
// Set "Selected" to false for the entire collection
|
||||
// TODO: Remove this when we allow multiple criteria
|
||||
TrialCriteriaTypes.update({}, {
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
// Set the current Criteria in the collection to selected
|
||||
TrialCriteriaTypes.update(this._id, {
|
||||
$set: {
|
||||
selected: isChecked
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* When the Clear Study/Timepoint Associations button is clicked, we
|
||||
* send a call to the server to erase all entries in the Timepoints Collection.
|
||||
*/
|
||||
'click a.clearAllStudyTimepointAssociations': function() {
|
||||
Meteor.call('clearAllTimepoints', function(error) {
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
.trialCriteriaLabel
|
||||
margin: 0 5px
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<template name="recistDescription">
|
||||
<h4>RECIST 1.1</h4>
|
||||
<h5>Baseline Checks</h5>
|
||||
<ul>
|
||||
<li>Extranodal lesions must be >= 10 mm long axis AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Extranodal lesions must be >= 20 mm on chest x-ray (although x-rays rarely used for clinical trial assessment)</li>
|
||||
<li>Nodal lesions must be >= 15 mm short axis AND >= double the acquisition slice thickness by CT and MR</li>
|
||||
<li>Up to a max of 2 target lesions per organ</li>
|
||||
<li>Up to a max of 5 target lesions total</li>
|
||||
<li>Non-targets can only be assessed as 'present'</li>
|
||||
<li>Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)</li>
|
||||
</ul>
|
||||
<!-- Time Point Measurement Total = Sum of long axis measurements for extranodal target lesion + short axis measurements for nodal lesions</li>-->
|
||||
</template>
|
||||
@@ -0,0 +1,47 @@
|
||||
Meteor.startup(function() {
|
||||
toolManager.addTool('bidirectional', {
|
||||
mouse: cornerstoneTools.bidirectional,
|
||||
touch: cornerstoneTools.bidirectionalTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('nonTarget', {
|
||||
mouse: cornerstoneTools.nonTarget,
|
||||
touch: cornerstoneTools.nonTargetTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('scaleOverlayTool', {
|
||||
mouse: cornerstoneTools.scaleOverlayTool,
|
||||
touch: cornerstoneTools.scaleOverlayTool
|
||||
});
|
||||
|
||||
toolManager.addTool('deleteLesionKeyboardTool', {
|
||||
mouse: cornerstoneTools.deleteLesionKeyboardTool,
|
||||
touch: cornerstoneTools.deleteLesionKeyboardTool
|
||||
});
|
||||
|
||||
toolManager.addTool('crTool', {
|
||||
mouse: cornerstoneTools.crTool,
|
||||
touch: cornerstoneTools.crToolTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('unTool', {
|
||||
mouse: cornerstoneTools.unTool,
|
||||
touch: cornerstoneTools.unToolTouch
|
||||
});
|
||||
|
||||
toolManager.addTool('exTool', {
|
||||
mouse: cornerstoneTools.exTool,
|
||||
touch: cornerstoneTools.exToolTouch
|
||||
});
|
||||
|
||||
let states = toolManager.getToolDefaultStates();
|
||||
states.deactivate.push('bidirectional');
|
||||
states.deactivate.push('nonTarget');
|
||||
states.deactivate.push('length');
|
||||
states.deactivate.push('crTool');
|
||||
states.deactivate.push('unTool');
|
||||
states.deactivate.push('exTool');
|
||||
|
||||
states.activate.push('deleteLesionKeyboardTool');
|
||||
toolManager.setToolDefaultStates(states);
|
||||
});
|
||||
@@ -0,0 +1,373 @@
|
||||
// Create a client-only Collection to store our Validation Errors
|
||||
ValidationErrors = new Meteor.Collection(null);
|
||||
ValidationErrors._debugName = 'ValidationErrors';
|
||||
|
||||
// Set Validate.js Library's default options
|
||||
validate.options = {
|
||||
format: 'detailed'
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array of validation error messages given an Object of validation errors
|
||||
* and an optional prefix for the messages. An example of a useful prefix would be
|
||||
* the location of the measurement or something like 'Target 1 '.
|
||||
*
|
||||
* @param validationErrors
|
||||
* @param prefix
|
||||
*/
|
||||
function addValidationErrorsToCollection(validationErrors, prefix, type) {
|
||||
// If no input was given, stop here
|
||||
if (!validationErrors || !validationErrors.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop through each of the entries in the validationErrors Array
|
||||
validationErrors.forEach(function(validationError) {
|
||||
var existingError = ValidationErrors.findOne({
|
||||
attribute: validationError.attribute,
|
||||
validator: validationError.validator,
|
||||
error: validationError.error,
|
||||
prefix: prefix
|
||||
});
|
||||
|
||||
if (existingError) {
|
||||
ValidationErrors.update(existingError._id, {
|
||||
$set: {
|
||||
value: validationError.value
|
||||
}
|
||||
});
|
||||
} else {
|
||||
validationError.type = type;
|
||||
validationError.prefix = prefix;
|
||||
ValidationErrors.insert(validationError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs conformance checks related to a group of measurements. This function
|
||||
* searches the input object of Constraints and looks for the 'group' attribute.
|
||||
*
|
||||
* It calculates some general group-level values for the current set of Measurements
|
||||
* and validates these using the input constraints.
|
||||
*
|
||||
* @param constraints
|
||||
* @returns {Array} Array of error messages related to the input conformance checks
|
||||
*/
|
||||
function assessGroupOfMeasurements(constraints) {
|
||||
log.info('assessGroupOfMeasurements');
|
||||
|
||||
// Retrieve the group-level constraints
|
||||
var groupConstraints = constraints.group;
|
||||
|
||||
// If no group-level constraints exist, stop here
|
||||
if (!groupConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
var type = 'group';
|
||||
ValidationErrors.remove({
|
||||
type: type
|
||||
});
|
||||
|
||||
// Calculate some simple group-level Measurement statistics for validation
|
||||
var testStructure = {
|
||||
totalNumberOfLesions: Measurements.find().count()
|
||||
};
|
||||
|
||||
// Run the conformance checks with the validate.js library
|
||||
var validationErrors = validate(testStructure, groupConstraints);
|
||||
|
||||
// Return any error messages as a flattened array of errors
|
||||
addValidationErrorsToCollection(validationErrors, '', type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs conformance checks related to per-organ sets of measurements.
|
||||
*
|
||||
* This function searches the input object of Constraints and looks for the
|
||||
* 'perOrgan' attribute.
|
||||
*
|
||||
* It calculates some general per-organ statistics for the current set of Measurements
|
||||
* and validates these using the input constraints.
|
||||
*
|
||||
* @param constraints
|
||||
* @returns {Array} Array of error messages related to the input conformance checks
|
||||
*/
|
||||
function assessMeasurementPerOrgan(constraints) {
|
||||
log.info('assessMeasurementPerOrgan');
|
||||
|
||||
// Retrieve the per-organ constraints
|
||||
var perOrganConstraints = constraints.perOrgan;
|
||||
|
||||
// If no per-organ constraints exist, stop here
|
||||
if (!perOrganConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a list of all unique locations that contain measurements
|
||||
// by looping through the Measurements Collection
|
||||
var organLocations = [];
|
||||
Measurements.find().forEach(function(measurement) {
|
||||
if (organLocations.indexOf(measurement.location) > -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
organLocations.push(measurement.location);
|
||||
});
|
||||
|
||||
var type = 'perOrgan';
|
||||
ValidationErrors.remove({
|
||||
type: type
|
||||
});
|
||||
|
||||
// Loop through each unique organ location in order to validate
|
||||
// the per-organ constraints for each organ
|
||||
organLocations.forEach(function(location) {
|
||||
// Calculate the number of Lesions per Organ
|
||||
var numberOfLesionsPerOrgan = Measurements.find({
|
||||
location: location
|
||||
}).count();
|
||||
|
||||
// Store per-organ Measurement statistics for validation
|
||||
// Right now this is only the numberOfLesionsPerOrgan, but later
|
||||
// this may include other checks
|
||||
var testStructure = {
|
||||
numberOfLesionsPerOrgan: numberOfLesionsPerOrgan
|
||||
};
|
||||
|
||||
// Run the conformance checks with the validate.js library
|
||||
var validationErrors = validate(testStructure, perOrganConstraints);
|
||||
|
||||
// Obtain any error messages as a flattened array of errors, prefixed
|
||||
// with the Organ name, in the form 'Liver Left: '
|
||||
addValidationErrorsToCollection(validationErrors, location + ': ', type);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs conformance checks on a single Measurement given the
|
||||
* cornerstone toolData related to it.
|
||||
*
|
||||
* @param constraints
|
||||
* @param measurementData CornerstoneTools toolData Object for this specific Measurement
|
||||
* @returns {Array} Array of error messages related to the input conformance checks
|
||||
*/
|
||||
function assessSingleMeasurement(constraints, measurementData) {
|
||||
log.info('assessSingleMeasurement');
|
||||
|
||||
// Check whether this is a Target or Non-Target Measurement
|
||||
var targetType = measurementData.isTarget ? 'target' : 'nonTarget';
|
||||
|
||||
// Retrieve any target/non-target-specific single-measurement constraints
|
||||
// from the input constraint structure
|
||||
var measurementConstraints = constraints[targetType];
|
||||
|
||||
// If no relevant constraints exist, stop here
|
||||
if (!measurementConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check whether this is a Nodal or Extranodal Measurement
|
||||
var nodalType = measurementData.isNodal ? 'nodal' : 'extraNodal';
|
||||
|
||||
// Retrieve any nodal/extra-nodal-specific constraints to see if we can apply them
|
||||
var constraintsToApply;
|
||||
if (measurementData.isNodal !== undefined && measurementConstraints[nodalType]) {
|
||||
// Check if we have enough information (about nodality of this Measurement,
|
||||
// and nodality-specific constraints) to apply nodality-specific constraints
|
||||
constraintsToApply = measurementConstraints[nodalType];
|
||||
} else if (measurementConstraints.all) {
|
||||
// If we have no data about the nodality of this Measurement, or no relevant
|
||||
// specific constraints, we should apply the constraints valid for 'all' nodality
|
||||
// types
|
||||
constraintsToApply = measurementConstraints.all;
|
||||
}
|
||||
|
||||
// Calculate a lesion name based on whether or not we have a Target or Non-target
|
||||
// Measurement, and the lesion number of this Measurement.
|
||||
var lesionName = measurementData.isTarget ? 'Target' : 'Non-target';
|
||||
lesionName = lesionName + ' ' + measurementData.lesionNumber + ': ';
|
||||
|
||||
ValidationErrors.remove({
|
||||
prefix: lesionName
|
||||
});
|
||||
|
||||
// Use validate.js to check the criteria
|
||||
var validationErrors = validate(measurementData, constraintsToApply);
|
||||
|
||||
if (validationErrors) {
|
||||
validationErrors.forEach(function(error) {
|
||||
error.measurementId = measurementData._id;
|
||||
});
|
||||
}
|
||||
|
||||
// Use the Lesion Name as a prefix to concatenate any validation error messages into
|
||||
// an array to return
|
||||
addValidationErrorsToCollection(validationErrors, lesionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate from a single Measurement up the chain to include group and perOrgan
|
||||
* conformance checks
|
||||
*
|
||||
* @param measurementData The CornerstoneTools toolData for a single Measurement
|
||||
*/
|
||||
function validateSingleMeasurement(measurementData) {
|
||||
// Obtain the name of the current TrialResponseAssessmentCriteria that
|
||||
// we are using.
|
||||
var criteriaTypes = TrialCriteriaTypes.find({
|
||||
selected: true
|
||||
}).map(function(criteria) {
|
||||
return criteria.id;
|
||||
});
|
||||
var currentConstraints = getTrialCriteriaConstraints(criteriaTypes, measurementData.imageId);
|
||||
|
||||
// If we have no relevant constraints, stop here
|
||||
if (!currentConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the relevant Measurement in the Measurements Collection
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
|
||||
// If no such Measurement exists, stop here
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the current timepointId that the user was editing the Measurement on
|
||||
var timepointId = measurementData.timepointId;
|
||||
|
||||
// Find the specific measurement data for this Measurement at this Timepoint
|
||||
var currentMeasurement = measurement.timepoints[timepointId];
|
||||
|
||||
// Return here if the measurement was removed during validation
|
||||
if (!currentMeasurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Include target and nodal flags on the timepoint-specific data so it is easier to validate
|
||||
// TODO: Rethink what to pass to assessSingleMeasurement?
|
||||
currentMeasurement.isTarget = measurement.isTarget;
|
||||
currentMeasurement.isNodal = measurement.isNodal;
|
||||
currentMeasurement.lesionNumber = measurement.lesionNumber;
|
||||
currentMeasurement._id = measurement._id;
|
||||
|
||||
// Run the single-measurement-specific conformance checks
|
||||
// If any messages exist, add them to the array of messages
|
||||
assessSingleMeasurement(currentConstraints, currentMeasurement);
|
||||
|
||||
validateGroups();
|
||||
}
|
||||
|
||||
function validateGroups() {
|
||||
log.info('validateGroups');
|
||||
|
||||
// Obtain the names of the current TrialResponseAssessmentCriteria that
|
||||
// we are using.
|
||||
var criteriaTypes = TrialCriteriaTypes.find({
|
||||
selected: true
|
||||
}).map(function(criteria) {
|
||||
return criteria.id;
|
||||
});
|
||||
|
||||
// Criteria for the specific image are retrieved from the general set of criteria.
|
||||
var currentConstraints = getTrialCriteriaConstraints(criteriaTypes);
|
||||
if (!currentConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Revisit this! We can't use the Timepoints collection inside ANY
|
||||
// of these functions, since it causes an infinite loop, since Measurement
|
||||
// validation is performed inside the observe:added hook for the Measurements
|
||||
// Collection.
|
||||
|
||||
var timepointTypes = ['baseline', 'followup'];
|
||||
timepointTypes.forEach(function(timepointType) {
|
||||
// Retrieve the current constraints which apply to the specific Timepoint type
|
||||
// (e.g. baseline, followup) that this Measurement is being edited on.
|
||||
var timepointConstraints = currentConstraints[timepointType];
|
||||
if (!timepointConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Run the group-level conformance checks
|
||||
assessGroupOfMeasurements(timepointConstraints);
|
||||
|
||||
// Run the per-organ conformance checks
|
||||
assessMeasurementPerOrgan(timepointConstraints);
|
||||
});
|
||||
}
|
||||
|
||||
function validateAll() {
|
||||
// Obtain the names of the current TrialResponseAssessmentCriteria that
|
||||
// we are using.
|
||||
var criteriaTypes = TrialCriteriaTypes.find({
|
||||
selected: true
|
||||
}).map(function(criteria) {
|
||||
return criteria.id;
|
||||
});
|
||||
|
||||
Measurements.find().forEach(function(measurement) {
|
||||
Object.keys(measurement.timepoints).forEach(function(timepointId) {
|
||||
var currentMeasurement = measurement.timepoints[timepointId];
|
||||
currentMeasurement.isTarget = measurement.isTarget;
|
||||
currentMeasurement.isNodal = measurement.isNodal;
|
||||
currentMeasurement.lesionNumber = measurement.lesionNumber;
|
||||
currentMeasurement._id = measurement._id;
|
||||
|
||||
// Criteria for the specific image are retrieved from the general set of criteria.
|
||||
var currentConstraints = getTrialCriteriaConstraints(criteriaTypes, currentMeasurement.imageId);
|
||||
if (!currentConstraints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Run the single-measurement-specific conformance checks
|
||||
// If any messages exist, add them to the array of messages
|
||||
assessSingleMeasurement(currentConstraints, currentMeasurement);
|
||||
});
|
||||
});
|
||||
|
||||
validateGroups();
|
||||
}
|
||||
|
||||
var validationTimeout = 400;
|
||||
|
||||
/**
|
||||
* Validate the measurements after a set delay period
|
||||
*
|
||||
* @param measurementData Input measurement data from CornerstoneTools
|
||||
*/
|
||||
function validateDelayed(measurementData) {
|
||||
// Erase any currently-waiting validation call
|
||||
clearTimeout(validationTimeout);
|
||||
|
||||
// Set a timeout to run validation after a delay
|
||||
// Currently this is 400 milliseconds
|
||||
setTimeout(function() {
|
||||
validateSingleMeasurement(measurementData);
|
||||
}, validationTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all measurements after a set delay period
|
||||
*/
|
||||
function validateAllDelayed() {
|
||||
// Erase any currently-waiting validation call
|
||||
clearTimeout(validationTimeout);
|
||||
|
||||
// Set a timeout to run validation after a delay
|
||||
// Currently this is 400 milliseconds
|
||||
setTimeout(function() {
|
||||
validateAll();
|
||||
}, validationTimeout);
|
||||
}
|
||||
|
||||
TrialResponseCriteria = {
|
||||
validateAll: validateAll,
|
||||
validateAllDelayed: validateAllDelayed,
|
||||
validateSingleMeasurement: validateSingleMeasurement,
|
||||
validateDelayed: validateDelayed,
|
||||
validateGroups: validateGroups
|
||||
};
|
||||
@@ -0,0 +1,394 @@
|
||||
// Define the Trial Criteria Structure
|
||||
TrialCriteriaConstraints = {
|
||||
RECIST: RECIST,
|
||||
irRC: irRC
|
||||
};
|
||||
|
||||
/**
|
||||
* RECIST 1.1 Trial Criteria Definition
|
||||
*
|
||||
* Baseline Checks:
|
||||
* - Extranodal lesions must be >/= 10 mm long axis AND >/= double the acquisition slice thickness by CT and MR
|
||||
* - Extranodal lesions must be >/= 20 mm on chest x-ray (although x-rays rarely used for clinical trial assessment)
|
||||
* - Nodal lesions must be >/= 15 mm short axis AND >/= double the acquisition slice thickness by CT and MR
|
||||
* - Up to a max of 2 target lesions per organ
|
||||
* - Up to a max of 5 target lesions total
|
||||
* - Non-targets can only be assessed as 'present'
|
||||
* - Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)
|
||||
* - Time Point Measurement Total = Sum of long axis measurements for extranodal target lesion + short axis measurements for nodal lesions
|
||||
*/
|
||||
function RECIST(image) {
|
||||
var acquisitionSliceThickness;
|
||||
|
||||
var isChestXray;
|
||||
if (image) {
|
||||
acquisitionSliceThickness = image.acquisitionSliceThickness;
|
||||
|
||||
// TODO: Use metaData to determine if this is a chest X-ray
|
||||
isChestXray = false;
|
||||
}
|
||||
|
||||
// Define the RECIST 1.1 structure
|
||||
var criteria = {
|
||||
baseline: {
|
||||
target: {},
|
||||
nonTarget: {},
|
||||
group: {}
|
||||
}
|
||||
};
|
||||
|
||||
if (acquisitionSliceThickness) {
|
||||
criteria.baseline.target.nodal = {
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: Math.max(15, 2 * acquisitionSliceThickness),
|
||||
message: '^Nodal lesions must be >= 15 mm short axis AND >= double the acquisition slice thickness (' +
|
||||
acquisitionSliceThickness + ' mm) for CT and MR.'
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
criteria.baseline.target.nodal = {
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 15,
|
||||
//message: '^Nodal target lesions must be >= %{count} mm short axis'
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
criteria.baseline.target.all = {
|
||||
// - Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)
|
||||
response: {
|
||||
exclusion: {
|
||||
within: {
|
||||
CR: 'Complete Response (CR)',
|
||||
UN: 'Unknown (UN)',
|
||||
NE: 'Non-evaluable (NE)',
|
||||
EX: 'Excluded (EX)'
|
||||
},
|
||||
message: '^Target lesions must have a length and cannot be marked as %{value} at baseline.'
|
||||
}
|
||||
},
|
||||
totalLesionBurden: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 2, // TODO: Check this, the value wasn't specified!
|
||||
//message: '^Total lesion burden (SPD target lesions + SPD new lesions) should be greater than %{count}.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
criteria.baseline.nonTarget.all = {
|
||||
// - Non-targets can only be assessed as 'present'
|
||||
response: {
|
||||
// This is a workaround since Validating equality to something is not implemented yet
|
||||
// https://github.com/ansman/validate.js/issues/79
|
||||
presence: {
|
||||
message: "^Non-target lesions can only be assessed as 'Present' at Baseline"
|
||||
},
|
||||
inclusion: {
|
||||
within: ['Present'],
|
||||
message: "^Non-target lesions can only be assessed as 'Present' at Baseline"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
criteria.baseline.perOrgan = {
|
||||
numberOfLesionsPerOrgan: {
|
||||
numericality: {
|
||||
lessThanOrEqualTo: 2,
|
||||
//message: '^A maximum of %{count} target lesions per organ are allowed at Baseline.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
criteria.baseline.group = {
|
||||
totalNumberOfLesions: {
|
||||
numericality: {
|
||||
lessThanOrEqualTo: 5,
|
||||
//message: '^A maximum of %{count} target lesions total are allowed at Baseline.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (acquisitionSliceThickness) {
|
||||
criteria.baseline.target.extraNodal = {
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: Math.max(10, 2 * acquisitionSliceThickness),
|
||||
message: '^Extranodal lesions must be >= 10 mm long axis AND >= double the acquisition slice thickness (' +
|
||||
acquisitionSliceThickness + ' mm) for CT and MR.'
|
||||
}
|
||||
}
|
||||
};
|
||||
} else if (isChestXray) {
|
||||
criteria.baseline.target.extraNodal = {
|
||||
// -
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 20,
|
||||
//message: '^Extranodal lesions must be >= %{count} mm on chest X-ray'
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
criteria.baseline.target.extraNodal = {
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 10,
|
||||
//message: '^Extranodal target lesions must be >= %{count} mm long axis'
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* irRC Trial Criteria Definition
|
||||
*
|
||||
* Baseline Checks:
|
||||
* - Target lesions must be >/= 10 X 10 mm
|
||||
* - Up to a max of 5 target lesions per organ
|
||||
* - Up to a max of 10 target lesions total
|
||||
* - Non-targets can only be assessed as 'present'
|
||||
* - Target lesions must have measurements (cannot be assessed as CR, UN/NE, EX)
|
||||
*/
|
||||
function irRC(image) {
|
||||
var acquisitionSliceThickness;
|
||||
if (image) {
|
||||
acquisitionSliceThickness = image.acquisitionSliceThickness;
|
||||
}
|
||||
|
||||
// Define the irRC structure
|
||||
var criteria = {
|
||||
baseline: {
|
||||
target: {},
|
||||
nonTarget: {}
|
||||
},
|
||||
followup: {
|
||||
newLesions: {
|
||||
target: {}
|
||||
},
|
||||
target: {}
|
||||
},
|
||||
all: {}
|
||||
};
|
||||
|
||||
if (acquisitionSliceThickness) {
|
||||
criteria.baseline.target.all = {
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: Math.max(10, acquisitionSliceThickness),
|
||||
message: '^Target lesions must be >= 10 mm long axis AND >= double the acquisition slice thickness (' +
|
||||
acquisitionSliceThickness + ' mm) for CT and MR.'
|
||||
}
|
||||
},
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: Math.max(10, acquisitionSliceThickness),
|
||||
message: '^Target lesions must be >= 10 mm short axis AND >= double the acquisition slice thickness (' +
|
||||
acquisitionSliceThickness + ' mm) for CT and MR.'
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
criteria.baseline.target.all = {
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 10,
|
||||
//message: '^Target lesions must be >= %{count} mm long axis.'
|
||||
}
|
||||
},
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 10,
|
||||
//message: '^Target lesions must be >= %{count} mm short axis.'
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
criteria.baseline.target.all.response = {
|
||||
exclusion: {
|
||||
within: {
|
||||
CR: 'Complete Response (CR)',
|
||||
UN: 'Unknown (UN)',
|
||||
NE: 'Non-evaluable (NE)',
|
||||
EX: 'Excluded (EX)'
|
||||
},
|
||||
message: '^^Target lesions must have a length and cannot be marked as %{value} at baseline.'
|
||||
}
|
||||
};
|
||||
|
||||
criteria.baseline.nonTarget.all = {
|
||||
response: {
|
||||
// This is a workaround since Validating equality to something is not implemented yet
|
||||
// https://github.com/ansman/validate.js/issues/79
|
||||
presence: {
|
||||
message: "^Non-target lesions can only be assessed as 'Present' at Baseline"
|
||||
},
|
||||
inclusion: {
|
||||
within: ['Present'],
|
||||
message: "^Non-target lesions can only be assessed as 'Present' at Baseline"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
criteria.baseline.perOrgan = {
|
||||
numberOfLesionsPerOrgan: {
|
||||
numericality: {
|
||||
lessThanOrEqualTo: 5,
|
||||
//message: '^A maximum of %{count} target lesions per organ are allowed at Baseline.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
criteria.baseline.group = {
|
||||
totalNumberOfLesions: {
|
||||
numericality: {
|
||||
lessThanOrEqualTo: 10,
|
||||
//message: '^A maximum of %{count} target lesions total are allowed at Baseline.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (acquisitionSliceThickness) {
|
||||
criteria.followup.newLesions.target.all = {
|
||||
// - New target lesions must be >/= 5 X 5 mm AND >/= double the acquisition slice thickness by CT and MR
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: Math.max(5, 2 * acquisitionSliceThickness),
|
||||
message: '^New target lesions must be >= 5 mm long axis AND >= double the acquisition slice thickness (' +
|
||||
acquisitionSliceThickness + ' mm) for CT and MR.'
|
||||
}
|
||||
},
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: Math.max(5, 2 * acquisitionSliceThickness),
|
||||
message: '^New target lesions must be >= 5 mm short axis AND >= double the acquisition slice thickness (' +
|
||||
acquisitionSliceThickness + ' mm) for CT and MR.'
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
criteria.followup.newLesions.target.all = {
|
||||
// - New target lesions must be >/= 5 X 5 mm
|
||||
longestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 5,
|
||||
//message: '^New target lesions must be >= %{count} mm long axis.'
|
||||
}
|
||||
},
|
||||
shortestDiameter: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 5,
|
||||
//message: '^New target lesions must be >= %{count} mm short axis.'
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
criteria.followup.group = {
|
||||
numberOfLesionsPerOrgan: {
|
||||
numericality: {
|
||||
lessThanOrEqualTo: 5,
|
||||
//message: '^A maximum of %{count} target lesions per organ are allowed at Followup.'
|
||||
}
|
||||
},
|
||||
totalNumberOfLesions: {
|
||||
numericality: {
|
||||
lessThanOrEqualTo: 10,
|
||||
//message: '^A maximum of %{count} target lesions total are allowed at Followup.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Check the actual requirement for total burden!
|
||||
criteria.all.group = {
|
||||
totalLesionBurden: {
|
||||
numericality: {
|
||||
greaterThanOrEqualTo: 100,
|
||||
//message: '^Total lesion burden (SPD target lesions + SPD new lesions) should be greater than %{count}.'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve trial criteria constraints based on the image that measurements appear upon
|
||||
* If no image is specified, it is assumed that group or per Organ level criteria are desired.
|
||||
*
|
||||
* @param criteriaTypes An array of valid Trial Criteria set names (e.g. ['RECIST', 'irRC'])
|
||||
* NOTE: Multiple criteria are not yet supported
|
||||
*
|
||||
* @param imageId A Cornerstone Image ID
|
||||
* @returns {*} An Object of Trial Criteria that can be used to validate measurements' conformance
|
||||
*/
|
||||
getTrialCriteriaConstraints = function(criteriaTypes, imageId) {
|
||||
// TODO: update this when we allow multiple criteria
|
||||
var allCriteria = [];
|
||||
criteriaTypes.forEach(function(criteriaType) {
|
||||
if (!TrialCriteriaConstraints[criteriaType]) {
|
||||
throw 'No such Trial Criteria defined: ' + criteriaType;
|
||||
}
|
||||
|
||||
// If no imageId was specified, skip customization of the criteria
|
||||
// and return the requested criteria right away
|
||||
var criteria;
|
||||
if (!imageId) {
|
||||
criteria = TrialCriteriaConstraints[criteriaType]();
|
||||
allCriteria.push(criteria);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, retrieve the series metaData to identify the modality of the image
|
||||
var seriesMetaData = cornerstoneTools.metaData.get('series', imageId);
|
||||
if (!seriesMetaData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Get the rest of the metaData that has already been loaded by Cornerstone
|
||||
var image = {};
|
||||
|
||||
// If we are looking at an MR or CT image, we should pass the slice thickness
|
||||
// to the Trial Criteria functions so that they can customize the validation rules
|
||||
if (seriesMetaData.modality === 'MR' || seriesMetaData.modality === 'CT') {
|
||||
var instanceMetaData = cornerstoneTools.metaData.get('instance', imageId);
|
||||
image.acquisitionSliceThickness = instanceMetaData.sliceThickness;
|
||||
}
|
||||
|
||||
// Retrieve the study metaData in order to find the timepoint type
|
||||
var studyMetaData = cornerstoneTools.metaData.get('study', imageId);
|
||||
if (!studyMetaData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the related Timepoint document
|
||||
const timepointApi = Template.instance().timepointApi;
|
||||
if (!timepointApi) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timepoint = timepointApi.study(studyMetaData.studyInstanceUid)[0];
|
||||
if (!timepoint) {
|
||||
log.warn('Timepoint related to study is missing.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the Timepoint's type (e.g. 'baseline' or 'followup')
|
||||
var timepointType = timepoint.timepointType;
|
||||
|
||||
// Obtain the customized trial criteria given the image metaData
|
||||
criteria = TrialCriteriaConstraints[criteriaType](image);
|
||||
|
||||
// Return the relevant criteria given the current timepoint type
|
||||
allCriteria.push(criteria[timepointType]);
|
||||
});
|
||||
|
||||
return allCriteria[0];
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
clearMeasurementTimepointData = function(measurementId, timepointId) {
|
||||
var data = Measurements.findOne(measurementId);
|
||||
|
||||
// Clear the Measurement data for this timepoint
|
||||
var imageId = data.timepoints[timepointId].imageId;
|
||||
var toolType = data.toolType;
|
||||
removeToolDataWithMeasurementId(imageId, toolType, measurementId);
|
||||
|
||||
// Update any viewports that are currently displaying this imageId
|
||||
var enabledElements = cornerstone.getEnabledElementsByImageId(imageId);
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
cornerstone.updateImage(enabledElement.element);
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
function removeToolDataWithMeasurementId(imageId, toolType, measurementId) {
|
||||
log.info('removeToolDataWithMeasurementId');
|
||||
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
|
||||
// Find any related toolData
|
||||
if (!toolState[imageId] || !toolState[imageId][toolType]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var toolData = toolState[imageId][toolType].data;
|
||||
if (!toolData.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Search toolData for entries linked to the specified Measurement
|
||||
var toRemove = [];
|
||||
toolData.forEach(function(measurement, index) {
|
||||
if (measurement.id === measurementId ||
|
||||
measurement._id === measurementId) {
|
||||
toRemove.push(index);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
log.info('Removing Indices: ');
|
||||
log.info(toRemove);
|
||||
|
||||
// If any toolData entries need to be removed, splice them from
|
||||
// the toolData array
|
||||
toRemove.forEach(function(index) {
|
||||
toolData.splice(index, 1);
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
var responseTypes = {
|
||||
crTool: 'CR',
|
||||
exTool: 'EX',
|
||||
unTool: 'UN'
|
||||
};
|
||||
|
||||
convertNonTarget = function(measurementApi, measurementData, newTooltype) {
|
||||
if (measurementData.toolType !== 'nonTarget') {
|
||||
return;
|
||||
}
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
|
||||
var timepoint = Timepoints.findOne({
|
||||
timepointId: measurementData.timepointId
|
||||
});
|
||||
|
||||
if (timepoint && timepoint.timepointType !== 'followup') {
|
||||
log.warn('Not a followup');
|
||||
return;
|
||||
}
|
||||
|
||||
// Next, update the measurementData and add it to the new tool type
|
||||
var newMeasurement = {
|
||||
id: 'notready',
|
||||
lesionNumber: measurementApi.getNewLesionNumber(measurementData.timepointId, false),
|
||||
visible: true,
|
||||
active: true,
|
||||
imageId: measurementData.imageId,
|
||||
seriesInstanceUid: measurementData.seriesInstanceUid,
|
||||
studyInstanceUid: measurementData.studyInstanceUid,
|
||||
patientId: measurementData.patientId,
|
||||
isTarget: false,
|
||||
toolType: newTooltype
|
||||
};
|
||||
|
||||
newMeasurement.handles = measurementData.handles;
|
||||
|
||||
if (responseTypes[newTooltype]) {
|
||||
newMeasurement.response = responseTypes[newTooltype];
|
||||
}
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
measurementApi.updateLesionData(newMeasurement);
|
||||
|
||||
// Set the new Measurement to have the same location as the old one
|
||||
if (measurement.location && measurement.locationId) {
|
||||
var existingMeasurement = Measurements.findOne({
|
||||
lesionNumber: newMeasurement.lesionNumber,
|
||||
isTarget: newMeasurement.isTarget
|
||||
});
|
||||
|
||||
if (!existingMeasurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
Measurements.update(existingMeasurement._id, {
|
||||
$set: {
|
||||
location: measurement.location,
|
||||
locationId: measurement.locationId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (measurement) {
|
||||
// Remove the timepointData from this Measurement and update it
|
||||
// in the database, if it is already in the database
|
||||
clearMeasurementTimepointData(measurement._id, measurementData.timepointId);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
convertToNonTarget = function(measurementApi, measurementData) {
|
||||
if (measurementData.isTarget === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
|
||||
var timepoint = Timepoints.findOne({
|
||||
timepointId: measurementData.timepointId
|
||||
});
|
||||
|
||||
// Next, update the measurementData and add it to the new tool type
|
||||
var toolType = 'nonTarget';
|
||||
var newMeasurement = {
|
||||
id: 'notready',
|
||||
lesionNumber: LesionManager.getNewLesionNumber(measurementData.timepointId, false),
|
||||
visible: true,
|
||||
active: true,
|
||||
imageId: measurementData.imageId,
|
||||
seriesInstanceUid: measurementData.seriesInstanceUid,
|
||||
studyInstanceUid: measurementData.studyInstanceUid,
|
||||
patientId: measurementData.patientId,
|
||||
isTarget: false,
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
if (timepoint && timepoint.timepointType === 'baseline') {
|
||||
newMeasurement.response = 'Present';
|
||||
} else {
|
||||
newMeasurement.response = '';
|
||||
}
|
||||
|
||||
newMeasurement.handles = {
|
||||
start: {
|
||||
x: (measurementData.handles.start.x + measurementData.handles.end.x) / 2,
|
||||
y: (measurementData.handles.start.y + measurementData.handles.end.y) / 2,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: Math.min(measurementData.handles.start.x, measurementData.handles.end.x),
|
||||
y: Math.min(measurementData.handles.start.y, measurementData.handles.end.y),
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: measurementData.handles.textBox.x,
|
||||
y: measurementData.handles.textBox.y,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
};
|
||||
|
||||
// Adds lesion data to timepoints array
|
||||
LesionManager.updateLesionData(newMeasurement);
|
||||
|
||||
// Set the new Measurement to have the same location as the old one
|
||||
if (measurement.location && measurement.locationId) {
|
||||
var existingMeasurement = Measurements.findOne({
|
||||
lesionNumber: newMeasurement.lesionNumber,
|
||||
isTarget: newMeasurement.isTarget
|
||||
});
|
||||
|
||||
if (!existingMeasurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
Measurements.update(existingMeasurement._id, {
|
||||
$set: {
|
||||
location: measurement.location,
|
||||
locationId: measurement.locationId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (measurement) {
|
||||
// Remove the timepointData from this Measurement and update it
|
||||
// in the database, if it is already in the database
|
||||
clearMeasurementTimepointData(measurement._id, measurementData.timepointId);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Calculates a Timepoint's name based on how many timepoints exist between it
|
||||
* and the latest Baseline. Names returned are in the form of 'Baseline', or
|
||||
* 'Follow-up 1', 'Follow-up 2', and so on.
|
||||
*
|
||||
* @param timepoint
|
||||
* @returns {*} The timepoint name
|
||||
*/
|
||||
getTimepointName = function(timepoint) {
|
||||
// Check if this is a Baseline timepoint, if it is, return 'Baseline'
|
||||
if (timepoint.timepointType === 'baseline') {
|
||||
return 'Baseline';
|
||||
}
|
||||
|
||||
// Retrieve all of the relevant follow-up timepoints for this patient
|
||||
var followupTimepoints = Timepoints.find({
|
||||
patientId: timepoint.patientId,
|
||||
timepointType: timepoint.timepointType
|
||||
}, {
|
||||
sort: {
|
||||
latestDate: 1
|
||||
}
|
||||
});
|
||||
|
||||
// Create an array of just timepointIds, so we can use indexOf
|
||||
// on it to find the current timepoint's relative position
|
||||
var followupTimepointIds = followupTimepoints.map(function(timepoint) {
|
||||
return timepoint.timepointId;
|
||||
});
|
||||
|
||||
// Calculate the index of the current timepoint in the array of all
|
||||
// relevant follow-up timepoints
|
||||
var index = followupTimepointIds.indexOf(timepoint.timepointId) + 1;
|
||||
|
||||
// If index is 0, it means that the current timepoint was not in the list
|
||||
// Log a warning and return here
|
||||
if (!index) {
|
||||
log.warn('Current follow-up was not in the list of relevant follow-ups?');
|
||||
return;
|
||||
}
|
||||
|
||||
// Return the timepoint name as 'Follow-up N'
|
||||
return 'Follow-up ' + index;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Returns timepoint object given a specified imageId
|
||||
*
|
||||
* @param imageId
|
||||
* @returns {*|{}} Timepoint object
|
||||
*/
|
||||
getTimepointObject = function(imageId) {
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
if (!study) {
|
||||
return;
|
||||
}
|
||||
|
||||
return Timepoints.findOne({
|
||||
studyInstanceUids: {
|
||||
$in: [study.studyInstanceUid]
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
pixelSpacingAutorunCheck = function() {
|
||||
log.info('lesionTool button change autorun');
|
||||
|
||||
// Get oncology tools
|
||||
var oncologyTools = $('button#lesion, button#nonTarget');
|
||||
|
||||
// TODO: Set activeViewport for empty viewport element
|
||||
var activeViewportIndex = Session.get('activeViewport');
|
||||
if (activeViewportIndex === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var element = $('.imageViewerViewport').get(activeViewportIndex);
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
} catch(error) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check value of rowPixelSpacing & columnPixelSpacing to define as unavailable
|
||||
if (!enabledElement ||
|
||||
!enabledElement.image ||
|
||||
!enabledElement.image.rowPixelSpacing ||
|
||||
!enabledElement.image.columnPixelSpacing) {
|
||||
// Disable Lesion Buttons
|
||||
oncologyTools.prop('disabled', true);
|
||||
} else {
|
||||
// Enable Lesion Buttons
|
||||
oncologyTools.prop('disabled', false);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Opens a new tab in the tabbed studylist environment using
|
||||
* a given timepoint and new tab title.
|
||||
*
|
||||
* @param timepointId The UID of the Timepoint to be opened
|
||||
* @param title The title to be used for the tab heading
|
||||
*/
|
||||
openNewTabWithTimepoint = function(timepointId, title) {
|
||||
const contentId = 'viewerTab';
|
||||
|
||||
const Timepoints = StudyList.timepointApi.timepoints;
|
||||
const timepoint = Timepoints.findOne({
|
||||
timepointId: timepointId
|
||||
});
|
||||
|
||||
if (!timepoint) {
|
||||
throw 'No such timepoint exists';
|
||||
}
|
||||
|
||||
// Get the relevant studyInstanceUids given the timepoints
|
||||
const data = getDataFromTimepoint(timepoint);
|
||||
if (!data.studyInstanceUids) {
|
||||
throw 'No studies found that are related to this timepoint';
|
||||
}
|
||||
|
||||
ViewerData = window.ViewerData || ViewerData;
|
||||
|
||||
// Update the ViewerData global object
|
||||
ViewerData[contentId] = {
|
||||
title: title,
|
||||
contentid: contentId,
|
||||
studyInstanceUids: data.studyInstanceUids,
|
||||
timepointIds: data.timepointIds,
|
||||
currentTimepointId: timepointId
|
||||
};
|
||||
|
||||
// Switch to the new tab
|
||||
switchToTab(contentId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves related studies given a Baseline or Follow-up Timepoint
|
||||
*
|
||||
* @param timepoint
|
||||
* @returns {Array}
|
||||
*/
|
||||
function getDataFromTimepoint(timepoint) {
|
||||
let relatedStudies = [timepoint.studyInstanceUids[0]];
|
||||
|
||||
// If this is the baseline, we should stop here and return the relevant studies
|
||||
if (isBaseline(timepoint)) {
|
||||
return {
|
||||
studyInstanceUids: relatedStudies,
|
||||
timepointIds: [timepoint.timepointId]
|
||||
};
|
||||
}
|
||||
|
||||
// Otherwise, this is a follow-up exam, so we should also find the baseline timepoint,
|
||||
// and all studies related to it. We also enforce that the Baseline should have a studyDate
|
||||
// prior to the latest studyDate in the current (Follow-up) Timepoint.
|
||||
const Timepoints = StudyList.timepointApi.timepoints;
|
||||
const baseline = Timepoints.findOne({
|
||||
timepointType: 'baseline',
|
||||
patientId: timepoint.patientId,
|
||||
latestDate: {
|
||||
$lte: timepoint.latestDate
|
||||
}
|
||||
});
|
||||
|
||||
let timepointIds = [];
|
||||
if (baseline) {
|
||||
// NOTE: Temporarily added [0], since we only need one study per timepoint to load immediately?
|
||||
relatedStudies = relatedStudies.concat(baseline.studyInstanceUids[0]);
|
||||
timepointIds.push(baseline.timepointId);
|
||||
} else {
|
||||
log.warn('No Baseline found while opening a Follow-up Timepoint');
|
||||
}
|
||||
|
||||
timepointIds.push(timepoint.timepointId);
|
||||
|
||||
return {
|
||||
studyInstanceUids: relatedStudies,
|
||||
timepointIds: timepointIds
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a Timepoints is a baseline or not
|
||||
* (abstracting this for later use, since I expect it to get more complex)
|
||||
*
|
||||
* @param timepoint a document from the Timepoints Collection
|
||||
* @returns {boolean} Whether or not the timepoint is stored as a Baseline
|
||||
*/
|
||||
function isBaseline(timepoint) {
|
||||
return (timepoint.timepointType === 'baseline');
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { TimepointsConfiguration } from 'meteor/ohif:measurements/both/configuration/timepoints';
|
||||
const TimepointApi = TimepointsConfiguration.getTimepointsApi();
|
||||
|
||||
Meteor.startup(function() {
|
||||
StudyList.callbacks['dblClickOnStudy'] = dblClickOnStudy;
|
||||
StudyList.callbacks['middleClickOnStudy'] = dblClickOnStudy;
|
||||
|
||||
StudyList.timepointApi = new TimepointApi();
|
||||
StudyList.timepointApi.retrieveTimepoints();
|
||||
});
|
||||
|
||||
/**
|
||||
* Lesion Tracker method including Timepoints / other studies
|
||||
*/
|
||||
function dblClickOnStudy(data) {
|
||||
// Use the formatPN template helper to clean up the patient name
|
||||
let title = formatPN(data.patientName);
|
||||
|
||||
const instance = Template.instance();
|
||||
|
||||
// Find the relevant timepoint given the clicked-on study
|
||||
const timepointApi = StudyList.timepointApi;
|
||||
if (!timepointApi) {
|
||||
console.log('No timepoint api on dbl-clicked study?');
|
||||
return;
|
||||
}
|
||||
|
||||
const timepoint = timepointApi.study(data.studyInstanceUid)[0];
|
||||
if (timepoint) {
|
||||
// Add the Timepoint name to the Patient name to create the tab title
|
||||
title += ' ' + timepointApi.name(timepoint);
|
||||
openNewTabWithTimepoint(timepoint.timepointId, title);
|
||||
} else {
|
||||
open(data.studyInstanceUid, title);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a study
|
||||
*
|
||||
* @param studyInstanceUid The UID of the Study to be opened
|
||||
* @param title The title to be used for the tab heading
|
||||
*/
|
||||
function open(studyInstanceUid, title) {
|
||||
const contentid = 'viewerTab';
|
||||
|
||||
ViewerData = window.ViewerData || ViewerData;
|
||||
|
||||
// Update the ViewerData global object
|
||||
ViewerData[contentid] = {
|
||||
title: title,
|
||||
contentid: contentid,
|
||||
studyInstanceUids: [studyInstanceUid]
|
||||
};
|
||||
|
||||
// Switch to the new tab
|
||||
switchToTab(contentid);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
function toolDataExists(toolState, imageId, toolType) {
|
||||
const currentToolState = toolState[imageId][toolType];
|
||||
return (currentToolState && currentToolState.data && currentToolState.data.length);
|
||||
}
|
||||
|
||||
syncMeasurementAndToolData = function(measurement) {
|
||||
log.info('syncMeasurementAndToolData');
|
||||
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
const imageId = measurement.imageId;
|
||||
const toolType = measurement.toolType;
|
||||
|
||||
// If no tool state exists for this imageId, create an empty object to store it
|
||||
if (!toolState[imageId]) {
|
||||
toolState[imageId] = {};
|
||||
}
|
||||
|
||||
// Check if we already have toolData for this imageId and toolType
|
||||
if (toolDataExists(toolState, imageId, toolType)) {
|
||||
// If we have toolData, we should search it for any toolData
|
||||
// related to the current Measurement
|
||||
const toolData = toolState[imageId][toolType].data;
|
||||
|
||||
// Create a flag so we know if we have successfully updated
|
||||
// this Measurement's in the toolData
|
||||
let alreadyExists = false;
|
||||
|
||||
// Loop through the toolData to search for this Measurement
|
||||
toolData.forEach(function(tool) {
|
||||
// Break the loop if this isn't the Measurement we are looking for
|
||||
if (tool._id !== measurement._id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we have found the Measurement, set the flag to True
|
||||
alreadyExists = true;
|
||||
|
||||
// Update the toolData from the Measurement data
|
||||
$.extend(tool, measurement);
|
||||
return false;
|
||||
});
|
||||
|
||||
// If we have found the Measurement we intended to update, we can stop
|
||||
// this function here
|
||||
if (alreadyExists === true) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// If no toolData exists for this toolType, create an empty array to hold some
|
||||
toolState[imageId][toolType] = {
|
||||
data: []
|
||||
};
|
||||
}
|
||||
|
||||
// If we have reached this point, it means we haven't found the Measurement we are
|
||||
// looking for in the current toolData. This means we need to add it.
|
||||
|
||||
// Add the MeasurementData into the toolData for this imageId
|
||||
toolState[imageId][toolType].data.push(measurement);
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Show / hide lesion tracker tools
|
||||
*/
|
||||
|
||||
var previousStates;
|
||||
var previousActiveTool;
|
||||
|
||||
var toolsShown = true;
|
||||
|
||||
toggleLesionTrackerTools = function() {
|
||||
if (toolsShown === true) {
|
||||
// Save the current settings for later
|
||||
previousStates = toolManager.getToolDefaultStates();
|
||||
previousActiveTool = toolManager.getActiveTool();
|
||||
|
||||
// Hide the tools (set them all to disabled)
|
||||
var toolDefaultStates = {
|
||||
activate: [ 'deleteLesionKeyboardTool' ],
|
||||
deactivate: [],
|
||||
enable: [],
|
||||
disable: [ 'bidirectional', 'nonTarget', 'length', 'crTool', 'unTool', 'exTool' ]
|
||||
};
|
||||
|
||||
toolManager.setToolDefaultStates(toolDefaultStates);
|
||||
|
||||
// Using setActiveTool with no arguments activates the
|
||||
// default tool on all available viewports
|
||||
toolManager.setActiveTool();
|
||||
|
||||
toolsShown = false;
|
||||
} else {
|
||||
// Show the tools (reload previous states)
|
||||
toolManager.setToolDefaultStates(previousStates);
|
||||
|
||||
// Using setActiveTool with no elements specified activates
|
||||
// the specified tool on all available viewports
|
||||
toolManager.setActiveTool(previousActiveTool);
|
||||
|
||||
toolsShown = true;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
// Create package logger using loglevel
|
||||
// https://atmospherejs.com/spacejamio/loglevel
|
||||
log = loglevel.createPackageLogger('lesiontracker', defaultLevel = 'info');
|
||||
@@ -0,0 +1,135 @@
|
||||
Package.describe({
|
||||
name: 'ohif:lesiontracker',
|
||||
summary: 'OHIF Lesion Tracker Tools',
|
||||
version: '0.0.1'
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
api.versionsFrom('1.4');
|
||||
|
||||
api.use('ecmascript');
|
||||
api.use('standard-app-packages');
|
||||
api.use('jquery');
|
||||
api.use('stylus');
|
||||
api.use('random');
|
||||
|
||||
api.use('validatejs');
|
||||
|
||||
// Control over logging
|
||||
api.use('practicalmeteor:loglevel');
|
||||
|
||||
// Template overriding
|
||||
api.use('aldeed:template-extension@4.0.0');
|
||||
|
||||
// Our custom packages
|
||||
api.use('design');
|
||||
api.use('ohif:core');
|
||||
api.use('ohif:study-list');
|
||||
api.use('ohif:cornerstone');
|
||||
api.use('ohif:measurements');
|
||||
|
||||
api.addFiles('log.js', [ 'client', 'server' ]);
|
||||
|
||||
api.addFiles('both/configuration/bidirectional.js', [ 'client', 'server' ]);
|
||||
api.addFiles('both/configuration/nonTarget.js', [ 'client', 'server' ]);
|
||||
api.addFiles('both/configuration/ellipse.js', [ 'client', 'server' ]);
|
||||
api.addFiles('both/configuration/length.js', [ 'client', 'server' ]);
|
||||
api.addFiles('both/configuration/measurementTools.js', [ 'client', 'server' ]);
|
||||
|
||||
api.addFiles('both/configuration/dataExchange.js', [ 'client', 'server' ]);
|
||||
api.addFiles('both/configuration/dataValidation.js', [ 'client', 'server' ]);
|
||||
api.addFiles('both/configuration/configuration.js', [ 'client', 'server' ]);
|
||||
|
||||
|
||||
api.addFiles('server/methods.js', 'server');
|
||||
|
||||
|
||||
// Client-side collections
|
||||
api.addFiles('client/collections/LesionLocations.js', 'client');
|
||||
api.addFiles('client/collections/LocationResponses.js', 'client');
|
||||
|
||||
// Additional Custom Cornerstone Tools for Lesion Tracker
|
||||
api.addFiles([
|
||||
'client/compatibility/bidirectionalTool.js',
|
||||
'client/compatibility/nonTargetTool.js',
|
||||
'client/compatibility/scaleOverlayTool.js',
|
||||
'client/compatibility/deleteLesionKeyboardTool.js',
|
||||
'client/compatibility/qualitativeTargetTools.js'
|
||||
], 'client', {
|
||||
bare: true
|
||||
});
|
||||
|
||||
api.addFiles('client/tools.js', 'client');
|
||||
|
||||
// UI Components
|
||||
api.addFiles('client/components/optionsModal/optionsModal.html', 'client');
|
||||
api.addFiles('client/components/optionsModal/optionsModal.styl', 'client');
|
||||
api.addFiles('client/components/optionsModal/optionsModal.js', 'client');
|
||||
|
||||
api.addFiles('client/components/optionsModal/recistDescription/recistDescription.html', 'client');
|
||||
api.addFiles('client/components/optionsModal/irRCDescription/irRCDescription.html', 'client');
|
||||
|
||||
api.addFiles('client/components/measurementLocationDialog/measurementLocationDialog.html', 'client');
|
||||
api.addFiles('client/components/measurementLocationDialog/measurementLocationDialog.js', 'client');
|
||||
api.addFiles('client/components/measurementLocationDialog/measurementLocationDialog.styl', 'client');
|
||||
|
||||
api.addFiles('client/components/nonTargetLesionDialog/nonTargetLesionDialog.html', 'client');
|
||||
api.addFiles('client/components/nonTargetLesionDialog/nonTargetLesionDialog.styl', 'client');
|
||||
api.addFiles('client/components/nonTargetLesionDialog/nonTargetLesionDialog.js', 'client');
|
||||
|
||||
api.addFiles('client/components/nonTargetResponseDialog/nonTargetResponseDialog.html', 'client');
|
||||
api.addFiles('client/components/nonTargetResponseDialog/nonTargetResponseDialog.styl', 'client');
|
||||
api.addFiles('client/components/nonTargetResponseDialog/nonTargetResponseDialog.js', 'client');
|
||||
|
||||
api.addFiles('client/components/measureFlow/measureFlow.html', 'client');
|
||||
api.addFiles('client/components/measureFlow/measureFlow.styl', 'client');
|
||||
api.addFiles('client/components/measureFlow/measureFlow.js', 'client');
|
||||
|
||||
// StudyList-related functions
|
||||
api.addFiles('lib/studylist/openNewTabWithTimepoint.js', 'client');
|
||||
api.addFiles('lib/studylist/studylistModification.js', 'client');
|
||||
|
||||
// Library functions
|
||||
api.addFiles('lib/TrialCriteriaConstraints.js', 'client');
|
||||
api.addFiles('lib/MeasurementValidation.js', 'client');
|
||||
|
||||
api.addFiles('lib/pixelSpacingAutorunCheck.js', 'client');
|
||||
api.addFiles('lib/toggleLesionTrackerTools.js', 'client');
|
||||
api.addFiles('lib/clearMeasurementTimepointData.js', 'client');
|
||||
api.addFiles('lib/convertToNonTarget.js', 'client');
|
||||
api.addFiles('lib/convertNonTarget.js', 'client');
|
||||
|
||||
api.addFiles('lib/syncMeasurementAndToolData.js', 'client');
|
||||
|
||||
// Export global functions
|
||||
api.export('pixelSpacingAutorunCheck', 'client');
|
||||
api.export('syncMeasurementAndToolData', 'client');
|
||||
api.export('syncImageMeasurementAndToolData', 'client');
|
||||
api.export('openNewTabWithTimepoint', 'client');
|
||||
api.export('activateLesion', 'client');
|
||||
api.export('activateMeasurements', 'client');
|
||||
api.export('deactivateAllToolData', 'client');
|
||||
api.export('toggleLesionTrackerTools', 'client');
|
||||
api.export('clearMeasurementTimepointData', 'client');
|
||||
api.export('getTrialCriteriaConstraints', 'client');
|
||||
api.export('convertToNonTarget', 'client');
|
||||
api.export('convertNonTarget', 'client');
|
||||
|
||||
// Export global objects
|
||||
api.export('MeasurementValidation', 'client');
|
||||
api.export('TrialCriteriaConstraints', 'client');
|
||||
|
||||
// Export client-side collections
|
||||
api.export('ValidationErrors', 'client');
|
||||
api.export('LesionLocations', 'client');
|
||||
api.export('LocationResponses', 'client');
|
||||
api.export('TrialCriteriaTypes', 'client');
|
||||
|
||||
// Export collections spanning both client and server
|
||||
api.export('AdditionalFindings', [ 'client', 'server' ]);
|
||||
|
||||
// Export utility classes
|
||||
api.export('FormUtils', 'client');
|
||||
|
||||
api.export('Configuration', ['client', 'server']);
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { measurementTools } from 'meteor/ohif:lesiontracker/both/configuration/measurementTools';
|
||||
|
||||
let MeasurementCollections = {};
|
||||
measurementTools.forEach(tool => {
|
||||
MeasurementCollections[tool.id] = new Mongo.Collection(tool.id);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Timepoints = new Mongo.Collection('timepoints');
|
||||
|
||||
// Drop our collections for testing purposes
|
||||
Meteor.startup(() => {
|
||||
Timepoints.remove({});
|
||||
measurementTools.forEach(tool => {
|
||||
MeasurementCollections[tool.id].remove({});
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
// TODO: Make storage use update instead of clearing the entire collection and
|
||||
// re-inserting everything.
|
||||
Meteor.methods({
|
||||
storeTimepoints(timepoints) {
|
||||
console.log('Storing Timepoints on the Server')
|
||||
console.log(JSON.stringify(timepoints, null, 2));
|
||||
Timepoints.remove({});
|
||||
timepoints.forEach(timepoint => {
|
||||
delete timepoint._id;
|
||||
Timepoints.insert(timepoint);
|
||||
});
|
||||
},
|
||||
|
||||
retrieveTimepoints() {
|
||||
console.log('Retrieving Timepoints from the Server');
|
||||
return Timepoints.find().fetch();
|
||||
},
|
||||
|
||||
storeMeasurements(measurementData) {
|
||||
console.log('Storing Measurements on the Server')
|
||||
console.log(JSON.stringify(measurementData, null, 2));
|
||||
|
||||
Object.keys(measurementData).forEach(toolId => {
|
||||
MeasurementCollections[toolId].remove({});
|
||||
|
||||
const measurements = measurementData[toolId];
|
||||
measurements.forEach(measurement => {
|
||||
MeasurementCollections[toolId].insert(measurement);
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
retrieveMeasurements() {
|
||||
console.log('Retrieving Measurements from the Server');
|
||||
let measurementData = {};
|
||||
|
||||
measurementTools.forEach(tool => {
|
||||
measurementData[tool.id] = MeasurementCollections[tool.id].find().fetch();
|
||||
});
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
Meteor.publish('timepoints', function() {
|
||||
return Timepoints.find();
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientTimepoints', function(patientId) {
|
||||
return Timepoints.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('studies', function() {
|
||||
return Studies.find();
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientAssociatedStudies', function(patientId) {
|
||||
return Studies.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientMeasurements', function(patientId) {
|
||||
return Measurements.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientImageMeasurements', function(patientId) {
|
||||
return ImageMeasurements.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('additionalFindings', function() {
|
||||
return AdditionalFindings.find();
|
||||
});
|
||||
|
||||
Meteor.publish('singlePatientAdditionalFindings', function(patientId) {
|
||||
return AdditionalFindings.find({
|
||||
patientId: patientId
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('reviewers', function() {
|
||||
return Reviewers.find();
|
||||
});
|
||||
|
||||
// Temporary fix to drop all Collections on server restart
|
||||
// http://stackoverflow.com/questions/23891631/meteor-how-can-i-drop-all-mongo-collections-and-clear-all-data-on-startup
|
||||
Meteor.startup(function() {
|
||||
for (var property in global) {
|
||||
var object = global[property];
|
||||
if (object instanceof Meteor.Collection) {
|
||||
if (!(/^server|currentServer$/).test(object._name)) {
|
||||
object.remove({});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user