@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,272 @@
|
|
|
1
|
+
import { api } from 'dicomweb-client';
|
|
2
|
+
import fixMultipart from './fixMultipart';
|
|
3
|
+
|
|
4
|
+
const { DICOMwebClient } = api;
|
|
5
|
+
|
|
6
|
+
const anyDicomwebClient = DICOMwebClient as any;
|
|
7
|
+
|
|
8
|
+
// Ugly over-ride, but the internals aren't otherwise accessible.
|
|
9
|
+
if (!anyDicomwebClient._orig_buildMultipartAcceptHeaderFieldValue) {
|
|
10
|
+
anyDicomwebClient._orig_buildMultipartAcceptHeaderFieldValue =
|
|
11
|
+
anyDicomwebClient._buildMultipartAcceptHeaderFieldValue;
|
|
12
|
+
anyDicomwebClient._buildMultipartAcceptHeaderFieldValue = function (mediaTypes, acceptableTypes) {
|
|
13
|
+
if (mediaTypes.length === 1 && mediaTypes[0].mediaType.endsWith('/*')) {
|
|
14
|
+
return '*/*';
|
|
15
|
+
} else {
|
|
16
|
+
return anyDicomwebClient._orig_buildMultipartAcceptHeaderFieldValue(
|
|
17
|
+
mediaTypes,
|
|
18
|
+
acceptableTypes
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* An implementation of the static wado client, that fetches data from
|
|
26
|
+
* a static response rather than actually doing real queries. This allows
|
|
27
|
+
* fast encoding of test data, but because it is static, anything actually
|
|
28
|
+
* performing searches doesn't work. This version fixes the query issue
|
|
29
|
+
* by manually implementing a query option.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export default class StaticWadoClient extends api.DICOMwebClient {
|
|
33
|
+
static studyFilterKeys = {
|
|
34
|
+
studyinstanceuid: '0020000D',
|
|
35
|
+
patientname: '00100010',
|
|
36
|
+
'00100020': 'mrn',
|
|
37
|
+
studydescription: '00081030',
|
|
38
|
+
studydate: '00080020',
|
|
39
|
+
modalitiesinstudy: '00080061',
|
|
40
|
+
accessionnumber: '00080050',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
static seriesFilterKeys = {
|
|
44
|
+
seriesinstanceuid: '0020000E',
|
|
45
|
+
seriesnumber: '00200011',
|
|
46
|
+
modality: '00080060',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
protected config;
|
|
50
|
+
protected staticWado;
|
|
51
|
+
|
|
52
|
+
constructor(config) {
|
|
53
|
+
super(config);
|
|
54
|
+
this.staticWado = config.staticWado;
|
|
55
|
+
this.config = config;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Handle improperly specified multipart/related return type.
|
|
60
|
+
* Note if the response is SUPPOSED to be multipart encoded already, then this
|
|
61
|
+
* will double-decode it.
|
|
62
|
+
*
|
|
63
|
+
* @param options
|
|
64
|
+
* @returns De-multiparted response data.
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
public retrieveBulkData(options): Promise<any[]> {
|
|
68
|
+
const shouldFixMultipart = this.config.fixBulkdataMultipart !== false;
|
|
69
|
+
const useOptions = {
|
|
70
|
+
...options,
|
|
71
|
+
};
|
|
72
|
+
if (this.staticWado) {
|
|
73
|
+
useOptions.mediaTypes = [{ mediaType: 'application/*' }];
|
|
74
|
+
}
|
|
75
|
+
return super
|
|
76
|
+
.retrieveBulkData(useOptions)
|
|
77
|
+
.then(result => (shouldFixMultipart ? fixMultipart(result) : result));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves instance frames using the image/* media type when configured
|
|
82
|
+
* to do so (static wado back end).
|
|
83
|
+
*/
|
|
84
|
+
public retrieveInstanceFrames(options) {
|
|
85
|
+
if (this.staticWado) {
|
|
86
|
+
return super.retrieveInstanceFrames({
|
|
87
|
+
...options,
|
|
88
|
+
mediaTypes: [{ mediaType: 'image/*' }],
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
return super.retrieveInstanceFrames(options);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Replace the search for studies remote query with a local version which
|
|
97
|
+
* retrieves a complete query list and then sub-selects from it locally.
|
|
98
|
+
* @param {*} options
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
async searchForStudies(options) {
|
|
102
|
+
if (!this.staticWado) {
|
|
103
|
+
return super.searchForStudies(options);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const searchResult = await super.searchForStudies(options);
|
|
107
|
+
const { queryParams } = options;
|
|
108
|
+
|
|
109
|
+
if (!queryParams) {
|
|
110
|
+
return searchResult;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const lowerParams = this.toLowerParams(queryParams);
|
|
114
|
+
const filtered = searchResult.filter(study => {
|
|
115
|
+
for (const key of Object.keys(StaticWadoClient.studyFilterKeys)) {
|
|
116
|
+
if (!this.filterItem(key, lowerParams, study, StaticWadoClient.studyFilterKeys)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
});
|
|
122
|
+
return filtered;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async searchForSeries(options) {
|
|
126
|
+
if (!this.staticWado) {
|
|
127
|
+
return super.searchForSeries(options);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const searchResult = await super.searchForSeries(options);
|
|
131
|
+
const { queryParams } = options;
|
|
132
|
+
if (!queryParams) {
|
|
133
|
+
return searchResult;
|
|
134
|
+
}
|
|
135
|
+
const lowerParams = this.toLowerParams(queryParams);
|
|
136
|
+
|
|
137
|
+
const filtered = searchResult.filter(series => {
|
|
138
|
+
for (const key of Object.keys(StaticWadoClient.seriesFilterKeys)) {
|
|
139
|
+
if (!this.filterItem(key, lowerParams, series, StaticWadoClient.seriesFilterKeys)) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return filtered;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Compares values, matching any instance of desired to any instance of
|
|
151
|
+
* actual by recursively go through the paired set of values. That is,
|
|
152
|
+
* this is O(m*n) where m is how many items in desired and n is the length of actual
|
|
153
|
+
* Then, at the individual item node, compares the Alphabetic name if present,
|
|
154
|
+
* and does a sub-string matching on string values, and otherwise does an
|
|
155
|
+
* exact match comparison.
|
|
156
|
+
*
|
|
157
|
+
* @param {*} desired
|
|
158
|
+
* @param {*} actual
|
|
159
|
+
* @param {*} options - fuzzyMatching: if true, then do a sub-string match
|
|
160
|
+
* @returns true if the values match
|
|
161
|
+
*/
|
|
162
|
+
compareValues(desired, actual, options) {
|
|
163
|
+
const { fuzzyMatching } = options;
|
|
164
|
+
|
|
165
|
+
if (Array.isArray(desired)) {
|
|
166
|
+
return desired.find(item => this.compareValues(item, actual, options));
|
|
167
|
+
}
|
|
168
|
+
if (Array.isArray(actual)) {
|
|
169
|
+
return actual.find(actualItem => this.compareValues(desired, actualItem, options));
|
|
170
|
+
}
|
|
171
|
+
if (actual?.Alphabetic) {
|
|
172
|
+
actual = actual.Alphabetic;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (fuzzyMatching && typeof actual === 'string' && typeof desired === 'string') {
|
|
176
|
+
const normalizeValue = str => {
|
|
177
|
+
return str.toLowerCase();
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const normalizedDesired = normalizeValue(desired);
|
|
181
|
+
const normalizedActual = normalizeValue(actual);
|
|
182
|
+
|
|
183
|
+
const tokenizeAndNormalize = str => str.split(/[\s^]+/).filter(Boolean);
|
|
184
|
+
|
|
185
|
+
const desiredTokens = tokenizeAndNormalize(normalizedDesired);
|
|
186
|
+
const actualTokens = tokenizeAndNormalize(normalizedActual);
|
|
187
|
+
|
|
188
|
+
return desiredTokens.every(desiredToken =>
|
|
189
|
+
actualTokens.some(actualToken => actualToken.startsWith(desiredToken))
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (typeof actual == 'string') {
|
|
194
|
+
if (actual.length === 0) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
if (desired.length === 0 || desired === '*') {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (desired[0] === '*' && desired[desired.length - 1] === '*') {
|
|
201
|
+
// console.log(`Comparing ${actual} to ${desired.substring(1, desired.length - 1)}`)
|
|
202
|
+
return actual.indexOf(desired.substring(1, desired.length - 1)) != -1;
|
|
203
|
+
} else if (desired[desired.length - 1] === '*') {
|
|
204
|
+
return actual.indexOf(desired.substring(0, desired.length - 1)) != -1;
|
|
205
|
+
} else if (desired[0] === '*') {
|
|
206
|
+
return actual.indexOf(desired.substring(1)) === actual.length - desired.length + 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return desired === actual;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Compares a pair of dates to see if the value is within the range */
|
|
213
|
+
compareDateRange(range, value) {
|
|
214
|
+
if (!value) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
const dash = range.indexOf('-');
|
|
218
|
+
if (dash === -1) {
|
|
219
|
+
return this.compareValues(range, value, {});
|
|
220
|
+
}
|
|
221
|
+
const start = range.substring(0, dash);
|
|
222
|
+
const end = range.substring(dash + 1);
|
|
223
|
+
return (!start || value >= start) && (!end || value <= end);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Filters the return list by the query parameters.
|
|
228
|
+
*
|
|
229
|
+
* @param anyCaseKey - a possible search key
|
|
230
|
+
* @param queryParams -
|
|
231
|
+
* @param {*} study
|
|
232
|
+
* @param {*} sourceFilterMap
|
|
233
|
+
* @returns
|
|
234
|
+
*/
|
|
235
|
+
filterItem(key: string, queryParams, study, sourceFilterMap) {
|
|
236
|
+
const isName = (key: string) => key.indexOf('name') !== -1;
|
|
237
|
+
|
|
238
|
+
const { supportsFuzzyMatching = false } = this.config;
|
|
239
|
+
|
|
240
|
+
const options = {
|
|
241
|
+
fuzzyMatching: isName(key) && supportsFuzzyMatching,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const altKey = sourceFilterMap[key] || key;
|
|
245
|
+
if (!queryParams) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
const testValue = queryParams[key] || queryParams[altKey];
|
|
249
|
+
if (!testValue) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
const valueElem = study[key] || study[altKey];
|
|
253
|
+
if (!valueElem) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
if (valueElem.vr === 'DA' && valueElem.Value?.[0]) {
|
|
257
|
+
return this.compareDateRange(testValue, valueElem.Value[0]);
|
|
258
|
+
}
|
|
259
|
+
const value = valueElem.Value;
|
|
260
|
+
|
|
261
|
+
return this.compareValues(testValue, value, options);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Converts the query parameters to lower case query parameters */
|
|
265
|
+
toLowerParams(queryParams: Record<string, unknown>): Record<string, unknown> {
|
|
266
|
+
const lowerParams = {};
|
|
267
|
+
Object.entries(queryParams).forEach(([key, value]) => {
|
|
268
|
+
lowerParams[key.toLowerCase()] = value;
|
|
269
|
+
});
|
|
270
|
+
return lowerParams;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { fixBulkDataURI } from './fixBulkDataURI';
|
|
2
|
+
|
|
3
|
+
function isPrimitive(v: any) {
|
|
4
|
+
return !(typeof v == 'object' || Array.isArray(v));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const vrNumerics = new Set([
|
|
8
|
+
'DS',
|
|
9
|
+
'FL',
|
|
10
|
+
'FD',
|
|
11
|
+
'IS',
|
|
12
|
+
'OD',
|
|
13
|
+
'OF',
|
|
14
|
+
'OL',
|
|
15
|
+
'OV',
|
|
16
|
+
'SL',
|
|
17
|
+
'SS',
|
|
18
|
+
'SV',
|
|
19
|
+
'UL',
|
|
20
|
+
'US',
|
|
21
|
+
'UV',
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Specialized for DICOM JSON format dataset cleaning.
|
|
26
|
+
* @param obj
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export function cleanDenaturalizedDataset(
|
|
30
|
+
obj: any,
|
|
31
|
+
options?: {
|
|
32
|
+
StudyInstanceUID: string;
|
|
33
|
+
SeriesInstanceUID: string;
|
|
34
|
+
dataSourceConfig: unknown;
|
|
35
|
+
}
|
|
36
|
+
): any {
|
|
37
|
+
if (Array.isArray(obj)) {
|
|
38
|
+
const newAry = obj.map(o => (isPrimitive(o) ? o : cleanDenaturalizedDataset(o, options)));
|
|
39
|
+
return newAry;
|
|
40
|
+
}
|
|
41
|
+
if (isPrimitive(obj)) {
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
Object.keys(obj).forEach(key => {
|
|
45
|
+
if (obj[key].Value === null && obj[key].vr) {
|
|
46
|
+
delete obj[key].Value;
|
|
47
|
+
} else if (Array.isArray(obj[key].Value) && obj[key].vr) {
|
|
48
|
+
if (obj[key].Value.length === 1 && obj[key].Value[0].BulkDataURI) {
|
|
49
|
+
if (options?.dataSourceConfig) {
|
|
50
|
+
// Not needed unless data source is directly used for loading data.
|
|
51
|
+
fixBulkDataURI(obj[key].Value[0], options, options.dataSourceConfig);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
obj[key].BulkDataURI = obj[key].Value[0].BulkDataURI;
|
|
55
|
+
|
|
56
|
+
// prevent mixed-content blockage
|
|
57
|
+
if (window.location.protocol === 'https:' && obj[key].BulkDataURI.startsWith('http:')) {
|
|
58
|
+
obj[key].BulkDataURI = obj[key].BulkDataURI.replace('http:', 'https:');
|
|
59
|
+
}
|
|
60
|
+
delete obj[key].Value;
|
|
61
|
+
} else if (vrNumerics.has(obj[key].vr)) {
|
|
62
|
+
obj[key].Value = obj[key].Value.map(v => +v);
|
|
63
|
+
} else {
|
|
64
|
+
obj[key].Value = obj[key].Value.map(entry => cleanDenaturalizedDataset(entry, options));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* This is required to make the denaturalized data transferrable when it has
|
|
73
|
+
* added proxy values.
|
|
74
|
+
*/
|
|
75
|
+
export function transferDenaturalizedDataset(dataset) {
|
|
76
|
+
const noNull = cleanDenaturalizedDataset(dataset);
|
|
77
|
+
return JSON.parse(JSON.stringify(noNull));
|
|
78
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function checkToken(token, data, dataOffset): boolean {
|
|
2
|
+
if (dataOffset + token.length > data.length) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
let endIndex = dataOffset;
|
|
7
|
+
|
|
8
|
+
for (let i = 0; i < token.length; i++) {
|
|
9
|
+
if (token[i] !== data[endIndex++]) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function stringToUint8Array(str: string): Uint8Array {
|
|
18
|
+
const uint = new Uint8Array(str.length);
|
|
19
|
+
|
|
20
|
+
for (let i = 0, j = str.length; i < j; i++) {
|
|
21
|
+
uint[i] = str.charCodeAt(i);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return uint;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function findIndexOfString(
|
|
28
|
+
data: Uint8Array,
|
|
29
|
+
str: string,
|
|
30
|
+
offset?: number
|
|
31
|
+
): number {
|
|
32
|
+
offset = offset || 0;
|
|
33
|
+
|
|
34
|
+
const token = stringToUint8Array(str);
|
|
35
|
+
|
|
36
|
+
for (let i = offset; i < data.length; i++) {
|
|
37
|
+
if (token[0] === data[i]) {
|
|
38
|
+
// console.log('match @', i);
|
|
39
|
+
if (checkToken(token, data, i)) {
|
|
40
|
+
return i;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
export default findIndexOfString;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { fixBulkDataURI } from './fixBulkDataURI';
|
|
2
|
+
|
|
3
|
+
const instance = { StudyInstanceUID: '1.2.3', SeriesInstanceUID: '4.5.6' };
|
|
4
|
+
const absRoot = 'https://viewer.example.com/dicomweb';
|
|
5
|
+
const relRoot = '/dicomweb';
|
|
6
|
+
|
|
7
|
+
function fix(BulkDataURI: string, config: Record<string, unknown> = {}) {
|
|
8
|
+
const value = { BulkDataURI };
|
|
9
|
+
fixBulkDataURI(value, instance, { wadoRoot: absRoot, ...config });
|
|
10
|
+
return value.BulkDataURI;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe('fixBulkDataURI', () => {
|
|
14
|
+
it('leaves an absolute URI unchanged without configuration', () => {
|
|
15
|
+
expect(fix('http://pacs.example.com/bulk/1')).toBe('http://pacs.example.com/bulk/1');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('applies transform to an absolute URI', () => {
|
|
19
|
+
const bulkDataURI = { transform: (uri: string) => uri.replace(/^http:/, 'https:') };
|
|
20
|
+
expect(fix('http://pacs.example.com/bulk/1', { bulkDataURI })).toBe(
|
|
21
|
+
'https://pacs.example.com/bulk/1'
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it.each([
|
|
26
|
+
[absRoot, 'https://viewer.example.com/pacs/bulk/1'],
|
|
27
|
+
[relRoot, '/pacs/bulk/1'],
|
|
28
|
+
])('resolves a transform result of /path against wadoRoot %s', (wadoRoot, expected) => {
|
|
29
|
+
const bulkDataURI = {
|
|
30
|
+
transform: (uri: string) => uri.replace('http://pacs.example.com', '/pacs'),
|
|
31
|
+
};
|
|
32
|
+
expect(fix('http://pacs.example.com/bulk/1', { wadoRoot, bulkDataURI })).toBe(expected);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('applies transform to a /path URI with a relative wadoRoot', () => {
|
|
36
|
+
const bulkDataURI = { transform: (uri: string) => `/pacs${uri}` };
|
|
37
|
+
expect(fix('/bulk/1', { wadoRoot: relRoot, bulkDataURI })).toBe('/pacs/bulk/1');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it.each([
|
|
41
|
+
[absRoot, 'https://viewer.example.com/orthanc/dicom-web/bulk/1'],
|
|
42
|
+
[relRoot, '/orthanc/dicom-web/bulk/1'],
|
|
43
|
+
])('replaces startsWith with prefixWith for wadoRoot %s', (wadoRoot, expected) => {
|
|
44
|
+
const bulkDataURI = { startsWith: 'http://localhost/', prefixWith: '/orthanc/' };
|
|
45
|
+
expect(fix('http://localhost/dicom-web/bulk/1', { wadoRoot, bulkDataURI })).toBe(expected);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it.each([
|
|
49
|
+
[absRoot, 'https://viewer.example.com/bulk/1'],
|
|
50
|
+
[relRoot, '/bulk/1'],
|
|
51
|
+
])('resolves /path against wadoRoot %s', (wadoRoot, expected) => {
|
|
52
|
+
expect(fix('/bulk/1', { wadoRoot })).toBe(expected);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it.each([
|
|
56
|
+
['bulkdata/1', undefined, `${absRoot}/studies/1.2.3/bulkdata/1`],
|
|
57
|
+
['series/4.5.6/bulk/1', undefined, `${absRoot}/studies/1.2.3/series/4.5.6/bulk/1`],
|
|
58
|
+
[
|
|
59
|
+
'instances/7.8.9/bulk/1',
|
|
60
|
+
undefined,
|
|
61
|
+
`${absRoot}/studies/1.2.3/series/4.5.6/instances/7.8.9/bulk/1`,
|
|
62
|
+
],
|
|
63
|
+
['bulk/1', undefined, `${absRoot}/studies/1.2.3/series/4.5.6/bulk/1`],
|
|
64
|
+
['bulk/1', 'studies', `${absRoot}/studies/1.2.3/bulk/1`],
|
|
65
|
+
])('resolves relative %s with relativeResolution %s', (uri, relativeResolution, expected) => {
|
|
66
|
+
expect(fix(uri, { bulkDataURI: { relativeResolution } })).toBe(expected);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifies a bulkDataURI to ensure it is absolute based on the DICOMWeb configuration and
|
|
3
|
+
* instance data. The modification is in-place.
|
|
4
|
+
*
|
|
5
|
+
* The steps run in this order: `bulkDataURI.transform`, then `startsWith`/`prefixWith`, then the
|
|
6
|
+
* resolution against the wado root below. Each step sees the result of the previous step.
|
|
7
|
+
*
|
|
8
|
+
* The function is not idempotent when `transform` is not: a second call on the same value applies
|
|
9
|
+
* `transform` again. Call it once per value, or pass a config without `transform`.
|
|
10
|
+
*
|
|
11
|
+
* If the bulkDataURI is relative to the series or study (according to the DICOM standard),
|
|
12
|
+
* it is made absolute by prepending the relevant paths.
|
|
13
|
+
*
|
|
14
|
+
* In scenarios where the bulkDataURI is a server-relative path (starting with '/'), the function
|
|
15
|
+
* handles two cases:
|
|
16
|
+
*
|
|
17
|
+
* 1. If the wado root is absolute (starts with 'http'), it prepends the wado root to the bulkDataURI.
|
|
18
|
+
* 2. If the wado root is relative, no changes are needed as the bulkDataURI is already correctly relative to the server root.
|
|
19
|
+
*
|
|
20
|
+
* @param value - The object containing BulkDataURI to be fixed.
|
|
21
|
+
* @param instance - The object (DICOM instance data) containing StudyInstanceUID and SeriesInstanceUID.
|
|
22
|
+
* @param dicomWebConfig - The DICOMWeb configuration object, containing wadoRoot and potentially bulkDataURI.relativeResolution.
|
|
23
|
+
* @returns The function modifies `value` in-place, it does not return a value.
|
|
24
|
+
*/
|
|
25
|
+
function fixBulkDataURI(value, instance, dicomWebConfig) {
|
|
26
|
+
// in case of the relative path, make it absolute. The current DICOM standard says
|
|
27
|
+
// the bulkdataURI is relative to the series. However, there are situations where
|
|
28
|
+
// it can be relative to the study too
|
|
29
|
+
let { BulkDataURI } = value;
|
|
30
|
+
const { bulkDataURI: uriConfig = {} } = dicomWebConfig;
|
|
31
|
+
|
|
32
|
+
BulkDataURI = uriConfig.transform?.(BulkDataURI) || BulkDataURI;
|
|
33
|
+
|
|
34
|
+
// Handle incorrectly prefixed origins
|
|
35
|
+
const { startsWith, prefixWith = '' } = uriConfig;
|
|
36
|
+
if (startsWith && BulkDataURI.startsWith(startsWith)) {
|
|
37
|
+
BulkDataURI = prefixWith + BulkDataURI.substring(startsWith.length);
|
|
38
|
+
}
|
|
39
|
+
// The branches below do not rewrite absolute URIs or /path URIs with a relative wadoRoot
|
|
40
|
+
value.BulkDataURI = BulkDataURI;
|
|
41
|
+
|
|
42
|
+
if (!BulkDataURI.startsWith('http') && !BulkDataURI.startsWith('/')) {
|
|
43
|
+
const { StudyInstanceUID, SeriesInstanceUID } = instance;
|
|
44
|
+
const isInstanceStart = BulkDataURI.startsWith('instances/') || BulkDataURI.startsWith('../');
|
|
45
|
+
if (
|
|
46
|
+
BulkDataURI.startsWith('series/') ||
|
|
47
|
+
BulkDataURI.startsWith('bulkdata/') ||
|
|
48
|
+
(uriConfig.relativeResolution === 'studies' && !isInstanceStart)
|
|
49
|
+
) {
|
|
50
|
+
value.BulkDataURI = `${dicomWebConfig.wadoRoot}/studies/${StudyInstanceUID}/${BulkDataURI}`;
|
|
51
|
+
} else if (
|
|
52
|
+
isInstanceStart ||
|
|
53
|
+
uriConfig.relativeResolution === 'series' ||
|
|
54
|
+
!uriConfig.relativeResolution
|
|
55
|
+
) {
|
|
56
|
+
value.BulkDataURI = `${dicomWebConfig.wadoRoot}/studies/${StudyInstanceUID}/series/${SeriesInstanceUID}/${BulkDataURI}`;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// in case it is relative path but starts at the server (e.g., /bulk/1e, note the missing http
|
|
62
|
+
// in the beginning and the first character is /) There are two scenarios, whether the wado root
|
|
63
|
+
// is absolute or relative. In case of absolute, we need to prepend the wado root to the bulkdata
|
|
64
|
+
// uri (e.g., bulkData: /bulk/1e, wado root: http://myserver.com/dicomweb, output: http://myserver.com/bulk/1e)
|
|
65
|
+
// and in case of relative wado root, we need to prepend the bulkdata uri to the wado root (e.g,. bulkData: /bulk/1e
|
|
66
|
+
// wado root: /dicomweb, output: /bulk/1e)
|
|
67
|
+
if (BulkDataURI[0] === '/') {
|
|
68
|
+
if (dicomWebConfig.wadoRoot.startsWith('http')) {
|
|
69
|
+
// Absolute wado root
|
|
70
|
+
const url = new URL(dicomWebConfig.wadoRoot);
|
|
71
|
+
value.BulkDataURI = `${url.origin}${BulkDataURI}`;
|
|
72
|
+
} else {
|
|
73
|
+
// Relative wado root, we don't need to do anything, bulkdata uri is already correct
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { fixBulkDataURI };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fix multi-valued keys so that those which are strings split by
|
|
3
|
+
* a backslash are returned as arrays.
|
|
4
|
+
*/
|
|
5
|
+
export function fixMultiValueKeys(naturalData, keys = ['ImageType']) {
|
|
6
|
+
for (const key of keys) {
|
|
7
|
+
if (typeof naturalData[key] === 'string') {
|
|
8
|
+
naturalData[key] = naturalData[key].split('\\');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return naturalData;
|
|
12
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import findIndexOfString from './findIndexOfString';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fix multipart data coming back from the retrieve bulkdata request, but
|
|
5
|
+
* incorrectly tagged as application/octet-stream. Some servers don't handle
|
|
6
|
+
* the response type correctly, and this method is relatively robust about
|
|
7
|
+
* detecting multipart data correctly. It will only extract one value.
|
|
8
|
+
*/
|
|
9
|
+
export default function fixMultipart(arrayData) {
|
|
10
|
+
const data = new Uint8Array(arrayData[0]);
|
|
11
|
+
// Don't know the exact minimum length, but it is at least 25 to encode multipart
|
|
12
|
+
if (data.length < 25) {
|
|
13
|
+
return arrayData;
|
|
14
|
+
}
|
|
15
|
+
const dashIndex = findIndexOfString(data, '--');
|
|
16
|
+
if (dashIndex > 6) {
|
|
17
|
+
return arrayData;
|
|
18
|
+
}
|
|
19
|
+
const tokenIndex = findIndexOfString(data, '\r\n\r\n', dashIndex);
|
|
20
|
+
if (tokenIndex > 512) {
|
|
21
|
+
// Allow for 512 characters in the header - there is no apriori limit, but
|
|
22
|
+
// this seems ok for now as we only expect it to have content type in it.
|
|
23
|
+
return arrayData;
|
|
24
|
+
}
|
|
25
|
+
const header = uint8ArrayToString(data, 0, tokenIndex);
|
|
26
|
+
// Now find the boundary marker
|
|
27
|
+
const responseHeaders = header.split('\r\n');
|
|
28
|
+
const boundary = findBoundary(responseHeaders);
|
|
29
|
+
|
|
30
|
+
if (!boundary) {
|
|
31
|
+
return arrayData;
|
|
32
|
+
}
|
|
33
|
+
// Start of actual data is 4 characters after the token
|
|
34
|
+
const offset = tokenIndex + 4;
|
|
35
|
+
|
|
36
|
+
const endIndex = findIndexOfString(data, boundary, offset);
|
|
37
|
+
if (endIndex === -1) {
|
|
38
|
+
return arrayData;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return [data.slice(offset, endIndex - 2).buffer];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function findBoundary(header: string[]): string {
|
|
45
|
+
for (let i = 0; i < header.length; i++) {
|
|
46
|
+
if (header[i].substr(0, 2) === '--') {
|
|
47
|
+
return header[i];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function findContentType(header: string[]): string {
|
|
53
|
+
for (let i = 0; i < header.length; i++) {
|
|
54
|
+
if (header[i].substr(0, 13) === 'Content-Type:') {
|
|
55
|
+
return header[i].substr(13).trim();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function uint8ArrayToString(data, offset, length) {
|
|
61
|
+
offset = offset || 0;
|
|
62
|
+
length = length || data.length - offset;
|
|
63
|
+
let str = '';
|
|
64
|
+
|
|
65
|
+
for (let i = offset; i < offset + length; i++) {
|
|
66
|
+
str += String.fromCharCode(data[i]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return str;
|
|
70
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import getWADORSImageId from './getWADORSImageId';
|
|
2
|
+
|
|
3
|
+
function buildInstanceWadoUrl(config, instance) {
|
|
4
|
+
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
|
|
5
|
+
const params = [];
|
|
6
|
+
|
|
7
|
+
params.push('requestType=WADO');
|
|
8
|
+
params.push(`studyUID=${StudyInstanceUID}`);
|
|
9
|
+
params.push(`seriesUID=${SeriesInstanceUID}`);
|
|
10
|
+
params.push(`objectUID=${SOPInstanceUID}`);
|
|
11
|
+
params.push('contentType=application/dicom');
|
|
12
|
+
params.push('transferSyntax=*');
|
|
13
|
+
|
|
14
|
+
const paramString = params.join('&');
|
|
15
|
+
|
|
16
|
+
return `${config.wadoUriRoot}?${paramString}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Obtain an imageId for Cornerstone from an image instance
|
|
21
|
+
*
|
|
22
|
+
* @param instance
|
|
23
|
+
* @param frame
|
|
24
|
+
* @param thumbnail
|
|
25
|
+
* @returns {string} The imageId to be used by Cornerstone
|
|
26
|
+
*/
|
|
27
|
+
export default function getImageId({ instance, frame, config, thumbnail = false }) {
|
|
28
|
+
if (!instance) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (instance.imageId && frame === undefined) {
|
|
33
|
+
return instance.imageId;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (instance.url) {
|
|
37
|
+
return instance.url;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const renderingAttr = thumbnail ? 'thumbnailRendering' : 'imageRendering';
|
|
41
|
+
|
|
42
|
+
if (!config[renderingAttr] || config[renderingAttr] === 'wadouri') {
|
|
43
|
+
const wadouri = buildInstanceWadoUrl(config, instance);
|
|
44
|
+
|
|
45
|
+
let imageId = 'dicomweb:' + wadouri;
|
|
46
|
+
if (frame !== undefined) {
|
|
47
|
+
imageId += '&frame=' + frame;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return imageId;
|
|
51
|
+
} else {
|
|
52
|
+
return getWADORSImageId(instance, config, frame); // WADO-RS Retrieve Frame
|
|
53
|
+
}
|
|
54
|
+
}
|