2017-01-18 13:59:09 +01:00
|
|
|
import { Template } from 'meteor/templating';
|
|
|
|
|
import { OHIF } from 'meteor/ohif:core';
|
2017-02-16 00:02:30 +01:00
|
|
|
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
2016-06-28 15:15:06 +02:00
|
|
|
|
2016-08-15 15:34:36 +02:00
|
|
|
Template.measurementTableHeaderRow.helpers({
|
2018-01-26 22:10:50 +01:00
|
|
|
numberOfMeasurements(toolGroupId) {
|
|
|
|
|
const { toolGroup, measurementRows } = Template.instance().data;
|
|
|
|
|
if (toolGroup.id === 'newTargets') {
|
|
|
|
|
let result = 0;
|
|
|
|
|
|
|
|
|
|
measurementRows.forEach(measurementRow => {
|
|
|
|
|
const measurementData = measurementRow.entries[0];
|
|
|
|
|
if (measurementData.isSplitLesion) return;
|
|
|
|
|
result++;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-23 23:04:42 +01:00
|
|
|
return measurementRows.length ? measurementRows.length : null;
|
2016-08-15 11:29:49 +02:00
|
|
|
},
|
|
|
|
|
|
2017-09-20 21:22:17 +02:00
|
|
|
getMax(toolGroupId) {
|
2017-01-23 23:04:42 +01:00
|
|
|
const { conformanceCriteria } = Template.instance().data;
|
|
|
|
|
if (!conformanceCriteria) return;
|
2017-01-18 13:59:09 +01:00
|
|
|
|
2017-09-20 21:22:17 +02:00
|
|
|
if (toolGroupId === 'targets') {
|
|
|
|
|
return conformanceCriteria.maxTargets.get();
|
|
|
|
|
} else if (toolGroupId === 'newTargets') {
|
|
|
|
|
return conformanceCriteria.maxNewTargets.get();
|
|
|
|
|
}
|
2016-08-15 11:29:49 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
anyUnmarkedLesionsLeft() {
|
2016-11-12 17:52:12 +01:00
|
|
|
// Skip New Lesions section
|
2016-08-15 15:34:36 +02:00
|
|
|
const instance = Template.instance();
|
2017-01-23 23:04:42 +01:00
|
|
|
const { toolGroup, measurementRows, timepointApi, measurementApi } = instance.data;
|
2017-09-20 19:09:10 +02:00
|
|
|
if (!measurementRows) return;
|
2016-11-12 17:52:12 +01:00
|
|
|
|
|
|
|
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
2017-09-20 19:09:10 +02:00
|
|
|
if (config.newLesions && config.newLesions.find(o => o.id === toolGroup.id)) return;
|
2016-08-15 11:29:49 +02:00
|
|
|
|
2017-01-18 13:59:09 +01:00
|
|
|
const current = timepointApi.current();
|
|
|
|
|
const prior = timepointApi.prior();
|
2017-09-20 19:09:10 +02:00
|
|
|
if (!prior) return true;
|
2016-11-06 21:08:04 +01:00
|
|
|
|
|
|
|
|
const currentFilter = { timepointId: current.timepointId };
|
|
|
|
|
const priorFilter = { timepointId: prior.timepointId };
|
2017-01-23 23:04:42 +01:00
|
|
|
const toolGroupId = toolGroup.id;
|
2016-11-06 21:08:04 +01:00
|
|
|
|
2017-01-23 23:04:42 +01:00
|
|
|
const numCurrent = measurementApi.fetch(toolGroupId, currentFilter).length;
|
|
|
|
|
const numPrior = measurementApi.fetch(toolGroupId, priorFilter).length;
|
2016-11-06 21:08:04 +01:00
|
|
|
const remaining = Math.max(numPrior - numCurrent, 0);
|
|
|
|
|
return remaining > 0;
|
2016-06-07 19:09:47 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-15 15:34:36 +02:00
|
|
|
Template.measurementTableHeaderRow.events({
|
2016-08-15 11:29:49 +02:00
|
|
|
'click .js-setTool'(event, instance) {
|
2017-01-23 23:04:42 +01:00
|
|
|
const { toolGroup } = instance.data;
|
2017-12-11 19:21:39 +01:00
|
|
|
const toolType = toolGroup.childTools[0].cornerstoneToolType;
|
|
|
|
|
const activeToolId = Array.isArray(toolType) ? toolType[0] : toolType;
|
|
|
|
|
Viewerbase.toolManager.setActiveTool(activeToolId);
|
2016-06-07 19:09:47 +02:00
|
|
|
}
|
2016-06-28 15:15:06 +02:00
|
|
|
});
|