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)
let location;
const previousTimepoint = timepointApi.priorOrBaseline();
const previousGroupEntry = groupCollection.findOne({
timepointId: previousTimepoint.timepointId
const baselineTimepoint = timepointApi.baseline();
const baselineGroupEntry = groupCollection.findOne({
timepointId: baselineTimepoint.timepointId
});
if (previousGroupEntry) {
const tool = this.tools[previousGroupEntry.toolId];
if (baselineGroupEntry) {
const tool = this.tools[baselineGroupEntry.toolId];
const found = tool.findOne({ measurementNumber });
if (found) {
location = found.location;
@ -273,7 +273,7 @@ class MeasurementApi {
});
}
sortMeasurements() {
sortMeasurements(baselineTimepointId) {
const tools = configuration.measurementTools;
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
currentAndPrior() {
const timepoints = [];

View File

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

View File

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

View File

@ -55,26 +55,27 @@ Template.measurementTableView.helpers({
newMeasurements(toolGroup) {
const { measurementApi, timepointApi } = Template.instance().data;
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 (!current || current.timepointType === 'baseline') {
OHIF.log.info('Skipping New Measurements section');
return;
}
// 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 atPrevious = measurementApi.fetch(measurementTypeId, {
timepointId: previous.timepointId
const atBaseline = measurementApi.fetch(measurementTypeId, {
timepointId: baseline.timepointId
});
// Obtain a list of the Measurement Numbers from the
// measurements which have previous timepoint's data
const numbers = atPrevious.map(m => m.measurementNumber);
// measurements which have baseline data
const numbers = atBaseline.map(m => m.measurementNumber);
// Retrieve all the data for this Measurement type which
// do NOT match the Measurement Numbers obtained above

View File

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

View File

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

View File

@ -40,22 +40,22 @@ OHIF.measurements.getMeasurementsGroupedByNumber = (measurementApi, timepointApi
// Create the result object
const groupedMeasurements = [];
const previous = timepointApi.priorOrBaseline();
if (!previous) return;
const baseline = timepointApi.baseline();
if (!baseline) return;
configuration.measurementTools.forEach(toolGroup => {
// Skip this tool group if it should not be displayed
if (!displayToolGroupMap[toolGroup.id]) return;
// Retrieve all the data for this Measurement type (e.g. 'targets')
// which was recorded at previous timepoint.
const atPrevious = measurementApi.fetch(toolGroup.id, {
timepointId: previous.timepointId
// which was recorded at baseline.
const atBaseline = measurementApi.fetch(toolGroup.id, {
timepointId: baseline.timepointId
});
// Obtain a list of the Measurement Numbers from the
// measurements which have previous timepoint's data
const numbers = atPrevious.map(m => m.measurementNumber);
// measurements which have baseline data
const numbers = atBaseline.map(m => m.measurementNumber);
// Retrieve all the data for this Measurement type which
// 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,
// and all studies related to it. We also enforce that the Prior should have a studyDate
// 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 Baseline should have a studyDate
// prior to the latest studyDate in the current (Follow-up) Timepoint.
const Timepoints = OHIF.studylist.timepointApi.timepoints;
const priorTimepoint = Timepoints.findOne({
const baseline = Timepoints.findOne({
timepointType: 'baseline',
patientId: timepoint.patientId,
latestDate: {
$lte: timepoint.latestDate
@ -101,11 +102,11 @@ const getDataFromTimepoint = timepoint => {
});
let timepointIds = [];
if (priorTimepoint) {
relatedStudies = relatedStudies.concat(priorTimepoint.studyInstanceUids);
timepointIds.push(priorTimepoint.timepointId);
if (baseline) {
relatedStudies = relatedStudies.concat(baseline.studyInstanceUids);
timepointIds.push(baseline.timepointId);
} 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);