@ohif/extension-default 3.14.0-beta.98 → 3.14.0-beta.99
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.umd.js +1 -1
- package/package.json +9 -6
- 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,45 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ChromePicker } from 'react-color';
|
|
3
|
+
import { FooterAction } from '@ohif/ui-next';
|
|
4
|
+
|
|
5
|
+
import './colorPickerDialog.css';
|
|
6
|
+
|
|
7
|
+
function ColorPickerDialog({ value, hide, onSave }) {
|
|
8
|
+
const [color, setColor] = useState(value);
|
|
9
|
+
|
|
10
|
+
const handleChange = color => {
|
|
11
|
+
setColor(color.rgb);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div data-cy="color-picker-dialog">
|
|
16
|
+
<ChromePicker
|
|
17
|
+
color={color}
|
|
18
|
+
onChange={handleChange}
|
|
19
|
+
presetColors={[]}
|
|
20
|
+
width={300}
|
|
21
|
+
/>
|
|
22
|
+
<FooterAction>
|
|
23
|
+
<FooterAction.Right>
|
|
24
|
+
<FooterAction.Secondary
|
|
25
|
+
dataCY="color-picker-cancel-btn"
|
|
26
|
+
onClick={hide}
|
|
27
|
+
>
|
|
28
|
+
Cancel
|
|
29
|
+
</FooterAction.Secondary>
|
|
30
|
+
<FooterAction.Primary
|
|
31
|
+
dataCY="color-picker-save-btn"
|
|
32
|
+
onClick={() => {
|
|
33
|
+
hide();
|
|
34
|
+
onSave(color);
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
Save
|
|
38
|
+
</FooterAction.Primary>
|
|
39
|
+
</FooterAction.Right>
|
|
40
|
+
</FooterAction>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default ColorPickerDialog;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the rendered URL that can be used for direct retrieve of the pixel data binary stream.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} config - The configuration object.
|
|
5
|
+
* @param {string} config.wadoRoot - The root URL for the WADO service.
|
|
6
|
+
* @param {object} params - The parameters object.
|
|
7
|
+
* @param {string} params.tag - The tag name of the URL to retrieve.
|
|
8
|
+
* @param {string} params.defaultPath - The path for the pixel data URL.
|
|
9
|
+
* @param {object} params.instance - The instance object that the tag is in.
|
|
10
|
+
* @param {string} params.defaultType - The mime type of the response.
|
|
11
|
+
* @param {string} params.singlepart - The type of the part to retrieve.
|
|
12
|
+
* @param {string} params.fetchPart - Unknown parameter.
|
|
13
|
+
* @param {string} params.url - Unknown parameter.
|
|
14
|
+
* @returns {string|Promise<string>} - An absolute URL to the binary stream.
|
|
15
|
+
*/
|
|
16
|
+
const createRenderedRetrieve = (config, params) => {
|
|
17
|
+
const { wadoRoot } = config;
|
|
18
|
+
const { instance, tag = 'PixelData' } = params;
|
|
19
|
+
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
|
|
20
|
+
const bulkDataURI = instance[tag]?.BulkDataURI ?? '';
|
|
21
|
+
|
|
22
|
+
if (bulkDataURI?.indexOf('?') !== -1) {
|
|
23
|
+
// The value instance has parameters, so it should not revert to the rendered
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (tag === 'PixelData' || tag === 'EncapsulatedDocument') {
|
|
28
|
+
return `${wadoRoot}/studies/${StudyInstanceUID}/series/${SeriesInstanceUID}/instances/${SOPInstanceUID}/rendered`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default createRenderedRetrieve;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import createRenderedRetrieve from './createRenderedRetrieve';
|
|
2
|
+
|
|
3
|
+
describe('createRenderedRetrieve', () => {
|
|
4
|
+
const config = {
|
|
5
|
+
wadoRoot: 'https://example.com/wado',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const params = {
|
|
9
|
+
instance: {
|
|
10
|
+
StudyInstanceUID: 'study-uid',
|
|
11
|
+
SeriesInstanceUID: 'series-uid',
|
|
12
|
+
SOPInstanceUID: 'sop-uid',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it('should return the rendered URL for PixelData tag', () => {
|
|
17
|
+
const result = createRenderedRetrieve(config, {
|
|
18
|
+
...params,
|
|
19
|
+
tag: 'PixelData',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(result).toBe(
|
|
23
|
+
'https://example.com/wado/studies/study-uid/series/series-uid/instances/sop-uid/rendered'
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should return the rendered URL for EncapsulatedDocument tag', () => {
|
|
28
|
+
const result = createRenderedRetrieve(config, {
|
|
29
|
+
...params,
|
|
30
|
+
tag: 'EncapsulatedDocument',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(result).toBe(
|
|
34
|
+
'https://example.com/wado/studies/study-uid/series/series-uid/instances/sop-uid/rendered'
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should return undefined for unknown tag', () => {
|
|
39
|
+
const result = createRenderedRetrieve(config, {
|
|
40
|
+
...params,
|
|
41
|
+
tag: 'UnknownTag',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
expect(result).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { TextEncoder, TextDecoder } from 'util';
|
|
2
|
+
import dcmjs from 'dcmjs';
|
|
3
|
+
import {
|
|
4
|
+
DICOM_WRITE_OPTIONS,
|
|
5
|
+
datasetToDicomPart10Buffer,
|
|
6
|
+
writeDicomDictToPart10Buffer,
|
|
7
|
+
} from './dicomWriter';
|
|
8
|
+
|
|
9
|
+
// jsdom does not expose TextEncoder/TextDecoder, which dcmjs's buffer streams need.
|
|
10
|
+
if (typeof (global as { TextEncoder?: unknown }).TextEncoder === 'undefined') {
|
|
11
|
+
(global as { TextEncoder?: unknown }).TextEncoder = TextEncoder;
|
|
12
|
+
}
|
|
13
|
+
if (typeof (global as { TextDecoder?: unknown }).TextDecoder === 'undefined') {
|
|
14
|
+
(global as { TextDecoder?: unknown }).TextDecoder = TextDecoder;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const RLE_LOSSLESS = '1.2.840.10008.1.2.5';
|
|
18
|
+
const EXPLICIT_VR_LITTLE_ENDIAN = '1.2.840.10008.1.2.1';
|
|
19
|
+
const IMPLICIT_VR_LITTLE_ENDIAN = '1.2.840.10008.1.2';
|
|
20
|
+
const PIXEL_DATA_TAG = '7FE00010';
|
|
21
|
+
|
|
22
|
+
// Use frames larger than dcmjs's 20KB fragment size so that, if a frame were
|
|
23
|
+
// ever split, we'd see more than one fragment per frame.
|
|
24
|
+
const FRAME_BYTES = 30000;
|
|
25
|
+
|
|
26
|
+
function makeDicomDict(transferSyntaxUID, vr, pixelDataValue) {
|
|
27
|
+
const dict = new dcmjs.data.DicomDict({
|
|
28
|
+
'00020010': { vr: 'UI', Value: [transferSyntaxUID] },
|
|
29
|
+
'00020002': { vr: 'UI', Value: ['1.2.840.10008.5.1.4.1.1.66.4'] },
|
|
30
|
+
'00020003': { vr: 'UI', Value: ['1.2.3.4.5'] },
|
|
31
|
+
});
|
|
32
|
+
dict.upsertTag(PIXEL_DATA_TAG, vr, pixelDataValue);
|
|
33
|
+
return dict;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Locates the PixelData element in a Part-10 buffer and, when it is encapsulated,
|
|
38
|
+
* walks the encapsulated items (Basic Offset Table + fragments).
|
|
39
|
+
*/
|
|
40
|
+
function inspectPixelData(arrayBuffer) {
|
|
41
|
+
const dv = new DataView(arrayBuffer);
|
|
42
|
+
|
|
43
|
+
// Skip the 128-byte preamble + "DICM", then read the file-meta group length
|
|
44
|
+
// from (0002,0000) UL to find where the dataset begins.
|
|
45
|
+
const metaGroupLength = dv.getUint32(140, true);
|
|
46
|
+
let offset = 144 + metaGroupLength;
|
|
47
|
+
|
|
48
|
+
// PixelData (7FE0,0010), explicit VR (OB/OW) — long form: VR(2) + reserved(2) + length(4).
|
|
49
|
+
const group = dv.getUint16(offset, true);
|
|
50
|
+
const element = dv.getUint16(offset + 2, true);
|
|
51
|
+
if (group !== 0x7fe0 || element !== 0x0010) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Expected PixelData at offset ${offset}, found ${group.toString(16)},${element.toString(16)}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const length = dv.getUint32(offset + 8, true);
|
|
58
|
+
if (length !== 0xffffffff) {
|
|
59
|
+
return { encapsulated: false, length };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Encapsulated: first item is the Basic Offset Table, then one item per fragment,
|
|
63
|
+
// terminated by the Sequence Delimitation Item (FFFE,E0DD).
|
|
64
|
+
let p = offset + 12;
|
|
65
|
+
const itemSizes: number[] = [];
|
|
66
|
+
|
|
67
|
+
while (p + 8 <= dv.byteLength) {
|
|
68
|
+
const itemGroup = dv.getUint16(p, true);
|
|
69
|
+
const itemElement = dv.getUint16(p + 2, true);
|
|
70
|
+
const itemLength = dv.getUint32(p + 4, true);
|
|
71
|
+
p += 8;
|
|
72
|
+
|
|
73
|
+
if (itemGroup === 0xfffe && itemElement === 0xe0dd) {
|
|
74
|
+
break; // sequence delimiter
|
|
75
|
+
}
|
|
76
|
+
if (itemGroup !== 0xfffe || itemElement !== 0xe000) {
|
|
77
|
+
throw new Error(`Unexpected item tag at ${p - 8}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
itemSizes.push(itemLength);
|
|
81
|
+
p += itemLength;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// itemSizes[0] is the Basic Offset Table; the rest are frame fragments.
|
|
85
|
+
return {
|
|
86
|
+
encapsulated: true,
|
|
87
|
+
totalItems: itemSizes.length,
|
|
88
|
+
basicOffsetTableSize: itemSizes[0],
|
|
89
|
+
fragmentSizes: itemSizes.slice(1),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
describe('dicomWriter DICOM_WRITE_OPTIONS fragmentation', () => {
|
|
94
|
+
it('writes exactly one fragment per frame (plus the Basic Offset Table) for compressed pixel data', () => {
|
|
95
|
+
const frames = [new Uint8Array(FRAME_BYTES).buffer, new Uint8Array(FRAME_BYTES).buffer];
|
|
96
|
+
const dict = makeDicomDict(RLE_LOSSLESS, 'OB', frames);
|
|
97
|
+
|
|
98
|
+
const buffer = writeDicomDictToPart10Buffer(dict);
|
|
99
|
+
const result = inspectPixelData(buffer);
|
|
100
|
+
|
|
101
|
+
expect(result.encapsulated).toBe(true);
|
|
102
|
+
// 1 Basic Offset Table item + 1 fragment per frame.
|
|
103
|
+
expect(result.totalItems).toBe(frames.length + 1);
|
|
104
|
+
expect(result.fragmentSizes).toHaveLength(frames.length);
|
|
105
|
+
// Each frame stayed in a single fragment despite exceeding the 20KB fragment size.
|
|
106
|
+
result.fragmentSizes.forEach(size => expect(size).toBe(FRAME_BYTES));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('does not fragment uncompressed pixel data', () => {
|
|
110
|
+
const pixelData = new Uint16Array(FRAME_BYTES).buffer;
|
|
111
|
+
const dict = makeDicomDict(EXPLICIT_VR_LITTLE_ENDIAN, 'OW', [pixelData]);
|
|
112
|
+
|
|
113
|
+
const buffer = writeDicomDictToPart10Buffer(dict);
|
|
114
|
+
const result = inspectPixelData(buffer);
|
|
115
|
+
|
|
116
|
+
expect(result.encapsulated).toBe(false);
|
|
117
|
+
expect(result.length).toBe(pixelData.byteLength);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('confirms fragmentMultiframe:false is what prevents a single large frame from splitting', () => {
|
|
121
|
+
// Control: with fragmentMultiframe enabled, a >20KB frame splits into multiple
|
|
122
|
+
// fragments — proving DICOM_WRITE_OPTIONS.fragmentMultiframe:false is meaningful.
|
|
123
|
+
const frames = [new Uint8Array(FRAME_BYTES).buffer];
|
|
124
|
+
const dict = makeDicomDict(RLE_LOSSLESS, 'OB', frames);
|
|
125
|
+
|
|
126
|
+
const buffer = dict.write({ ...DICOM_WRITE_OPTIONS, fragmentMultiframe: true });
|
|
127
|
+
const result = inspectPixelData(buffer);
|
|
128
|
+
|
|
129
|
+
expect(result.encapsulated).toBe(true);
|
|
130
|
+
expect(result.fragmentSizes.length).toBeGreaterThan(1);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Byte-level walk of the file meta group. Returns the meta element tags in file
|
|
136
|
+
* order and asserts that FileMetaInformationGroupLength spans them exactly.
|
|
137
|
+
*/
|
|
138
|
+
function readFileMetaTags(arrayBuffer: ArrayBuffer) {
|
|
139
|
+
const dv = new DataView(arrayBuffer);
|
|
140
|
+
|
|
141
|
+
// Preamble(128) + 'DICM'(4), then (0002,0000) UL <groupLength> must come first.
|
|
142
|
+
expect(dv.getUint16(132, true)).toBe(0x0002);
|
|
143
|
+
expect(dv.getUint16(134, true)).toBe(0x0000);
|
|
144
|
+
const groupLength = dv.getUint32(140, true);
|
|
145
|
+
const end = 144 + groupLength;
|
|
146
|
+
|
|
147
|
+
const tags: string[] = [];
|
|
148
|
+
let p = 144;
|
|
149
|
+
while (p < end) {
|
|
150
|
+
const group = dv.getUint16(p, true);
|
|
151
|
+
const element = dv.getUint16(p + 2, true);
|
|
152
|
+
const vr = String.fromCharCode(dv.getUint8(p + 4), dv.getUint8(p + 5));
|
|
153
|
+
|
|
154
|
+
// File meta is always Explicit VR Little Endian.
|
|
155
|
+
let length: number;
|
|
156
|
+
if (['OB', 'OW', 'OF', 'SQ', 'UT', 'UN'].includes(vr)) {
|
|
157
|
+
length = dv.getUint32(p + 8, true);
|
|
158
|
+
p += 12 + length;
|
|
159
|
+
} else {
|
|
160
|
+
length = dv.getUint16(p + 6, true);
|
|
161
|
+
p += 8 + length;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
tags.push(
|
|
165
|
+
`${group.toString(16).padStart(4, '0')}${element.toString(16).padStart(4, '0')}`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// The declared group length covers the meta elements exactly — a garbage
|
|
170
|
+
// element counted into it (or omitted from it) would break this.
|
|
171
|
+
expect(p).toBe(end);
|
|
172
|
+
|
|
173
|
+
return tags;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function makeNaturalizedDataset(meta) {
|
|
177
|
+
return {
|
|
178
|
+
_meta: meta,
|
|
179
|
+
SOPClassUID: '1.2.840.10008.5.1.4.1.1.88.33',
|
|
180
|
+
SOPInstanceUID: '1.2.3.4.5',
|
|
181
|
+
StudyInstanceUID: '1.2.3.4',
|
|
182
|
+
SeriesInstanceUID: '1.2.3.4.1',
|
|
183
|
+
Modality: 'SR',
|
|
184
|
+
PatientID: 'TEST-PATIENT',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
describe('datasetToDicomPart10Buffer file meta', () => {
|
|
189
|
+
it('writes only group-0002 elements (no garbage (0000,0000) tag) into the file meta', () => {
|
|
190
|
+
const dataset = makeNaturalizedDataset({
|
|
191
|
+
TransferSyntaxUID: { vr: 'UI', Value: [EXPLICIT_VR_LITTLE_ENDIAN] },
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const buffer = datasetToDicomPart10Buffer(dataset);
|
|
195
|
+
|
|
196
|
+
const tags = readFileMetaTags(buffer);
|
|
197
|
+
expect(tags.length).toBeGreaterThan(0);
|
|
198
|
+
tags.forEach(tag => expect(tag.startsWith('0002')).toBe(true));
|
|
199
|
+
// Elements must appear in ascending tag order within group 2.
|
|
200
|
+
expect(tags).toEqual([...tags].sort());
|
|
201
|
+
|
|
202
|
+
const reread = dcmjs.data.DicomMessage.readFile(buffer);
|
|
203
|
+
const metaKeys = Object.keys(reread.meta);
|
|
204
|
+
expect(metaKeys).not.toContain('00000000');
|
|
205
|
+
metaKeys.forEach(key => expect(key.startsWith('0002')).toBe(true));
|
|
206
|
+
expect(reread.meta['00020010'].Value).toEqual([EXPLICIT_VR_LITTLE_ENDIAN]);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('honors a plain-string _meta.TransferSyntaxUID that dcmjs alone would default away', () => {
|
|
210
|
+
// dcmjs datasetToDict only reads the object form (_meta.TransferSyntaxUID.Value[0])
|
|
211
|
+
// and silently falls back to Explicit VR LE for a plain string — the hex-key
|
|
212
|
+
// assignment in applyTransferSyntaxToFileMeta is what preserves it.
|
|
213
|
+
const dataset = makeNaturalizedDataset({
|
|
214
|
+
TransferSyntaxUID: IMPLICIT_VR_LITTLE_ENDIAN,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const buffer = datasetToDicomPart10Buffer(dataset);
|
|
218
|
+
|
|
219
|
+
const tags = readFileMetaTags(buffer);
|
|
220
|
+
tags.forEach(tag => expect(tag.startsWith('0002')).toBe(true));
|
|
221
|
+
|
|
222
|
+
const reread = dcmjs.data.DicomMessage.readFile(buffer);
|
|
223
|
+
expect(Object.keys(reread.meta)).not.toContain('00000000');
|
|
224
|
+
expect(reread.meta['00020010'].Value).toEqual([IMPLICIT_VR_LITTLE_ENDIAN]);
|
|
225
|
+
// The dataset body survives a round trip under the preserved syntax.
|
|
226
|
+
expect(reread.dict['00080018'].Value).toEqual(['1.2.3.4.5']);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import dcmjs from 'dcmjs';
|
|
2
|
+
|
|
3
|
+
export const EXPLICIT_VR_LITTLE_ENDIAN = '1.2.840.10008.1.2.1';
|
|
4
|
+
|
|
5
|
+
export const DICOM_WRITE_OPTIONS = {
|
|
6
|
+
allowInvalidVRLength: false,
|
|
7
|
+
// `fragmentMultiframe` only governs whether a SINGLE frame is split across
|
|
8
|
+
// multiple fragments (dcmjs splits frames larger than its 20KB fragment size).
|
|
9
|
+
// It does NOT merge frames: in an encapsulated (compressed) transfer syntax
|
|
10
|
+
// every frame is always written as its own fragment, preceded by the Basic
|
|
11
|
+
// Offset Table; in an uncompressed syntax pixel data is never fragmented at
|
|
12
|
+
// all. Keeping this `false` therefore yields exactly one fragment per frame
|
|
13
|
+
// for compressed SEG — the conformant layout — without splitting large frames.
|
|
14
|
+
fragmentMultiframe: false,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** OHIF runtime fields — not DICOM tags; must not be enumerable for dcmjs datasetToDict. */
|
|
18
|
+
export const RUNTIME_INSTANCE_PROPERTY_KEYS = [
|
|
19
|
+
'url',
|
|
20
|
+
'wadorsuri',
|
|
21
|
+
'wadouri',
|
|
22
|
+
'wadoRoot',
|
|
23
|
+
'wadoUri',
|
|
24
|
+
'wadoUriRoot',
|
|
25
|
+
'imageRendering',
|
|
26
|
+
'imageId',
|
|
27
|
+
'_parentInstance',
|
|
28
|
+
'frameNumber',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Attaches OHIF runtime data on an instance without enumerable keys (safe for dcmjs datasetToDict).
|
|
33
|
+
*/
|
|
34
|
+
export function setNonEnumerableInstanceProperty(
|
|
35
|
+
instance: Record<string, unknown>,
|
|
36
|
+
key: string,
|
|
37
|
+
value: unknown
|
|
38
|
+
) {
|
|
39
|
+
Object.defineProperty(instance, key, {
|
|
40
|
+
value,
|
|
41
|
+
enumerable: false,
|
|
42
|
+
writable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Re-defines any existing enumerable runtime properties as non-enumerable (keeps values).
|
|
49
|
+
*/
|
|
50
|
+
export function makeExistingPropertiesNonEnumerable(instance: Record<string, unknown>) {
|
|
51
|
+
for (const key of RUNTIME_INSTANCE_PROPERTY_KEYS) {
|
|
52
|
+
if (!Object.prototype.hasOwnProperty.call(instance, key)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const descriptor = Object.getOwnPropertyDescriptor(instance, key);
|
|
57
|
+
|
|
58
|
+
if (!descriptor || descriptor.enumerable === false) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setNonEnumerableInstanceProperty(instance, key, descriptor.value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getDatasetTransferSyntaxUID(dataset) {
|
|
67
|
+
const fromMeta = dataset?._meta?.TransferSyntaxUID;
|
|
68
|
+
|
|
69
|
+
if (typeof fromMeta === 'string') {
|
|
70
|
+
return fromMeta;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (Array.isArray(fromMeta?.Value)) {
|
|
74
|
+
return fromMeta.Value[0];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (typeof dataset?.TransferSyntaxUID === 'string') {
|
|
78
|
+
return dataset.TransferSyntaxUID;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return EXPLICIT_VR_LITTLE_ENDIAN;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function applyTransferSyntaxToFileMeta(dicomDict, transferSyntaxUID) {
|
|
85
|
+
if (!transferSyntaxUID || !dicomDict?.meta) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Hex key only: DicomMessage.write treats every meta key as a tag string, so a
|
|
90
|
+
// naturalized key like 'TransferSyntaxUID' would be parsed via parseInt(..., 16)
|
|
91
|
+
// into tag (0000,0000) and written as a garbage element in group 2.
|
|
92
|
+
dicomDict.meta['00020010'] = { vr: 'UI', Value: [transferSyntaxUID] };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function datasetToDicomPart10Buffer(dataset) {
|
|
96
|
+
makeExistingPropertiesNonEnumerable(dataset);
|
|
97
|
+
const transferSyntaxUID = getDatasetTransferSyntaxUID(dataset);
|
|
98
|
+
const dicomDict = dcmjs.data.datasetToDict(dataset);
|
|
99
|
+
applyTransferSyntaxToFileMeta(dicomDict, transferSyntaxUID);
|
|
100
|
+
return dicomDict.write(DICOM_WRITE_OPTIONS);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function datasetToDicomBlob(dataset) {
|
|
104
|
+
const part10Buffer = datasetToDicomPart10Buffer(dataset);
|
|
105
|
+
return new Blob([part10Buffer], { type: 'application/dicom' });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function writeDicomDictToPart10Buffer(dicomDict) {
|
|
109
|
+
return dicomDict.write(DICOM_WRITE_OPTIONS);
|
|
110
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a URL that can be used for direct retrieve of the bulkdata.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} config - The configuration object.
|
|
5
|
+
* @param {object} params - The parameters object.
|
|
6
|
+
* @param {string} params.tag - The tag name of the URL to retrieve.
|
|
7
|
+
* @param {string} params.defaultPath - The path for the pixel data URL.
|
|
8
|
+
* @param {object} params.instance - The instance object that the tag is in.
|
|
9
|
+
* @param {string} params.defaultType - The mime type of the response.
|
|
10
|
+
* @param {string} params.singlepart - The type of the part to retrieve.
|
|
11
|
+
* @param {string} params.fetchPart - Unknown.
|
|
12
|
+
* @returns {string|Promise<string>} - An absolute URL to the resource, if the absolute URL can be retrieved as singlepart,
|
|
13
|
+
* or is already retrieved, or a promise to a URL for such use if a BulkDataURI.
|
|
14
|
+
*/
|
|
15
|
+
const getBulkdataValue = (config, params) => {
|
|
16
|
+
const {
|
|
17
|
+
instance,
|
|
18
|
+
tag = 'PixelData',
|
|
19
|
+
defaultPath = '/pixeldata',
|
|
20
|
+
defaultType = 'video/mp4',
|
|
21
|
+
} = params;
|
|
22
|
+
|
|
23
|
+
const value = instance[tag];
|
|
24
|
+
|
|
25
|
+
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
|
|
26
|
+
|
|
27
|
+
const BulkDataURI =
|
|
28
|
+
(value && value.BulkDataURI) ||
|
|
29
|
+
`series/${SeriesInstanceUID}/instances/${SOPInstanceUID}${defaultPath}`;
|
|
30
|
+
const hasQuery = BulkDataURI.indexOf('?') !== -1;
|
|
31
|
+
const hasAccept = BulkDataURI.indexOf('accept=') !== -1;
|
|
32
|
+
const acceptUri =
|
|
33
|
+
BulkDataURI + (hasAccept ? '' : (hasQuery ? '&' : '?') + `accept=${defaultType}`);
|
|
34
|
+
|
|
35
|
+
if (acceptUri.startsWith('series/')) {
|
|
36
|
+
const { wadoRoot } = config;
|
|
37
|
+
return `${wadoRoot}/studies/${StudyInstanceUID}/${acceptUri}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The DICOMweb standard states that the default is multipart related, and then
|
|
41
|
+
// separately states that the accept parameter is the URL parameter equivalent of the accept header.
|
|
42
|
+
return acceptUri;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default getBulkdataValue;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import getBulkdataValue from './getBulkdataValue';
|
|
2
|
+
|
|
3
|
+
jest.mock('@ohif/core');
|
|
4
|
+
|
|
5
|
+
global.URL.createObjectURL = jest.fn(() => 'blob:');
|
|
6
|
+
|
|
7
|
+
describe('getBulkdataValue', () => {
|
|
8
|
+
const config = {
|
|
9
|
+
singlepart: true,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const params = {
|
|
13
|
+
instance: {
|
|
14
|
+
StudyInstanceUID: 'study-uid',
|
|
15
|
+
SeriesInstanceUID: 'series-uid',
|
|
16
|
+
SOPInstanceUID: 'sop-uid',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
it('should return the BulkDataURI with defaultType if singlepart is true without accept', () => {
|
|
21
|
+
const value = {
|
|
22
|
+
BulkDataURI: 'https://example.com/bulkdata',
|
|
23
|
+
retrieveBulkData: jest.fn().mockResolvedValueOnce(new Uint8Array([0, 1, 2])),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const result = getBulkdataValue(config, {
|
|
27
|
+
...params,
|
|
28
|
+
tag: 'PixelData',
|
|
29
|
+
instance: {
|
|
30
|
+
...params.instance,
|
|
31
|
+
PixelData: value,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(result).toContain(value.BulkDataURI);
|
|
36
|
+
expect(result).toContain('accept=video/mp4');
|
|
37
|
+
const acceptCount = result.match(/accept=video\/mp4/g)?.length || 0;
|
|
38
|
+
expect(acceptCount).toBe(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should return the BulkDataURI with accept', () => {
|
|
42
|
+
const value = {
|
|
43
|
+
BulkDataURI: 'https://example.com/bulkdata?accept=video/mp4',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const result = getBulkdataValue(config, {
|
|
47
|
+
...params,
|
|
48
|
+
tag: 'PixelData',
|
|
49
|
+
instance: {
|
|
50
|
+
...params.instance,
|
|
51
|
+
PixelData: value,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(result).toContain(value.BulkDataURI);
|
|
56
|
+
expect(result).toContain('accept=video/mp4');
|
|
57
|
+
const acceptCount = result.match(/accept=video\/mp4/g)?.length || 0;
|
|
58
|
+
expect(acceptCount).toBe(1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should return the BulkDataURI with accept and query params', () => {
|
|
62
|
+
const value = {
|
|
63
|
+
BulkDataURI: 'https://example.com/bulkdata?test=123',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const result = getBulkdataValue(config, {
|
|
67
|
+
...params,
|
|
68
|
+
tag: 'PixelData',
|
|
69
|
+
instance: {
|
|
70
|
+
...params.instance,
|
|
71
|
+
PixelData: value,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(result).toContain(value.BulkDataURI);
|
|
76
|
+
expect(result).toContain('accept=video/mp4');
|
|
77
|
+
expect(result).toContain('test=123');
|
|
78
|
+
const acceptCount = result.match(/accept=video\/mp4/g)?.length || 0;
|
|
79
|
+
expect(acceptCount).toBe(1);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should return default path with accept', () => {
|
|
83
|
+
const value = {
|
|
84
|
+
BulkDataURI: null,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const defaultPath = '/testing';
|
|
88
|
+
const defaultURI = `series/${params.instance.SeriesInstanceUID}/instances/${params.instance.SOPInstanceUID}${defaultPath}`;
|
|
89
|
+
|
|
90
|
+
const result = getBulkdataValue(config, {
|
|
91
|
+
...params,
|
|
92
|
+
defaultPath,
|
|
93
|
+
tag: 'PixelData',
|
|
94
|
+
instance: {
|
|
95
|
+
...params.instance,
|
|
96
|
+
PixelData: value,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(result).toContain(defaultURI);
|
|
101
|
+
expect(result).toContain('accept=video/mp4');
|
|
102
|
+
const acceptCount = result.match(/accept=video\/mp4/g)?.length || 0;
|
|
103
|
+
expect(acceptCount).toBe(1);
|
|
104
|
+
});
|
|
105
|
+
});
|