fix: local ModalitiesInStudy check (#5285)
Co-authored-by: Bill Wallace <wayfarer3130@gmail.com> Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
parent
722efe9587
commit
d2694048a4
@ -11,6 +11,7 @@ import { isDisplaySetFromUrl, sopInstanceLocation } from './custom-attribute/isD
|
|||||||
import numberOfDisplaySetsWithImages from './custom-attribute/numberOfDisplaySetsWithImages';
|
import numberOfDisplaySetsWithImages from './custom-attribute/numberOfDisplaySetsWithImages';
|
||||||
import seriesDescriptionsFromDisplaySets from './custom-attribute/seriesDescriptionsFromDisplaySets';
|
import seriesDescriptionsFromDisplaySets from './custom-attribute/seriesDescriptionsFromDisplaySets';
|
||||||
import uuidv4 from '../../utils/uuidv4';
|
import uuidv4 from '../../utils/uuidv4';
|
||||||
|
import { getUniqueAttributeFromList } from './lib/getUniqueAttributeFromList';
|
||||||
|
|
||||||
type Protocol = HangingProtocol.Protocol | HangingProtocol.ProtocolGenerator;
|
type Protocol = HangingProtocol.Protocol | HangingProtocol.ProtocolGenerator;
|
||||||
|
|
||||||
@ -77,15 +78,15 @@ export default class HangingProtocolService extends PubSubService {
|
|||||||
},
|
},
|
||||||
ModalitiesInStudy: {
|
ModalitiesInStudy: {
|
||||||
name: 'Gets the array of the modalities for the series',
|
name: 'Gets the array of the modalities for the series',
|
||||||
callback: metadata =>
|
callback: metadata => {
|
||||||
metadata.ModalitiesInStudy ??
|
if (metadata.ModalitiesInStudy?.length > 0) {
|
||||||
(metadata.series || []).reduce((prev, curr) => {
|
return metadata.ModalitiesInStudy;
|
||||||
const { Modality } = curr;
|
}
|
||||||
if (Modality && prev.indexOf(Modality) == -1) {
|
if (Array.isArray(metadata.series)) {
|
||||||
prev.push(Modality);
|
return getUniqueAttributeFromList(metadata.series, 'Modality');
|
||||||
}
|
}
|
||||||
return prev;
|
return [];
|
||||||
}, []),
|
},
|
||||||
},
|
},
|
||||||
isReconstructable: {
|
isReconstructable: {
|
||||||
name: 'Checks if the display set is reconstructable',
|
name: 'Checks if the display set is reconstructable',
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Returns an array of unique values for the given attribute from a series array.
|
||||||
|
* If the attribute is not present on the series, attempts to get it from the first instance.
|
||||||
|
* @param {Array} series - The series array to extract attributes from.
|
||||||
|
* @param {string} attribute - The attribute name to extract.
|
||||||
|
* @returns {Array} Array of unique attribute values.
|
||||||
|
*/
|
||||||
|
export function getUniqueAttributeFromList(series, attribute) {
|
||||||
|
return series.reduce((prev, curr) => {
|
||||||
|
let value = curr[attribute];
|
||||||
|
if (!value && curr.instances && curr.instances[0]) {
|
||||||
|
value = curr.instances[0][attribute];
|
||||||
|
}
|
||||||
|
if (value && prev.indexOf(value) === -1) {
|
||||||
|
prev.push(value);
|
||||||
|
}
|
||||||
|
return prev;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user