diff --git a/extensions/cornerstone-dicom-rt/src/viewports/OHIFCornerstoneRTViewport.tsx b/extensions/cornerstone-dicom-rt/src/viewports/OHIFCornerstoneRTViewport.tsx index 32f37970a..8d70b2701 100644 --- a/extensions/cornerstone-dicom-rt/src/viewports/OHIFCornerstoneRTViewport.tsx +++ b/extensions/cornerstone-dicom-rt/src/viewports/OHIFCornerstoneRTViewport.tsx @@ -51,6 +51,21 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) { const referencedDisplaySetRef = useRef(null); const referencedDisplaySetInstanceUID = rtDisplaySet.referencedDisplaySetInstanceUID; + // If the referencedDisplaySetInstanceUID is not found, it means the RTStruct series is being + // launched without its corresponding referenced display set (e.g., the RTStruct series is launched using + // series launch /mode?StudyInstanceUIDs=&SeriesInstanceUID). + // In such cases, we attempt to handle this scenario gracefully by + // invoking a custom handler. Ideally, if a user tries to launch a series that isn't viewable, + // (eg.: we can prompt them with an explanation and provide a link to the full study). + if (!referencedDisplaySetInstanceUID) { + const missingReferenceDisplaySetHandler = customizationService.getCustomization( + 'missingReferenceDisplaySetHandler' + ); + const { handled } = missingReferenceDisplaySetHandler(); + if (handled) { + return; + } + } const referencedDisplaySet = displaySetService.getDisplaySetByUID( referencedDisplaySetInstanceUID ); diff --git a/extensions/cornerstone-dicom-seg/src/viewports/OHIFCornerstoneSEGViewport.tsx b/extensions/cornerstone-dicom-seg/src/viewports/OHIFCornerstoneSEGViewport.tsx index bd5e65dd9..b6d8e5259 100644 --- a/extensions/cornerstone-dicom-seg/src/viewports/OHIFCornerstoneSEGViewport.tsx +++ b/extensions/cornerstone-dicom-seg/src/viewports/OHIFCornerstoneSEGViewport.tsx @@ -54,6 +54,21 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) { const { viewports, activeViewportId } = viewportGrid; const referencedDisplaySetInstanceUID = segDisplaySet.referencedDisplaySetInstanceUID; + // If the referencedDisplaySetInstanceUID is not found, it means the SEG series is being + // launched without its corresponding referenced display set (e.g., the SEG series is launched using + // series launch /mode?StudyInstanceUIDs=&SeriesInstanceUID). + // In such cases, we attempt to handle this scenario gracefully by + // invoking a custom handler. Ideally, if a user tries to launch a series that isn't viewable, + // (eg.: we can prompt them with an explanation and provide a link to the full study). + if (!referencedDisplaySetInstanceUID) { + const missingReferenceDisplaySetHandler = customizationService.getCustomization( + 'missingReferenceDisplaySetHandler' + ); + const { handled } = missingReferenceDisplaySetHandler(); + if (handled) { + return; + } + } const referencedDisplaySet = displaySetService.getDisplaySetByUID( referencedDisplaySetInstanceUID ); diff --git a/extensions/default/src/customizations/missingReferenceDisplaySetHandler.ts b/extensions/default/src/customizations/missingReferenceDisplaySetHandler.ts new file mode 100644 index 000000000..001b9c472 --- /dev/null +++ b/extensions/default/src/customizations/missingReferenceDisplaySetHandler.ts @@ -0,0 +1,5 @@ +export default { + missingReferenceDisplaySetHandler: () => { + return Promise.resolve({ handled: false }); + }, +};