Reverting wrong logic for baseline time points

This commit is contained in:
Bruno Alves de Faria 2017-09-15 08:21:47 -03:00
parent 45d660636b
commit 29a8a3db8f
9 changed files with 35 additions and 39 deletions

View File

@ -86,12 +86,12 @@ class MeasurementApi {
// Get the current location (if already defined) // Get the current location (if already defined)
let location; let location;
const previousTimepoint = timepointApi.priorOrBaseline(); const baselineTimepoint = timepointApi.baseline();
const previousGroupEntry = groupCollection.findOne({ const baselineGroupEntry = groupCollection.findOne({
timepointId: previousTimepoint.timepointId timepointId: baselineTimepoint.timepointId
}); });
if (previousGroupEntry) { if (baselineGroupEntry) {
const tool = this.tools[previousGroupEntry.toolId]; const tool = this.tools[baselineGroupEntry.toolId];
const found = tool.findOne({ measurementNumber }); const found = tool.findOne({ measurementNumber });
if (found) { if (found) {
location = found.location; location = found.location;
@ -273,7 +273,7 @@ class MeasurementApi {
}); });
} }
sortMeasurements() { sortMeasurements(baselineTimepointId) {
const tools = configuration.measurementTools; const tools = configuration.measurementTools;
const includedTools = tools.filter(tool => { const includedTools = tools.filter(tool => {

View File

@ -167,11 +167,6 @@ class TimepointApi {
}); });
} }
// Return the prior timepoint or baseline if not found
priorOrBaseline() {
return this.prior() || this.baseline();
}
// Return only the current and prior Timepoints // Return only the current and prior Timepoints
currentAndPrior() { currentAndPrior() {
const timepoints = []; const timepoints = [];

View File

@ -83,8 +83,8 @@ Template.measurementTableRow.events({
measurementApi.deleteMeasurements(measurementTypeId, { measurementNumber }); measurementApi.deleteMeasurements(measurementTypeId, { measurementNumber });
// Sync the new measurement data with cornerstone tools // Sync the new measurement data with cornerstone tools
const previous = timepointApi.priorOrBaseline(); const baseline = timepointApi.baseline();
measurementApi.sortMeasurements(previous.timepointId); measurementApi.sortMeasurements(baseline.timepointId);
// Repaint the images on all viewports without the removed measurements // Repaint the images on all viewports without the removed measurements
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element)); _.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));

View File

@ -111,8 +111,8 @@ Template.measurementTableTimepointCell.events({
}); });
// Sync the new measurement data with cornerstone tools // Sync the new measurement data with cornerstone tools
const previous = timepointApi.priorOrBaseline(); const baseline = timepointApi.baseline();
measurementApi.sortMeasurements(previous.timepointId); measurementApi.sortMeasurements(baseline.timepointId);
// Repaint the images on all viewports without the removed measurements // Repaint the images on all viewports without the removed measurements
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element)); _.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));

View File

