feat(handler): Add handler for unsupported sopclassUIDs (#3601)
This commit is contained in:
1 parent
de6976df3b
commit
f845f87716
16 files changed
+180
-64
No files matched your search
@@ -16,6 +16,7 @@ class DisplaySetMessage {
|
||||
INCONSISTENT_COMPONENTS: 10,
|
||||
INCONSISTENT_ORIENTATIONS: 11,
|
||||
INCONSISTENT_POSITION_INFORMATION: 12,
|
||||
UNSUPPORTED_DISPLAYSET: 13,
|
||||
};
|
||||
|
||||
constructor(id: number) {
|
||||
|
||||
@@ -9,6 +9,7 @@ export type DisplaySet = {
|
||||
StudyInstanceUID: string;
|
||||
SeriesInstanceUID?: string;
|
||||
numImages?: number;
|
||||
unsupported?: boolean;
|
||||
};
|
||||
|
||||
const displaySetCache = new Map<string, DisplaySet>();
|
||||
@@ -48,6 +49,7 @@ export default class DisplaySetService extends PubSubService {
|
||||
};
|
||||
|
||||
public activeDisplaySets = [];
|
||||
public unsuportedSOPClassHandler;
|
||||
extensionManager: ExtensionManager;
|
||||
|
||||
protected activeDisplaySetsMap = new Map<string, DisplaySet>();
|
||||
@@ -58,6 +60,8 @@ export default class DisplaySetService extends PubSubService {
|
||||
|
||||
constructor() {
|
||||
super(EVENTS);
|
||||
this.unsuportedSOPClassHandler =
|
||||
'@ohif/extension-default.sopClassHandlerModule.not-supported-display-sets-handler';
|
||||
}
|
||||
|
||||
public init(extensionManager, SOPClassHandlerIds): void {
|
||||
@@ -85,6 +89,14 @@ export default class DisplaySetService extends PubSubService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the handler for unsupported sop classes
|
||||
* @param sopClassHandlerUID
|
||||
*/
|
||||
public setUnsuportedSOPClassHandler(sopClassHandler) {
|
||||
this.unsuportedSOPClassHandler = sopClassHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new display sets directly, as specified.
|
||||
* Use this function when the display sets are created externally directly
|
||||
@@ -256,6 +268,47 @@ export default class DisplaySetService extends PubSubService {
|
||||
this.activeDisplaySetsMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function hides the old makeDisplaySetForInstances function to first
|
||||
* separate the instances by sopClassUID so each call have only instances
|
||||
* with the same sopClassUID, to avoid a series composed by different
|
||||
* sopClassUIDs be filtered inside one of the SOPClassHandler functions and
|
||||
* didn't appear in the series list.
|
||||
* @param instancesSrc
|
||||
* @param settings
|
||||
* @returns
|
||||
*/
|
||||
public makeDisplaySetForInstances(
|
||||
instancesSrc: InstanceMetadata[],
|
||||
settings
|
||||
): DisplaySet[] {
|
||||
// creating a sopClassUID list and for each sopClass associate its respective
|
||||
// instance list
|
||||
const instancesForSetSOPClasses = instancesSrc.reduce(
|
||||
(sopClassList, instance) => {
|
||||
if (!(instance.SOPClassUID in sopClassList)) {
|
||||
sopClassList[instance.SOPClassUID] = [];
|
||||
}
|
||||
sopClassList[instance.SOPClassUID].push(instance);
|
||||
return sopClassList;
|
||||
},
|
||||
{}
|
||||
);
|
||||
// for each sopClassUID, call the old makeDisplaySetForInstances with a
|
||||
// instance list composed only by instances with the same sopClassUID and
|
||||
// accumulate the displaySets in the variable allDisplaySets
|
||||
const sopClasses = Object.keys(instancesForSetSOPClasses);
|
||||
let allDisplaySets = [];
|
||||
sopClasses.forEach(sopClass => {
|
||||
const displaySets = this._makeDisplaySetForInstances(
|
||||
instancesForSetSOPClasses[sopClass],
|
||||
settings
|
||||
);
|
||||
allDisplaySets = [...allDisplaySets, ...displaySets];
|
||||
});
|
||||
return allDisplaySets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new display sets for the instances contained in instancesSrc
|
||||
* according to the sop class handlers registered.
|
||||
@@ -272,7 +325,7 @@ export default class DisplaySetService extends PubSubService {
|
||||
* @param settings are settings to add
|
||||
* @returns Array of the display sets added.
|
||||
*/
|
||||
public makeDisplaySetForInstances(
|
||||
private _makeDisplaySetForInstances(
|
||||
instancesSrc: InstanceMetadata[],
|
||||
settings
|
||||
): DisplaySet[] {
|
||||
@@ -355,6 +408,26 @@ export default class DisplaySetService extends PubSubService {
|
||||
allDisplaySets.push(...displaySets);
|
||||
}
|
||||
}
|
||||
// applying the default sopClassUID handler
|
||||
if (allDisplaySets.length === 0) {
|
||||
// applying hp-defined viewport settings to the displaysets
|
||||
const handler = this.extensionManager.getModuleEntry(
|
||||
this.unsuportedSOPClassHandler
|
||||
);
|
||||
const displaySets = handler.getDisplaySetsFromSeries(instances);
|
||||
if (displaySets?.length) {
|
||||
displaySets.forEach(ds => {
|
||||
Object.keys(settings).forEach(key => {
|
||||
ds[key] = settings[key];
|
||||
});
|
||||
});
|
||||
|
||||
this._addDisplaySetsToCache(displaySets);
|
||||
this._addActiveDisplaySets(displaySets);
|
||||
|
||||
allDisplaySets.push(...displaySets);
|
||||
}
|
||||
}
|
||||
return allDisplaySets;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ interface IDisplaySet {
|
||||
StudyInstanceUID: string;
|
||||
SeriesInstanceUID?: string;
|
||||
SeriesNumber?: string;
|
||||
unsupported?: boolean;
|
||||
}
|
||||
|
||||
export default IDisplaySet;
|
||||
@@ -559,6 +559,13 @@ export default class HangingProtocolService extends PubSubService {
|
||||
}
|
||||
|
||||
getViewportsRequireUpdate(viewportIndex, displaySetInstanceUID) {
|
||||
const { displaySetService } = this._servicesManager.services;
|
||||
const displaySet = displaySetService.getDisplaySetByUID(
|
||||
displaySetInstanceUID
|
||||
);
|
||||
if (displaySet?.unsupported) {
|
||||
throw new Error('Unsupported displaySet');
|
||||
}
|
||||
const newDisplaySetInstanceUID = displaySetInstanceUID;
|
||||
const protocol = this.protocol;
|
||||
const protocolStage = protocol.stages[this.stageIndex];
|
||||
@@ -1431,7 +1438,7 @@ export default class HangingProtocolService extends PubSubService {
|
||||
}
|
||||
|
||||
const studyDisplaySets = this.displaySets.filter(
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID && !it?.unsupported
|
||||
);
|
||||
|
||||
const studyMatchDetails = this.protocolEngine.findMatch(
|
||||
|
||||
Reference in new issue
Block a user