continue consolidating packages, converting various pieces to react
This commit is contained in:
1 parent
5f30f7bd35
commit
7b66dec163
90 files changed
+350
-485
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,15 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Overridable namespace to allow getting study boxes data externally.
|
||||
*
|
||||
* The function must handle the first parameter as a studyInformation object containing at least the
|
||||
* studyInstanceUid attribute.
|
||||
*
|
||||
* Shall return a promise that will be resolved with an object containing those attributes:
|
||||
* - studyInstanceUid {String}: copy of studyInformation.studyInstanceUid
|
||||
* - modalities {String}: 2 uppercase letters for each modality split by any non-alphabetical char(s)
|
||||
* - studyDate {String}: date formatted as YYYYMMDD
|
||||
* - studyDescription {String}: study description string
|
||||
*/
|
||||
OHIF.studies.getStudyBoxData = false;
|
||||
@@ -8,3 +8,11 @@ import './user.js';
|
||||
import './object.js';
|
||||
import './DICOMWeb/';
|
||||
import './getCurrentServer.js';
|
||||
import './DICOMTagDescriptions.js';
|
||||
import './getStudyBoxData';
|
||||
import './loadStudy';
|
||||
import './retrieveStudiesMetadata';
|
||||
import './retrieveStudyMetadata';
|
||||
import './searchStudies';
|
||||
import './parseFloatArray';
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { ReactiveDict } from 'meteor/reactive-dict';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { Meteor } from "meteor/meteor";
|
||||
|
||||
// Create a studies loaded state dictionary to enable reactivity. Values: loading|loaded|failed
|
||||
OHIF.studies.loadingDict = new ReactiveDict();
|
||||
|
||||
/**
|
||||
* 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) => {
|
||||
// Disable reactivity to get the current loading state
|
||||
let currentLoadingState;
|
||||
Tracker.nonreactive(() => {
|
||||
currentLoadingState = OHIF.studies.loadingDict.get(studyInstanceUid) || '';
|
||||
});
|
||||
|
||||
// Set the loading state as the study is not yet loaded
|
||||
if (currentLoadingState !== 'loading') {
|
||||
OHIF.studies.loadingDict.set(studyInstanceUid, 'loading');
|
||||
}
|
||||
|
||||
const studyLoaded = OHIF.viewer.Studies.findBy({ studyInstanceUid: studyInstanceUid });
|
||||
if (studyLoaded) {
|
||||
OHIF.studies.loadingDict.set(studyInstanceUid, 'loaded');
|
||||
resolve(studyLoaded);
|
||||
return;
|
||||
}
|
||||
|
||||
return OHIF.studies.retrieveStudyMetadata(studyInstanceUid).then(study => {
|
||||
if (window.HipaaLogger &&
|
||||
OHIF.user &&
|
||||
OHIF.user.userLoggedIn &&
|
||||
OHIF.user.userLoggedIn()) {
|
||||
window.HipaaLogger.logEvent({
|
||||
eventType: 'viewed',
|
||||
userId: OHIF.user.getUserId(),
|
||||
userName: OHIF.user.getName(),
|
||||
collectionName: 'Study',
|
||||
recordId: studyInstanceUid,
|
||||
patientId: study.patientId,
|
||||
patientName: study.patientName
|
||||
});
|
||||
}
|
||||
|
||||
// Once the data was retrieved, the series are sorted by series and instance number
|
||||
OHIF.viewerbase.sortStudy(study);
|
||||
|
||||
// Updates WADO-RS metaDataManager
|
||||
OHIF.viewerbase.updateMetaDataManager(study);
|
||||
|
||||
// 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);
|
||||
studyMetadata.addDisplaySet(displaySet);
|
||||
});
|
||||
|
||||
// Persist study data into OHIF.viewer
|
||||
OHIF.viewer.Studies.insert(study);
|
||||
OHIF.viewer.StudyMetadataList.insert(study);
|
||||
|
||||
// Add the study to the loading listener to allow loading progress handling
|
||||
const studyLoadingListener = OHIF.viewerbase.StudyLoadingListener.getInstance();
|
||||
studyLoadingListener.addStudy(study);
|
||||
|
||||
// Add the studyInstanceUid to the loaded state dictionary
|
||||
OHIF.studies.loadingDict.set(studyInstanceUid, 'loaded');
|
||||
|
||||
resolve(study);
|
||||
}).catch((...args) => {
|
||||
OHIF.studies.loadingDict.set(studyInstanceUid, 'failed');
|
||||
reject(args);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
export const parseFloatArray = function(obj) {
|
||||
var result = [];
|
||||
|
||||
if (!obj) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var objs = obj.split("\\");
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
result.push(parseFloat(objs[i]));
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Retrieves metaData for multiple studies at once.
|
||||
*
|
||||
* 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
|
||||
* @return Promise
|
||||
*/
|
||||
OHIF.studies.retrieveStudiesMetadata = (studyInstanceUids, seriesInstanceUids) => {
|
||||
// Create an empty array to store the Promises for each metaData retrieval call
|
||||
const promises = [];
|
||||
|
||||
// Loop through the array of studyInstanceUids
|
||||
studyInstanceUids.forEach(function(studyInstanceUid) {
|
||||
// Send the call and resolve or reject the related promise based on its outcome
|
||||
const promise = OHIF.studies.retrieveStudyMetadata(studyInstanceUid, seriesInstanceUids);
|
||||
|
||||
// Add the current promise to the array of promises
|
||||
promises.push(promise);
|
||||
});
|
||||
|
||||
// When all of the promises are complete, this callback runs
|
||||
const promise = Promise.all(promises);
|
||||
|
||||
// Warn the error on console if some retrieval failed
|
||||
promise.catch(error => OHIF.log.warn(error));
|
||||
|
||||
return promise;
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
// 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();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
OHIF.studies.deleteStudyMetadataPromise = (studyInstanceUid) => {
|
||||
if (StudyMetaDataPromises.has(studyInstanceUid)) {
|
||||
StudyMetaDataPromises.delete(studyInstanceUid);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.studies.retrieveStudyMetadata = (studyInstanceUid, seriesInstanceUids) => {
|
||||
|
||||
// @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 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);
|
||||
}
|
||||
|
||||
const seriesKeys = Array.isArray(seriesInstanceUids) ? '|' + seriesInstanceUids.join('|') : '';
|
||||
const timingKey = `retrieveStudyMetadata[${studyInstanceUid}${seriesKeys}]`;
|
||||
OHIF.log.time(timingKey);
|
||||
|
||||
// Create a promise to handle the data retrieval
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const server = OHIF.servers.getCurrentServer();
|
||||
|
||||
// If no study metadata is in the cache variable, we need to retrieve it from
|
||||
// the server with a call.
|
||||
if (server.type === 'dicomWeb' && server.requestOptions.requestFromBrowser === true) {
|
||||
OHIF.studies.services.WADO.RetrieveMetadata(server, studyInstanceUid).then(function (data) {
|
||||
resolve(data)
|
||||
}, reject);
|
||||
}
|
||||
});
|
||||
|
||||
// Store the promise in cache
|
||||
StudyMetaDataPromises.set(studyInstanceUid, promise);
|
||||
|
||||
return promise;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
const studySearchPromises = new Map();
|
||||
|
||||
/**
|
||||
* Search for studies information by the given filter
|
||||
*
|
||||
* @param {Object} filter Filter that will be used on search
|
||||
* @returns {Promise} resolved with an array of studies information or rejected with an error
|
||||
*/
|
||||
OHIF.studies.searchStudies = filter => {
|
||||
const promiseKey = JSON.stringify(filter);
|
||||
if (studySearchPromises.has(promiseKey)) {
|
||||
return studySearchPromises.get(promiseKey);
|
||||
} else {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const server = OHIF.servers.getCurrentServer();
|
||||
|
||||
if (server.type === 'dicomWeb' && server.requestOptions.requestFromBrowser === true) {
|
||||
OHIF.studies.services.QIDO.Studies(server, filter).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
studySearchPromises.set(promiseKey, promise);
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user