Fixing issues on timepoints order hanging

This commit is contained in:
Bruno Alves de Faria 2017-11-01 10:35:03 -02:00
parent b4327eb457
commit c42722192b
3 changed files with 23 additions and 14 deletions

View File

@ -16,11 +16,12 @@ class TimepointApi {
return configuration; return configuration;
} }
constructor(currentTimepointId, configuration) { constructor(currentTimepointId, options={}) {
if (currentTimepointId) { if (currentTimepointId) {
this.currentTimepointId = currentTimepointId; this.currentTimepointId = currentTimepointId;
} }
this.options = options;
this.timepoints = new Mongo.Collection(null); this.timepoints = new Mongo.Collection(null);
this.timepoints.attachSchema(TimepointSchema); this.timepoints.attachSchema(TimepointSchema);
this.timepoints._debugName = 'Timepoints'; this.timepoints._debugName = 'Timepoints';
@ -161,7 +162,7 @@ class TimepointApi {
}); });
} }
// Return only the current and prior Timepoints // Return only the current and prior timepoints
currentAndPrior() { currentAndPrior() {
const timepoints = []; const timepoints = [];
@ -178,6 +179,11 @@ class TimepointApi {
return timepoints; return timepoints;
} }
// Return only the comparison timepoints
comparison() {
return this.currentAndPrior();
}
// Return only the baseline timepoint // Return only the baseline timepoint
baseline() { baseline() {
return this.timepoints.findOne({ timepointType: 'baseline' }); return this.timepoints.findOne({ timepointType: 'baseline' });

View File

@ -21,7 +21,7 @@ Template.measurementTable.onCreated(() => {
} else if (tableLayout === 'key') { } else if (tableLayout === 'key') {
timepoints = timepointApi.key(); timepoints = timepointApi.key();
} else { } else {
timepoints = timepointApi.currentAndPrior(); timepoints = timepointApi.comparison();
} }
// Return key timepoints // Return key timepoints

View File

@ -66,8 +66,16 @@ OHIF.measurements.jumpToRowItem = (rowItem, timepoints) => {
const $viewports = $('.imageViewerViewport'); const $viewports = $('.imageViewerViewport');
const numViewports = Math.max($viewports.length, 0); const numViewports = Math.max($viewports.length, 0);
// Clone the timepoint list to prevent modifying the original object
const timepointList = _.clone(timepoints);
// Reverse the timepointList array if the flag is set
if (OHIF.viewer.invertViewportTimepointsOrder) {
timepointList.reverse();
}
// Retrieve the timepoints that are currently being displayed in the Measurement Table // Retrieve the timepoints that are currently being displayed in the Measurement Table
const numTimepoints = Math.max(timepoints.length, 1); const numTimepoints = Math.max(timepointList.length, 1);
const numViewportsToUpdate = Math.min(numTimepoints, numViewports); const numViewportsToUpdate = Math.min(numTimepoints, numViewports);
@ -75,10 +83,13 @@ OHIF.measurements.jumpToRowItem = (rowItem, timepoints) => {
const measurementsData = []; const measurementsData = [];
const promises = new Set(); const promises = new Set();
for (let i = 0; i < numViewportsToUpdate; i++) { for (let i = 0; i < numViewportsToUpdate; i++) {
const { timepointId } = timepoints[i]; const { timepointId } = timepointList[i];
const dataAtThisTimepoint = _.where(rowItem.entries, { timepointId }); const dataAtThisTimepoint = _.where(rowItem.entries, { timepointId });
if (!dataAtThisTimepoint || !dataAtThisTimepoint.length) continue; if (!dataAtThisTimepoint || !dataAtThisTimepoint.length) {
measurementsData.push(null);
continue;
}
const measurementData = dataAtThisTimepoint[0]; const measurementData = dataAtThisTimepoint[0];
measurementsData.push(measurementData); measurementsData.push(measurementData);
@ -99,14 +110,6 @@ OHIF.measurements.jumpToRowItem = (rowItem, timepoints) => {
// Deactivate stack synchronizer because it will be re-activated later // Deactivate stack synchronizer because it will be re-activated later
OHIF.viewer.stackImagePositionOffsetSynchronizer.deactivate(); OHIF.viewer.stackImagePositionOffsetSynchronizer.deactivate();
// Display timepoints in the order of viewports which is set by the hanging protocol
// Reverse the array if the first timepoint does not match with the first viewport data
const layoutManager = OHIF.viewerbase.layoutManager;
const viewportData = layoutManager.viewportData[0];
if (timepoints[0].studyInstanceUids.indexOf(viewportData.studyInstanceUid) < 0) {
timepoints.reverse();
}
const renderPromises = []; const renderPromises = [];
for (let viewportIndex = 0; viewportIndex < numViewportsToUpdate; viewportIndex++) { for (let viewportIndex = 0; viewportIndex < numViewportsToUpdate; viewportIndex++) {
const measurementData = measurementsData[viewportIndex]; const measurementData = measurementsData[viewportIndex];