Fixing metadata issues
This commit is contained in:
1 parent
a742c8036d
commit
19c31ffbb8
14 files changed
+197
-128
No files matched your search
+7
-3
@@ -1,3 +1,8 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { ReactiveDict } from 'meteor/reactive-dict';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.seriesDetailsTable.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
@@ -31,8 +36,7 @@ Template.seriesDetailsTable.onRendered(() => {
|
||||
// Get series list for the study
|
||||
_.map(studies, (selectedStudy, index) => {
|
||||
studies[index].seriesList = [];
|
||||
getStudyMetadata(selectedStudy.studyInstanceUid, study => {
|
||||
|
||||
OHIF.studylist.retrieveStudyMetadata(study => {
|
||||
// Set series list
|
||||
studies[index].seriesList = study.seriesList;
|
||||
studies[index].displaySeriesLoadingText = false;
|
||||
@@ -48,4 +52,4 @@ Template.seriesDetailsTable.helpers({
|
||||
const instance = Template.instance();
|
||||
return instance.selectedStudies.get('studies');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,9 @@
|
||||
import { $ } from 'meteor/jquery';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Retrieves metaData for multiple studies at once.
|
||||
*
|
||||
* This function calls getStudyMetadata several times, asynchronously,
|
||||
* This function calls retrieveStudyMetadata several times, asynchronously,
|
||||
* and waits for all of the results to be returned.
|
||||
*
|
||||
* @param studyInstanceUids The UIDs of the Studies to be retrieved
|
||||
@@ -27,32 +26,21 @@ OHIF.studylist.getStudiesMetadata = (studyInstanceUids, doneCallback, failCallba
|
||||
|
||||
// Loop through the array of studyInstanceUids
|
||||
studyInstanceUids.forEach(function(studyInstanceUid) {
|
||||
// Create a new Deferred to monitor the progress of the asynchronous
|
||||
// metaData retrieval
|
||||
const deferred = new $.Deferred();
|
||||
|
||||
// Send the call, and attach doneCallbacks and failCallbacks
|
||||
// which can resolve or reject the related promise based on its outcome
|
||||
getStudyMetadata(studyInstanceUid, function(study) {
|
||||
deferred.resolve(study);
|
||||
}, function(error) {
|
||||
deferred.reject(error);
|
||||
});
|
||||
const promise = OHIF.studylist.retrieveStudyMetadata(studyInstanceUid);
|
||||
|
||||
// Add the current promise to the array of promises
|
||||
promises.push(deferred.promise());
|
||||
promises.push(promise);
|
||||
});
|
||||
|
||||
// When all of the promises are complete, this callback runs
|
||||
$.when.apply($, promises).done(function() {
|
||||
// Convert the Arguments Array-like Object to an actual array
|
||||
const studies = $.makeArray(arguments);
|
||||
|
||||
Promise.all(promises).then(studies => {
|
||||
// Pass the studies array to the doneCallback, if one exists
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback(studies);
|
||||
}
|
||||
}).fail(function(error) {
|
||||
}).catch(error => {
|
||||
OHIF.log.warn(error);
|
||||
if (failCallback && typeof failCallback === 'function') {
|
||||
failCallback(error);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
|
||||
// DEPRECATED - use OHIF.studylist.retrieveStudyMetadata instead
|
||||
// Define the StudyMetaData object. This is used as a cache
|
||||
// to store study meta data information to prevent unnecessary
|
||||
// calls to the server
|
||||
|
||||
@@ -7,5 +7,6 @@ import './getStudiesMetadata.js';
|
||||
import './importStudies.js';
|
||||
import './openNewTab.js';
|
||||
import './queryStudies.js';
|
||||
import './retrieveStudyMetadata.js';
|
||||
import './studylist.js';
|
||||
import './switchToTab.js';
|
||||
@@ -5,31 +5,26 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
* @param studiesToQuery Studies to query
|
||||
*/
|
||||
queryStudies = function(studiesToQuery, options) {
|
||||
const studiesQueried = [],
|
||||
numberOfStudiesToQuery = studiesToQuery.length,
|
||||
notify = (options || {}).notify || function() { /* noop */ }
|
||||
let studiesQueried = 0;
|
||||
const numberOfStudiesToQuery = studiesToQuery.length;
|
||||
const notify = (options || {}).notify || function() { /* noop */ };
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (studiesToQuery.length < 1) {
|
||||
return reject();
|
||||
}
|
||||
const promises = [];
|
||||
|
||||
studiesToQuery.forEach(function(studyToQuery) {
|
||||
getStudyMetadata(studyToQuery.studyInstanceUid, function(study) {
|
||||
studiesQueried.push(study);
|
||||
|
||||
notify({
|
||||
total: numberOfStudiesToQuery,
|
||||
processed: studiesQueried.length
|
||||
});
|
||||
|
||||
if (studiesQueried.length === numberOfStudiesToQuery) {
|
||||
resolve(studiesQueried);
|
||||
}
|
||||
studiesToQuery.forEach(studyToQuery => {
|
||||
const promise = OHIF.studylist.retrieveStudyMetadata(studyToQuery.studyInstanceUid);
|
||||
promise.then(study => {
|
||||
studiesQueried++;
|
||||
notify({
|
||||
total: numberOfStudiesToQuery,
|
||||
processed: studiesQueried
|
||||
});
|
||||
});
|
||||
promises.push(promise);
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
};
|
||||
|
||||
queryStudiesWithProgress = function(studiesToQuery) {
|
||||
return OHIF.ui.showDialog('dialogProgress', {
|
||||
@@ -60,7 +55,7 @@ queryStudiesWithProgress = function(studiesToQuery) {
|
||||
* @returns {number}
|
||||
*/
|
||||
getNumberOfFilesInStudy = function(study) {
|
||||
var numberOFFilesToExport = 0;
|
||||
let numberOFFilesToExport = 0;
|
||||
|
||||
study.seriesList.forEach(function(series) {
|
||||
series.instances.forEach(function(instance) {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
|
||||
// Define the StudyMetaDataPromises object. This is used as a cache to store study meta data
|
||||
// promises and prevent unnecessary subsequent calls to the server
|
||||
const StudyMetaDataPromises = new Map();
|
||||
|
||||
/**
|
||||
* Retrieves study metadata using a server call
|
||||
*
|
||||
* @param {String} studyInstanceUid The UID of the Study to be retrieved
|
||||
* @returns {Promise} that will be resolved with the metadata or rejected with the error
|
||||
*/
|
||||
OHIF.studylist.retrieveStudyMetadata = studyInstanceUid => {
|
||||
// If the StudyMetaDataPromises cache already has a pending or resolved promise related to the
|
||||
// given studyInstanceUid, then that promise is returned
|
||||
if (StudyMetaDataPromises.has(studyInstanceUid)) {
|
||||
return StudyMetaDataPromises.get(studyInstanceUid);
|
||||
}
|
||||
|
||||
console.time('retrieveStudyMetadata');
|
||||
|
||||
// Create a promise to handle the data retrieval
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
// If no study metadata is in the cache variable, we need to retrieve it from
|
||||
// the server with a call.
|
||||
Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) {
|
||||
console.timeEnd('retrieveStudyMetadata');
|
||||
|
||||
if (Meteor.user && Meteor.user()) {
|
||||
HipaaLogger.logEvent({
|
||||
eventType: 'viewed',
|
||||
userId: Meteor.userId(),
|
||||
userName: Meteor.user().profile.fullName,
|
||||
collectionName: 'Study',
|
||||
recordId: studyInstanceUid,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
});
|
||||
}
|
||||
|
||||
if (error) {
|
||||
OHIF.log.warn(error);
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!study) {
|
||||
throw new Meteor.Error('GetStudyMetadata', 'No study data returned from server');
|
||||
}
|
||||
|
||||
// Once the data was retrieved, the series are sorted by series and instance number
|
||||
OHIF.viewerbase.sortStudy(study);
|
||||
|
||||
// Add additional metadata to our study from the studylist
|
||||
const studylistStudy = StudyListStudies.findOne({
|
||||
studyInstanceUid: study.studyInstanceUid
|
||||
});
|
||||
|
||||
if (!studylistStudy) {
|
||||
// return;
|
||||
} else {
|
||||
Object.assign(study, studylistStudy);
|
||||
}
|
||||
|
||||
// Transform the study in a StudyMetadata object
|
||||
const studyMetadata = new OHIF.metadata.StudyMetadata(study);
|
||||
|
||||
// Add the display sets to the study
|
||||
study.displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(studyMetadata);
|
||||
study.displaySets.forEach(displaySet => {
|
||||
OHIF.viewerbase.stackManager.makeAndAddStack(study, displaySet);
|
||||
});
|
||||
|
||||
// Resolve the promise with the final study metadata object
|
||||
resolve(study);
|
||||
});
|
||||
});
|
||||
|
||||
// Store the promise in cache
|
||||
StudyMetaDataPromises.set(studyInstanceUid, promise);
|
||||
|
||||
return promise;
|
||||
};
|
||||
Reference in new issue
Block a user