Fixes for lesion activation and loaded timepoint indicators
This commit is contained in:
parent
97bcb6b6f5
commit
231df3e5b1
@ -7,7 +7,6 @@ Template.viewer.onCreated(function() {
|
||||
ValidationErrors.remove({});
|
||||
|
||||
var self = this;
|
||||
var firstMeasurementsActivated = false;
|
||||
var contentId = this.data.contentId;
|
||||
|
||||
OHIF = OHIF || {
|
||||
@ -192,17 +191,6 @@ Template.viewer.onCreated(function() {
|
||||
// Cornerstone ToolData structure
|
||||
syncMeasurementAndToolData(data);
|
||||
|
||||
// Activate first measurements in image box as default if exists
|
||||
if (!firstMeasurementsActivated) {
|
||||
var templateData = {
|
||||
contentId: Session.get('activeContentId')
|
||||
};
|
||||
|
||||
// Activate measurement
|
||||
activateLesion(data._id, templateData);
|
||||
firstMeasurementsActivated = true;
|
||||
}
|
||||
|
||||
// Update each displayed viewport
|
||||
updateAllViewports();
|
||||
},
|
||||
|
||||
@ -99,6 +99,10 @@ Meteor.methods({
|
||||
|
||||
isPasswordExpired: function(passwordExpirationDays) {
|
||||
var passwordSetDate = Meteor.users.find({_id: Meteor.userId()}).fetch()[0].services.password.setDate;
|
||||
if (!passwordSetDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
passwordSetDate.setDate(passwordSetDate.getDate() + passwordExpirationDays);
|
||||
|
||||
if (passwordSetDate <= new Date()) {
|
||||
@ -135,6 +139,10 @@ Meteor.methods({
|
||||
console.log(currentUser);
|
||||
|
||||
var lastLoginDate = currentUser.lastLoginDate;
|
||||
if (!lastLoginDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(lastLoginDate);
|
||||
lastLoginDate.setDate(lastLoginDate.getDate() + inactivityPeriodDays);
|
||||
console.log(lastLoginDate);
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
{{ #each timepoints }}
|
||||
{{ >lesionTableTimepointHeader }}
|
||||
{{ /each }}
|
||||
<!--What is this for?-->
|
||||
<!--<th id="thSpacer"> </th>-->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@ -11,7 +11,7 @@ Template.lesionTable.helpers({
|
||||
timepoints: function() {
|
||||
return Timepoints.find({}, {
|
||||
sort: {
|
||||
timepointName: 1
|
||||
latestDate: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -68,69 +68,20 @@ Template.lesionTable.onCreated(function() {
|
||||
Session.setDefault('NewSeriesLoaded', false);
|
||||
|
||||
Template.lesionTable.onRendered(function() {
|
||||
var self = this;
|
||||
|
||||
// Track ViewerData to get active timepoints
|
||||
// Put a visual indicator (<) in timepoint header in lesion table for active timepoints
|
||||
// timepointLoaded property is used to put indicator for loaded timepoints in viewport
|
||||
self.autorun(function() {
|
||||
// Temporary until we have a real window manager with events for series/study changed
|
||||
if (!Session.get('NewSeriesLoaded')) {
|
||||
return;
|
||||
// Find the first measurement by Lesion Number
|
||||
var firstLesion = Measurements.findOne({}, {
|
||||
sort: {
|
||||
lesionNumber: 1
|
||||
}
|
||||
|
||||
log.info('ViewerData changed, check for displayed timepoints');
|
||||
|
||||
// Get study dates of imageViewerViewport elements
|
||||
var loadedStudyDates = {
|
||||
patientId: '',
|
||||
dates: []
|
||||
};
|
||||
|
||||
var viewports = $('.imageViewerViewport').not('.empty');
|
||||
viewports.each(function(index, element) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
if (!enabledElement || !enabledElement.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
var imageId = enabledElement.image.imageId;
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyDate = study.studyDate;
|
||||
loadedStudyDates.patientId = study.patientId;
|
||||
|
||||
// Check whether or not studyDate has been added before
|
||||
if (loadedStudyDates.dates.indexOf(studyDate) < 0) {
|
||||
loadedStudyDates.dates.push(studyDate);
|
||||
}
|
||||
});
|
||||
|
||||
// If study date is loaded into viewport, set timepointLoaded property in Timepoints collection as true
|
||||
// Else set timepointLoaded property as false
|
||||
if (!loadedStudyDates.dates.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var timepoints = Timepoints.find({
|
||||
patientId: loadedStudyDates.patientId
|
||||
}, {
|
||||
reactive: false
|
||||
});
|
||||
|
||||
timepoints.forEach(function(timepoint) {
|
||||
var timepointLoaded = false;
|
||||
if (loadedStudyDates.dates.indexOf(timepoint.timepointName) > -1) {
|
||||
timepointLoaded = true;
|
||||
}
|
||||
|
||||
Timepoints.update(timepoint._id, {
|
||||
$set: {
|
||||
timepointLoaded: timepointLoaded
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Temporary until we have a real window manager with events for series/study changed
|
||||
Session.set('NewSeriesLoaded', false);
|
||||
});
|
||||
|
||||
// Create an object to store the ContentId inside
|
||||
var templateData = {
|
||||
contentId: Session.get('activeContentId')
|
||||
};
|
||||
|
||||
// Activate the first lesion
|
||||
if (firstLesion) {
|
||||
activateLesion(firstLesion._id, templateData);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template name="lesionTableTimepointHeader">
|
||||
<th class="lesionTableTimepointCell" title="Latest study date: {{formatDA latestDate "MM/DD/YYYY"}}"
|
||||
<th class="lesionTableTimepointCell {{ #if isLoaded }}loaded{{/if}}" title="Latest study date: {{formatDA latestDate "MM/DD/YYYY"}}"
|
||||
data-toggle="tooltip" data-placement="top">
|
||||
{{ timepointName }}
|
||||
</th>
|
||||
|
||||
@ -2,5 +2,38 @@ Template.lesionTableTimepointHeader.helpers({
|
||||
'timepointName': function() {
|
||||
var timepoint = this;
|
||||
return getTimepointName(timepoint);
|
||||
},
|
||||
isLoaded: function() {
|
||||
Session.get('NewSeriesLoaded');
|
||||
|
||||
log.info('ViewerData changed, check for displayed timepoints');
|
||||
|
||||
var timepoint = this;
|
||||
|
||||
var isLoaded = false;
|
||||
var viewports = $('.imageViewerViewport').not('.empty');
|
||||
viewports.each(function(index, element) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
if (!enabledElement || !enabledElement.image) {
|
||||
return;
|
||||
}
|
||||
|
||||
var study = cornerstoneTools.metaData.get('study', enabledElement.image.imageId);
|
||||
|
||||
var currentTimepoint = Timepoints.findOne({
|
||||
studyInstanceUids: {
|
||||
$in: [study.studyInstanceUid]
|
||||
}
|
||||
});
|
||||
|
||||
if (currentTimepoint && currentTimepoint._id === timepoint._id) {
|
||||
isLoaded = true;
|
||||
|
||||
// Break the loop
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return isLoaded;
|
||||
}
|
||||
});
|
||||
@ -1,3 +1,3 @@
|
||||
.timepointIndicator
|
||||
font-size 12px
|
||||
line-height 12px
|
||||
#lesionTableContainer .lesionTable thead tr th.lesionTableTimepointCell.loaded
|
||||
//font-weight: bold
|
||||
color: #4fbfff
|
||||
@ -16,34 +16,47 @@ activateLesion = function(measurementId, templateData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the timepoint data from this Measurement
|
||||
var timepoints = measurementData.timepoints;
|
||||
// Create an empty array to store the ordered timepoint data for this
|
||||
// measurement
|
||||
var orderedTimepointEntries = [];
|
||||
|
||||
// Get all non-dummy timepoint entries in the Measurement
|
||||
// TODO=Re-evaluate this approach to populating viewports with timepoints
|
||||
// What is the desired behaviour here?
|
||||
var timepointsWithEntries = [];
|
||||
Object.keys(timepoints).forEach(function(key) {
|
||||
var timepoint = timepoints[key];
|
||||
// Retrieve the Cursor for this patient's Timepoints in ascending order by studyDate
|
||||
var sortedTimepoints = Timepoints.find({}, {
|
||||
sort: {
|
||||
latestDate: 1
|
||||
}
|
||||
})
|
||||
|
||||
if (timepoint.imageId === '' ||
|
||||
timepoint.studyInstanceUid === '' ||
|
||||
timepoint.seriesInstanceUid === '') {
|
||||
// Loop through each timepoint and populate the orderTimepointEntries array with
|
||||
// The measurement data at each timepoint. The most recent measurements will be first in
|
||||
// the array.
|
||||
sortedTimepoints.forEach(function(timepoint) {
|
||||
var measurementDataAtTimepoint = measurementData.timepoints[timepoint.timepointId];
|
||||
if (!measurementDataAtTimepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
timepointsWithEntries.push(timepoint);
|
||||
orderedTimepointEntries.push(measurementDataAtTimepoint);
|
||||
});
|
||||
|
||||
// If there are no non-dummy timepoint entries, stop here
|
||||
if (!timepointsWithEntries.length) {
|
||||
// If there is no timepoint data to display for this Measurement, stop here
|
||||
if (!orderedTimepointEntries.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the list of available viewports
|
||||
var viewports = $('.imageViewerViewport').not('.empty');
|
||||
|
||||
// Remove earlier timepoint data entries
|
||||
if (orderedTimepointEntries.length > viewports.length) {
|
||||
var difference = orderedTimepointEntries.length - viewports.length;
|
||||
orderedTimepointEntries.splice(0, difference);
|
||||
}
|
||||
|
||||
// Loop through the viewports and display each timepoint
|
||||
$('.imageViewerViewport').not('.empty').each(function(viewportIndex, element) {
|
||||
viewports.each(function(viewportIndex, element) {
|
||||
// Stop if we run out of timepoints before viewports
|
||||
if (viewportIndex >= timepointsWithEntries.length) {
|
||||
if (viewportIndex >= orderedTimepointEntries.length) {
|
||||
// Update the element anyway, to remove any other highlights that are present
|
||||
deactivateAllToolData(element, 'lesion');
|
||||
deactivateAllToolData(element, 'nonTarget');
|
||||
@ -55,7 +68,7 @@ activateLesion = function(measurementId, templateData) {
|
||||
// Find measurements related to the Nth timepoint
|
||||
// TODO=Re-evaluate this approach to populating viewports with timepoints
|
||||
// What is the desired behaviour here?
|
||||
var measurementAtTimepoint = timepointsWithEntries[viewportIndex];
|
||||
var measurementAtTimepoint = orderedTimepointEntries[viewportIndex];
|
||||
|
||||
// Find the image that is currently in this viewport
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user