From bd748eae32d702dc7e14d0aab50a82d7ad493e40 Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Wed, 28 Dec 2016 11:40:53 -0200 Subject: [PATCH] LT-115: Grouping tools schemas --- .../both/configuration/measurementTools.js | 18 ++++------- .../configuration/toolGroups/nonTargets.js | 20 ++++++++++++ .../both/configuration/toolGroups/targets.js | 22 +++++++++++++ .../both/configuration/toolGroups/temp.js | 21 +++++++++++++ .../{target.js => tools/bidirectional.js} | 31 ++++++++++--------- .../both/configuration/{ => tools}/ellipse.js | 0 .../both/configuration/{ => tools}/length.js | 0 .../configuration/{ => tools}/nonTarget.js | 21 ++++++------- .../configuration/{ => tools}/targetCR.js | 24 +++++++++----- .../configuration/{ => tools}/targetUN.js | 24 +++++++++----- .../both/configuration/measurements.js | 6 ++-- .../components/caseProgress/caseProgress.js | 2 +- .../measurementTableTimepointCell.js | 2 +- .../measurementTableView.html | 2 +- 14 files changed, 134 insertions(+), 59 deletions(-) create mode 100644 Packages/ohif-lesiontracker/both/configuration/toolGroups/nonTargets.js create mode 100644 Packages/ohif-lesiontracker/both/configuration/toolGroups/targets.js create mode 100644 Packages/ohif-lesiontracker/both/configuration/toolGroups/temp.js rename Packages/ohif-lesiontracker/both/configuration/{target.js => tools/bidirectional.js} (80%) rename Packages/ohif-lesiontracker/both/configuration/{ => tools}/ellipse.js (100%) rename Packages/ohif-lesiontracker/both/configuration/{ => tools}/length.js (100%) rename Packages/ohif-lesiontracker/both/configuration/{ => tools}/nonTarget.js (80%) rename Packages/ohif-lesiontracker/both/configuration/{ => tools}/targetCR.js (73%) rename Packages/ohif-lesiontracker/both/configuration/{ => tools}/targetUN.js (73%) diff --git a/Packages/ohif-lesiontracker/both/configuration/measurementTools.js b/Packages/ohif-lesiontracker/both/configuration/measurementTools.js index d444553bc..b9d26d10c 100644 --- a/Packages/ohif-lesiontracker/both/configuration/measurementTools.js +++ b/Packages/ohif-lesiontracker/both/configuration/measurementTools.js @@ -1,15 +1,9 @@ -import { target } from './target'; -import { targetCR } from './targetCR'; -import { targetUN } from './targetUN'; -import { nonTarget } from './nonTarget'; -import { length } from './length'; -import { ellipse } from './ellipse'; +import { targets } from './toolGroups/targets'; +import { nonTargets } from './toolGroups/nonTargets'; +import { temp } from './toolGroups/temp'; export const measurementTools = [ - target, - targetCR, - targetUN, - nonTarget, - length, - ellipse + targets, + nonTargets, + temp ]; diff --git a/Packages/ohif-lesiontracker/both/configuration/toolGroups/nonTargets.js b/Packages/ohif-lesiontracker/both/configuration/toolGroups/nonTargets.js new file mode 100644 index 000000000..452ebffe5 --- /dev/null +++ b/Packages/ohif-lesiontracker/both/configuration/toolGroups/nonTargets.js @@ -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 +}; diff --git a/Packages/ohif-lesiontracker/both/configuration/toolGroups/targets.js b/Packages/ohif-lesiontracker/both/configuration/toolGroups/targets.js new file mode 100644 index 000000000..947fae0a1 --- /dev/null +++ b/Packages/ohif-lesiontracker/both/configuration/toolGroups/targets.js @@ -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 +}; diff --git a/Packages/ohif-lesiontracker/both/configuration/toolGroups/temp.js b/Packages/ohif-lesiontracker/both/configuration/toolGroups/temp.js new file mode 100644 index 000000000..50bbd8e9a --- /dev/null +++ b/Packages/ohif-lesiontracker/both/configuration/toolGroups/temp.js @@ -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 +}; diff --git a/Packages/ohif-lesiontracker/both/configuration/target.js b/Packages/ohif-lesiontracker/both/configuration/tools/bidirectional.js similarity index 80% rename from Packages/ohif-lesiontracker/both/configuration/target.js rename to Packages/ohif-lesiontracker/both/configuration/tools/bidirectional.js index 9f3fb7541..11ddd9556 100644 --- a/Packages/ohif-lesiontracker/both/configuration/target.js +++ b/Packages/ohif-lesiontracker/both/configuration/tools/bidirectional.js @@ -3,7 +3,7 @@ import { MeasurementSchemaTypes } from 'meteor/ohif:measurements/both/schema/mea const CornerstoneHandleSchema = MeasurementSchemaTypes.CornerstoneHandleSchema; -const TargetHandlesSchema = new SimpleSchema({ +const BidirectionalHandlesSchema = new SimpleSchema({ start: { type: CornerstoneHandleSchema, label: 'Start' @@ -26,11 +26,15 @@ const TargetHandlesSchema = new SimpleSchema({ }, }); -const TargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, { +const BidirectionalSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolMeasurement, { handles: { - type: TargetHandlesSchema, + type: BidirectionalHandlesSchema, label: 'Handles' }, + measurementNumber: { + type: Number, + label: 'Measurement Number' + }, location: { type: String, 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 // const targetType = 'target'; // const nodalType = data.isNodal ? 'nodal' : 'extraNodal'; @@ -79,19 +83,18 @@ function displayFunction(data) { } return data.longestDiameter; -} +}; -export const target = { - id: 'targets', - name: 'Targets', +export const bidirectional = { + toolGroup: 'targets', cornerstoneToolType: 'bidirectional', - schema: TargetSchema, + schema: BidirectionalSchema, options: { - showInMeasurementTable: true, - measurementTableOptions: { - key: 'targets', - displayFunction: displayFunction + measurementTable: { + displayFunction }, - includeInCaseProgress: true, + caseProgress: { + include: true + } } }; diff --git a/Packages/ohif-lesiontracker/both/configuration/ellipse.js b/Packages/ohif-lesiontracker/both/configuration/tools/ellipse.js similarity index 100% rename from Packages/ohif-lesiontracker/both/configuration/ellipse.js rename to Packages/ohif-lesiontracker/both/configuration/tools/ellipse.js diff --git a/Packages/ohif-lesiontracker/both/configuration/length.js b/Packages/ohif-lesiontracker/both/configuration/tools/length.js similarity index 100% rename from Packages/ohif-lesiontracker/both/configuration/length.js rename to Packages/ohif-lesiontracker/both/configuration/tools/length.js diff --git a/Packages/ohif-lesiontracker/both/configuration/nonTarget.js b/Packages/ohif-lesiontracker/both/configuration/tools/nonTarget.js similarity index 80% rename from Packages/ohif-lesiontracker/both/configuration/nonTarget.js rename to Packages/ohif-lesiontracker/both/configuration/tools/nonTarget.js index fd622a81f..064105a8c 100644 --- a/Packages/ohif-lesiontracker/both/configuration/nonTarget.js +++ b/Packages/ohif-lesiontracker/both/configuration/tools/nonTarget.js @@ -23,6 +23,10 @@ const NonTargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneTool type: NonTargetHandlesSchema, label: 'Handles' }, + measurementNumber: { + type: Number, + label: 'Measurement Number' + }, response: { type: String, label: 'Response', @@ -40,21 +44,16 @@ const NonTargetSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneTool } }]); -function displayFunction(data) { - return data.response; -} - export const nonTarget = { - id: 'nonTargets', - name: 'Non-Targets', + toolGroup: 'nonTargets', cornerstoneToolType: 'nonTarget', schema: NonTargetSchema, - displayFunction: displayFunction, options: { - showInMeasurementTable: true, - measurementTableOptions: { - displayFunction: displayFunction + measurementTable: { + displayFunction: data => data.response }, - includeInCaseProgress: true, + caseProgress: { + include: true + } } }; diff --git a/Packages/ohif-lesiontracker/both/configuration/targetCR.js b/Packages/ohif-lesiontracker/both/configuration/tools/targetCR.js similarity index 73% rename from Packages/ohif-lesiontracker/both/configuration/targetCR.js rename to Packages/ohif-lesiontracker/both/configuration/tools/targetCR.js index 0800324ff..048d12e56 100644 --- a/Packages/ohif-lesiontracker/both/configuration/targetCR.js +++ b/Packages/ohif-lesiontracker/both/configuration/tools/targetCR.js @@ -23,11 +23,20 @@ const TargetCRSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM type: TargetCRHandlesSchema, label: 'Handles' }, + measurementNumber: { + type: Number, + label: 'Measurement Number' + }, location: { type: String, label: 'Location', optional: true }, + response: { + type: String, + label: 'Response', + optional: true // Optional because it is added after initial drawing, via a callback + }, description: { type: String, label: 'Description', @@ -40,17 +49,16 @@ const TargetCRSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM } }]); -function displayFunction(data) { - return data.location; -} - export const targetCR = { - id: 'targetsCR', - memberOf: 'targets', - name: 'CR Targets', + toolGroup: 'targets', cornerstoneToolType: 'targetCR', schema: TargetCRSchema, options: { - includeInCaseProgress: true, + measurementTable: { + displayFunction: data => data.response + }, + caseProgress: { + include: true + } } }; diff --git a/Packages/ohif-lesiontracker/both/configuration/targetUN.js b/Packages/ohif-lesiontracker/both/configuration/tools/targetUN.js similarity index 73% rename from Packages/ohif-lesiontracker/both/configuration/targetUN.js rename to Packages/ohif-lesiontracker/both/configuration/tools/targetUN.js index 9ab8963ed..08d13ad3b 100644 --- a/Packages/ohif-lesiontracker/both/configuration/targetUN.js +++ b/Packages/ohif-lesiontracker/both/configuration/tools/targetUN.js @@ -23,11 +23,20 @@ const TargetUNSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM type: TargetUNHandlesSchema, label: 'Handles' }, + measurementNumber: { + type: Number, + label: 'Measurement Number' + }, location: { type: String, label: 'Location', optional: true }, + response: { + type: String, + label: 'Response', + optional: true // Optional because it is added after initial drawing, via a callback + }, description: { type: String, label: 'Description', @@ -40,17 +49,16 @@ const TargetUNSchema = new SimpleSchema([MeasurementSchemaTypes.CornerstoneToolM } }]); -function displayFunction(data) { - return data.location; -} - export const targetUN = { - id: 'targetsUN', - memberOf: 'targets', - name: 'UN Targets', + toolGroup: 'targets', cornerstoneToolType: 'targetUN', schema: TargetUNSchema, options: { - includeInCaseProgress: true, + measurementTable: { + displayFunction: data => data.response + }, + caseProgress: { + include: true + } } }; diff --git a/Packages/ohif-measurements/both/configuration/measurements.js b/Packages/ohif-measurements/both/configuration/measurements.js index f7862450a..1f6dda8e3 100644 --- a/Packages/ohif-measurements/both/configuration/measurements.js +++ b/Packages/ohif-measurements/both/configuration/measurements.js @@ -134,7 +134,7 @@ class MeasurementApi { $nin: numbers } }; - + return collection.find(filter).fetch(); } @@ -144,7 +144,7 @@ class MeasurementApi { const hasNoDataAtTimepoint = this.hasNoDataAtTimepoint; 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; @@ -227,7 +227,7 @@ class MeasurementApi { // 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 - includedTools.forEach(tool => { + includedTools.forEach(tool => { const collection = this[tool.id]; const toolType = tool.cornerstoneToolType; const measurements = hasNoDataAtTimepoint(collection, baselineTimepointId); diff --git a/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js b/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js index 852f83fc0..b8ef8e05b 100644 --- a/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js +++ b/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js @@ -66,7 +66,7 @@ Template.caseProgress.onRendered(() => { const config = OHIF.measurements.MeasurementApi.getConfiguration(); 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 api = instance.data.measurementApi; diff --git a/Packages/ohif-measurements/client/components/measurementTable/measurementTableTimepointCell/measurementTableTimepointCell.js b/Packages/ohif-measurements/client/components/measurementTable/measurementTableTimepointCell/measurementTableTimepointCell.js index d52ba6d23..b64d0ae03 100644 --- a/Packages/ohif-measurements/client/components/measurementTable/measurementTableTimepointCell/measurementTableTimepointCell.js +++ b/Packages/ohif-measurements/client/components/measurementTable/measurementTableTimepointCell/measurementTableTimepointCell.js @@ -37,7 +37,7 @@ Template.measurementTableTimepointCell.helpers({ // TODO: Figure out what is going on here? console.warn('Something went wrong?'); } - const displayFunction = tool.options.measurementTableOptions.displayFunction; + const displayFunction = tool.options.measurementTable.displayFunction; return displayFunction(data); } }); diff --git a/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.html b/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.html index 343b8f81f..83b94ced1 100644 --- a/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.html +++ b/Packages/ohif-measurements/client/components/measurementTable/measurementTableView/measurementTableView.html @@ -2,7 +2,7 @@
{{#let config=measurementConfiguration}} {{#each measurementType in config.measurementTools}} - {{#if measurementType.options.showInMeasurementTable}} + {{#if measurementType.options.measurementTable.displayFunction}} {{#let collection=(groupByMeasurementNumber measurementType.id)}} {{>measurementTableHeaderRow measurementType=measurementType