feat: Improve unsupported displayset messages (#4979)

This commit is contained in:
Devu-trenser authored and GitHub committed 2025-04-22 09:11:28 -04:00
1 parent 59136e5435
commit 3b8faa8a76
3 files changed
+28 -7

No files matched your search

@@ -6,9 +6,21 @@ import { DisplaySetMessage, DisplaySetMessageList } from '@ohif/core';
export default function getDisplaySetsFromUnsupportedSeries(instances) { export default function getDisplaySetsFromUnsupportedSeries(instances) {
const imageSet = new ImageSet(instances); const imageSet = new ImageSet(instances);
const messages = new DisplaySetMessageList(); const messages = new DisplaySetMessageList();
messages.addMessage(DisplaySetMessage.CODES.UNSUPPORTED_DISPLAYSET);
const instance = instances[0]; 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({ imageSet.setAttributes({
displaySetInstanceUID: imageSet.uid, // create a local alias for the imageSet UID displaySetInstanceUID: imageSet.uid, // create a local alias for the imageSet UID
SeriesDate: instance.SeriesDate, SeriesDate: instance.SeriesDate,
@@ -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 { class DisplaySetMessage {
id: number; id: number;
args: Record<string, any>;
static CODES = { static CODES = {
NO_VALID_INSTANCES: 1, NO_VALID_INSTANCES: 1,
NO_POSITION_INFORMATION: 2, NO_POSITION_INFORMATION: 2,
@@ -17,10 +21,13 @@ class DisplaySetMessage {
INCONSISTENT_ORIENTATIONS: 11, INCONSISTENT_ORIENTATIONS: 11,
INCONSISTENT_POSITION_INFORMATION: 12, INCONSISTENT_POSITION_INFORMATION: 12,
UNSUPPORTED_DISPLAYSET: 13, 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.id = id;
this.args = args;
} }
} }
/** /**
@@ -29,8 +36,8 @@ class DisplaySetMessage {
class DisplaySetMessageList { class DisplaySetMessageList {
messages = []; messages = [];
public addMessage(messageId: number): void { public addMessage(messageId: number, args: Record<string, any> = {}): void {
const message = new DisplaySetMessage(messageId); const message = new DisplaySetMessage(messageId, args);
this.messages.push(message); this.messages.push(message);
} }
@@ -43,7 +50,7 @@ class DisplaySetMessageList {
} }
public includesAllMessages(messageIdList: number[]): boolean { public includesAllMessages(messageIdList: number[]): boolean {
return messageIdList.every(messageId => this.include(messageId)); return messageIdList.every(messageId => this.includesMessage(messageId));
} }
} }
@@ -12,5 +12,7 @@
"10": "Display set has frames with inconsistent number of components.", "10": "Display set has frames with inconsistent number of components.",
"11": "Display set has frames with inconsistent orientations.", "11": "Display set has frames with inconsistent orientations.",
"12": "Display set has inconsistent position information.", "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."
} }