LT-323: First measurement is activated on Case Load
This commit is contained in:
parent
880569196a
commit
de86d4141f
@ -2,6 +2,7 @@ import { Template } from 'meteor/templating';
|
|||||||
import { Session } from 'meteor/session';
|
import { Session } from 'meteor/session';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
|
Session.set('ViewerMainReady', false);
|
||||||
Session.set('TimepointsReady', false);
|
Session.set('TimepointsReady', false);
|
||||||
Session.set('MeasurementsReady', false);
|
Session.set('MeasurementsReady', false);
|
||||||
|
|
||||||
@ -116,6 +117,55 @@ Template.viewer.onCreated(() => {
|
|||||||
// Disable Lesion Tracker Tools if the opened study is not associated
|
// Disable Lesion Tracker Tools if the opened study is not associated
|
||||||
OHIF.lesiontracker.toggleLesionTrackerToolsButtons(false);
|
OHIF.lesiontracker.toggleLesionTrackerToolsButtons(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instance.autorun(() => {
|
||||||
|
if (!Session.get('TimepointsReady') ||
|
||||||
|
!Session.get('MeasurementsReady') ||
|
||||||
|
!Session.get('ViewerMainReady')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find and activate the first measurement by Lesion Number
|
||||||
|
// NOTE: This is inefficient, we should be using a hanging protocol
|
||||||
|
// to hang the first measurement's imageId immediately, rather
|
||||||
|
// than changing images after initial loading...
|
||||||
|
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
||||||
|
const measurementTypeId = config.measurementTools[0].id;
|
||||||
|
const measurementApi = instance.data.measurementApi;
|
||||||
|
const timepointApi = instance.data.timepointApi;
|
||||||
|
|
||||||
|
const collection = measurementApi[measurementTypeId];
|
||||||
|
const sorting = {
|
||||||
|
sort: {
|
||||||
|
measurementNumber: -1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = collection.find({}, sorting).fetch();
|
||||||
|
|
||||||
|
let timepoints = [timepointApi.current()];
|
||||||
|
const prior = timepointApi.prior();
|
||||||
|
if (prior) {
|
||||||
|
timepoints.push(prior);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Clean this up, it's probably an inefficient way to get what we need
|
||||||
|
const groupObject = _.groupBy(data, m => m.measurementNumber);
|
||||||
|
|
||||||
|
// Reformat the data
|
||||||
|
const rows = Object.keys(groupObject).map(key => ({
|
||||||
|
measurementTypeId: measurementTypeId,
|
||||||
|
measurementNumber: key,
|
||||||
|
entries: groupObject[key]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const rowItem = rows[0];
|
||||||
|
|
||||||
|
// Activate the first lesion
|
||||||
|
if (rowItem) {
|
||||||
|
OHIF.measurements.jumpToRowItem(rowItem, timepoints);
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.viewer.helpers({
|
Template.viewer.helpers({
|
||||||
@ -138,3 +188,9 @@ Template.viewer.events({
|
|||||||
OHIF.measurements.MeasurementHandlers.onRemoved(event, instance, eventData);
|
OHIF.measurements.MeasurementHandlers.onRemoved(event, instance, eventData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Template.viewer.onDestroyed(() => {
|
||||||
|
Session.set('ViewerMainReady', false);
|
||||||
|
Session.set('TimepointsReady', false);
|
||||||
|
Session.set('MeasurementsReady', false);
|
||||||
|
});
|
||||||
@ -48,45 +48,6 @@ Template.measurementTable.onRendered(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.measurementTable.onRendered(() => {
|
|
||||||
// Find and activate the first measurement by Lesion Number
|
|
||||||
// NOTE: This is inefficient, we should be using a hanging protocol
|
|
||||||
// to hang the first measurement's imageId immediately, rather
|
|
||||||
// than changing images after initial loading...
|
|
||||||
const instance = Template.instance();
|
|
||||||
|
|
||||||
const config = OHIF.measurements.MeasurementApi.getConfiguration();
|
|
||||||
const measurementTypeId = config.measurementTools[0].id;
|
|
||||||
const measurementApi = instance.data.measurementApi;
|
|
||||||
const collection = measurementApi[measurementTypeId];
|
|
||||||
const sorting = {
|
|
||||||
sort: {
|
|
||||||
measurementNumber: -1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const data = collection.find({}, sorting).fetch();
|
|
||||||
|
|
||||||
const timepoints = instance.data.timepoints.get();
|
|
||||||
|
|
||||||
// TODO: Clean this up, it's probably an inefficient way to get what we need
|
|
||||||
const groupObject = _.groupBy(data, entry => entry.measurementNumber);
|
|
||||||
|
|
||||||
// Reformat the data
|
|
||||||
const rows = Object.keys(groupObject).map(key => ({
|
|
||||||
measurementTypeId: measurementTypeId,
|
|
||||||
measurementNumber: key,
|
|
||||||
entries: groupObject[key]
|
|
||||||
}));
|
|
||||||
|
|
||||||
const rowItem = rows[0];
|
|
||||||
|
|
||||||
// Activate the first lesion
|
|
||||||
if (rowItem) {
|
|
||||||
OHIF.measurements.jumpToRowItem(rowItem, timepoints);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Template.measurementTable.helpers({
|
Template.measurementTable.helpers({
|
||||||
buttonGroupData() {
|
buttonGroupData() {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
|
|||||||
@ -71,11 +71,11 @@ OHIF.measurements.jumpToRowItem = (rowItem, timepoints) => {
|
|||||||
|
|
||||||
// Retrieve the timepoints that are currently being displayed in the
|
// Retrieve the timepoints that are currently being displayed in the
|
||||||
// Measurement Table
|
// Measurement Table
|
||||||
const numTimepoints = timepoints.length;
|
const numTimepoints = Math.max(timepoints.length, 1);
|
||||||
|
|
||||||
// Retrieve the list of available viewports
|
// Retrieve the list of available viewports
|
||||||
const $viewports = $('.imageViewerViewport');
|
const $viewports = $('.imageViewerViewport');
|
||||||
const numViewports = $viewports.length;
|
const numViewports = Math.max($viewports.length, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Two Timepoints, Two measurements, load Followup (FU and BA), display FU in left and BA in right
|
Two Timepoints, Two measurements, load Followup (FU and BA), display FU in left and BA in right
|
||||||
|
|||||||
@ -37,6 +37,8 @@ Template.viewerMain.onRendered(() => {
|
|||||||
|
|
||||||
// Enable hotkeys
|
// Enable hotkeys
|
||||||
enableHotkeys();
|
enableHotkeys();
|
||||||
|
|
||||||
|
Session.set('ViewerMainReady', Random.id());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user