Bug Fix: OHIF Study Metadata API implementation not correctly reading Study and Series level data + Adding ES5.1 properties to Study Metadata API abstract classes to prevent protected attribute override
This commit is contained in:
parent
5d5df29e09
commit
2b22aecc15
@ -308,10 +308,11 @@ HP.ProtocolEngine = class ProtocolEngine {
|
||||
* @returns {any|*} The number of available prior studies with the same patientId
|
||||
*/
|
||||
getNumberOfAvailablePriors(study) {
|
||||
var studies = StudyListStudies.find({
|
||||
patientId: study.patientId,
|
||||
const instance = study.getFirstInstance();
|
||||
const studies = StudyListStudies.find({
|
||||
patientId: instance.getRawValue('x00100020'), // PatientID,
|
||||
studyDate: {
|
||||
$lt: study.studyDate
|
||||
$lt: instance.getRawValue('x00080020') // StudyDate
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -7,16 +7,47 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
/**
|
||||
* @param {Object} Instance object.
|
||||
*/
|
||||
constructor(data) {
|
||||
constructor(data, series, study) {
|
||||
super(data);
|
||||
this._cache = Object.create(null); // Object with null prototype for fast and safe lookups...
|
||||
this.init();
|
||||
this.init(series, study);
|
||||
}
|
||||
|
||||
init() {
|
||||
const data = this.getData();
|
||||
// set protected property...
|
||||
this._sopInstanceUID = data.sopInstanceUid;
|
||||
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
|
||||
@ -28,8 +59,16 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
}
|
||||
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
const data = this.getData();
|
||||
const rawValue = data[propertyName];
|
||||
|
||||
// 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...
|
||||
@ -44,9 +83,7 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
tagExists(tagOrProperty) {
|
||||
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
|
||||
|
||||
const data = this.getData();
|
||||
|
||||
return (propertyName in data);
|
||||
return (propertyName in this._instance || propertyName in this._series || propertyName in this._study);
|
||||
}
|
||||
|
||||
// Override
|
||||
@ -72,7 +109,7 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
|
||||
|
||||
if (tagInfo.propertyName !== null) {
|
||||
// This function tries to translate standard DICOM property names into local naming convention.
|
||||
propertyName = tagInfo.propertyName.replace(/^SOP/, 'sop').replace(/UID$/, 'Uid');
|
||||
propertyName = tagInfo.propertyName.replace(/^SOP/, 'sop').replace(/UID$/, 'Uid').replace(/ID$/, 'Id');
|
||||
propertyName = propertyName.charAt(0).toLowerCase() + propertyName.substr(1);
|
||||
}
|
||||
|
||||
|
||||
@ -6,19 +6,25 @@ export class OHIFSeriesMetadata extends Viewerbase.metadata.SeriesMetadata {
|
||||
/**
|
||||
* @param {Object} Series object.
|
||||
*/
|
||||
constructor(data) {
|
||||
constructor(data, study) {
|
||||
super(data);
|
||||
this.init();
|
||||
this.init(study);
|
||||
}
|
||||
|
||||
init() {
|
||||
const data = this.getData();
|
||||
init(study) {
|
||||
const series = this.getData();
|
||||
|
||||
// define "_seriesInstanceUID" protected property...
|
||||
Object.defineProperty(this, '_seriesInstanceUID', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: series.seriesInstanceUid
|
||||
});
|
||||
|
||||
// set protected property...
|
||||
this._seriesInstanceUID = data.seriesInstanceUid;
|
||||
// populate internal list of instances...
|
||||
data.instances.forEach(instance => {
|
||||
this.addInstance(new OHIFInstanceMetadata(instance));
|
||||
series.instances.forEach(instance => {
|
||||
this.addInstance(new OHIFInstanceMetadata(instance, series, study));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -12,13 +12,19 @@ export class OHIFStudyMetadata extends Viewerbase.metadata.StudyMetadata {
|
||||
}
|
||||
|
||||
init() {
|
||||
const data = this.getData();
|
||||
const study = this.getData();
|
||||
|
||||
// define "_studyInstanceUID" protected property...
|
||||
Object.defineProperty(this, '_studyInstanceUID', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: study.studyInstanceUid
|
||||
});
|
||||
|
||||
// set protected property...
|
||||
this._studyInstanceUID = data.studyInstanceUid;
|
||||
// populate internal list of series...
|
||||
data.seriesList.forEach(series => {
|
||||
this.addSeries(new OHIFSeriesMetadata(series));
|
||||
study.seriesList.forEach(series => {
|
||||
this.addSeries(new OHIFSeriesMetadata(series, study));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -11,8 +11,21 @@ export class InstanceMetadata extends Metadata {
|
||||
|
||||
constructor(data) {
|
||||
super(data);
|
||||
this._sopInstanceUID = null;
|
||||
this._imageId = null;
|
||||
// Initialize Private Properties
|
||||
Object.defineProperties(this, {
|
||||
_sopInstanceUID: {
|
||||
configurable: true, // configurable so that it can be redefined in sub-classes...
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: null
|
||||
},
|
||||
_imageId: {
|
||||
configurable: true, // configurable so that it can be redefined in sub-classes...
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: null
|
||||
}
|
||||
});
|
||||
// Initialize Public Properties
|
||||
this._definePublicProperties();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
const STRING = 'string';
|
||||
const NUMBER = 'number';
|
||||
const FUNCTION = 'function';
|
||||
const OBJECT = 'object';
|
||||
|
||||
export class Metadata {
|
||||
|
||||
@ -14,7 +15,14 @@ export class Metadata {
|
||||
*/
|
||||
|
||||
constructor(data) {
|
||||
this._data = data;
|
||||
// Define the main "_data" private property as an immutable property.
|
||||
// IMPORTANT: This property can only be set during instance construction.
|
||||
Object.defineProperty(this, '_data', {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: data
|
||||
});
|
||||
}
|
||||
|
||||
getData() {
|
||||
@ -24,7 +32,7 @@ export class Metadata {
|
||||
getDataProperty(propertyName) {
|
||||
let propertyValue;
|
||||
const _data = this._data;
|
||||
if (_data instanceof Object || typeof _data === 'object' && _data !== null) {
|
||||
if (_data instanceof Object || typeof _data === OBJECT && _data !== null) {
|
||||
propertyValue = _data[propertyName];
|
||||
}
|
||||
return propertyValue;
|
||||
|
||||
@ -5,8 +5,21 @@ export class SeriesMetadata extends Metadata {
|
||||
|
||||
constructor(data) {
|
||||
super(data);
|
||||
this._seriesInstanceUID = null;
|
||||
this._instances = []; // InstanceMetadata[]
|
||||
// Initialize Private Properties
|
||||
Object.defineProperties(this, {
|
||||
_seriesInstanceUID: {
|
||||
configurable: true, // configurable so that it can be redefined in sub-classes...
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: null
|
||||
},
|
||||
_instances: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: []
|
||||
}
|
||||
});
|
||||
// Initialize Public Properties
|
||||
this._definePublicProperties();
|
||||
}
|
||||
|
||||
@ -6,9 +6,27 @@ export class StudyMetadata extends Metadata {
|
||||
|
||||
constructor(data) {
|
||||
super(data);
|
||||
this._studyInstanceUID = null;
|
||||
this._series = []; // SeriesMetadata[]
|
||||
this._displaySets = [];
|
||||
// Initialize Private Properties
|
||||
Object.defineProperties(this, {
|
||||
__studyInstanceUID: {
|
||||
configurable: true, // configurable so that it can be redefined in sub-classes...
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: null
|
||||
},
|
||||
_series: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: []
|
||||
},
|
||||
_displaySets: {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: []
|
||||
}
|
||||
});
|
||||
// Initialize Public Properties
|
||||
this._definePublicProperties();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user