Removing search loops and proprietary tag definitions from DICOMTagDescriptions viewerbase utility.

This commit is contained in:
Emanuel F. Oliveira authored and Eloízio Salgado committed 2017-03-02 10:16:09 -03:00
1 parent e75330fe87
commit 0be2f5887a
5 files changed
+485 -419

No files matched your search

@@ -1,5 +1,4 @@
import { Metadata } from './Metadata';
import { dicomTagDescriptions } from '../../dicomTagDescriptions';
import { OHIFError } from '../OHIFError';
const UNDEFINED = 'undefined';
@@ -165,38 +164,6 @@ export class InstanceMetadata extends Metadata {
* Static Methods
*/
static getTagInfo(tagOrProperty) {
let tagName = null,
propertyName = null;
if (typeof tagOrProperty === NUMBER) {
// if it's a number, build an hexadecimal representation...
tagName = 'x' + ('00000000' + tagOrProperty.toString(16)).substr(-8);
} else if (typeof tagOrProperty === STRING) {
if (REGEX_TAG.test(tagOrProperty)) {
tagName = tagOrProperty;
} else {
propertyName = tagOrProperty;
}
}
if (propertyName !== null) {
// try to figure out the "tagName" using the provided "propertyName"...
for (let tag in dicomTagDescriptions) {
// No need to check for "hasOwnProperty" here since dicomTagDescriptions is an object with no prototype...
if (dicomTagDescriptions[tag] === propertyName) {
tagName = tag;
break;
}
}
} else if (tagName !== null) {
// try to figure out the "propertyName" using the provided "tagName"...
propertyName = dicomTagDescriptions[tagName] || null;
}
return { tagName, propertyName };
}
/**
* Get an value based that can be index based. This function is called by all getters. See above functions.
* - If value is a String and has indexes:
@@ -0,0 +1,42 @@
class StudySummary {
constructor(propertyMap) {
// Define the main immutable "_data" private property.
Object.defineProperty(this, '_data', {
configurable: false,
enumerable: false,
writable: false,
value: Object.create(null)
});
const hasOwn = Object.prototype.hasOwnProperty;
const data = this._data;
for (let property in propertyMap) {
if (hasOwn.call(propertyMap, property)) {
data[property] = propertyMap[property];
}
}
}
propertyExists(propertyName) {
const internalPropertyName = this.getInternalPropertyName(propertyName);
return (internalPropertyName in this._data);
}
getPropertyValue(propertyName) {
const internalPropertyName = this.getInternalPropertyName(propertyName);
return this._data[internalPropertyName];
}
/**
* This function is supposed to translate external property names into internal property names.
* By default it implements the simplest translation possible. For
*/
getInternalPropertyName(propertyName) {
return propertyName;
}
}