Preventing all timepoint studies from being loaded at once

This commit is contained in:
Bruno Alves de Faria 2017-10-06 08:22:08 -03:00
parent 09dc9a4639
commit 956e6da0b3
4 changed files with 74 additions and 37 deletions

View File

@ -193,8 +193,7 @@ class TimepointApi {
// Return only the key timepoints (current, prior, nadir and baseline) // Return only the key timepoints (current, prior, nadir and baseline)
key() { key() {
// Create a new Mini Mongo Collection to store the result const result = [];
const result = new Mongo.Collection(null);
// Get all the timepoints // Get all the timepoints
const all = this.all(); const all = this.all();
@ -202,28 +201,27 @@ class TimepointApi {
// Iterate over each timepoint and insert the key ones in the result // Iterate over each timepoint and insert the key ones in the result
_.each(all, (timepoint, index) => { _.each(all, (timepoint, index) => {
if (index < 2 || index === (all.length - 1)) { if (index < 2 || index === (all.length - 1)) {
result.insert(timepoint); result.push(timepoint);
} }
}); });
// Return the resulting timepoints // Return the resulting timepoints
return result.find().fetch(); return result;
} }
// Return only the timepoints for the given study // Return only the timepoints for the given study
study(studyInstanceUid) { study(studyInstanceUid) {
// Create a new Mini Mongo Collection to store the result const result = [];
const result = new Mongo.Collection(null);
// Iterate over each timepoint and insert the key ones in the result // Iterate over each timepoint and insert the key ones in the result
_.each(this.all(), (timepoint, index) => { _.each(this.all(), (timepoint, index) => {
if (_.contains(timepoint.studyInstanceUids, studyInstanceUid)) { if (_.contains(timepoint.studyInstanceUids, studyInstanceUid)) {
result.insert(timepoint); result.push(timepoint);
} }
}); });
// Return the resulting timepoints // Return the resulting timepoints
return result.find().fetch(); return result;
} }
// Return the timepoint's name // Return the timepoint's name

View File

@ -1,5 +1,31 @@
import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { SimpleSchema } from 'meteor/aldeed:simple-schema';
const StudiesData = new SimpleSchema({
studyInstanceUid: {
type: String,
label: 'Study Instance Uid'
},
description: {
type: String,
label: 'Study Description',
optional: true
},
date: {
type: Date,
label: 'Study Date'
},
modality: {
type: String,
label: 'Study Modality'
},
loaded: {
type: Boolean,
label: 'Defines if the Study is already loaded',
optional: true,
defaultValue: false
}
});
export const schema = new SimpleSchema({ export const schema = new SimpleSchema({
patientId: { patientId: {
type: String, type: String,
@ -36,5 +62,10 @@ export const schema = new SimpleSchema({
type: Number, type: Number,
label: 'Number of patient\'s visit', label: 'Number of patient\'s visit',
optional: true optional: true
},
studiesData: {
type: [StudiesData],
label: 'Studies minimal data to allow lazy loading',
optional: true
} }
}); });

View File

@ -10,14 +10,14 @@ import { OHIF } from 'meteor/ohif:core';
* @return Promise * @return Promise
*/ */
OHIF.studylist.retrieveStudiesMetadata = (studyInstanceUids, seriesInstanceUids, doneCallback, failCallback) => { OHIF.studylist.retrieveStudiesMetadata = (studyInstanceUids, seriesInstanceUids, doneCallback, failCallback) => {
// Check to make sure studyInstanceUids were actually input // // Check to make sure studyInstanceUids were actually input
if (!studyInstanceUids || !studyInstanceUids.length) { // if (!studyInstanceUids || !studyInstanceUids.length) {
if (failCallback && typeof failCallback === 'function') { // if (failCallback && typeof failCallback === 'function') {
failCallback('No studyInstanceUids were input'); // failCallback('No studyInstanceUids were input');
} // }
//
return; // return;
} // }
// Create an empty array to store the Promises for each metaData retrieval call // Create an empty array to store the Promises for each metaData retrieval call
const promises = []; const promises = [];

View File

@ -1,3 +1,4 @@
import { _ } from 'meteor/underscore';
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
/** /**
@ -9,32 +10,37 @@ import { OHIF } from 'meteor/ohif:core';
* @param {Object} timepointsFilter An object containing the filter to retrieve the timepoints * @param {Object} timepointsFilter An object containing the filter to retrieve the timepoints
* @return {Promise} Promise that will be resolved with the studies when the metadata is loaded * @return {Promise} Promise that will be resolved with the studies when the metadata is loaded
*/ */
export const prepareViewerData = ({ studyInstanceUids, seriesInstanceUids, timepointId, timepointsFilter={}}) => { export const prepareViewerData = ({ studyInstanceUids, seriesInstanceUids, timepointId, timepointsFilter={} }) => {
// Clear the cornerstone tool data to sync the measurements with the measurements API // Clear the cornerstone tool data to sync the measurements with the measurements API
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState({}); cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState({});
// Retrieve the studies metadata // Retrieve the studies metadata
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
const processData = viewerData => { const processData = viewerData => {
OHIF.studylist.retrieveStudiesMetadata(viewerData.studyInstanceUids, viewerData.seriesInstanceUids).then(studies => { const studies = [];
// Add additional metadata to our study from the studylist resolve({
studies.forEach(study => { studies,
const studylistStudy = OHIF.studylist.collections.Studies.findOne({ viewerData
studyInstanceUid: study.studyInstanceUid });
}); // OHIF.studylist.retrieveStudiesMetadata(viewerData.studyInstanceUids, viewerData.seriesInstanceUids).then(studies => {
// // Add additional metadata to our study from the studylist
if (!studylistStudy) { // studies.forEach(study => {
return; // const studylistStudy = OHIF.studylist.collections.Studies.findOne({
} // studyInstanceUid: study.studyInstanceUid
// });
Object.assign(study, studylistStudy); //
}); // if (!studylistStudy) {
// return;
resolve({ // }
studies, //
viewerData // Object.assign(study, studylistStudy);
}); // });
}).catch(reject); //
// resolve({
// studies,
// viewerData
// });
// }).catch(reject);
}; };
// Check if the studies are already given and ignore the timepoint ID if so // Check if the studies are already given and ignore the timepoint ID if so
@ -79,7 +85,7 @@ const buildViewerDataFromTimepointId = timepointId => {
* @returns {Object} An object containing the related studies UIDs and timepoint IDs * @returns {Object} An object containing the related studies UIDs and timepoint IDs
*/ */
const getDataFromTimepoint = timepoint => { const getDataFromTimepoint = timepoint => {
let relatedStudies = timepoint.studyInstanceUids; let relatedStudies = _.clone(timepoint.studyInstanceUids);
// If this is the baseline, we should stop here and return the relevant studies // If this is the baseline, we should stop here and return the relevant studies
if (isBaseline(timepoint)) { if (isBaseline(timepoint)) {
@ -117,6 +123,8 @@ const getDataFromTimepoint = timepoint => {
timepointIds.push(prior.timepointId); timepointIds.push(prior.timepointId);
} }
relatedStudies = _.uniq(relatedStudies);
timepointIds.push(timepoint.timepointId); timepointIds.push(timepoint.timepointId);
return { return {