Move ohif:metadata into ohif:core
This commit is contained in:
1 parent
700fff763c
commit
da36c33c70
8 files changed
+22
-72
No files matched your search
@@ -1,119 +0,0 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
|
||||
const InstanceMetadata = Viewerbase.metadata.InstanceMetadata;
|
||||
const DICOMTagDescriptions = Viewerbase.DICOMTagDescriptions;
|
||||
|
||||
export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
|
||||
/**
|
||||
* @param {Object} Instance object.
|
||||
*/
|
||||
constructor(data, series, study, uid) {
|
||||
super(data, uid);
|
||||
this.init(series, study);
|
||||
}
|
||||
|
||||
init(series, study) {
|
||||
const instance = this.getData();
|
||||
|
||||
// Initialize Private Properties
|
||||
Object.defineProperties(this, {
|
||||
_sopInstanceUID: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: instance.sopInstanceUid
|
||||
},
|
||||
_study: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: study
|
||||
},
|
||||
_series: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: series
|
||||
},
|
||||
_instance: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: instance
|
||||
},
|
||||
_cache: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: Object.create(null)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Override
|
||||
getTagValue(tagOrProperty, defaultValue, bypassCache) {
|
||||
|
||||
// check if this property has been cached...
|
||||
if (tagOrProperty in this._cache && bypassCache !== true) {
|
||||
return this._cache[tagOrProperty];
|
||||
}
|
||||
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
|
||||
// Search property value in the whole study metadata chain...
|
||||
let rawValue;
|
||||
if (propertyName in this._instance) {
|
||||
rawValue = this._instance[propertyName];
|
||||
} else if (propertyName in this._series) {
|
||||
rawValue = this._series[propertyName];
|
||||
} else if (propertyName in this._study) {
|
||||
rawValue = this._study[propertyName];
|
||||
}
|
||||
|
||||
if (rawValue !== void 0) {
|
||||
// if rawValue value is not undefined, cache result...
|
||||
this._cache[tagOrProperty] = rawValue;
|
||||
return rawValue;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// Override
|
||||
tagExists(tagOrProperty) {
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
|
||||
return (propertyName in this._instance || propertyName in this._series || propertyName in this._study);
|
||||
}
|
||||
|
||||
// Override
|
||||
getImageId(frame, thumbnail) {
|
||||
// If _imageID is not cached, create it
|
||||
if (this._imageId === null) {
|
||||
this._imageId = Viewerbase.getImageId(this.getData(), frame, thumbnail);
|
||||
}
|
||||
|
||||
return this._imageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static methods
|
||||
*/
|
||||
|
||||
// @TODO: The current mapping of standard DICOM property names to local property names is not optimal.
|
||||
// The inconsistency in property naming makes this function increasingly complex.
|
||||
// A possible solution to improve this would be adapt retriveMetadata names to use DICOM standard names as in dicomTagDescriptions.js
|
||||
static getPropertyName(tagOrProperty) {
|
||||
let propertyName;
|
||||
const tagInfo = DICOMTagDescriptions.find(tagOrProperty);
|
||||
|
||||
if (tagInfo !== void 0) {
|
||||
// This function tries to translate standard DICOM property names into local naming convention.
|
||||
propertyName = tagInfo.keyword.replace(/^SOP/, 'sop').replace(/UID$/, 'Uid').replace(/ID$/, 'Id');
|
||||
propertyName = propertyName.charAt(0).toLowerCase() + propertyName.substr(1);
|
||||
}
|
||||
|
||||
return propertyName;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
import { OHIFInstanceMetadata } from './OHIFInstanceMetadata';
|
||||
|
||||
export class OHIFSeriesMetadata extends Viewerbase.metadata.SeriesMetadata {
|
||||
|
||||
/**
|
||||
* @param {Object} Series object.
|
||||
*/
|
||||
constructor(data, study, uid) {
|
||||
super(data, uid);
|
||||
this.init(study);
|
||||
}
|
||||
|
||||
init(study) {
|
||||
const series = this.getData();
|
||||
|
||||
// define "_seriesInstanceUID" protected property...
|
||||
Object.defineProperty(this, '_seriesInstanceUID', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: series.seriesInstanceUid
|
||||
});
|
||||
|
||||
// populate internal list of instances...
|
||||
series.instances.forEach(instance => {
|
||||
this.addInstance(new OHIFInstanceMetadata(instance, series, study));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
import { OHIFSeriesMetadata } from './OHIFSeriesMetadata';
|
||||
|
||||
export class OHIFStudyMetadata extends Viewerbase.metadata.StudyMetadata {
|
||||
|
||||
/**
|
||||
* @param {Object} Study object.
|
||||
*/
|
||||
constructor(data, uid) {
|
||||
super(data, uid);
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const study = this.getData();
|
||||
|
||||
// define "_studyInstanceUID" protected property
|
||||
Object.defineProperty(this, '_studyInstanceUID', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: study.studyInstanceUid
|
||||
});
|
||||
|
||||
// populate internal list of series
|
||||
study.seriesList.forEach(series => {
|
||||
this.addSeries(new OHIFSeriesMetadata(series, study));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Metadata } from '../namespace';
|
||||
|
||||
// OHIFStudyMetadata, OHIFSeriesMetadata, OHIFInstanceMetadata
|
||||
import { OHIFStudyMetadata } from './OHIFStudyMetadata';
|
||||
import { OHIFSeriesMetadata } from './OHIFSeriesMetadata';
|
||||
import { OHIFInstanceMetadata } from './OHIFInstanceMetadata';
|
||||
|
||||
Metadata.StudyMetadata = OHIFStudyMetadata;
|
||||
Metadata.SeriesMetadata = OHIFSeriesMetadata;
|
||||
Metadata.InstanceMetadata = OHIFInstanceMetadata;
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Import namespace...
|
||||
*/
|
||||
|
||||
import { OHIF, Metadata } from './namespace.js';
|
||||
|
||||
/**
|
||||
* Import scripts that will populate the Metadata namespace as a side effect only import. This is effectively the public API...
|
||||
*/
|
||||
|
||||
import './client/'; // which is actually: import './client/index.js';
|
||||
|
||||
/**
|
||||
* Export relevant objects...
|
||||
*
|
||||
* With the following export it becomes possible to import "OHIF" from "ohif:core" and "Metadata"
|
||||
* from "ohif:metadata" using a single import (a shorthand), like this:
|
||||
*
|
||||
* import { OHIF } from 'meteor/ohif:metadata';
|
||||
*
|
||||
* Which is equivalent to:
|
||||
*
|
||||
* import { OHIF } from 'meteor/ohif:core';
|
||||
* import 'meteor/ohif:metadata';
|
||||
*
|
||||
* The second (extended) format should be used when other OHIF packages are also to be used within
|
||||
* the current module. This makes it explicit that the following imports will populate their
|
||||
* respective namespaces within the to "OHIF" namespace. Example:
|
||||
*
|
||||
* import { OHIF } from 'meteor/ohif:core';
|
||||
* import 'meteor/ohif:metadata';
|
||||
* import 'meteor/ohif:hanging-protocols';
|
||||
* [ ... ]
|
||||
* OHIF.metadata.setActiveViewport(...);
|
||||
* OHIF.hangingprotocols.doSomething(...);
|
||||
*
|
||||
*/
|
||||
|
||||
export { OHIF, Metadata };
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Import main dependency...
|
||||
*/
|
||||
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Create Metadata namespace...
|
||||
*/
|
||||
|
||||
const Metadata = {};
|
||||
|
||||
/**
|
||||
* Append Metadata namespace to OHIF namespace...
|
||||
*/
|
||||
|
||||
OHIF.metadata = Metadata;
|
||||
|
||||
/**
|
||||
* Export relevant objects...
|
||||
*/
|
||||
|
||||
export { OHIF, Metadata };
|
||||
Reference in new issue
Block a user