Isolating ohif:study-list package from measurements and lesiontracker
This commit is contained in:
1 parent
ddc45df4bd
commit
fda272fd7d
14 files changed
+89
-76
No files matched your search
@@ -0,0 +1,75 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
|
||||
// Important metadata classes
|
||||
const { OHIFError, metadata } = OHIF.viewerbase;
|
||||
const { StudySummary, StudyMetadata } = metadata;
|
||||
|
||||
export class OHIFStudyMetadataSource extends OHIF.viewerbase.StudyMetadataSource {
|
||||
|
||||
/**
|
||||
* Get study metadata for a study with given study InstanceUID
|
||||
* @param {String} studyInstanceUID Study InstanceUID
|
||||
* @return {Promise} A Promise object
|
||||
*/
|
||||
getByInstanceUID(studyInstanceUID) {
|
||||
return OHIF.studies.retrieveStudyMetadata(studyInstanceUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load study info (OHIF.viewer.Studies) and study metadata (OHIF.viewer.StudyMetadataList) for a given study.
|
||||
* @param {StudySummary|StudyMetadata} study of StudySummary or StudyMetadata object.
|
||||
*/
|
||||
loadStudy(study) {
|
||||
if (!(study instanceof StudyMetadata) && !(study instanceof StudySummary)) {
|
||||
throw new OHIFError('OHIFStudyMetadataSource::loadStudy study is not an instance of StudySummary or StudyMetadata');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const studyInstanceUID = study.getStudyInstanceUID();
|
||||
|
||||
if (study instanceof StudyMetadata) {
|
||||
const alreadyLoaded = OHIF.viewer.Studies.findBy({
|
||||
studyInstanceUid: studyInstanceUID
|
||||
});
|
||||
|
||||
if (!alreadyLoaded) {
|
||||
OHIFStudyMetadataSource._updateStudyCollections(study);
|
||||
}
|
||||
|
||||
resolve(study);
|
||||
return;
|
||||
}
|
||||
|
||||
this.getByInstanceUID(studyInstanceUID).then(studyInfo => {
|
||||
// Create study metadata object
|
||||
const studyMetadata = new OHIF.metadata.StudyMetadata(studyInfo, studyInfo.studyInstanceUid);
|
||||
|
||||
// Get Study display sets
|
||||
const displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(studyMetadata);
|
||||
|
||||
// Set studyMetadata display sets
|
||||
studyMetadata.setDisplaySets(displaySets);
|
||||
|
||||
OHIFStudyMetadataSource._updateStudyCollections(studyMetadata);
|
||||
resolve(studyMetadata);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
// Static methods
|
||||
static _updateStudyCollections(studyMetadata) {
|
||||
const studyInfo = studyMetadata.getData();
|
||||
|
||||
// Set some studyInfo properties
|
||||
studyInfo.selected = true;
|
||||
studyInfo.displaySets = studyMetadata.getDisplaySets();
|
||||
|
||||
// Insert new study info object in Studies TypeSafeCollection
|
||||
OHIF.viewer.Studies.insert(studyInfo);
|
||||
|
||||
// Insert new study metadata in StudyMetadataList TypeSafeCollection
|
||||
OHIF.viewer.StudyMetadataList.insert(studyMetadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import 'meteor/ohif:viewerbase';
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const STRING = 'string';
|
||||
const propertyReplacementMap = {
|
||||
modalities: 'ModalitiesInStudy',
|
||||
patientBirthdate: 'PatientBirthDate'
|
||||
};
|
||||
|
||||
/**
|
||||
* OHIF Viewers specialized version of StudySummary class
|
||||
*/
|
||||
export class OHIFStudySummary extends OHIF.viewerbase.metadata.StudySummary {
|
||||
|
||||
// @Override
|
||||
addTags(tagMap) {
|
||||
const _hasOwn = Object.prototype.hasOwnProperty;
|
||||
const _tagMap = Object.create(null);
|
||||
for (let property in tagMap) {
|
||||
if (_hasOwn.call(tagMap, property)) {
|
||||
let standardProperty = OHIFStudySummary.getStandardPropertyName(property);
|
||||
if (standardProperty) {
|
||||
_tagMap[standardProperty] = tagMap[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
super.addTags(_tagMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns a non-standard, OHIF specific, DICOM property name into a standard one.
|
||||
* @param {string} property A string representing a non-conforming keyword.
|
||||
* @returns {string|undefined} Returns a standard-conforming property name.
|
||||
*/
|
||||
static getStandardPropertyName(property) {
|
||||
let standardProperty;
|
||||
if (typeof property === STRING && property.charAt(0) !== '_') {
|
||||
if (property in propertyReplacementMap) {
|
||||
standardProperty = propertyReplacementMap[propertyReplacementMap];
|
||||
} else {
|
||||
standardProperty = property.replace(/^sop/, 'SOP').replace(/Uid$/, 'UID').replace(/Id$/, 'ID');
|
||||
standardProperty = standardProperty.charAt(0).toUpperCase() + standardProperty.substr(1);
|
||||
}
|
||||
}
|
||||
return standardProperty;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { OHIFStudyMetadataSource } from './OHIFStudyMetadataSource';
|
||||
import { OHIFStudySummary } from './OHIFStudySummary';
|
||||
|
||||
OHIF.studies.classes = {
|
||||
OHIFStudyMetadataSource,
|
||||
OHIFStudySummary
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
import './classes';
|
||||
import './loadStudy';
|
||||
import './retrieveStudiesMetadata';
|
||||
import './retrieveStudyMetadata';
|
||||
|
||||
Reference in new issue
Block a user