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:
Erik Ziegler committed 2016-11-15 08:21:46 +01:00
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,
},
}