LT-115: Grouping tools schemas

This commit is contained in:
Bruno Alves de Faria committed 2017-01-02 16:32:09 -02:00
1 parent 0e857d3520
commit bd748eae32
14 files changed
+134 -59

No files matched your search

@@ -1,15 +1,9 @@
import { target } from './target'; import { targets } from './toolGroups/targets';
import { targetCR } from './targetCR'; import { nonTargets } from './toolGroups/nonTargets';
import { targetUN } from './targetUN'; import { temp } from './toolGroups/temp';
import { nonTarget } from './nonTarget';
import { length } from './length';
import { ellipse } from './ellipse';
export const measurementTools = [ export const measurementTools = [
target, targets,
targetCR, nonTargets,
targetUN, temp
nonTarget,
length,
ellipse
]; ];
@@ -0,0 +1,20 @@
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { nonTarget } from '../tools/nonTarget';
const NonTargetSchema = new SimpleSchema({
toolId: {
type: String,
label: 'Tool ID'
},
toolItemUid: {
type: String,
label: 'Tool Item UID'
}
});
export const nonTargets = {
id: 'nonTargets',
name: 'Non-Targets',
childTools: [nonTarget],
schema: NonTargetSchema
};
@@ -0,0 +1,22 @@
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { bidirectional } from '../tools/bidirectional';
import { targetCR } from '../tools/targetCR';
import { targetUN } from '../tools/targetUN';
const TargetSchema = new SimpleSchema({
toolId: {
type: String,
label: 'Tool ID'
},
toolItemUid: {
type: String,
label: 'Tool Item UID'
}
});
export const targets = {
id: 'targets',
name: 'Targets',
childTools: [bidirectional, targetCR, targetUN],
schema: TargetSchema
};
@@ -0,0 +1,21 @@
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { length } from '../tools/length';
import { ellipse } from '../tools/ellipse';
const TempSchema = new SimpleSchema({
toolId: {
type: String,
label: 'Tool ID'
},
toolItemUid: {
type: String,
label: 'Tool Item UID'
}
});
export const temp = {
id: 'temp',
name: 'Temporary',
childTools: [length, ellipse],
schema: TempSchema
};
@@ -3,7 +3,7 @@ import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/mea
const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema; const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema;
const TargetHandlesSchema = new SimpleSchema({ const BidirectionalHandlesSchema = new SimpleSchema({
start: { start: {
type: CornerstoneHandleSchema, type: CornerstoneHandleSchema,
label: 'Start' label: 'Start'
@@ -26,11 +26,15 @@ const TargetHandlesSchema = new SimpleSchema({
}, },
}); });
const TargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, { const BidirectionalSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, {
handles: { handles: {
type: TargetHandlesSchema, type: BidirectionalHandlesSchema,
label: 'Handles' label: 'Handles'
}, },
measurementNumber: {
type: Number,
label: 'Measurement Number'
},
location: { location: {
type: String, type: String,
label: 'Location', label: 'Location',
@@ -58,7 +62,7 @@ const TargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMea
} }
}]); }]);
function displayFunction(data) { const displayFunction = data => {
// Check whether this is a Nodal or Extranodal Measurement // Check whether this is a Nodal or Extranodal Measurement
// const targetType = 'target'; // const targetType = 'target';
// const nodalType = data.isNodal ? 'nodal' : 'extraNodal'; // const nodalType = data.isNodal ? 'nodal' : 'extraNodal';
@@ -79,19 +83,18 @@ function displayFunction(data) {
} }
return data.longestDiameter; return data.longestDiameter;
} };
export const target = { export const bidirectional = {
id: 'targets', toolGroup: 'targets',
name: 'Targets',
cornerstoneToolType: 'bidirectional', cornerstoneToolType: 'bidirectional',
schema: TargetSchema, schema: BidirectionalSchema,
options: { options: {
showInMeasurementTable: true, measurementTable: {
measurementTableOptions: { displayFunction
key: 'targets',
displayFunction: displayFunction
}, },
includeInCaseProgress: true, caseProgress: {
include: true
}
} }
}; };
@@ -23,6 +23,10 @@ const NonTargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneTool
type: NonTargetHandlesSchema, type: NonTargetHandlesSchema,
label: 'Handles' label: 'Handles'
}, },
measurementNumber: {
type: Number,
label: 'Measurement Number'
},
response: { response: {
type: String, type: String,
label: 'Response', label: 'Response',
@@ -40,21 +44,16 @@ const NonTargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneTool
} }
}]); }]);
function displayFunction(data) {
return data.response;
}
export const nonTarget = { export const nonTarget = {
id: 'nonTargets', toolGroup: 'nonTargets',
name: 'Non-Targets',
cornerstoneToolType: 'nonTarget', cornerstoneToolType: 'nonTarget',
schema: NonTargetSchema, schema: NonTargetSchema,
displayFunction: displayFunction,
options: { options: {
showInMeasurementTable: true, measurementTable: {
measurementTableOptions: { displayFunction: data => data.response
displayFunction: displayFunction
}, },
includeInCaseProgress: true, caseProgress: {
include: true
}
} }
}; };
@@ -23,11 +23,20 @@ const TargetCRSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM
type: TargetCRHandlesSchema, type: TargetCRHandlesSchema,
label: 'Handles' label: 'Handles'
}, },
measurementNumber: {
type: Number,
label: 'Measurement Number'
},
location: { location: {
type: String, type: String,
label: 'Location', label: 'Location',
optional: true optional: true
}, },
response: {
type: String,
label: 'Response',
optional: true // Optional because it is added after initial drawing, via a callback
},
description: { description: {
type: String, type: String,
label: 'Description', label: 'Description',
@@ -40,17 +49,16 @@ const TargetCRSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM
} }
}]); }]);
function displayFunction(data) {
return data.location;
}
export const targetCR = { export const targetCR = {
id: 'targetsCR', toolGroup: 'targets',
memberOf: 'targets',
name: 'CR Targets',
cornerstoneToolType: 'targetCR', cornerstoneToolType: 'targetCR',
schema: TargetCRSchema, schema: TargetCRSchema,
options: { options: {
includeInCaseProgress: true, measurementTable: {
displayFunction: data => data.response
},
caseProgress: {
include: true
}
} }
}; };
@@ -23,11 +23,20 @@ const TargetUNSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM
type: TargetUNHandlesSchema, type: TargetUNHandlesSchema,
label: 'Handles' label: 'Handles'
}, },
measurementNumber: {
type: Number,
label: 'Measurement Number'
},
location: { location: {
type: String, type: String,
label: 'Location', label: 'Location',
optional: true optional: true
}, },
response: {
type: String,
label: 'Response',
optional: true // Optional because it is added after initial drawing, via a callback
},
description: { description: {
type: String, type: String,
label: 'Description', label: 'Description',
@@ -40,17 +49,16 @@ const TargetUNSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM
} }
}]); }]);
function displayFunction(data) {
return data.location;
}
export const targetUN = { export const targetUN = {
id: 'targetsUN', toolGroup: 'targets',
memberOf: 'targets',
name: 'UN Targets',
cornerstoneToolType: 'targetUN', cornerstoneToolType: 'targetUN',
schema: TargetUNSchema, schema: TargetUNSchema,
options: { options: {
includeInCaseProgress: true, measurementTable: {
displayFunction: data => data.response
},
caseProgress: {
include: true
}
} }
}; };
@@ -134,7 +134,7 @@ class MeasurementApi {
$nin: numbers $nin: numbers
} }
}; };
return collection.find(filter).fetch(); return collection.find(filter).fetch();
} }
@@ -144,7 +144,7 @@ class MeasurementApi {
const hasNoDataAtTimepoint = this.hasNoDataAtTimepoint; const hasNoDataAtTimepoint = this.hasNoDataAtTimepoint;
const includedTools = tools.filter(tool => { const includedTools = tools.filter(tool => {
return (tool.options && tool.options.includeInCaseProgress === true); return (tool.options && tool.options.caseProgress && tool.options.caseProgress.include);
}); });
let overallMeasurementNumber = 1; let overallMeasurementNumber = 1;
@@ -227,7 +227,7 @@ class MeasurementApi {
// Next, handle New Measurements (i.e. no baseline data) // Next, handle New Measurements (i.e. no baseline data)
// Note that this cannot be combined with the loop above due to the incrementing of the overallMeasurementNumber // Note that this cannot be combined with the loop above due to the incrementing of the overallMeasurementNumber
includedTools.forEach(tool => { includedTools.forEach(tool => {
const collection = this[tool.id]; const collection = this[tool.id];
const toolType = tool.cornerstoneToolType; const toolType = tool.cornerstoneToolType;
const measurements = hasNoDataAtTimepoint(collection, baselineTimepointId); const measurements = hasNoDataAtTimepoint(collection, baselineTimepointId);
@@ -66,7 +66,7 @@ Template.caseProgress.onRendered(() => {
const config = OHIF.measurements.MeasurementApi.getConfiguration(); const config = OHIF.measurements.MeasurementApi.getConfiguration();
const tools = config.measurementTools; const tools = config.measurementTools;
const toolsToInclude = tools.filter(tool => tool.options && tool.options.includeInCaseProgress); const toolsToInclude = tools.filter(tool => tool.options && tool.options.caseProgress && tool.options.caseProgress.include);
const toolIds = toolsToInclude.map(tool => tool.id); const toolIds = toolsToInclude.map(tool => tool.id);
const api = instance.data.measurementApi; const api = instance.data.measurementApi;
@@ -37,7 +37,7 @@ Template.measurementTableTimepointCell.helpers({
// TODO: Figure out what is going on here? // TODO: Figure out what is going on here?
console.warn('Something went wrong?'); console.warn('Something went wrong?');
} }
const displayFunction = tool.options.measurementTableOptions.displayFunction; const displayFunction = tool.options.measurementTable.displayFunction;
return displayFunction(data); return displayFunction(data);
} }
}); });
@@ -2,7 +2,7 @@
<div class="measurementTableView scrollArea"> <div class="measurementTableView scrollArea">
{{#let config=measurementConfiguration}} {{#let config=measurementConfiguration}}
{{#each measurementType in config.measurementTools}} {{#each measurementType in config.measurementTools}}
{{#if measurementType.options.showInMeasurementTable}} {{#if measurementType.options.measurementTable.displayFunction}}
{{#let collection=(groupByMeasurementNumber measurementType.id)}} {{#let collection=(groupByMeasurementNumber measurementType.id)}}
{{>measurementTableHeaderRow {{>measurementTableHeaderRow
measurementType=measurementType measurementType=measurementType