@ -55,26 +55,27 @@ Template.measurementTableView.helpers({
newMeasurements(toolGroup) { newMeasurements(toolGroup) {
const { measurementApi, timepointApi } = Template.instance().data; const { measurementApi, timepointApi } = Template.instance().data;
const current = timepointApi.current(); const current = timepointApi.current();
const previous = timepointApi.priorOrBaseline(); const baseline = timepointApi.baseline();
if (!measurementApi || !timepointApi || !current || !previous) return; if (!measurementApi || !timepointApi || !current || !baseline) return;
// If this is a baseline, stop here since there are no new measurements to display // If this is a baseline, stop here since there are no new measurements to display
if (!current || current.timepointType === 'baseline') { if (!current || current.timepointType === 'baseline') {
OHIF.log.info('Skipping New Measurements section'); OHIF.log.info('Skipping New Measurements section');
return; return;
} }
// Retrieve all the data for this Measurement type (e.g. 'targets') // Retrieve all the data for this Measurement type (e.g. 'targets')
// which was recorded at previous timepoint. // which was recorded at baseline.
const measurementTypeId = toolGroup.measurementTypeId; const measurementTypeId = toolGroup.measurementTypeId;
const atPrevious = measurementApi.fetch(measurementTypeId, { const atBaseline = measurementApi.fetch(measurementTypeId, {
timepointId: previous.timepointId timepointId: baseline.timepointId
}); });
// Obtain a list of the Measurement Numbers from the // Obtain a list of the Measurement Numbers from the
// measurements which have previous timepoint's data // measurements which have baseline data
const numbers = atPrevious.map(m => m.measurementNumber); const numbers = atBaseline.map(m => m.measurementNumber);
// Retrieve all the data for this Measurement type which // Retrieve all the data for this Measurement type which
// do NOT match the Measurement Numbers obtained above // do NOT match the Measurement Numbers obtained above

View File

@ -26,7 +26,6 @@ export class BaseCriterion {
if (options.newTarget) { if (options.newTarget) {
_.each(data.targets, target => { _.each(data.targets, target => {
const { measurementNumber } = target.measurement; const { measurementNumber } = target.measurement;
// FIXME we might not have the baseline timepoint
if (target.timepoint.timepointType === 'baseline') { if (target.timepoint.timepointType === 'baseline') {
baselineMeasurementNumbers.push(measurementNumber); baselineMeasurementNumbers.push(measurementNumber);
} }

View File

@ -139,8 +139,8 @@ class MeasurementHandlers {
}); });
// Sync the new measurement data with cornerstone tools // Sync the new measurement data with cornerstone tools
const previous = timepointApi.priorOrBaseline(); const baseline = timepointApi.baseline();
measurementApi.sortMeasurements(previous.timepointId); measurementApi.sortMeasurements(baseline.timepointId);
// Repaint the images on all viewports without the removed measurements // Repaint the images on all viewports without the removed measurements
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element)); _.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));

View File

@ -40,22 +40,22 @@ OHIF.measurements.getMeasurementsGroupedByNumber = (measurementApi, timepointApi
// Create the result object // Create the result object
const groupedMeasurements = []; const groupedMeasurements = [];
const previous = timepointApi.priorOrBaseline(); const baseline = timepointApi.baseline();
if (!previous) return; if (!baseline) return;
configuration.measurementTools.forEach(toolGroup => { configuration.measurementTools.forEach(toolGroup => {
// Skip this tool group if it should not be displayed // Skip this tool group if it should not be displayed
if (!displayToolGroupMap[toolGroup.id]) return; if (!displayToolGroupMap[toolGroup.id]) return;
// Retrieve all the data for this Measurement type (e.g. 'targets') // Retrieve all the data for this Measurement type (e.g. 'targets')
// which was recorded at previous timepoint. // which was recorded at baseline.
const atPrevious = measurementApi.fetch(toolGroup.id, { const atBaseline = measurementApi.fetch(toolGroup.id, {
timepointId: previous.timepointId timepointId: baseline.timepointId
}); });
// Obtain a list of the Measurement Numbers from the // Obtain a list of the Measurement Numbers from the
// measurements which have previous timepoint's data // measurements which have baseline data
const numbers = atPrevious.map(m => m.measurementNumber); const numbers = atBaseline.map(m => m.measurementNumber);
// Retrieve all the data for this Measurement type which // Retrieve all the data for this Measurement type which
// match the Measurement Numbers obtained above // match the Measurement Numbers obtained above

View File

@ -89,11 +89,12 @@ const getDataFromTimepoint = timepoint => {
}; };
} }
// Otherwise, this is a follow-up exam, so we should also find the prior timepoint, // Otherwise, this is a follow-up exam, so we should also find the baseline timepoint,
// and all studies related to it. We also enforce that the Prior should have a studyDate // and all studies related to it. We also enforce that the Baseline should have a studyDate
// prior to the latest studyDate in the current (Follow-up) Timepoint. // prior to the latest studyDate in the current (Follow-up) Timepoint.
const Timepoints = OHIF.studylist.timepointApi.timepoints; const Timepoints = OHIF.studylist.timepointApi.timepoints;
const priorTimepoint = Timepoints.findOne({ const baseline = Timepoints.findOne({
timepointType: 'baseline',
patientId: timepoint.patientId, patientId: timepoint.patientId,
latestDate: { latestDate: {
$lte: timepoint.latestDate $lte: timepoint.latestDate
@ -101,11 +102,11 @@ const getDataFromTimepoint = timepoint => {
}); });
let timepointIds = []; let timepointIds = [];
if (priorTimepoint) { if (baseline) {
relatedStudies = relatedStudies.concat(priorTimepoint.studyInstanceUids); relatedStudies = relatedStudies.concat(baseline.studyInstanceUids);
timepointIds.push(priorTimepoint.timepointId); timepointIds.push(baseline.timepointId);
} else { } else {
OHIF.log.warn('No prior Timepoint found while opening a Follow-up Timepoint'); OHIF.log.warn('No Baseline found while opening a Follow-up Timepoint');
} }
timepointIds.push(timepoint.timepointId); timepointIds.push(timepoint.timepointId);