feat: Improve unsupported displayset messages (#4979)

This commit is contained in:
Devu-trenser 2025-04-22 18:41:28 +05:30 committed by GitHub
parent 59136e5435
commit 3b8faa8a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 7 deletions

View File

@ -6,9 +6,21 @@ import { DisplaySetMessage, DisplaySetMessageList } from '@ohif/core';
export default function getDisplaySetsFromUnsupportedSeries(instances) {
const imageSet = new ImageSet(instances);
const messages = new DisplaySetMessageList();
messages.addMessage(DisplaySetMessage.CODES.UNSUPPORTED_DISPLAYSET);
const instance = instances[0];
if (!instances.length) {
messages.addMessage(DisplaySetMessage.CODES.NO_VALID_INSTANCES);
} else {
const sopClassUid = instance.SOPClassUID;
if (sopClassUid) {
messages.addMessage(DisplaySetMessage.CODES.UNSUPPORTED_SOP_CLASS_UID, {
sopClassUid,
});
} else {
messages.addMessage(DisplaySetMessage.CODES.MISSING_SOP_CLASS_UID);
}
}
imageSet.setAttributes({
displaySetInstanceUID: imageSet.uid, // create a local alias for the imageSet UID
SeriesDate: instance.SeriesDate,

View File

@ -1,8 +1,12 @@
/**
* Defines a displaySet message, that could be any pf the potential problems of a displaySet
* Defines a displaySet message, that could be any pf the potential problems of a displaySet.
*
* @property {number} id - message ID.
* @property {Record<string, any>} args - message arguments, will be passed to the translation function when the message is rendered.
*/
class DisplaySetMessage {
id: number;
args: Record<string, any>;
static CODES = {
NO_VALID_INSTANCES: 1,
NO_POSITION_INFORMATION: 2,
@ -17,10 +21,13 @@ class DisplaySetMessage {
INCONSISTENT_ORIENTATIONS: 11,
INCONSISTENT_POSITION_INFORMATION: 12,
UNSUPPORTED_DISPLAYSET: 13,
UNSUPPORTED_SOP_CLASS_UID: 14,
MISSING_SOP_CLASS_UID: 15,
};
constructor(id: number) {
constructor(id: number, args: Record<string, any> = {}) {
this.id = id;
this.args = args;
}
}
/**
@ -29,8 +36,8 @@ class DisplaySetMessage {
class DisplaySetMessageList {
messages = [];
public addMessage(messageId: number): void {
const message = new DisplaySetMessage(messageId);
public addMessage(messageId: number, args: Record<string, any> = {}): void {
const message = new DisplaySetMessage(messageId, args);
this.messages.push(message);
}
@ -43,7 +50,7 @@ class DisplaySetMessageList {
}
public includesAllMessages(messageIdList: number[]): boolean {
return messageIdList.every(messageId => this.include(messageId));
return messageIdList.every(messageId => this.includesMessage(messageId));
}
}

View File

@ -12,5 +12,7 @@
"10": "Display set has frames with inconsistent number of components.",
"11": "Display set has frames with inconsistent orientations.",
"12": "Display set has inconsistent position information.",
"13": "Unsupported display set."
"13": "Unsupported display set.",
"14": "SOP Class UID {{ sopClassUid }} is not supported.",
"15": "Display Set is missing a SOP Class UID. Please check the file."
}