Fixed displaySet search inside protocolEngine
This commit is contained in:
parent
f96a37e1bc
commit
4c84961d4c
@ -500,19 +500,13 @@ HP.ProtocolEngine = class ProtocolEngine {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Filter imageSet function: filter by InstanceUid
|
|
||||||
const filterImageSetFn = (imageSet, sopInstanceUid) => {
|
|
||||||
// @TODO: remove getData() here
|
|
||||||
const found = imageSet.getData().sopInstanceUid === instance.sopInstanceUid;
|
|
||||||
return found;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find the displaySet
|
// Find the displaySet
|
||||||
const displaySet = study.getDisplaySets().find(ds => ds.images.filter(imageSet => filterImageSetFn));
|
const currentSOPInstanceUID = instance.getSOPInstanceUID();
|
||||||
|
const displaySet = study.findDisplaySet(displaySet => displaySet.images.find(image => image.getSOPInstanceUID() === currentSOPInstanceUID));
|
||||||
|
|
||||||
// If the instance was found, set the displaySet ID
|
// If the instance was found, set the displaySet ID
|
||||||
if (displaySet) {
|
if (displaySet) {
|
||||||
imageDetails.displaySetInstanceUid = displaySet.displaySetInstanceUid;
|
imageDetails.displaySetInstanceUid = displaySet.getUID();
|
||||||
imageDetails.imageId = instance.getImageId();
|
imageDetails.imageId = instance.getImageId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { Random } from 'meteor/random';
|
import { Random } from 'meteor/random';
|
||||||
|
import { OHIFError } from './OHIFError';
|
||||||
|
|
||||||
|
const OBJECT = 'object';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class defines an ImageSet object which will be used across the viewer. This object represents
|
* This class defines an ImageSet object which will be used across the viewer. This object represents
|
||||||
@ -11,13 +14,29 @@ export class ImageSet {
|
|||||||
constructor(images) {
|
constructor(images) {
|
||||||
|
|
||||||
if (Array.isArray(images) !== true) {
|
if (Array.isArray(images) !== true) {
|
||||||
throw new TypeError('ImageSet expects an array of images...');
|
throw new OHIFError('ImageSet expects an array of images...');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main ImageSet attributes
|
// @property "images"
|
||||||
this.images = images; // Array of images
|
Object.defineProperty(this, 'images', {
|
||||||
this.uid = Random.id(); // Unique ID of the instance
|
enumerable: false,
|
||||||
|
configurable: false,
|
||||||
|
writable: false,
|
||||||
|
value: images
|
||||||
|
});
|
||||||
|
|
||||||
|
// @property "uid"
|
||||||
|
Object.defineProperty(this, 'uid', {
|
||||||
|
enumerable: false,
|
||||||
|
configurable: false,
|
||||||
|
writable: false,
|
||||||
|
value: Random.id() // Unique ID of the instance
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getUID() {
|
||||||
|
return this.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttribute(attribute, value) {
|
setAttribute(attribute, value) {
|
||||||
@ -29,7 +48,7 @@ export class ImageSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setAttributes(attributes) {
|
setAttributes(attributes) {
|
||||||
if (typeof attributes === 'object' && attributes !== null) {
|
if (typeof attributes === OBJECT && attributes !== null) {
|
||||||
const imageSet = this, hasOwn = Object.prototype.hasOwnProperty;
|
const imageSet = this, hasOwn = Object.prototype.hasOwnProperty;
|
||||||
for (let attribute in attributes) {
|
for (let attribute in attributes) {
|
||||||
if (hasOwn.call(attributes, attribute)) {
|
if (hasOwn.call(attributes, attribute)) {
|
||||||
|
|||||||
@ -89,6 +89,21 @@ export class StudyMetadata extends Metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search the associated display sets using the supplied callback as criteria. The callback is passed
|
||||||
|
* two arguments: display set (a ImageSet instance) and index (the integer
|
||||||
|
* index of the display set within the current study)
|
||||||
|
* @param {function} callback The callback function which will be invoked for each display set instance.
|
||||||
|
* @returns {undefined} Nothing is returned.
|
||||||
|
*/
|
||||||
|
findDisplaySet(callback) {
|
||||||
|
if (Metadata.isValidCallback(callback)) {
|
||||||
|
return this._displaySets.find((displaySet, index) => {
|
||||||
|
return callback.call(null, displaySet, index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the StudyInstanceUID of the current study.
|
* Returns the StudyInstanceUID of the current study.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user