Preventing all timepoint studies from being loaded at once
This commit is contained in:
parent
09dc9a4639
commit
956e6da0b3
@ -193,8 +193,7 @@ class TimepointApi {
|
||||
|
||||
// Return only the key timepoints (current, prior, nadir and baseline)
|
||||
key() {
|
||||
// Create a new Mini Mongo Collection to store the result
|
||||
const result = new Mongo.Collection(null);
|
||||
const result = [];
|
||||
|
||||
// Get all the timepoints
|
||||
const all = this.all();
|
||||
@ -202,28 +201,27 @@ class TimepointApi {
|
||||
// Iterate over each timepoint and insert the key ones in the result
|
||||
_.each(all, (timepoint, index) => {
|
||||
if (index < 2 || index === (all.length - 1)) {
|
||||
result.insert(timepoint);
|
||||
result.push(timepoint);
|
||||
}
|
||||
});
|
||||
|
||||
// Return the resulting timepoints
|
||||
return result.find().fetch();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return only the timepoints for the given study
|
||||
study(studyInstanceUid) {
|
||||
// Create a new Mini Mongo Collection to store the result
|
||||
const result = new Mongo.Collection(null);
|
||||
const result = [];
|
||||
|
||||
// Iterate over each timepoint and insert the key ones in the result
|
||||
_.each(this.all(), (timepoint, index) => {
|
||||
if (_.contains(timepoint.studyInstanceUids, studyInstanceUid)) {
|
||||
result.insert(timepoint);
|
||||
result.push(timepoint);
|
||||
}
|
||||
});
|
||||
|
||||
// Return the resulting timepoints
|
||||
return result.find().fetch();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return the timepoint's name
|
||||
|
||||
@ -1,5 +1,31 @@
|
||||
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({
|
||||
patientId: {
|
||||
type: String,
|
||||
@ -36,5 +62,10 @@ export const schema = new SimpleSchema({
|
||||
type: Number,
|
||||
label: 'Number of patient\'s visit',
|
||||
optional: true
|
||||
},
|
||||
studiesData: {
|
||||
type: [StudiesData],
|
||||
label: 'Studies minimal data to allow lazy loading',
|
||||
optional: true
|
||||
}
|
||||
});
|
||||
|
||||
@ -10,14 +10,14 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
* @return Promise
|
||||
*/
|
||||
OHIF.studylist.retrieveStudiesMetadata = (studyInstanceUids, seriesInstanceUids, doneCallback, failCallback) => {
|
||||
// Check to make sure studyInstanceUids were actually input
|
||||
if (!studyInstanceUids || !studyInstanceUids.length) {
|
||||
if (failCallback && typeof failCallback === 'function') {
|
||||
failCallback('No studyInstanceUids were input');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// // Check to make sure studyInstanceUids were actually input
|
||||
// if (!studyInstanceUids || !studyInstanceUids.length) {
|
||||
// if (failCallback && typeof failCallback === 'function') {
|
||||
// failCallback('No studyInstanceUids were input');
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Create an empty array to store the Promises for each metaData retrieval call
|
||||
const promises = [];
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { _ } from 'meteor/underscore';
|
||||
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
|
||||
* @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
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState({});
|
||||
|
||||
// Retrieve the studies metadata
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const processData = viewerData => {
|
||||
OHIF.studylist.retrieveStudiesMetadata(viewerData.studyInstanceUids, viewerData.seriesInstanceUids).then(studies => {
|
||||
// Add additional metadata to our study from the studylist
|
||||
studies.forEach(study => {
|
||||
const studylistStudy = OHIF.studylist.collections.Studies.findOne({
|
||||
studyInstanceUid: study.studyInstanceUid
|
||||
});
|
||||
|
||||
if (!studylistStudy) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.assign(study, studylistStudy);
|
||||
});
|
||||
|
||||
resolve({
|
||||
studies,
|
||||
viewerData
|
||||
});
|
||||
}).catch(reject);
|
||||
const studies = [];
|
||||
resolve({
|
||||
studies,
|
||||
viewerData
|
||||
});
|
||||
// OHIF.studylist.retrieveStudiesMetadata(viewerData.studyInstanceUids, viewerData.seriesInstanceUids).then(studies => {
|
||||
// // Add additional metadata to our study from the studylist
|
||||
// studies.forEach(study => {
|
||||
// const studylistStudy = OHIF.studylist.collections.Studies.findOne({
|
||||
// studyInstanceUid: study.studyInstanceUid
|
||||
// });
|
||||
//
|
||||
// if (!studylistStudy) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Object.assign(study, studylistStudy);
|
||||
// });
|
||||
//
|
||||
// resolve({
|
||||
// studies,
|
||||
// viewerData
|
||||
// });
|
||||
// }).catch(reject);
|
||||
};
|
||||
|
||||
// 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
|
||||
*/
|
||||
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 (isBaseline(timepoint)) {
|
||||
@ -117,6 +123,8 @@ const getDataFromTimepoint = timepoint => {
|
||||
timepointIds.push(prior.timepointId);
|
||||
}
|
||||
|
||||
relatedStudies = _.uniq(relatedStudies);
|
||||
|
||||
timepointIds.push(timepoint.timepointId);
|
||||
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user