@ohif/extension-cornerstone 3.14.0-beta.1 → 3.14.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/915.ohif-extension-cornerstone.umd.js +1 -1
- package/dist/ohif-extension-cornerstone.umd.js +1 -5
- package/package.json +33 -25
- package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
- package/src/Viewport/OHIFCornerstoneViewport.tsx +502 -0
- package/src/Viewport/Overlays/CornerstoneOverlays.tsx +103 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.css +25 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.tsx +469 -0
- package/src/Viewport/Overlays/ViewportImageScrollbar.tsx +106 -0
- package/src/Viewport/Overlays/ViewportImageSliceLoadingIndicator.tsx +87 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.css +41 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.tsx +136 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/ViewportSliceProgressScrollbar.tsx +195 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/helpers.ts +46 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/hooks.ts +383 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/index.ts +1 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/types.ts +17 -0
- package/src/Viewport/Overlays/utils.ts +66 -0
- package/src/commandsModule.ts +2951 -0
- package/src/components/AccordionGroup/AccordionGroup.tsx +195 -0
- package/src/components/AccordionGroup/index.ts +4 -0
- package/src/components/ActiveViewportWindowLevel/ActiveViewportWindowLevel.tsx +23 -0
- package/src/components/ActiveViewportWindowLevel/index.js +1 -0
- package/src/components/AdvancedRenderingControls/AdvancedRenderingControls.tsx +149 -0
- package/src/components/AdvancedRenderingControls/index.ts +1 -0
- package/src/components/CinePlayer/CinePlayer.tsx +247 -0
- package/src/components/CinePlayer/index.ts +3 -0
- package/src/components/DicomUpload/DicomUpload.tsx +111 -0
- package/src/components/DicomUpload/DicomUploadProgress.tsx +396 -0
- package/src/components/DicomUpload/DicomUploadProgressItem.tsx +119 -0
- package/src/components/ExportSegmentationSubMenuItem.tsx +75 -0
- package/src/components/MeasurementItems.tsx +70 -0
- package/src/components/MeasurementTableNested.tsx +30 -0
- package/src/components/MeasurementsMenu.tsx +84 -0
- package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
- package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
- package/src/components/ModalityLoadBadge/index.ts +1 -0
- package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
- package/src/components/NavigationComponent/index.ts +3 -0
- package/src/components/OHIFViewportActionCorners.tsx +94 -0
- package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
- package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
- package/src/components/OpacityMenu/index.ts +2 -0
- package/src/components/PanelAccordionTrigger.tsx +48 -0
- package/src/components/SegmentationToolConfig.tsx +71 -0
- package/src/components/SegmentationUtilityButton.tsx +61 -0
- package/src/components/SelectItemWithModality.tsx +29 -0
- package/src/components/SeriesMeasurements.tsx +90 -0
- package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
- package/src/components/StudyMeasurements.tsx +88 -0
- package/src/components/StudyMeasurementsActions.tsx +75 -0
- package/src/components/StudySummaryFromMetadata.test.ts +47 -0
- package/src/components/StudySummaryFromMetadata.tsx +31 -0
- package/src/components/StudySummaryWithActions.tsx +14 -0
- package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
- package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
- package/src/components/ThresholdMenu/index.ts +2 -0
- package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
- package/src/components/TrackingStatus/index.ts +1 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
- package/src/components/VOIManualControlMenu/index.ts +2 -0
- package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
- package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
- package/src/components/ViewportColorbar/index.ts +5 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
- package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -0
- package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
- package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
- package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
- package/src/components/ViewportWindowLevel/index.js +1 -0
- package/src/components/ViewportWindowLevel/utils.ts +176 -0
- package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
- package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
- package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
- package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
- package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
- package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
- package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
- package/src/components/WindowLevelActionMenu/index.ts +11 -0
- package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
- package/src/components/index.ts +12 -0
- package/src/constants/index.ts +13 -0
- package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
- package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
- package/src/customizations/captureViewportModalCustomization.tsx +175 -0
- package/src/customizations/colorbarCustomization.ts +93 -0
- package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
- package/src/customizations/layoutSelectorCustomization.ts +104 -0
- package/src/customizations/measurementsCustomization.ts +124 -0
- package/src/customizations/miscCustomization.ts +22 -0
- package/src/customizations/modalityColorMapCustomization.ts +23 -0
- package/src/customizations/segmentationHydrationCustomization.ts +16 -0
- package/src/customizations/segmentationPanelCustomization.tsx +119 -0
- package/src/customizations/segmentationToolbarCustomization.ts +964 -0
- package/src/customizations/toolGroupToolsCustomization.ts +204 -0
- package/src/customizations/toolbarButtonsCustomization.ts +805 -0
- package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
- package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
- package/src/customizations/viewportOverlayCustomization.tsx +46 -0
- package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
- package/src/customizations/viewportToolsCustomization.ts +33 -0
- package/src/customizations/volumeRenderingCustomization.ts +14 -0
- package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
- package/src/enums.ts +9 -0
- package/src/getCustomizationModule.tsx +54 -0
- package/src/getHangingProtocolModule.ts +47 -0
- package/src/getPanelModule.tsx +128 -0
- package/src/getSopClassHandlerModule.js +284 -0
- package/src/getToolbarModule.tsx +622 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
- package/src/hooks/useMeasurementTracking.ts +132 -0
- package/src/hooks/useMeasurements.ts +104 -0
- package/src/hooks/useSegmentations.ts +147 -0
- package/src/hooks/useViewportDisplaySets.ts +284 -0
- package/src/hooks/useViewportHover.ts +77 -0
- package/src/hooks/useViewportRendering.tsx +868 -0
- package/src/hooks/useViewportSegmentations.ts +245 -0
- package/src/hps/fourUp.ts +117 -0
- package/src/hps/frameView.ts +1581 -0
- package/src/hps/main3D.ts +142 -0
- package/src/hps/mpr.ts +197 -0
- package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
- package/src/hps/only3D.ts +70 -0
- package/src/hps/primary3D.ts +142 -0
- package/src/hps/primaryAxial.ts +114 -0
- package/src/id.js +5 -0
- package/src/index.tsx +350 -0
- package/src/init.tsx +445 -0
- package/src/initCineService.ts +75 -0
- package/src/initContextMenu.ts +94 -0
- package/src/initCornerstoneTools.js +188 -0
- package/src/initDoubleClick.ts +82 -0
- package/src/initMeasurementService.ts +576 -0
- package/src/initStudyPrefetcherService.ts +33 -0
- package/src/initWADOImageLoader.js +56 -0
- package/src/panels/PanelMeasurement.tsx +84 -0
- package/src/panels/PanelSegmentation.tsx +338 -0
- package/src/services/ColorbarService/ColorbarService.ts +242 -0
- package/src/services/ColorbarService/index.ts +2 -0
- package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
- package/src/services/CornerstoneCacheService/index.js +3 -0
- package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
- package/src/services/SegmentationService/SegmentationService.test.ts +3698 -0
- package/src/services/SegmentationService/SegmentationService.ts +2376 -0
- package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
- package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
- package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
- package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
- package/src/services/SegmentationService/backends/index.ts +4 -0
- package/src/services/SegmentationService/index.ts +3 -0
- package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
- package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
- package/src/services/SyncGroupService/index.js +3 -0
- package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
- package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
- package/src/services/ToolGroupService/index.js +3 -0
- package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
- package/src/services/ViewedDataService/index.ts +3 -0
- package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
- package/src/services/ViewportService/IViewportService.ts +64 -0
- package/src/services/ViewportService/Viewport.ts +372 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
- package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
- package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
- package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
- package/src/services/ViewportService/adapter/index.ts +16 -0
- package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
- package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
- package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
- package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
- package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
- package/src/services/ViewportService/backends/NextViewportBackend.ts +671 -0
- package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
- package/src/services/ViewportService/backends/README.md +62 -0
- package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
- package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
- package/src/services/ViewportService/constants.ts +3 -0
- package/src/state.ts +34 -0
- package/src/stores/index.ts +5 -0
- package/src/stores/presentationUtils.ts +42 -0
- package/src/stores/useLutPresentationStore.ts +166 -0
- package/src/stores/usePositionPresentationStore.ts +172 -0
- package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
- package/src/stores/useSegmentationPresentationStore.ts +417 -0
- package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
- package/src/stores/useSynchronizersStore.ts +84 -0
- package/src/synchronizers/frameViewSynchronizer.ts +52 -0
- package/src/tools/CalibrationLineTool.ts +97 -0
- package/src/tools/ImageOverlayViewerTool.tsx +279 -0
- package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
- package/src/tools/WindowLevelTool.test.ts +55 -0
- package/src/tools/WindowLevelTool.ts +22 -0
- package/src/types/AppTypes.ts +70 -0
- package/src/types/Colorbar.ts +114 -0
- package/src/types/Colormap.ts +16 -0
- package/src/types/CornerstoneCacheService.ts +40 -0
- package/src/types/CornerstoneServices.ts +18 -0
- package/src/types/Presentation.ts +83 -0
- package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
- package/src/types/ViewportPresets.ts +53 -0
- package/src/types/VolumeLighting.ts +7 -0
- package/src/types/VolumeRenderingConfig.ts +8 -0
- package/src/types/WindowLevel.ts +5 -0
- package/src/types/index.ts +10 -0
- package/src/utils/ActiveViewportBehavior.tsx +80 -0
- package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
- package/src/utils/DicomFileUploader.ts +204 -0
- package/src/utils/JumpPresets.ts +14 -0
- package/src/utils/autoHydrateViewportTypes.ts +69 -0
- package/src/utils/colormaps.js +1597 -0
- package/src/utils/createSegmentationForViewport.ts +83 -0
- package/src/utils/dicomLoaderService.js +225 -0
- package/src/utils/ecgMetadata.test.ts +137 -0
- package/src/utils/ecgMetadata.ts +109 -0
- package/src/utils/findNearbyToolData.test.ts +125 -0
- package/src/utils/findNearbyToolData.ts +21 -0
- package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
- package/src/utils/generateSegmentationCSVReport.ts +131 -0
- package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
- package/src/utils/getActiveViewportEnabledElement.ts +8 -0
- package/src/utils/getCenterExtent.test.ts +313 -0
- package/src/utils/getCenterExtent.ts +46 -0
- package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
- package/src/utils/getCornerstoneBlendMode.ts +25 -0
- package/src/utils/getCornerstoneOrientation.test.ts +78 -0
- package/src/utils/getCornerstoneOrientation.ts +31 -0
- package/src/utils/getCornerstoneViewportType.test.ts +169 -0
- package/src/utils/getCornerstoneViewportType.ts +88 -0
- package/src/utils/getInterleavedFrames.test.ts +85 -0
- package/src/utils/getInterleavedFrames.ts +73 -0
- package/src/utils/getLegacyViewportType.ts +64 -0
- package/src/utils/getNthFrames.test.ts +145 -0
- package/src/utils/getNthFrames.ts +31 -0
- package/src/utils/getViewportEnabledElement.test.ts +83 -0
- package/src/utils/getViewportEnabledElement.ts +8 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
- package/src/utils/hydrationUtils.test.ts +572 -0
- package/src/utils/hydrationUtils.ts +197 -0
- package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
- package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/initGpuSettingsPreset.ts +51 -0
- package/src/utils/initViewTiming.test.ts +342 -0
- package/src/utils/initViewTiming.ts +52 -0
- package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
- package/src/utils/initWebWorkerProgressHandler.ts +110 -0
- package/src/utils/interleave.test.ts +304 -0
- package/src/utils/interleave.ts +32 -0
- package/src/utils/interleaveCenterLoader.test.ts +547 -0
- package/src/utils/interleaveCenterLoader.ts +143 -0
- package/src/utils/interleaveTopToBottom.test.ts +487 -0
- package/src/utils/interleaveTopToBottom.ts +132 -0
- package/src/utils/isAnyDisplaySetCommon.ts +18 -0
- package/src/utils/isDisplaySetOverlayable.ts +96 -0
- package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
- package/src/utils/isMeasurementWithinViewport.ts +33 -0
- package/src/utils/isReferenceViewable.test.ts +581 -0
- package/src/utils/isReferenceViewable.ts +95 -0
- package/src/utils/loadDisplaySetData.ts +49 -0
- package/src/utils/measurementServiceMappings/Angle.ts +200 -0
- package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
- package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
- package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
- package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
- package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
- package/src/utils/measurementServiceMappings/Length.ts +206 -0
- package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
- package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
- package/src/utils/measurementServiceMappings/Probe.ts +192 -0
- package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
- package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
- package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
- package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
- package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
- package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
- package/src/utils/measurementServiceMappings/index.ts +3 -0
- package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
- package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
- package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
- package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
- package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
- package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
- package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
- package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
- package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
- package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
- package/src/utils/nextViewportPolicies.ts +41 -0
- package/src/utils/nextViewports.ts +157 -0
- package/src/utils/nthLoader.test.ts +317 -0
- package/src/utils/nthLoader.ts +78 -0
- package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
- package/src/utils/presentations/getViewportPresentations.ts +151 -0
- package/src/utils/promptHydrationDialog.test.ts +490 -0
- package/src/utils/promptHydrationDialog.ts +197 -0
- package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
- package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
- package/src/utils/segmentUtils.test.ts +515 -0
- package/src/utils/segmentUtils.ts +46 -0
- package/src/utils/segmentationExportUtils.test.ts +100 -0
- package/src/utils/segmentationExportUtils.ts +171 -0
- package/src/utils/segmentationHandlers.test.ts +614 -0
- package/src/utils/segmentationHandlers.ts +164 -0
- package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
- package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
- package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
- package/src/utils/toggleVOISliceSync.test.ts +606 -0
- package/src/utils/toggleVOISliceSync.ts +103 -0
- package/src/utils/transitions.test.ts +351 -0
- package/src/utils/transitions.ts +300 -0
- package/src/utils/updateSegmentationStats.test.ts +942 -0
- package/src/utils/updateSegmentationStats.ts +192 -0
- package/src/utils/viewportDataShape.ts +85 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import promptHydrationDialog, { HydrationType } from './promptHydrationDialog';
|
|
2
|
+
|
|
3
|
+
describe('promptHydrationDialog', () => {
|
|
4
|
+
const mockUIViewportDialogService = {
|
|
5
|
+
show: jest.fn(),
|
|
6
|
+
hide: jest.fn(),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const mockCustomizationService = {
|
|
10
|
+
getCustomization: jest.fn(),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const mockExtensionManager = {
|
|
14
|
+
appConfig: {
|
|
15
|
+
measurementTrackingMode: 'standard',
|
|
16
|
+
disableConfirmationPrompts: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const mockServicesManager = {
|
|
21
|
+
services: {
|
|
22
|
+
uiViewportDialogService: mockUIViewportDialogService,
|
|
23
|
+
customizationService: mockCustomizationService,
|
|
24
|
+
},
|
|
25
|
+
_extensionManager: mockExtensionManager,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const mockDisplaySet = {
|
|
29
|
+
displaySetInstanceUID: 'test-display-set-uid',
|
|
30
|
+
SeriesInstanceUID: 'test-series-uid',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const mockHydrateCallback = jest.fn();
|
|
34
|
+
const mockPreHydrateCallback = jest.fn();
|
|
35
|
+
|
|
36
|
+
const defaultParameters = {
|
|
37
|
+
servicesManager: mockServicesManager as unknown as AppTypes.ServicesManager,
|
|
38
|
+
viewportId: 'test-viewport-id',
|
|
39
|
+
displaySet: mockDisplaySet as unknown as AppTypes.DisplaySet,
|
|
40
|
+
preHydrateCallbacks: [mockPreHydrateCallback],
|
|
41
|
+
hydrateCallback: mockHydrateCallback,
|
|
42
|
+
type: HydrationType.SEG,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
jest.clearAllMocks();
|
|
47
|
+
mockCustomizationService.getCustomization.mockReturnValue('Test message');
|
|
48
|
+
mockHydrateCallback.mockResolvedValue(true);
|
|
49
|
+
jest.spyOn(window, 'setTimeout').mockImplementation((callback: () => void) => {
|
|
50
|
+
callback();
|
|
51
|
+
return 0 as unknown as NodeJS.Timeout;
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
jest.restoreAllMocks();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return HYDRATE response when disableConfirmationPrompts is true for non-SR types', async () => {
|
|
60
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
61
|
+
|
|
62
|
+
const result = await promptHydrationDialog(defaultParameters);
|
|
63
|
+
|
|
64
|
+
expect(mockUIViewportDialogService.show).not.toHaveBeenCalled();
|
|
65
|
+
expect(mockPreHydrateCallback).toHaveBeenCalled();
|
|
66
|
+
expect(mockHydrateCallback).toHaveBeenCalledWith({
|
|
67
|
+
segDisplaySet: mockDisplaySet,
|
|
68
|
+
viewportId: defaultParameters.viewportId,
|
|
69
|
+
});
|
|
70
|
+
expect(result).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should show dialog when disableConfirmationPrompts is false for non-SR types', async () => {
|
|
74
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
75
|
+
|
|
76
|
+
const promise = promptHydrationDialog(defaultParameters);
|
|
77
|
+
|
|
78
|
+
expect(mockUIViewportDialogService.show).toHaveBeenCalledWith({
|
|
79
|
+
id: 'promptHydrateSEG',
|
|
80
|
+
viewportId: defaultParameters.viewportId,
|
|
81
|
+
type: 'info',
|
|
82
|
+
message: 'Test message',
|
|
83
|
+
actions: [
|
|
84
|
+
{
|
|
85
|
+
id: 'no-hydrate',
|
|
86
|
+
type: 'secondary',
|
|
87
|
+
text: 'No',
|
|
88
|
+
value: 0,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'yes-hydrate',
|
|
92
|
+
type: 'primary',
|
|
93
|
+
text: 'Yes',
|
|
94
|
+
value: 5,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
onSubmit: expect.any(Function),
|
|
98
|
+
onOutsideClick: expect.any(Function),
|
|
99
|
+
onKeyPress: expect.any(Function),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const onSubmit = mockUIViewportDialogService.show.mock.calls[0][0].onSubmit;
|
|
103
|
+
onSubmit(5);
|
|
104
|
+
|
|
105
|
+
const result = await promise;
|
|
106
|
+
expect(result).toBe(true);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should handle CANCEL response', async () => {
|
|
110
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
111
|
+
|
|
112
|
+
const promise = promptHydrationDialog(defaultParameters);
|
|
113
|
+
|
|
114
|
+
const onSubmit = mockUIViewportDialogService.show.mock.calls[0][0].onSubmit;
|
|
115
|
+
onSubmit(0);
|
|
116
|
+
|
|
117
|
+
const result = await promise;
|
|
118
|
+
expect(result).toBe(false);
|
|
119
|
+
expect(mockHydrateCallback).not.toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should handle onOutsideClick', async () => {
|
|
123
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
124
|
+
|
|
125
|
+
const promise = promptHydrationDialog(defaultParameters);
|
|
126
|
+
|
|
127
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
128
|
+
onOutsideClick();
|
|
129
|
+
|
|
130
|
+
const result = await promise;
|
|
131
|
+
expect(result).toBe(false);
|
|
132
|
+
expect(mockUIViewportDialogService.hide).toHaveBeenCalled();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should handle onKeyPress Enter', async () => {
|
|
136
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
137
|
+
|
|
138
|
+
const promise = promptHydrationDialog(defaultParameters);
|
|
139
|
+
|
|
140
|
+
const onKeyPress = mockUIViewportDialogService.show.mock.calls[0][0].onKeyPress;
|
|
141
|
+
onKeyPress({ key: 'Enter' });
|
|
142
|
+
|
|
143
|
+
const result = await promise;
|
|
144
|
+
expect(result).toBe(true);
|
|
145
|
+
expect(mockUIViewportDialogService.hide).toHaveBeenCalled();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should handle onKeyPress non-Enter key', async () => {
|
|
149
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
150
|
+
|
|
151
|
+
const promise = promptHydrationDialog(defaultParameters);
|
|
152
|
+
|
|
153
|
+
const onKeyPress = mockUIViewportDialogService.show.mock.calls[0][0].onKeyPress;
|
|
154
|
+
onKeyPress({ key: 'Escape' });
|
|
155
|
+
|
|
156
|
+
expect(mockUIViewportDialogService.hide).not.toHaveBeenCalled();
|
|
157
|
+
|
|
158
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
159
|
+
onOutsideClick();
|
|
160
|
+
|
|
161
|
+
const result = await promise;
|
|
162
|
+
expect(result).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should handle SEG type hydration with setTimeout', async () => {
|
|
166
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
167
|
+
|
|
168
|
+
await promptHydrationDialog({
|
|
169
|
+
...defaultParameters,
|
|
170
|
+
type: HydrationType.SEG,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
expect(window.setTimeout).toHaveBeenCalledWith(expect.any(Function), 0);
|
|
174
|
+
expect(mockHydrateCallback).toHaveBeenCalledWith({
|
|
175
|
+
segDisplaySet: mockDisplaySet,
|
|
176
|
+
viewportId: defaultParameters.viewportId,
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should handle RTSTRUCT type hydration', async () => {
|
|
181
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
182
|
+
|
|
183
|
+
const result = await promptHydrationDialog({
|
|
184
|
+
...defaultParameters,
|
|
185
|
+
type: HydrationType.RTSTRUCT,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
expect(mockHydrateCallback).toHaveBeenCalledWith({
|
|
189
|
+
rtDisplaySet: mockDisplaySet,
|
|
190
|
+
viewportId: defaultParameters.viewportId,
|
|
191
|
+
servicesManager: mockServicesManager,
|
|
192
|
+
});
|
|
193
|
+
expect(result).toBe(true);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('should handle SR type hydration when standardMode is true', async () => {
|
|
197
|
+
mockExtensionManager.appConfig.measurementTrackingMode = 'standard';
|
|
198
|
+
const mockHydrationResult = {
|
|
199
|
+
StudyInstanceUID: 'test-study-uid',
|
|
200
|
+
SeriesInstanceUIDs: ['series-1', 'series-2'],
|
|
201
|
+
};
|
|
202
|
+
mockHydrateCallback.mockResolvedValue(mockHydrationResult);
|
|
203
|
+
|
|
204
|
+
const promise = promptHydrationDialog({
|
|
205
|
+
...defaultParameters,
|
|
206
|
+
type: HydrationType.SR,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const onSubmit = mockUIViewportDialogService.show.mock.calls[0][0].onSubmit;
|
|
210
|
+
onSubmit(5);
|
|
211
|
+
|
|
212
|
+
const result = await promise;
|
|
213
|
+
|
|
214
|
+
expect(result).toEqual({
|
|
215
|
+
userResponse: 5,
|
|
216
|
+
displaySetInstanceUID: mockDisplaySet.displaySetInstanceUID,
|
|
217
|
+
srSeriesInstanceUID: mockDisplaySet.SeriesInstanceUID,
|
|
218
|
+
viewportId: defaultParameters.viewportId,
|
|
219
|
+
StudyInstanceUID: mockHydrationResult.StudyInstanceUID,
|
|
220
|
+
SeriesInstanceUIDs: mockHydrationResult.SeriesInstanceUIDs,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should handle SR type hydration when standardMode is false', async () => {
|
|
225
|
+
mockExtensionManager.appConfig.measurementTrackingMode = 'other';
|
|
226
|
+
|
|
227
|
+
const result = await promptHydrationDialog({
|
|
228
|
+
...defaultParameters,
|
|
229
|
+
type: HydrationType.SR,
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
expect(mockUIViewportDialogService.show).not.toHaveBeenCalled();
|
|
233
|
+
expect(result).toEqual({
|
|
234
|
+
userResponse: 5,
|
|
235
|
+
displaySetInstanceUID: mockDisplaySet.displaySetInstanceUID,
|
|
236
|
+
srSeriesInstanceUID: mockDisplaySet.SeriesInstanceUID,
|
|
237
|
+
viewportId: defaultParameters.viewportId,
|
|
238
|
+
StudyInstanceUID: undefined,
|
|
239
|
+
SeriesInstanceUIDs: undefined,
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('should handle SR type with CANCEL response', async () => {
|
|
244
|
+
mockExtensionManager.appConfig.measurementTrackingMode = 'standard';
|
|
245
|
+
|
|
246
|
+
const promise = promptHydrationDialog({
|
|
247
|
+
...defaultParameters,
|
|
248
|
+
type: HydrationType.SR,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const onSubmit = mockUIViewportDialogService.show.mock.calls[0][0].onSubmit;
|
|
252
|
+
onSubmit(0);
|
|
253
|
+
|
|
254
|
+
const result = await promise;
|
|
255
|
+
|
|
256
|
+
expect(result).toEqual({
|
|
257
|
+
userResponse: 0,
|
|
258
|
+
displaySetInstanceUID: mockDisplaySet.displaySetInstanceUID,
|
|
259
|
+
srSeriesInstanceUID: mockDisplaySet.SeriesInstanceUID,
|
|
260
|
+
viewportId: defaultParameters.viewportId,
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('should handle undefined preHydrateCallbacks', async () => {
|
|
265
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
266
|
+
|
|
267
|
+
await promptHydrationDialog({
|
|
268
|
+
...defaultParameters,
|
|
269
|
+
preHydrateCallbacks: undefined,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
expect(mockHydrateCallback).toHaveBeenCalled();
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('should handle empty preHydrateCallbacks array', async () => {
|
|
276
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
277
|
+
|
|
278
|
+
await promptHydrationDialog({
|
|
279
|
+
...defaultParameters,
|
|
280
|
+
preHydrateCallbacks: [],
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
expect(mockHydrateCallback).toHaveBeenCalled();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('should execute multiple preHydrateCallbacks', async () => {
|
|
287
|
+
const mockPreHydrateCallback2 = jest.fn();
|
|
288
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
289
|
+
|
|
290
|
+
await promptHydrationDialog({
|
|
291
|
+
...defaultParameters,
|
|
292
|
+
preHydrateCallbacks: [mockPreHydrateCallback, mockPreHydrateCallback2],
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
expect(mockPreHydrateCallback).toHaveBeenCalled();
|
|
296
|
+
expect(mockPreHydrateCallback2).toHaveBeenCalled();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('should get correct customization message key for SEG type', async () => {
|
|
300
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
301
|
+
|
|
302
|
+
const promise = promptHydrationDialog({
|
|
303
|
+
...defaultParameters,
|
|
304
|
+
type: HydrationType.SEG,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
expect(mockCustomizationService.getCustomization).toHaveBeenCalledWith(
|
|
308
|
+
'viewportNotification.hydrateSEGMessage'
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
312
|
+
onOutsideClick();
|
|
313
|
+
await promise;
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should get correct customization message key for RTSTRUCT type', async () => {
|
|
317
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
318
|
+
|
|
319
|
+
const promise = promptHydrationDialog({
|
|
320
|
+
...defaultParameters,
|
|
321
|
+
type: HydrationType.RTSTRUCT,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
expect(mockCustomizationService.getCustomization).toHaveBeenCalledWith(
|
|
325
|
+
'viewportNotification.hydrateRTMessage'
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
329
|
+
onOutsideClick();
|
|
330
|
+
await promise;
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('should get correct customization message key for SR type', async () => {
|
|
334
|
+
mockExtensionManager.appConfig.measurementTrackingMode = 'standard';
|
|
335
|
+
|
|
336
|
+
const promise = promptHydrationDialog({
|
|
337
|
+
...defaultParameters,
|
|
338
|
+
type: HydrationType.SR,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
expect(mockCustomizationService.getCustomization).toHaveBeenCalledWith(
|
|
342
|
+
'viewportNotification.hydrateSRMessage'
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
346
|
+
onOutsideClick();
|
|
347
|
+
await promise;
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should get default customization message key for unknown type', async () => {
|
|
351
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
352
|
+
|
|
353
|
+
const promise = promptHydrationDialog({
|
|
354
|
+
...defaultParameters,
|
|
355
|
+
type: 'UNKNOWN_TYPE',
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
expect(mockCustomizationService.getCustomization).toHaveBeenCalledWith(
|
|
359
|
+
'viewportNotification.hydrateMessage'
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
363
|
+
onOutsideClick();
|
|
364
|
+
await promise;
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('should get correct dialog id for SEG type', async () => {
|
|
368
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
369
|
+
|
|
370
|
+
const promise = promptHydrationDialog({
|
|
371
|
+
...defaultParameters,
|
|
372
|
+
type: HydrationType.SEG,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(mockUIViewportDialogService.show).toHaveBeenCalledWith(
|
|
376
|
+
expect.objectContaining({
|
|
377
|
+
id: 'promptHydrateSEG',
|
|
378
|
+
})
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
382
|
+
onOutsideClick();
|
|
383
|
+
await promise;
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('should get correct dialog id for SR type', async () => {
|
|
387
|
+
mockExtensionManager.appConfig.measurementTrackingMode = 'standard';
|
|
388
|
+
|
|
389
|
+
const promise = promptHydrationDialog({
|
|
390
|
+
...defaultParameters,
|
|
391
|
+
type: HydrationType.SR,
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
expect(mockUIViewportDialogService.show).toHaveBeenCalledWith(
|
|
395
|
+
expect.objectContaining({
|
|
396
|
+
id: 'promptHydrateSR',
|
|
397
|
+
})
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
401
|
+
onOutsideClick();
|
|
402
|
+
await promise;
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('should get default dialog id for unknown type', async () => {
|
|
406
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
407
|
+
|
|
408
|
+
const promise = promptHydrationDialog({
|
|
409
|
+
...defaultParameters,
|
|
410
|
+
type: 'UNKNOWN_TYPE',
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
expect(mockUIViewportDialogService.show).toHaveBeenCalledWith(
|
|
414
|
+
expect.objectContaining({
|
|
415
|
+
id: 'promptHydrate',
|
|
416
|
+
})
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
420
|
+
onOutsideClick();
|
|
421
|
+
await promise;
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it('should handle hydrateCallback returning false for SEG', async () => {
|
|
425
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
426
|
+
mockHydrateCallback.mockResolvedValue(false);
|
|
427
|
+
|
|
428
|
+
const result = await promptHydrationDialog({
|
|
429
|
+
...defaultParameters,
|
|
430
|
+
type: HydrationType.SEG,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
expect(result).toBe(false);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it('should handle hydrateCallback returning false for RTSTRUCT', async () => {
|
|
437
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = true;
|
|
438
|
+
mockHydrateCallback.mockResolvedValue(false);
|
|
439
|
+
|
|
440
|
+
const result = await promptHydrationDialog({
|
|
441
|
+
...defaultParameters,
|
|
442
|
+
type: HydrationType.RTSTRUCT,
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
expect(result).toBe(false);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
it('should handle SR hydration with null result', async () => {
|
|
449
|
+
mockExtensionManager.appConfig.measurementTrackingMode = 'standard';
|
|
450
|
+
mockHydrateCallback.mockResolvedValue(null);
|
|
451
|
+
|
|
452
|
+
const promise = promptHydrationDialog({
|
|
453
|
+
...defaultParameters,
|
|
454
|
+
type: HydrationType.SR,
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const onSubmit = mockUIViewportDialogService.show.mock.calls[0][0].onSubmit;
|
|
458
|
+
onSubmit(5);
|
|
459
|
+
|
|
460
|
+
const result = await promise;
|
|
461
|
+
|
|
462
|
+
expect(result).toEqual({
|
|
463
|
+
userResponse: 5,
|
|
464
|
+
displaySetInstanceUID: mockDisplaySet.displaySetInstanceUID,
|
|
465
|
+
srSeriesInstanceUID: mockDisplaySet.SeriesInstanceUID,
|
|
466
|
+
viewportId: defaultParameters.viewportId,
|
|
467
|
+
StudyInstanceUID: undefined,
|
|
468
|
+
SeriesInstanceUIDs: undefined,
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
it('should handle RTSTRUCT type in getDialogId', async () => {
|
|
473
|
+
mockExtensionManager.appConfig.disableConfirmationPrompts = false;
|
|
474
|
+
|
|
475
|
+
const promise = promptHydrationDialog({
|
|
476
|
+
...defaultParameters,
|
|
477
|
+
type: 'RTSTRUCT',
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
expect(mockUIViewportDialogService.show).toHaveBeenCalledWith(
|
|
481
|
+
expect.objectContaining({
|
|
482
|
+
id: 'promptHydrateRT',
|
|
483
|
+
})
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
const onOutsideClick = mockUIViewportDialogService.show.mock.calls[0][0].onOutsideClick;
|
|
487
|
+
onOutsideClick();
|
|
488
|
+
await promise;
|
|
489
|
+
});
|
|
490
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export type HydrationCallback = (params: any) => Promise<boolean>;
|
|
2
|
+
|
|
3
|
+
export const HydrationType = {
|
|
4
|
+
SEG: 'SEG',
|
|
5
|
+
SR: 'SR',
|
|
6
|
+
RTSTRUCT: 'RTSTRUCT',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export interface HydrationDialogProps {
|
|
10
|
+
servicesManager: AppTypes.ServicesManager;
|
|
11
|
+
viewportId: string;
|
|
12
|
+
displaySet: AppTypes.DisplaySet;
|
|
13
|
+
preHydrateCallbacks?: HydrationCallback[];
|
|
14
|
+
hydrateCallback: HydrationCallback;
|
|
15
|
+
type: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface HydrationSRResult {
|
|
19
|
+
userResponse: number;
|
|
20
|
+
displaySetInstanceUID: string;
|
|
21
|
+
srSeriesInstanceUID: string;
|
|
22
|
+
viewportId: string;
|
|
23
|
+
StudyInstanceUID?: string;
|
|
24
|
+
SeriesInstanceUIDs?: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const RESPONSE = {
|
|
28
|
+
NO_NEVER: -1,
|
|
29
|
+
CANCEL: 0,
|
|
30
|
+
CREATE_REPORT: 1,
|
|
31
|
+
ADD_SERIES: 2,
|
|
32
|
+
SET_STUDY_AND_SERIES: 3,
|
|
33
|
+
NO_NOT_FOR_SERIES: 4,
|
|
34
|
+
HYDRATE: 5,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function getCustomizationMessageKey(type: string): string {
|
|
38
|
+
switch (type) {
|
|
39
|
+
case HydrationType.RTSTRUCT:
|
|
40
|
+
return 'viewportNotification.hydrateRTMessage';
|
|
41
|
+
case HydrationType.SEG:
|
|
42
|
+
return 'viewportNotification.hydrateSEGMessage';
|
|
43
|
+
case HydrationType.SR:
|
|
44
|
+
return 'viewportNotification.hydrateSRMessage';
|
|
45
|
+
default:
|
|
46
|
+
return 'viewportNotification.hydrateMessage';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getDialogId(type: string): string {
|
|
51
|
+
switch (type) {
|
|
52
|
+
case HydrationType.RTSTRUCT:
|
|
53
|
+
return 'promptHydrateRT';
|
|
54
|
+
case HydrationType.SEG:
|
|
55
|
+
return 'promptHydrateSEG';
|
|
56
|
+
case HydrationType.SR:
|
|
57
|
+
return 'promptHydrateSR';
|
|
58
|
+
default:
|
|
59
|
+
return 'promptHydrate';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function promptHydrationDialog({
|
|
64
|
+
servicesManager,
|
|
65
|
+
viewportId,
|
|
66
|
+
displaySet,
|
|
67
|
+
preHydrateCallbacks = [],
|
|
68
|
+
hydrateCallback,
|
|
69
|
+
type,
|
|
70
|
+
}: HydrationDialogProps): Promise<boolean | HydrationSRResult> {
|
|
71
|
+
const { uiViewportDialogService, customizationService } = servicesManager.services;
|
|
72
|
+
const extensionManager = servicesManager._extensionManager;
|
|
73
|
+
const appConfig = extensionManager.appConfig;
|
|
74
|
+
|
|
75
|
+
// Todo: make this use enum from the extension, we should move the enum
|
|
76
|
+
const standardMode = appConfig?.measurementTrackingMode === 'standard';
|
|
77
|
+
|
|
78
|
+
return new Promise(async function (resolve, reject) {
|
|
79
|
+
// For RT and SEG, we check disableConfirmationPrompts
|
|
80
|
+
// For SR, we check if standardMode is true
|
|
81
|
+
const shouldPrompt =
|
|
82
|
+
type === HydrationType.SR ? standardMode : !appConfig?.disableConfirmationPrompts;
|
|
83
|
+
|
|
84
|
+
const promptResult = shouldPrompt
|
|
85
|
+
? await _askHydrate(uiViewportDialogService, customizationService, viewportId, type)
|
|
86
|
+
: RESPONSE.HYDRATE;
|
|
87
|
+
|
|
88
|
+
if (promptResult === RESPONSE.HYDRATE) {
|
|
89
|
+
// Execute preHydrate callbacks
|
|
90
|
+
preHydrateCallbacks?.forEach(callback => {
|
|
91
|
+
callback();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (type === HydrationType.SEG) {
|
|
95
|
+
// SEG needs setTimeout
|
|
96
|
+
window.setTimeout(async () => {
|
|
97
|
+
try {
|
|
98
|
+
const isHydrated = await hydrateCallback({
|
|
99
|
+
segDisplaySet: displaySet,
|
|
100
|
+
viewportId,
|
|
101
|
+
});
|
|
102
|
+
resolve(isHydrated);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
reject(error);
|
|
105
|
+
}
|
|
106
|
+
}, 0);
|
|
107
|
+
} else if (type === HydrationType.RTSTRUCT) {
|
|
108
|
+
// RT hydration
|
|
109
|
+
window.setTimeout(async () => {
|
|
110
|
+
try {
|
|
111
|
+
const isHydrated = await hydrateCallback({
|
|
112
|
+
rtDisplaySet: displaySet,
|
|
113
|
+
viewportId,
|
|
114
|
+
servicesManager,
|
|
115
|
+
});
|
|
116
|
+
resolve(isHydrated);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
reject(error);
|
|
119
|
+
}
|
|
120
|
+
}, 0);
|
|
121
|
+
} else if (type === HydrationType.SR) {
|
|
122
|
+
// SR has a different result structure
|
|
123
|
+
const hydrationResult = await hydrateCallback(displaySet);
|
|
124
|
+
|
|
125
|
+
resolve({
|
|
126
|
+
userResponse: promptResult,
|
|
127
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
128
|
+
srSeriesInstanceUID: displaySet.SeriesInstanceUID,
|
|
129
|
+
viewportId,
|
|
130
|
+
StudyInstanceUID: hydrationResult?.StudyInstanceUID,
|
|
131
|
+
SeriesInstanceUIDs: hydrationResult?.SeriesInstanceUIDs,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
if (type === HydrationType.SR) {
|
|
136
|
+
resolve({
|
|
137
|
+
userResponse: promptResult,
|
|
138
|
+
displaySetInstanceUID: displaySet.displaySetInstanceUID,
|
|
139
|
+
srSeriesInstanceUID: displaySet.SeriesInstanceUID,
|
|
140
|
+
viewportId,
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
resolve(false);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function _askHydrate(
|
|
150
|
+
uiViewportDialogService: AppTypes.UIViewportDialogService,
|
|
151
|
+
customizationService: AppTypes.CustomizationService,
|
|
152
|
+
viewportId: string,
|
|
153
|
+
type: string
|
|
154
|
+
) {
|
|
155
|
+
return new Promise(function (resolve, reject) {
|
|
156
|
+
const messageKey = getCustomizationMessageKey(type);
|
|
157
|
+
const message = customizationService.getCustomization(messageKey);
|
|
158
|
+
const actions = [
|
|
159
|
+
{
|
|
160
|
+
id: 'no-hydrate',
|
|
161
|
+
type: 'secondary',
|
|
162
|
+
text: 'No',
|
|
163
|
+
value: RESPONSE.CANCEL,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 'yes-hydrate',
|
|
167
|
+
type: 'primary',
|
|
168
|
+
text: 'Yes',
|
|
169
|
+
value: RESPONSE.HYDRATE,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
const onSubmit = result => {
|
|
173
|
+
uiViewportDialogService.hide();
|
|
174
|
+
resolve(result);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
uiViewportDialogService.show({
|
|
178
|
+
id: getDialogId(type),
|
|
179
|
+
viewportId,
|
|
180
|
+
type: 'info',
|
|
181
|
+
message,
|
|
182
|
+
actions,
|
|
183
|
+
onSubmit,
|
|
184
|
+
onOutsideClick: () => {
|
|
185
|
+
uiViewportDialogService.hide();
|
|
186
|
+
resolve(RESPONSE.CANCEL);
|
|
187
|
+
},
|
|
188
|
+
onKeyPress: event => {
|
|
189
|
+
if (event.key === 'Enter') {
|
|
190
|
+
onSubmit(RESPONSE.HYDRATE);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default promptHydrationDialog;
|