@ohif/extension-default 3.14.0-beta.10 → 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/ohif-extension-default.css +1 -1
- package/dist/ohif-extension-default.umd.js +1 -1
- package/package.json +14 -10
- package/src/Actions/createReportAsync.tsx +45 -0
- package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
- package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
- package/src/Components/ItemListComponent.tsx +95 -0
- package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
- package/src/Components/LineChartViewport/index.ts +1 -0
- package/src/Components/MoreDropdownMenu.tsx +112 -0
- package/src/Components/ProgressDropdownWithService.tsx +101 -0
- package/src/Components/SidePanelWithServices.tsx +122 -0
- package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
- package/src/CustomizableContextMenu/index.ts +5 -0
- package/src/CustomizableContextMenu/types.ts +126 -0
- package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
- package/src/DicomJSONDataSource/index.js +326 -0
- package/src/DicomLocalDataSource/index.js +273 -0
- package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
- package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
- package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
- package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
- package/src/DicomWebDataSource/exampleInstances.js +280 -0
- package/src/DicomWebDataSource/index.ts +808 -0
- package/src/DicomWebDataSource/qido.js +215 -0
- package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
- package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
- package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
- package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
- package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
- package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
- package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
- package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
- package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
- package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
- package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
- package/src/DicomWebDataSource/utils/getImageId.js +54 -0
- package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
- package/src/DicomWebDataSource/utils/index.ts +9 -0
- package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
- package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
- package/src/DicomWebProxyDataSource/index.ts +90 -0
- package/src/MergeDataSource/index.test.ts +212 -0
- package/src/MergeDataSource/index.ts +319 -0
- package/src/MergeDataSource/types.ts +46 -0
- package/src/Panels/DataSourceSelector.tsx +55 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
- package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
- package/src/Panels/StudyBrowser/constants/index.ts +4 -0
- package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
- package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
- package/src/Panels/StudyBrowser/types/index.ts +4 -0
- package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
- package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
- package/src/Panels/createReportDialogPrompt.tsx +128 -0
- package/src/Panels/debounce.js +25 -0
- package/src/Panels/getImageSrcFromImageId.js +16 -0
- package/src/Panels/getStudiesForPatientByMRN.js +19 -0
- package/src/Panels/index.js +5 -0
- package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
- package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
- package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
- package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
- package/src/Toolbar/ToolRowWrapper.tsx +41 -0
- package/src/Toolbar/Toolbar.tsx +98 -0
- package/src/Toolbar/ToolbarDivider.tsx +5 -0
- package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
- package/src/Toolbar/index.ts +7 -0
- package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
- package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
- package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
- package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
- package/src/ViewerLayout/ViewerHeader.tsx +124 -0
- package/src/ViewerLayout/constants/panels.ts +42 -0
- package/src/ViewerLayout/index.tsx +227 -0
- package/src/ViewerLayout/useUndoRedoState.ts +75 -0
- package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
- package/src/commandsModule.ts +970 -0
- package/src/customizations/aboutModalCustomization.tsx +42 -0
- package/src/customizations/appearanceModalCustomization.tsx +143 -0
- package/src/customizations/contextMenuCustomization.ts +25 -0
- package/src/customizations/contextMenuUICustomization.ts +5 -0
- package/src/customizations/customRoutesCustomization.ts +6 -0
- package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
- package/src/customizations/datasourcesCustomization.tsx +14 -0
- package/src/customizations/defaultContextMenuCustomization.ts +22 -0
- package/src/customizations/hangingProtocolsCustomization.ts +15 -0
- package/src/customizations/headerRightSideCustomization.ts +19 -0
- package/src/customizations/helloPageCustomization.tsx +14 -0
- package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
- package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
- package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
- package/src/customizations/labellingFlowCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
- package/src/customizations/menuContentCustomization.tsx +67 -0
- package/src/customizations/metadataContextCustomization.test.ts +22 -0
- package/src/customizations/metadataContextCustomization.ts +28 -0
- package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
- package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
- package/src/customizations/multimonitorCustomization.ts +63 -0
- package/src/customizations/notificationCustomization.ts +29 -0
- package/src/customizations/onDropHandlerCustomization.ts +5 -0
- package/src/customizations/onboardingCustomization.ts +200 -0
- package/src/customizations/overlayItemCustomization.tsx +33 -0
- package/src/customizations/progressDropdownCustomization.ts +5 -0
- package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
- package/src/customizations/reportDialogCustomization.test.ts +701 -0
- package/src/customizations/reportDialogCustomization.tsx +661 -0
- package/src/customizations/sortingCriteriaCustomization.ts +14 -0
- package/src/customizations/studyBrowserCustomization.test.ts +69 -0
- package/src/customizations/studyBrowserCustomization.ts +95 -0
- package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
- package/src/customizations/userPreferencesCustomization.tsx +342 -0
- package/src/customizations/workListCustomization.ts +107 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
- package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
- package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
- package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
- package/src/findViewportsByPosition.ts +102 -0
- package/src/getCustomizationModule.tsx +109 -0
- package/src/getDataSourcesModule.js +44 -0
- package/src/getDisplaySetMessages.ts +54 -0
- package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
- package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
- package/src/getHangingProtocolModule.js +155 -0
- package/src/getLayoutTemplateModule.js +28 -0
- package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
- package/src/getPTImageIdInstanceMetadata.ts +124 -0
- package/src/getPanelModule.tsx +29 -0
- package/src/getSopClassHandlerModule.js +152 -0
- package/src/getSopClassHandlerModule.test.js +78 -0
- package/src/getToolbarModule.tsx +63 -0
- package/src/getViewportModule.tsx +12 -0
- package/src/hangingprotocols/hpCompare.ts +189 -0
- package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
- package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
- package/src/hangingprotocols/hpMNGrid.ts +419 -0
- package/src/hangingprotocols/hpMammo.ts +202 -0
- package/src/hangingprotocols/hpScale.ts +132 -0
- package/src/hangingprotocols/index.ts +16 -0
- package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
- package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
- package/src/hangingprotocols/utils/laterality.ts +9 -0
- package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
- package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
- package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
- package/src/hangingprotocols/utils/studySelectors.ts +14 -0
- package/src/hangingprotocols/utils/viewCode.test.js +25 -0
- package/src/hangingprotocols/utils/viewCode.ts +17 -0
- package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
- package/src/hooks/usePatientInfo.tsx +63 -0
- package/src/id.js +5 -0
- package/src/index.ts +113 -0
- package/src/init.ts +169 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/useDisplaySetSelectorStore.ts +83 -0
- package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
- package/src/stores/useToggleHangingProtocolStore.ts +76 -0
- package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
- package/src/stores/useUIStateStore.ts +87 -0
- package/src/stores/useViewportGridStore.ts +89 -0
- package/src/stores/useViewportsByPositionStore.ts +100 -0
- package/src/types/AppTypes.ts +20 -0
- package/src/types/commandModuleTypes.tsx +6 -0
- package/src/utils/Toolbox.tsx +123 -0
- package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
- package/src/utils/addIcon.ts +6 -0
- package/src/utils/appendFrameQueryToImageId.js +9 -0
- package/src/utils/callInputDialog.tsx +126 -0
- package/src/utils/colorPickerDialog.css +4 -0
- package/src/utils/colorPickerDialog.tsx +45 -0
- package/src/utils/createRenderedRetrieve.js +32 -0
- package/src/utils/createRenderedRetrieve.test.js +46 -0
- package/src/utils/dicomWriter.test.ts +228 -0
- package/src/utils/dicomWriter.ts +110 -0
- package/src/utils/getBulkdataValue.js +45 -0
- package/src/utils/getBulkdataValue.test.js +105 -0
- package/src/utils/getDirectURL.test.ts +207 -0
- package/src/utils/getDirectURL.ts +65 -0
- package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/layerConfigurationUtils.ts +202 -0
- package/src/utils/promptLabelAnnotation.js +47 -0
- package/src/utils/promptSaveReport.test.ts +106 -0
- package/src/utils/promptSaveReport.tsx +117 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
- package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
- package/src/utils/registerStoredInstanceImageId.ts +66 -0
- package/src/utils/reuseCachedLayouts.ts +92 -0
- package/src/utils/secureConfigFetch.js +115 -0
- package/src/utils/secureConfigFetch.test.js +163 -0
- package/src/utils/seriesDescriptionHistory.ts +83 -0
- package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
- package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
- package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
- package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
- package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
- package/src/utils/validations/checkMultiframe.ts +25 -0
- package/src/utils/validations/checkSingleFrames.ts +36 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import getDirectURL from './getDirectURL';
|
|
2
|
+
import getBulkdataValue from './getBulkdataValue';
|
|
3
|
+
import createRenderedRetrieve from './createRenderedRetrieve';
|
|
4
|
+
|
|
5
|
+
const mockedGetBulkdataValue = getBulkdataValue as jest.Mock;
|
|
6
|
+
const mockedCreateRenderedRetrieve = createRenderedRetrieve as jest.Mock;
|
|
7
|
+
|
|
8
|
+
jest.mock('@ohif/core');
|
|
9
|
+
jest.mock('./getBulkdataValue');
|
|
10
|
+
jest.mock('./createRenderedRetrieve');
|
|
11
|
+
|
|
12
|
+
global.URL.createObjectURL = jest.fn(() => 'blob:') as jest.Mock;
|
|
13
|
+
|
|
14
|
+
describe('getDirectURL', () => {
|
|
15
|
+
interface GetDirectURLConfig {
|
|
16
|
+
singlepart: boolean | string[];
|
|
17
|
+
defaultType: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface GetDirectURLParams {
|
|
21
|
+
tag: string;
|
|
22
|
+
defaultPath: string;
|
|
23
|
+
instance: {
|
|
24
|
+
StudyInstanceUID: string;
|
|
25
|
+
SeriesInstanceUID: string;
|
|
26
|
+
SOPInstanceUID: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
url?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const config: GetDirectURLConfig = {
|
|
33
|
+
singlepart: true,
|
|
34
|
+
defaultType: 'video/mp4',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const params: GetDirectURLParams = {
|
|
38
|
+
tag: 'PixelData',
|
|
39
|
+
defaultPath: '/path/to/pixeldata',
|
|
40
|
+
instance: {
|
|
41
|
+
StudyInstanceUID: 'study-uid',
|
|
42
|
+
SeriesInstanceUID: 'series-uid',
|
|
43
|
+
SOPInstanceUID: 'sop-uid',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
mockedGetBulkdataValue.mockClear();
|
|
49
|
+
mockedCreateRenderedRetrieve.mockClear();
|
|
50
|
+
(global.URL.createObjectURL as jest.Mock).mockClear();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should return the provided URL if it exists', () => {
|
|
54
|
+
const url = 'https://example.com/direct-retrieve';
|
|
55
|
+
|
|
56
|
+
const result = getDirectURL(config, {
|
|
57
|
+
...params,
|
|
58
|
+
url: 'https://example.com/direct-retrieve',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(result).toBe(url);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return the DirectRetrieveURL if it exists', () => {
|
|
65
|
+
const value = {
|
|
66
|
+
DirectRetrieveURL: 'https://example.com/direct-retrieve',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const result = getDirectURL(config, {
|
|
70
|
+
...params,
|
|
71
|
+
tag: 'PixelData',
|
|
72
|
+
instance: {
|
|
73
|
+
...params.instance,
|
|
74
|
+
PixelData: value,
|
|
75
|
+
} as GetDirectURLParams['instance'],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(result).toBe(value.DirectRetrieveURL);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should return the URL for InlineBinary', () => {
|
|
82
|
+
const value = {
|
|
83
|
+
InlineBinary: 'base64-encoded-data',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const result = getDirectURL(config, {
|
|
87
|
+
...params,
|
|
88
|
+
tag: 'PixelData',
|
|
89
|
+
instance: {
|
|
90
|
+
...params.instance,
|
|
91
|
+
PixelData: value,
|
|
92
|
+
} as GetDirectURLParams['instance'],
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(result).toContain('blob:');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should return the BulkDataURI with defaultType if singlepart is false and there is no retrieveBulkData', () => {
|
|
99
|
+
const value = {
|
|
100
|
+
BulkDataURI: 'https://example.com/bulkdata',
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const result = getDirectURL(
|
|
104
|
+
{
|
|
105
|
+
...config,
|
|
106
|
+
singlepart: false,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
...params,
|
|
110
|
+
tag: 'PixelData',
|
|
111
|
+
instance: {
|
|
112
|
+
...params.instance,
|
|
113
|
+
PixelData: value,
|
|
114
|
+
} as GetDirectURLParams['instance'],
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
expect(result).toBeUndefined();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should return the BulkDataURI with defaultType if singlepart is false with retrieveBulkData', async () => {
|
|
122
|
+
interface PixelDataValueWithRetrieveBulkData {
|
|
123
|
+
BulkDataURI: string;
|
|
124
|
+
retrieveBulkData: jest.Mock<Promise<Uint8Array>, []>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const value: PixelDataValueWithRetrieveBulkData = {
|
|
128
|
+
BulkDataURI: 'https://example.com/bulkdata',
|
|
129
|
+
retrieveBulkData: jest.fn().mockResolvedValueOnce(new Uint8Array([0, 1, 2])),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const result = await getDirectURL(
|
|
133
|
+
{
|
|
134
|
+
...config,
|
|
135
|
+
singlepart: false,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
...params,
|
|
139
|
+
tag: 'PixelData',
|
|
140
|
+
instance: {
|
|
141
|
+
...params.instance,
|
|
142
|
+
PixelData: value,
|
|
143
|
+
} as GetDirectURLParams['instance'],
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(result).toContain('blob:');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should return the BulkDataURI with defaultType if singlepart does not include fetchPart', async () => {
|
|
151
|
+
const arr = new Uint8Array([0, 1, 2]);
|
|
152
|
+
|
|
153
|
+
interface PixelDataValueWithRetrieveBulkData {
|
|
154
|
+
BulkDataURI: string;
|
|
155
|
+
retrieveBulkData: jest.Mock<Promise<Uint8Array>, []>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const value: PixelDataValueWithRetrieveBulkData = {
|
|
159
|
+
BulkDataURI: 'https://example.com/bulkdata',
|
|
160
|
+
retrieveBulkData: jest.fn().mockResolvedValueOnce(arr),
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const result = await getDirectURL(
|
|
164
|
+
{
|
|
165
|
+
...config,
|
|
166
|
+
singlepart: ['audio'],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
...params,
|
|
170
|
+
tag: 'PixelData',
|
|
171
|
+
instance: {
|
|
172
|
+
...params.instance,
|
|
173
|
+
PixelData: value,
|
|
174
|
+
} as GetDirectURLParams['instance'],
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
expect(result).toContain('blob:');
|
|
179
|
+
expect(global.URL.createObjectURL).toHaveBeenCalledWith(
|
|
180
|
+
new Blob([arr], { type: 'accept=video/mp4' })
|
|
181
|
+
);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should return the URL from getBulkdataValue if it exists', () => {
|
|
185
|
+
const bulkDataURL = 'https://example.com/bulkdata';
|
|
186
|
+
|
|
187
|
+
mockedGetBulkdataValue.mockReturnValueOnce(bulkDataURL);
|
|
188
|
+
|
|
189
|
+
const result = getDirectURL(config, params);
|
|
190
|
+
|
|
191
|
+
expect(mockedGetBulkdataValue).toHaveBeenCalledWith(config, params);
|
|
192
|
+
expect(result).toBe(bulkDataURL);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('should return the URL from createRenderedRetrieve if getBulkdataValue returns falsy', () => {
|
|
196
|
+
const renderedRetrieveURL = 'https://example.com/rendered-retrieve';
|
|
197
|
+
|
|
198
|
+
mockedGetBulkdataValue.mockReturnValueOnce(null);
|
|
199
|
+
mockedCreateRenderedRetrieve.mockReturnValueOnce(renderedRetrieveURL);
|
|
200
|
+
|
|
201
|
+
const result = getDirectURL(config, params);
|
|
202
|
+
|
|
203
|
+
expect(mockedGetBulkdataValue).not.toHaveBeenCalled();
|
|
204
|
+
expect(mockedCreateRenderedRetrieve).toHaveBeenCalledWith(config, params);
|
|
205
|
+
expect(result).toBe(renderedRetrieveURL);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { utils } from '@ohif/core';
|
|
2
|
+
|
|
3
|
+
import getBulkdataValue from './getBulkdataValue';
|
|
4
|
+
import createRenderedRetrieve from './createRenderedRetrieve';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a URL that can be used for direct retrieve of the bulkdata
|
|
8
|
+
*
|
|
9
|
+
* @param {object} params
|
|
10
|
+
* @param {string} params.tag is the tag name of the URL to retrieve
|
|
11
|
+
* @param {string} params.defaultPath path for the pixel data url
|
|
12
|
+
* @param {object} params.instance is the instance object that the tag is in
|
|
13
|
+
* @param {string} params.defaultType is the mime type of the response
|
|
14
|
+
* @param {string} params.singlepart is the type of the part to retrieve
|
|
15
|
+
* @param {string} params.fetchPart unknown?
|
|
16
|
+
* @param {string} params.url unknown?
|
|
17
|
+
* @returns an absolute URL to the resource, if the absolute URL can be retrieved as singlepart,
|
|
18
|
+
* or is already retrieved, or a promise to a URL for such use if a BulkDataURI
|
|
19
|
+
*/
|
|
20
|
+
const getDirectURL = (config, params) => {
|
|
21
|
+
const { singlepart } = config;
|
|
22
|
+
const {
|
|
23
|
+
instance,
|
|
24
|
+
tag = 'PixelData',
|
|
25
|
+
defaultType = 'video/mp4',
|
|
26
|
+
singlepart: fetchPart = 'video',
|
|
27
|
+
url = null,
|
|
28
|
+
} = params;
|
|
29
|
+
|
|
30
|
+
if (url) {
|
|
31
|
+
return url;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const value = instance[tag];
|
|
35
|
+
if (value) {
|
|
36
|
+
if (value.DirectRetrieveURL) {
|
|
37
|
+
return value.DirectRetrieveURL;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (value.InlineBinary) {
|
|
41
|
+
const blob = utils.b64toBlob(value.InlineBinary, defaultType);
|
|
42
|
+
value.DirectRetrieveURL = URL.createObjectURL(blob);
|
|
43
|
+
return value.DirectRetrieveURL;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!singlepart || (singlepart !== true && singlepart.indexOf(fetchPart) === -1)) {
|
|
47
|
+
if (value.retrieveBulkData) {
|
|
48
|
+
// Try the specified retrieve type.
|
|
49
|
+
const options = {
|
|
50
|
+
mediaType: defaultType,
|
|
51
|
+
};
|
|
52
|
+
return value.retrieveBulkData(options).then(arr => {
|
|
53
|
+
value.DirectRetrieveURL = URL.createObjectURL(new Blob([arr], { type: defaultType }));
|
|
54
|
+
return value.DirectRetrieveURL;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
console.warn('Unable to retrieve', tag, 'from', instance);
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return createRenderedRetrieve(config, params) || getBulkdataValue(config, params);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default getDirectURL;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const MIN_SR_SERIES_NUMBER = 4700;
|
|
2
|
+
|
|
3
|
+
export function getNextSeriesNumber({ displaySetService, modality, minSeriesNumber }) {
|
|
4
|
+
const activeDisplaySets = displaySetService.getActiveDisplaySets();
|
|
5
|
+
const modalityDisplaySets = activeDisplaySets.filter(ds => ds.Modality === modality);
|
|
6
|
+
const modalitySeriesNumbers = modalityDisplaySets.map(ds => ds.SeriesNumber);
|
|
7
|
+
const maxSeriesNumber = Math.max(...modalitySeriesNumbers, minSeriesNumber);
|
|
8
|
+
|
|
9
|
+
const allSeriesNumbers = activeDisplaySets.map(ds => ds.SeriesNumber);
|
|
10
|
+
|
|
11
|
+
let finalSeriesNumber = maxSeriesNumber + 1;
|
|
12
|
+
while (allSeriesNumbers.includes(finalSeriesNumber)) {
|
|
13
|
+
finalSeriesNumber++;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return { SeriesNumber: finalSeriesNumber, InstanceNumber: 1 };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getSRSeriesAndInstanceNumber({ displaySetService, SeriesInstanceUid }) {
|
|
20
|
+
if (!SeriesInstanceUid) {
|
|
21
|
+
return getNextSeriesNumber({
|
|
22
|
+
displaySetService,
|
|
23
|
+
modality: 'SR',
|
|
24
|
+
minSeriesNumber: MIN_SR_SERIES_NUMBER,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const displaySetsMap = displaySetService.getDisplaySetCache();
|
|
29
|
+
const displaySets = Array.from(displaySetsMap.values());
|
|
30
|
+
const srDisplaySet = displaySets.find(
|
|
31
|
+
ds => ds.Modality === 'SR' && ds.SeriesInstanceUID === SeriesInstanceUid
|
|
32
|
+
);
|
|
33
|
+
const InstanceNumber = srDisplaySet.instances?.length + 1;
|
|
34
|
+
|
|
35
|
+
if (!srDisplaySet?.SeriesNumber || !InstanceNumber) {
|
|
36
|
+
return getNextSeriesNumber({
|
|
37
|
+
displaySetService,
|
|
38
|
+
modality: 'SR',
|
|
39
|
+
minSeriesNumber: MIN_SR_SERIES_NUMBER,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
SeriesNumber: srDisplaySet.SeriesNumber,
|
|
45
|
+
InstanceNumber,
|
|
46
|
+
referenceDisplaySet: srDisplaySet,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { isNextViewport, NEXT_OVERLAY_OPACITY } from '@ohif/extension-cornerstone';
|
|
2
|
+
|
|
3
|
+
export const DERIVED_OVERLAY_MODALITIES = ['SEG', 'RTSTRUCT'];
|
|
4
|
+
export const DEFAULT_COLORMAP = 'hsv';
|
|
5
|
+
export const DEFAULT_OPACITY = 0.9;
|
|
6
|
+
export const DEFAULT_OPACITY_PERCENT = DEFAULT_OPACITY * 100;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get modality-specific color and opacity settings from the customization service
|
|
10
|
+
*/
|
|
11
|
+
export function getModalityOverlayColormap(customizationService, modality) {
|
|
12
|
+
const modalityOverlayDefaultColorMaps = customizationService?.getCustomization(
|
|
13
|
+
'cornerstone.modalityOverlayDefaultColorMaps'
|
|
14
|
+
) || { defaultSettings: {} };
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
modalityOverlayDefaultColorMaps.defaultSettings[modality] || {
|
|
18
|
+
colormap: DEFAULT_COLORMAP,
|
|
19
|
+
opacity: DEFAULT_OPACITY,
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create display set options based on modality and opacity settings
|
|
26
|
+
*/
|
|
27
|
+
export function createColormapOverlayDisplaySetOptions(displaySet, opacity, customizationService) {
|
|
28
|
+
if (displaySet.Modality === 'SEG') {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const modalitySettings = getModalityOverlayColormap(customizationService, displaySet.Modality);
|
|
33
|
+
return {
|
|
34
|
+
colormap: {
|
|
35
|
+
name: modalitySettings.colormap || DEFAULT_COLORMAP,
|
|
36
|
+
opacity: opacity / 100, // Convert from percentage to 0-1 range
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Configure viewport for adding a display set layer
|
|
43
|
+
*/
|
|
44
|
+
export function configureViewportForLayerAddition(params: {
|
|
45
|
+
viewport: any;
|
|
46
|
+
displaySetInstanceUID: string;
|
|
47
|
+
currentDisplaySetUIDs: string[];
|
|
48
|
+
servicesManager: AppTypes.ServicesManager;
|
|
49
|
+
}): any {
|
|
50
|
+
const { viewport, displaySetInstanceUID, currentDisplaySetUIDs, servicesManager } = params;
|
|
51
|
+
const { cornerstoneViewportService, displaySetService, customizationService } =
|
|
52
|
+
servicesManager.services;
|
|
53
|
+
|
|
54
|
+
const { viewportId } = viewport;
|
|
55
|
+
|
|
56
|
+
// Set the display set UIDs for the viewport
|
|
57
|
+
const allDisplaySetInstanceUIDs = [...currentDisplaySetUIDs, displaySetInstanceUID];
|
|
58
|
+
viewport.displaySetInstanceUIDs = allDisplaySetInstanceUIDs;
|
|
59
|
+
|
|
60
|
+
if (!viewport.viewportOptions) {
|
|
61
|
+
viewport.viewportOptions = {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const requestedLayerDisplaySet = displaySetService.getDisplaySetByUID(displaySetInstanceUID);
|
|
65
|
+
|
|
66
|
+
if (!viewport.viewportOptions.orientation) {
|
|
67
|
+
viewport.viewportOptions.orientation = cornerstoneViewportService.getOrientation(viewportId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// If a viewport type was already set do not reset it.
|
|
71
|
+
if (!viewport.viewportOptions.viewportType) {
|
|
72
|
+
// If the live Cornerstone viewport is already orthographic (volume), keep it as
|
|
73
|
+
// 'volume'. Prevents accidentally downgrading a volume viewport to 'stack' when
|
|
74
|
+
// viewportOptions arrives without a viewportType (e.g. from the HP overlay path).
|
|
75
|
+
const csViewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
|
|
76
|
+
if (csViewport?.type === 'orthographic') {
|
|
77
|
+
viewport.viewportOptions.viewportType = 'volume';
|
|
78
|
+
// Special handling for overlay display sets
|
|
79
|
+
} else if (requestedLayerDisplaySet.isOverlayDisplaySet) {
|
|
80
|
+
// Do not force volume for SEG and RTSTRUCT if it and all the current display sets are for the same display set
|
|
81
|
+
const isSameDisplaySet = currentDisplaySetUIDs.every(uid => {
|
|
82
|
+
const currentDisplaySet = displaySetService.getDisplaySetByUID(uid);
|
|
83
|
+
return currentDisplaySet.isOverlayDisplaySet
|
|
84
|
+
? currentDisplaySet.referencedDisplaySetInstanceUID ===
|
|
85
|
+
requestedLayerDisplaySet.referencedDisplaySetInstanceUID
|
|
86
|
+
: uid === requestedLayerDisplaySet.referencedDisplaySetInstanceUID;
|
|
87
|
+
});
|
|
88
|
+
if (isSameDisplaySet) {
|
|
89
|
+
viewport.viewportOptions.viewportType = 'stack';
|
|
90
|
+
} else {
|
|
91
|
+
viewport.viewportOptions.viewportType = 'volume';
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
viewport.viewportOptions.viewportType = 'volume';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Native ("next") viewports need the legacy-equivalent initial overlay opacity
|
|
99
|
+
// (see the NEXT_OVERLAY_OPACITY policy in @ohif/extension-cornerstone).
|
|
100
|
+
const liveCsViewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
|
|
101
|
+
const isLiveViewportNext = !!liveCsViewport && isNextViewport(liveCsViewport);
|
|
102
|
+
|
|
103
|
+
// create same amount of display set options as the number of display set UIDs
|
|
104
|
+
const displaySetOptions = allDisplaySetInstanceUIDs.map((uid, index) => {
|
|
105
|
+
// There is already a display set option for this display set, so return it.
|
|
106
|
+
if (viewport.displaySetOptions?.[index]) {
|
|
107
|
+
return viewport.displaySetOptions[index];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (index === 0) {
|
|
111
|
+
// no colormap for background
|
|
112
|
+
return {};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const displaySet = displaySetService.getDisplaySetByUID(uid);
|
|
116
|
+
const overlayOptions = createColormapOverlayDisplaySetOptions(
|
|
117
|
+
displaySet,
|
|
118
|
+
90,
|
|
119
|
+
customizationService
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
if (isLiveViewportNext && typeof overlayOptions.colormap?.opacity === 'number') {
|
|
123
|
+
overlayOptions.colormap.opacity = NEXT_OVERLAY_OPACITY;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return overlayOptions;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
viewport.displaySetOptions = displaySetOptions;
|
|
130
|
+
|
|
131
|
+
return viewport;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Configure viewport for removing a display set layer
|
|
136
|
+
*/
|
|
137
|
+
export function configureViewportForLayerRemoval(params: {
|
|
138
|
+
viewport: any;
|
|
139
|
+
displaySetInstanceUID: string;
|
|
140
|
+
currentDisplaySetUIDs: string[];
|
|
141
|
+
servicesManager: AppTypes.ServicesManager;
|
|
142
|
+
}): any {
|
|
143
|
+
const { viewport, displaySetInstanceUID, currentDisplaySetUIDs, servicesManager } = params;
|
|
144
|
+
const { cornerstoneViewportService, displaySetService } = servicesManager.services;
|
|
145
|
+
|
|
146
|
+
const { viewportId } = viewport;
|
|
147
|
+
|
|
148
|
+
// Filter out the display set to remove
|
|
149
|
+
viewport.displaySetInstanceUIDs = currentDisplaySetUIDs.filter(
|
|
150
|
+
uid => uid !== displaySetInstanceUID
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
if (!viewport.viewportOptions) {
|
|
154
|
+
viewport.viewportOptions = {};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const csViewportOrthographic =
|
|
158
|
+
cornerstoneViewportService.getCornerstoneViewport(viewportId)?.type === 'orthographic';
|
|
159
|
+
viewport.viewportOptions.viewportType = csViewportOrthographic ? 'volume' : 'stack';
|
|
160
|
+
|
|
161
|
+
// orientation
|
|
162
|
+
if (!viewport.viewportOptions.orientation) {
|
|
163
|
+
viewport.viewportOptions.orientation = cornerstoneViewportService.getOrientation(viewportId);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Recreate the display set options
|
|
167
|
+
viewport.displaySetOptions = viewport.displaySetInstanceUIDs.map(() => {
|
|
168
|
+
// For simplicity, we're returning empty options for now
|
|
169
|
+
// In a more complete implementation, we would need to preserve existing display set options
|
|
170
|
+
return {};
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return viewport;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Check if a display set can be added as a layer to the specified viewport
|
|
178
|
+
*/
|
|
179
|
+
export function canAddDisplaySetToViewport(params: {
|
|
180
|
+
viewportId: string;
|
|
181
|
+
displaySetInstanceUID: string;
|
|
182
|
+
servicesManager: AppTypes.ServicesManager;
|
|
183
|
+
}): boolean {
|
|
184
|
+
const { viewportId, displaySetInstanceUID, servicesManager } = params;
|
|
185
|
+
const { displaySetService, viewportGridService } = servicesManager.services;
|
|
186
|
+
|
|
187
|
+
// Check if the display set exists
|
|
188
|
+
const displaySet = displaySetService.getDisplaySetByUID(displaySetInstanceUID);
|
|
189
|
+
if (!displaySet) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Get current display sets in the viewport
|
|
194
|
+
const currentDisplaySetUIDs = viewportGridService.getDisplaySetsUIDsForViewport(viewportId);
|
|
195
|
+
|
|
196
|
+
// Check if the display set is already in the viewport
|
|
197
|
+
if (currentDisplaySetUIDs.includes(displaySetInstanceUID)) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { callInputDialogAutoComplete } from './callInputDialog';
|
|
2
|
+
|
|
3
|
+
function promptLabelAnnotation({ servicesManager }, ctx, evt) {
|
|
4
|
+
const { measurementService, customizationService, toolGroupService, uiDialogService } =
|
|
5
|
+
servicesManager.services;
|
|
6
|
+
const { viewportId, StudyInstanceUID, SeriesInstanceUID, measurementId, toolName } = evt;
|
|
7
|
+
return new Promise(resolve => {
|
|
8
|
+
(async () => {
|
|
9
|
+
const toolGroup = toolGroupService.getToolGroupForViewport(viewportId);
|
|
10
|
+
const activeToolOptions = toolGroup.getToolConfiguration(toolName);
|
|
11
|
+
if (activeToolOptions.getTextCallback) {
|
|
12
|
+
resolve({
|
|
13
|
+
StudyInstanceUID,
|
|
14
|
+
SeriesInstanceUID,
|
|
15
|
+
viewportId,
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
const labelConfig = customizationService.getCustomization('measurementLabels');
|
|
19
|
+
const measurement = measurementService.getMeasurement(measurementId);
|
|
20
|
+
const renderContent = customizationService.getCustomization('ui.labellingComponent');
|
|
21
|
+
|
|
22
|
+
const value = await callInputDialogAutoComplete({
|
|
23
|
+
measurement,
|
|
24
|
+
uiDialogService,
|
|
25
|
+
labelConfig,
|
|
26
|
+
renderContent,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
measurementService.update(
|
|
30
|
+
measurementId,
|
|
31
|
+
{
|
|
32
|
+
...value,
|
|
33
|
+
},
|
|
34
|
+
true
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
resolve({
|
|
38
|
+
StudyInstanceUID,
|
|
39
|
+
SeriesInstanceUID,
|
|
40
|
+
viewportId,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default promptLabelAnnotation;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import PROMPT_RESPONSES from './_shared/PROMPT_RESPONSES';
|
|
2
|
+
|
|
3
|
+
const mockCreateReportDialogPrompt = jest.fn();
|
|
4
|
+
const mockCreateReportAsync = jest.fn();
|
|
5
|
+
|
|
6
|
+
jest.mock('../Panels', () => ({
|
|
7
|
+
createReportDialogPrompt: (...args) => mockCreateReportDialogPrompt(...args),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
jest.mock('../Actions/createReportAsync', () => ({
|
|
11
|
+
__esModule: true,
|
|
12
|
+
default: (...args) => mockCreateReportAsync(...args),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
import promptSaveReport from './promptSaveReport';
|
|
16
|
+
|
|
17
|
+
const MEASUREMENTS = [{ uid: 'measurement-1' }, { uid: 'measurement-2' }];
|
|
18
|
+
|
|
19
|
+
function setup({ storedDisplaySet = { predecessorImageId: 'wadors:/stored-sr' } } = {}) {
|
|
20
|
+
const runCommand = jest.fn();
|
|
21
|
+
const servicesManager = {
|
|
22
|
+
services: {
|
|
23
|
+
measurementService: { getMeasurements: () => MEASUREMENTS },
|
|
24
|
+
displaySetService: { getDisplaySetByUID: jest.fn(() => storedDisplaySet) },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
mockCreateReportDialogPrompt.mockResolvedValue({
|
|
29
|
+
action: PROMPT_RESPONSES.CREATE_REPORT,
|
|
30
|
+
value: 'Measurements',
|
|
31
|
+
dataSourceName: 'dicomweb',
|
|
32
|
+
series: null,
|
|
33
|
+
seriesNumber: 3001,
|
|
34
|
+
});
|
|
35
|
+
// Stands in for the store, which is what the real one drives through getReport.
|
|
36
|
+
mockCreateReportAsync.mockImplementation(async ({ getReport }) => {
|
|
37
|
+
await getReport();
|
|
38
|
+
return ['created-display-set'];
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const run = () =>
|
|
42
|
+
promptSaveReport(
|
|
43
|
+
{ servicesManager, commandsManager: { runCommand }, extensionManager: {} } as any,
|
|
44
|
+
{ trackedStudy: '1.2.3', trackedSeries: ['1.2.3.4'], measurementFilter: () => true },
|
|
45
|
+
{ data: { StudyInstanceUID: '1.2.3', viewportId: 'viewport-1', isBackupSave: false } }
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return { run, runCommand, servicesManager };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const commandCall = (runCommand: jest.Mock, name: string) =>
|
|
52
|
+
runCommand.mock.calls.find(call => call[0] === name);
|
|
53
|
+
|
|
54
|
+
describe('promptSaveReport', () => {
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
jest.clearAllMocks();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('stores the measurements with the series the dialog resolved', async () => {
|
|
60
|
+
const { run, runCommand } = setup();
|
|
61
|
+
|
|
62
|
+
await run();
|
|
63
|
+
|
|
64
|
+
expect(commandCall(runCommand, 'storeMeasurements')[1]).toMatchObject({
|
|
65
|
+
dataSource: 'dicomweb',
|
|
66
|
+
options: {
|
|
67
|
+
SeriesDescription: 'Measurements',
|
|
68
|
+
SeriesNumber: 3001,
|
|
69
|
+
predecessorImageId: null,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('records the report just written as the predecessor of the measurements', async () => {
|
|
75
|
+
const { run, runCommand, servicesManager } = setup();
|
|
76
|
+
|
|
77
|
+
await run();
|
|
78
|
+
|
|
79
|
+
expect(servicesManager.services.displaySetService.getDisplaySetByUID).toHaveBeenCalledWith(
|
|
80
|
+
'created-display-set'
|
|
81
|
+
);
|
|
82
|
+
expect(commandCall(runCommand, 'recordMeasurementsPredecessor')[1]).toEqual({
|
|
83
|
+
measurements: MEASUREMENTS,
|
|
84
|
+
predecessorImageId: 'wadors:/stored-sr',
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('records nothing when the stored report cannot be identified', async () => {
|
|
89
|
+
const { run, runCommand } = setup({ storedDisplaySet: {} });
|
|
90
|
+
|
|
91
|
+
await run();
|
|
92
|
+
|
|
93
|
+
expect(commandCall(runCommand, 'recordMeasurementsPredecessor')).toBeUndefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('does not store anything when the dialog is cancelled', async () => {
|
|
97
|
+
const { run, runCommand } = setup();
|
|
98
|
+
mockCreateReportDialogPrompt.mockResolvedValue({ action: PROMPT_RESPONSES.CANCEL });
|
|
99
|
+
|
|
100
|
+
const result = await run();
|
|
101
|
+
|
|
102
|
+
expect(mockCreateReportAsync).not.toHaveBeenCalled();
|
|
103
|
+
expect(runCommand).not.toHaveBeenCalled();
|
|
104
|
+
expect(result.userResponse).toBe(PROMPT_RESPONSES.CANCEL);
|
|
105
|
+
});
|
|
106
|
+
});
|