ohif-viewer/Packages/ohif-studies/imports/client/lib/loadStudy.js
2017-10-25 22:18:42 -02:00

21 lines
808 B
JavaScript

import { OHIF } from 'meteor/ohif:core';
/**
* Load the study metadata and store its information locally
*
* @param {String} studyInstanceUid The UID of the Study to be loaded
* @returns {Promise} that will be resolved with the study metadata or rejected with an error
*/
OHIF.studies.loadStudy = studyInstanceUid => new Promise((resolve, reject) => {
OHIF.studies.retrieveStudyMetadata(studyInstanceUid).then(study => {
// Double check to make sure this study wasn't already inserted into OHIF.viewer.Studies
// so we don't cause duplicate entry errors
const loaded = OHIF.viewer.Studies.findBy({ studyInstanceUid: study.studyInstanceUid });
if (!loaded) {
OHIF.viewer.Studies.insert(study);
}
resolve(study);
}).catch(reject);
});