* modified * new files in existing extensions/libraries/modes * fixed bugs and tests * Clean up * fix: viewport display fixed * Fixed configs for deployment * Removed unnecessary files and functions * Fixed default HP module * Added white labelling * Fixed hash routing * Removed unnecessary routers Co-authored-by: Alireza Sedghi <ar.sedghi@gmail.com>
78 lines
2.5 KiB
JavaScript
78 lines
2.5 KiB
JavaScript
import RetrieveMetadata from './wado/retrieveMetadata.js';
|
|
|
|
const moduleName = 'RetrieveStudyMetadata';
|
|
// Cache for promises. Prevents unnecessary subsequent calls to the server
|
|
const StudyMetaDataPromises = new Map();
|
|
|
|
/**
|
|
* Retrieves study metadata
|
|
*
|
|
* @param {Object} server Object with server configuration parameters
|
|
* @param {string} StudyInstanceUID The UID of the Study to be retrieved
|
|
* @param {boolean} enabledStudyLazyLoad Whether the study metadata should be loaded asynchronusly.
|
|
* @param {function} storeInstancesCallback A callback used to store the retrieved instance metadata.
|
|
* @param {Object} [filters] - Object containing filters to be applied on retrieve metadata process
|
|
* @param {string} [filter.seriesInstanceUID] - series instance uid to filter results against
|
|
* @returns {Promise} that will be resolved with the metadata or rejected with the error
|
|
*/
|
|
export function retrieveStudyMetadata(
|
|
dicomWebClient,
|
|
StudyInstanceUID,
|
|
enableStudyLazyLoad,
|
|
filters,
|
|
sortCriteria,
|
|
sortFunction
|
|
) {
|
|
// @TODO: Whenever a study metadata request has failed, its related promise will be rejected once and for all
|
|
// and further requests for that metadata will always fail. On failure, we probably need to remove the
|
|
// corresponding promise from the "StudyMetaDataPromises" map...
|
|
|
|
if (!dicomWebClient) {
|
|
throw new Error(
|
|
`${moduleName}: Required 'dicomWebClient' parameter not provided.`
|
|
);
|
|
}
|
|
if (!StudyInstanceUID) {
|
|
throw new Error(
|
|
`${moduleName}: Required 'StudyInstanceUID' parameter not provided.`
|
|
);
|
|
}
|
|
|
|
// Already waiting on result? Return cached promise
|
|
if (StudyMetaDataPromises.has(StudyInstanceUID)) {
|
|
return StudyMetaDataPromises.get(StudyInstanceUID);
|
|
}
|
|
|
|
// Create a promise to handle the data retrieval
|
|
const promise = new Promise((resolve, reject) => {
|
|
RetrieveMetadata(
|
|
dicomWebClient,
|
|
StudyInstanceUID,
|
|
enableStudyLazyLoad,
|
|
filters,
|
|
sortCriteria,
|
|
sortFunction
|
|
).then(function(data) {
|
|
resolve(data);
|
|
}, reject);
|
|
});
|
|
|
|
// Store the promise in cache
|
|
StudyMetaDataPromises.set(StudyInstanceUID, promise);
|
|
|
|
return promise;
|
|
}
|
|
|
|
/**
|
|
* Delete the cached study metadata retrieval promise to ensure that the browser will
|
|
* re-retrieve the study metadata when it is next requested
|
|
*
|
|
* @param {String} StudyInstanceUID The UID of the Study to be removed from cache
|
|
*
|
|
*/
|
|
export function deleteStudyMetadataPromise(StudyInstanceUID) {
|
|
if (StudyMetaDataPromises.has(StudyInstanceUID)) {
|
|
StudyMetaDataPromises.delete(StudyInstanceUID);
|
|
}
|
|
}
|