Creating a method to check if a measurement is a new lesion

This commit is contained in:
Bruno Alves de Faria 2018-01-03 10:11:04 -02:00
parent f8b732d81e
commit 40693f08d8
2 changed files with 36 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import './getLocationLabel';
import './getTimepointName';
import './getToolConfiguration';
import './hangingProtocolCustomizations';
import './isNewLesionsMeasurement';
import './MeasurementHandlers';
import './MeasurementManager';
import './navigateOverLesions';

View File

@ -0,0 +1,35 @@
import { OHIF } from 'meteor/ohif:core';
import { _ } from 'meteor/underscore';
/**
* Check if the given measurement is a new lesion
*
* @param measurementData Measurement that will be checked
* @returns {Boolean} Boolean value telling if the given measurement is a new lesion or not
*/
OHIF.measurements.isNewLesionsMeasurement = measurementData => {
if (!measurementData) return;
const { timepointApi, measurementApi } = OHIF.viewer;
const { timepointId, toolType } = measurementData;
const toolConfig = OHIF.measurements.getToolConfiguration(toolType);
// Stop here if the needed information is not set
if (!measurementApi || !timepointApi || !timepointId || !toolConfig) return;
const { toolGroupId } = toolConfig;
const current = timepointApi.timepoints.findOne({ timepointId });
const baseline = timepointApi.baseline();
// Stop here if there's no current or baseline timepoints, or if the current is the baseline
if (!current || !baseline || current.timepointType === 'baseline') return false;
// Retrieve all the data for the given tool group (e.g. 'targets')
const atBaseline = measurementApi.fetch(toolGroupId, { timepointId: baseline.timepointId });
// Obtain a list of the Measurement Numbers from the measurements which have baseline data
const numbers = atBaseline.map(m => m.measurementNumber);
// Return true if the measurement number from follow-up is not present at baseline
return !_.contains(numbers, measurementData.measurementNumber);
};