@ohif/extension-default 3.14.0-beta.1 → 3.14.0-beta.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/ohif-extension-default.css +1 -1
  2. package/dist/ohif-extension-default.umd.js +1 -1
  3. package/package.json +14 -10
  4. package/src/Actions/createReportAsync.tsx +45 -0
  5. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  6. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  7. package/src/Components/ItemListComponent.tsx +95 -0
  8. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  9. package/src/Components/LineChartViewport/index.ts +1 -0
  10. package/src/Components/MoreDropdownMenu.tsx +112 -0
  11. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  12. package/src/Components/SidePanelWithServices.tsx +122 -0
  13. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  15. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  16. package/src/CustomizableContextMenu/index.ts +5 -0
  17. package/src/CustomizableContextMenu/types.ts +126 -0
  18. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  19. package/src/DicomJSONDataSource/index.js +326 -0
  20. package/src/DicomLocalDataSource/index.js +273 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  22. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  23. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  24. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  25. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  26. package/src/DicomWebDataSource/index.ts +808 -0
  27. package/src/DicomWebDataSource/qido.js +215 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  29. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  30. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  31. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  33. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  34. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  35. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  36. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  37. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  38. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  40. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  41. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  42. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  43. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  44. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  45. package/src/DicomWebDataSource/utils/index.ts +9 -0
  46. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  50. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  51. package/src/DicomWebProxyDataSource/index.ts +90 -0
  52. package/src/MergeDataSource/index.test.ts +212 -0
  53. package/src/MergeDataSource/index.ts +319 -0
  54. package/src/MergeDataSource/types.ts +46 -0
  55. package/src/Panels/DataSourceSelector.tsx +55 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  57. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  58. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  59. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  60. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  62. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  63. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  64. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  65. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  66. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  67. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  68. package/src/Panels/debounce.js +25 -0
  69. package/src/Panels/getImageSrcFromImageId.js +16 -0
  70. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  71. package/src/Panels/index.js +5 -0
  72. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  74. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  75. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  76. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  77. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  78. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  79. package/src/Toolbar/Toolbar.tsx +98 -0
  80. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  81. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  82. package/src/Toolbar/index.ts +7 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  84. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  85. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  86. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  87. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  88. package/src/ViewerLayout/constants/panels.ts +42 -0
  89. package/src/ViewerLayout/index.tsx +227 -0
  90. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  91. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  92. package/src/commandsModule.ts +970 -0
  93. package/src/customizations/aboutModalCustomization.tsx +42 -0
  94. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  95. package/src/customizations/contextMenuCustomization.ts +25 -0
  96. package/src/customizations/contextMenuUICustomization.ts +5 -0
  97. package/src/customizations/customRoutesCustomization.ts +6 -0
  98. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  99. package/src/customizations/datasourcesCustomization.tsx +14 -0
  100. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  101. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  102. package/src/customizations/headerRightSideCustomization.ts +19 -0
  103. package/src/customizations/helloPageCustomization.tsx +14 -0
  104. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  105. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  106. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  107. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  109. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  110. package/src/customizations/menuContentCustomization.tsx +67 -0
  111. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  112. package/src/customizations/metadataContextCustomization.ts +28 -0
  113. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  114. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  115. package/src/customizations/multimonitorCustomization.ts +63 -0
  116. package/src/customizations/notificationCustomization.ts +29 -0
  117. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  118. package/src/customizations/onboardingCustomization.ts +200 -0
  119. package/src/customizations/overlayItemCustomization.tsx +33 -0
  120. package/src/customizations/progressDropdownCustomization.ts +5 -0
  121. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  122. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  123. package/src/customizations/reportDialogCustomization.tsx +661 -0
  124. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  125. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  126. package/src/customizations/studyBrowserCustomization.ts +95 -0
  127. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  128. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  129. package/src/customizations/workListCustomization.ts +107 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  131. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  132. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  133. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  134. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  135. package/src/findViewportsByPosition.ts +102 -0
  136. package/src/getCustomizationModule.tsx +109 -0
  137. package/src/getDataSourcesModule.js +44 -0
  138. package/src/getDisplaySetMessages.ts +54 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  140. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  141. package/src/getHangingProtocolModule.js +155 -0
  142. package/src/getLayoutTemplateModule.js +28 -0
  143. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  144. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  145. package/src/getPanelModule.tsx +29 -0
  146. package/src/getSopClassHandlerModule.js +152 -0
  147. package/src/getSopClassHandlerModule.test.js +78 -0
  148. package/src/getToolbarModule.tsx +63 -0
  149. package/src/getViewportModule.tsx +12 -0
  150. package/src/hangingprotocols/hpCompare.ts +189 -0
  151. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  152. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  153. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  154. package/src/hangingprotocols/hpMammo.ts +202 -0
  155. package/src/hangingprotocols/hpScale.ts +132 -0
  156. package/src/hangingprotocols/index.ts +16 -0
  157. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  158. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  159. package/src/hangingprotocols/utils/laterality.ts +9 -0
  160. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  161. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  162. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  163. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  164. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  165. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  166. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  167. package/src/hooks/usePatientInfo.tsx +63 -0
  168. package/src/id.js +5 -0
  169. package/src/index.ts +113 -0
  170. package/src/init.ts +169 -0
  171. package/src/stores/index.ts +7 -0
  172. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  173. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  174. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  175. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  176. package/src/stores/useUIStateStore.ts +87 -0
  177. package/src/stores/useViewportGridStore.ts +89 -0
  178. package/src/stores/useViewportsByPositionStore.ts +100 -0
  179. package/src/types/AppTypes.ts +20 -0
  180. package/src/types/commandModuleTypes.tsx +6 -0
  181. package/src/utils/Toolbox.tsx +123 -0
  182. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  183. package/src/utils/addIcon.ts +6 -0
  184. package/src/utils/appendFrameQueryToImageId.js +9 -0
  185. package/src/utils/callInputDialog.tsx +126 -0
  186. package/src/utils/colorPickerDialog.css +4 -0
  187. package/src/utils/colorPickerDialog.tsx +45 -0
  188. package/src/utils/createRenderedRetrieve.js +32 -0
  189. package/src/utils/createRenderedRetrieve.test.js +46 -0
  190. package/src/utils/dicomWriter.test.ts +228 -0
  191. package/src/utils/dicomWriter.ts +110 -0
  192. package/src/utils/getBulkdataValue.js +45 -0
  193. package/src/utils/getBulkdataValue.test.js +105 -0
  194. package/src/utils/getDirectURL.test.ts +207 -0
  195. package/src/utils/getDirectURL.ts +65 -0
  196. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  197. package/src/utils/index.ts +2 -0
  198. package/src/utils/layerConfigurationUtils.ts +202 -0
  199. package/src/utils/promptLabelAnnotation.js +47 -0
  200. package/src/utils/promptSaveReport.test.ts +106 -0
  201. package/src/utils/promptSaveReport.tsx +117 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  203. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  204. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  205. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  206. package/src/utils/reuseCachedLayouts.ts +92 -0
  207. package/src/utils/secureConfigFetch.js +115 -0
  208. package/src/utils/secureConfigFetch.test.js +163 -0
  209. package/src/utils/seriesDescriptionHistory.ts +83 -0
  210. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  212. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  213. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  214. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  215. package/src/utils/validations/checkMultiframe.ts +25 -0
  216. package/src/utils/validations/checkSingleFrames.ts +36 -0
@@ -0,0 +1,808 @@
1
+ import { api } from 'dicomweb-client';
2
+ import { DicomMetadataStore, IWebApiDataSource, utils, errorHandler, classes } from '@ohif/core';
3
+
4
+ import {
5
+ mapParams,
6
+ search as qidoSearch,
7
+ seriesInStudy,
8
+ processResults,
9
+ processSeriesResults,
10
+ } from './qido.js';
11
+ import dcm4cheeReject from './dcm4cheeReject.js';
12
+
13
+ import getImageId from './utils/getImageId.js';
14
+ import dcmjs from 'dcmjs';
15
+ import dicomImageLoader from '@cornerstonejs/dicom-image-loader';
16
+ import { retrieveStudyMetadata, deleteStudyMetadataPromise } from './retrieveStudyMetadata.js';
17
+ import StaticWadoClient from './utils/StaticWadoClient';
18
+ import getDirectURL from '../utils/getDirectURL';
19
+ import { fixBulkDataURI } from './utils/fixBulkDataURI';
20
+ import { HeadersInterface } from '@ohif/core/src/types/RequestHeaders';
21
+ import {
22
+ getDatasetTransferSyntaxUID,
23
+ setNonEnumerableInstanceProperty,
24
+ writeDicomDictToPart10Buffer,
25
+ } from '../utils/dicomWriter';
26
+ import { getGetThumbnailSrc, ThumbnailContext } from './retrieveThumbnail';
27
+ import { getRenderedURL } from './retrieveRendered';
28
+ import retrieveBulkData from './retrieveBulkData';
29
+
30
+ const { DicomMetaDictionary, DicomDict } = dcmjs.data;
31
+
32
+ const { naturalizeDataset, denaturalizeDataset } = DicomMetaDictionary;
33
+
34
+ const ImplementationClassUID = '2.25.270695996825855179949881587723571202391.2.0.0';
35
+ const ImplementationVersionName = 'OHIF-3.11.0';
36
+
37
+ const metadataProvider = classes.MetadataProvider;
38
+
39
+ export type DicomWebConfig = {
40
+ /** Data source name */
41
+ name: string;
42
+ // wadoUriRoot - Legacy? (potentially unused/replaced)
43
+ /** Base URL to use for QIDO requests */
44
+ qidoRoot?: string;
45
+ wadoRoot?: string; // - Base URL to use for WADO requests
46
+ stowRoot?: string; // - Base URL to use for STOW requests (defaults to wadoRoot)
47
+ wadoUri?: string; // - Base URL to use for WADO URI requests
48
+ imageRendering?: string; // - wadors | ? (unsure of where/how this is used)
49
+ thumbnailRendering?: string;
50
+ /**
51
+ wadors - render using the wadors fetch. The full image is retrieved and rendered in cornerstone to thumbnail size png and returned as binary data to the src attribute of the image tag.
52
+ for example, <img src=data:image/png;base64,sdlfk;adkfadfk....asldfjkl;asdkf>
53
+ thumbnailDirect - get the direct url endpoint for the thumbnail as the image src (eg not authentication required).
54
+ for example, <img src=http://server:port/wadors/studies/1.2.3/thumbnail?accept=image/jpeg>
55
+ thumbnail - render using the thumbnail endpoint on wadors using bulkDataURI, passing authentication params to the url.
56
+ rendered - should use the rendered endpoint instead of the thumbnail endpoint
57
+ */
58
+ thumbnailRequestStrategy?: 'bulkDataRetrieve' | 'fetch';
59
+ /**
60
+ * Thumbnail data request strategy when `thumbnailRendering` is `thumbnail`/`rendered`; ignored for `wadors`/`thumbnailDirect`.
61
+ *
62
+ * - `bulkDataRetrieve` (default): Uses the DICOMweb client's bulk data retrieve API (`retrieveBulkData`)
63
+ * - `fetch`: `GET` the WADO-RS thumbnail or rendered resource URL with auth headers and use the
64
+ * response body as a JPEG blob URL. For series-level context, if that `GET` fails, a single
65
+ * QIDO instances query (`limit=1`) is used to obtain `SOPInstanceUID` and the fetch is retried once.
66
+ */
67
+ /** Whether the server supports reject calls (i.e. DCM4CHEE) */
68
+ supportsReject?: boolean;
69
+ /** indicates if the retrieves can fetch singlepart. Options are bulkdata, video, image, or true */
70
+ singlepart?: boolean | string;
71
+ /** Transfer syntax to request from the server */
72
+ requestTransferSyntaxUID?: string;
73
+ acceptHeader?: string[]; // - Accept header to use for requests
74
+ /** Whether to omit quotation marks for multipart requests */
75
+ omitQuotationForMultipartRequest?: boolean;
76
+ /** Whether the server supports fuzzy matching */
77
+ supportsFuzzyMatching?: boolean;
78
+ /** Whether the server supports wildcard matching */
79
+ supportsWildcard?: boolean;
80
+ /** Whether the server supports the native DICOM model */
81
+ supportsNativeDICOMModel?: boolean;
82
+ /** Whether to enable request tag */
83
+ enableRequestTag?: boolean;
84
+ /** Whether to enable study lazy loading */
85
+ enableStudyLazyLoad?: boolean;
86
+ /** Whether to enable bulkDataURI */
87
+ bulkDataURI?: BulkDataURIConfig;
88
+ /** Function that is called after the configuration is initialized */
89
+ onConfiguration: (config: DicomWebConfig, params) => DicomWebConfig;
90
+ /** Whether to use the static WADO client */
91
+ staticWado?: boolean;
92
+ /** User authentication service */
93
+ userAuthenticationService: Record<string, unknown>;
94
+ };
95
+
96
+ export type BulkDataURIConfig = {
97
+ /** Enable bulkdata uri configuration */
98
+ enabled?: boolean;
99
+ /**
100
+ * Remove the startsWith string.
101
+ * This is used to correct reverse proxied URLs by removing the startsWith path
102
+ */
103
+ startsWith?: string;
104
+ /**
105
+ * Adds this prefix path. Only used if the startsWith is defined and has
106
+ * been removed. This allows replacing the base path.
107
+ */
108
+ prefixWith?: string;
109
+ /** Transform the bulkdata path. Used to replace a portion of the path */
110
+ transform?: (uri: string) => string;
111
+ /**
112
+ * Adds relative resolution to the path handling.
113
+ * series is the default, as the metadata retrieved is series level.
114
+ */
115
+ relativeResolution?: 'studies' | 'series';
116
+ };
117
+
118
+ /**
119
+ * The header options are the options passed into the generateWadoHeader
120
+ * command. This takes an extensible set of attributes to allow future enhancements.
121
+ */
122
+ export interface HeaderOptions {
123
+ includeTransferSyntax?: boolean;
124
+ }
125
+
126
+ /**
127
+ * Metadata and some other requests don't permit the transfer syntax to be included,
128
+ * so pass in the excludeTransferSyntax parameter.
129
+ */
130
+ export const excludeTransferSyntax: HeaderOptions = { includeTransferSyntax: false };
131
+
132
+ /**
133
+ * Creates a DICOM Web API based on the provided configuration.
134
+ *
135
+ * @param dicomWebConfig - Configuration for the DICOM Web API
136
+ * @returns DICOM Web API object
137
+ */
138
+ function createDicomWebApi(dicomWebConfig: DicomWebConfig, servicesManager) {
139
+ const { userAuthenticationService } = servicesManager.services;
140
+ let dicomWebConfigCopy, clientConfig, dicomWebClient, getAuthorizationHeader, generateWadoHeader;
141
+ // Default to enabling bulk data retrieves, with no other customization as
142
+ // this is part of hte base standard.
143
+ dicomWebConfig.bulkDataURI ||= { enabled: true };
144
+
145
+ /**
146
+ * Adds the retrieve bulkdata function to naturalized DICOM data.
147
+ * This is done recursively, for sub-sequences. Shared by both the lazy
148
+ * (async) and non-lazy (sync) series-metadata retrieval paths.
149
+ */
150
+ const addRetrieveBulkDataNaturalized = (naturalized, instance = naturalized) => {
151
+ if (!naturalized) {
152
+ return naturalized;
153
+ }
154
+ for (const key of Object.keys(naturalized)) {
155
+ const value = naturalized[key];
156
+
157
+ if (Array.isArray(value) && typeof value[0] === 'object') {
158
+ // Fix recursive values
159
+ const validValues = value.filter(Boolean);
160
+ validValues.forEach(child => addRetrieveBulkDataNaturalized(child, instance));
161
+ continue;
162
+ }
163
+
164
+ // The value.Value will be set with the bulkdata read value
165
+ // in which case it isn't necessary to re-read this.
166
+ if (value && value.BulkDataURI && !value.Value) {
167
+ // handle the scenarios where bulkDataURI is relative path
168
+ fixBulkDataURI(value, instance, dicomWebConfig);
169
+ // Provide a method to fetch bulkdata. The client is shared, so set the
170
+ // current auth headers at fetch time, as the other ops here do.
171
+ value.retrieveBulkData = options => {
172
+ dicomWebClient.headers = getAuthorizationHeader();
173
+ return retrieveBulkData.call(dicomWebClient, value, options);
174
+ };
175
+ }
176
+ }
177
+ return naturalized;
178
+ };
179
+
180
+ /**
181
+ * naturalizes the dataset, and adds a retrieve bulkdata method
182
+ * to any values containing BulkDataURI.
183
+ * @param {*} instance
184
+ * @returns naturalized dataset, with retrieveBulkData methods
185
+ */
186
+ const addRetrieveBulkData = instance => {
187
+ const naturalized = naturalizeDataset(instance);
188
+
189
+ // if we know the server doesn't use bulkDataURI, then don't
190
+ if (!dicomWebConfig.bulkDataURI?.enabled) {
191
+ return naturalized;
192
+ }
193
+
194
+ return addRetrieveBulkDataNaturalized(naturalized);
195
+ };
196
+
197
+ const implementation = {
198
+ initialize: ({ params, query }) => {
199
+ if (dicomWebConfig.onConfiguration && typeof dicomWebConfig.onConfiguration === 'function') {
200
+ dicomWebConfig = dicomWebConfig.onConfiguration(dicomWebConfig, {
201
+ params,
202
+ query,
203
+ });
204
+ }
205
+
206
+ dicomWebConfigCopy = JSON.parse(JSON.stringify(dicomWebConfig));
207
+
208
+ getAuthorizationHeader = () => {
209
+ const xhrRequestHeaders: HeadersInterface = {};
210
+ const authHeaders = userAuthenticationService.getAuthorizationHeader();
211
+ if (authHeaders && authHeaders.Authorization) {
212
+ xhrRequestHeaders.Authorization = authHeaders.Authorization;
213
+ }
214
+ return xhrRequestHeaders;
215
+ };
216
+
217
+ /**
218
+ * Generates the wado header for requesting resources from DICOMweb.
219
+ * These are classified into those that are dependent on the transfer syntax
220
+ * and those that aren't, as defined by the include transfer syntax attribute.
221
+ */
222
+ generateWadoHeader = (options: HeaderOptions): HeadersInterface => {
223
+ const authorizationHeader = getAuthorizationHeader();
224
+ if (options?.includeTransferSyntax !== false) {
225
+ //Generate accept header depending on config params
226
+ const formattedAcceptHeader = utils.generateAcceptHeader(
227
+ dicomWebConfig.acceptHeader,
228
+ dicomWebConfig.requestTransferSyntaxUID,
229
+ dicomWebConfig.omitQuotationForMultipartRequest
230
+ );
231
+ return {
232
+ ...authorizationHeader,
233
+ Accept: formattedAcceptHeader,
234
+ };
235
+ } else {
236
+ // The base header will be included in the request. We simply skip customization options around
237
+ // transfer syntaxes and whether the request is multipart. In other words, a request in
238
+ // which the server expects Accept: application/dicom+json will still include that in the
239
+ // header.
240
+ return {
241
+ ...authorizationHeader,
242
+ };
243
+ }
244
+ };
245
+
246
+ // Each service falls back to the other configured roots so that no URL is
247
+ // left undefined when a deployment configures only one of them.
248
+ const qidoURL = dicomWebConfig.qidoRoot ?? dicomWebConfig.wadoRoot;
249
+ const wadoURL = dicomWebConfig.wadoRoot ?? dicomWebConfig.qidoRoot;
250
+ const stowURL = dicomWebConfig.stowRoot ?? wadoURL;
251
+
252
+ clientConfig = {
253
+ url: wadoURL,
254
+ staticWado: dicomWebConfig.staticWado,
255
+ singlepart: dicomWebConfig.singlepart,
256
+ headers: userAuthenticationService.getAuthorizationHeader(),
257
+ errorInterceptor: errorHandler.getHTTPErrorHandler(),
258
+ supportsFuzzyMatching: dicomWebConfig.supportsFuzzyMatching,
259
+ };
260
+
261
+ dicomWebClient = dicomWebConfig.staticWado
262
+ ? new StaticWadoClient(clientConfig)
263
+ : new api.DICOMwebClient(clientConfig);
264
+
265
+ // dicomweb-client reads `qidoURL`, `wadoURL` and `stowURL` fresh on every
266
+ // request, so a single client can serve all three services. Its
267
+ // constructor can only differentiate them via the `*URLPrefix` options,
268
+ // which are concatenated onto the single `baseURL` - OHIF's roots are
269
+ // independent absolute URLs that need not even share a host, so the
270
+ // prefixes cannot express them and the fields are assigned directly.
271
+ dicomWebClient.qidoURL = qidoURL;
272
+ dicomWebClient.wadoURL = wadoURL;
273
+ dicomWebClient.stowURL = stowURL;
274
+ },
275
+ query: {
276
+ studies: {
277
+ mapParams: mapParams.bind(),
278
+ search: async function (origParams) {
279
+ dicomWebClient.headers = getAuthorizationHeader();
280
+ const { studyInstanceUid, seriesInstanceUid, ...mappedParams } =
281
+ mapParams(origParams, {
282
+ supportsFuzzyMatching: dicomWebConfig.supportsFuzzyMatching,
283
+ supportsWildcard: dicomWebConfig.supportsWildcard,
284
+ }) || {};
285
+
286
+ const results = await qidoSearch(dicomWebClient, undefined, undefined, mappedParams);
287
+
288
+ return processResults(results);
289
+ },
290
+ processResults: processResults.bind(),
291
+ },
292
+ series: {
293
+ // mapParams: mapParams.bind(),
294
+ search: async function (studyInstanceUid) {
295
+ dicomWebClient.headers = getAuthorizationHeader();
296
+ const results = await seriesInStudy(dicomWebClient, studyInstanceUid);
297
+
298
+ return processSeriesResults(results);
299
+ },
300
+ // processResults: processResults.bind(),
301
+ },
302
+ instances: {
303
+ search: (studyInstanceUid, queryParameters) => {
304
+ dicomWebClient.headers = getAuthorizationHeader();
305
+ return qidoSearch.call(
306
+ undefined,
307
+ dicomWebClient,
308
+ studyInstanceUid,
309
+ null,
310
+ queryParameters
311
+ );
312
+ },
313
+ },
314
+ },
315
+ retrieve: {
316
+ /**
317
+ * Generates a URL that can be used for direct retrieve of the bulkdata
318
+ *
319
+ * @param {object} params
320
+ * @param {string} params.tag is the tag name of the URL to retrieve
321
+ * @param {object} params.instance is the instance object that the tag is in
322
+ * @param {string} params.defaultType is the mime type of the response
323
+ * @param {string} params.singlepart is the type of the part to retrieve
324
+ * @returns an absolute URL to the resource, if the absolute URL can be retrieved as singlepart,
325
+ * or is already retrieved, or a promise to a URL for such use if a BulkDataURI
326
+ */
327
+
328
+ getGetThumbnailSrc: function (thumbnailContext: ThumbnailContext, imageId) {
329
+ return getGetThumbnailSrc({
330
+ thumbnailContext,
331
+ imageId,
332
+ config: dicomWebConfig,
333
+ getAuthorizationHeader,
334
+ qidoDicomWebClient: dicomWebClient,
335
+ retrieve: this,
336
+ });
337
+ },
338
+ directURL: params => {
339
+ return getDirectURL(
340
+ {
341
+ wadoRoot: dicomWebConfig.wadoRoot,
342
+ singlepart: dicomWebConfig.singlepart,
343
+ },
344
+ params
345
+ );
346
+ },
347
+ renderedURL: (params, options) => {
348
+ return getRenderedURL({
349
+ config: dicomWebConfig,
350
+ getAuthorizationHeader,
351
+ retrieve: implementation.retrieve,
352
+ userAuthenticationService,
353
+ })(params, options);
354
+ },
355
+ /**
356
+ * Provide direct access to the dicom web client for certain use cases
357
+ * where the dicom web client is used by an external library such as the
358
+ * microscopy viewer.
359
+ * The returned instance is configured for all three services, so QIDO and
360
+ * STOW operations are also routed to the correct root.
361
+ */
362
+ getWadoDicomWebClient: () => dicomWebClient,
363
+
364
+ /**
365
+ * Best-effort prefetch of a whole multiframe instance as a single Part 10
366
+ * object, registered into the Cornerstone3D NATURALIZED frame registry so
367
+ * subsequent per-frame image loads are served locally instead of issuing
368
+ * one network request per frame (see the "Behaviours" doc
369
+ * segmentation-multiframe-part10-prefetch).
370
+ *
371
+ * Whether to use it at all is the caller's policy (the SEG handler
372
+ * resolves the `loadMultiframeAsPart10` config/customization, defaulting
373
+ * it on — per-frame loading is the explicit opt-out there).
374
+ * Never throws into the caller — on any failure it resolves `done` to
375
+ * `false` and the normal per-frame load path is used.
376
+ *
377
+ * @returns `{ done: Promise<boolean>, cancel: () => void }`.
378
+ */
379
+ prefetchInstanceFrames: ({ instance, imageId }) => {
380
+ const noop = { done: Promise.resolve(false), cancel: () => {} };
381
+
382
+ if (!instance || !imageId) {
383
+ return noop;
384
+ }
385
+
386
+ const StudyInstanceUID = instance.StudyInstanceUID;
387
+ const SeriesInstanceUID = instance.SeriesInstanceUID;
388
+ const SOPInstanceUID = instance.SOPInstanceUID || instance.SopInstanceUID;
389
+
390
+ if (!StudyInstanceUID || !SeriesInstanceUID || !SOPInstanceUID) {
391
+ return noop;
392
+ }
393
+
394
+ let cancelled = false;
395
+
396
+ // Lazy resolver: dicomweb-client.retrieveInstance returns the Part 10
397
+ // instance as an ArrayBuffer, unwrapping multipart/related transparently
398
+ // (and returning the raw object for single-part responses).
399
+ const resolvePart10 = async () => {
400
+ dicomWebClient.headers = getAuthorizationHeader();
401
+ const result = await dicomWebClient.retrieveInstance({
402
+ studyInstanceUID: StudyInstanceUID,
403
+ seriesInstanceUID: SeriesInstanceUID,
404
+ sopInstanceUID: SOPInstanceUID,
405
+ });
406
+
407
+ if (cancelled) {
408
+ throw new Error('prefetchInstanceFrames cancelled');
409
+ }
410
+
411
+ if (result instanceof ArrayBuffer) {
412
+ return result;
413
+ }
414
+ if (Array.isArray(result) && result[0] instanceof ArrayBuffer) {
415
+ return result[0];
416
+ }
417
+ if (result && (result as { buffer?: ArrayBuffer }).buffer instanceof ArrayBuffer) {
418
+ return (result as ArrayBufferView).buffer as ArrayBuffer;
419
+ }
420
+ throw new Error('Unexpected retrieveInstance result for instance prefetch');
421
+ };
422
+
423
+ const done = (async () => {
424
+ try {
425
+ await dicomImageLoader.prefetchPart10Instance(imageId, resolvePart10);
426
+ return !cancelled;
427
+ } catch (error) {
428
+ console.warn(
429
+ '[prefetchInstanceFrames] full-instance prefetch failed; falling back to per-frame loads',
430
+ error
431
+ );
432
+ return false;
433
+ }
434
+ })();
435
+
436
+ return {
437
+ done,
438
+ cancel: () => {
439
+ cancelled = true;
440
+ },
441
+ };
442
+ },
443
+
444
+ bulkDataURI: async ({ StudyInstanceUID, BulkDataURI }) => {
445
+ dicomWebClient.headers = getAuthorizationHeader();
446
+ const options = {
447
+ multipart: false,
448
+ BulkDataURI,
449
+ StudyInstanceUID,
450
+ };
451
+ return dicomWebClient.retrieveBulkData(options).then(val => {
452
+ const ret = (val && val[0]) || undefined;
453
+ return ret;
454
+ });
455
+ },
456
+ series: {
457
+ metadata: async ({
458
+ StudyInstanceUID,
459
+ filters,
460
+ sortCriteria,
461
+ sortFunction,
462
+ madeInClient = false,
463
+ returnPromises = false,
464
+ } = {}) => {
465
+ if (!StudyInstanceUID) {
466
+ throw new Error('Unable to query for SeriesMetadata without StudyInstanceUID');
467
+ }
468
+
469
+ if (dicomWebConfig.enableStudyLazyLoad) {
470
+ return implementation._retrieveSeriesMetadataAsync(
471
+ StudyInstanceUID,
472
+ filters,
473
+ sortCriteria,
474
+ sortFunction,
475
+ madeInClient,
476
+ returnPromises
477
+ );
478
+ }
479
+
480
+ return implementation._retrieveSeriesMetadataSync(
481
+ StudyInstanceUID,
482
+ filters,
483
+ sortCriteria,
484
+ sortFunction,
485
+ madeInClient
486
+ );
487
+ },
488
+ },
489
+ },
490
+
491
+ store: {
492
+ dicom: async (dataset, request, dicomDict) => {
493
+ dicomWebClient.headers = getAuthorizationHeader();
494
+ if (dataset instanceof ArrayBuffer) {
495
+ const options = {
496
+ datasets: [dataset],
497
+ request,
498
+ };
499
+ await dicomWebClient.storeInstances(options);
500
+ } else {
501
+ let effectiveDicomDict = dicomDict;
502
+
503
+ if (!dicomDict) {
504
+ const meta = {
505
+ FileMetaInformationVersion: dataset._meta?.FileMetaInformationVersion?.Value,
506
+ MediaStorageSOPClassUID: dataset.SOPClassUID,
507
+ MediaStorageSOPInstanceUID: dataset.SOPInstanceUID,
508
+ TransferSyntaxUID: getDatasetTransferSyntaxUID(dataset),
509
+ ImplementationClassUID,
510
+ ImplementationVersionName,
511
+ };
512
+
513
+ const denaturalized = denaturalizeDataset(meta);
514
+ const defaultDicomDict = new DicomDict(denaturalized);
515
+ defaultDicomDict.dict = denaturalizeDataset(dataset);
516
+
517
+ effectiveDicomDict = defaultDicomDict;
518
+ }
519
+
520
+ const part10Buffer = writeDicomDictToPart10Buffer(effectiveDicomDict);
521
+
522
+ const options = {
523
+ datasets: [part10Buffer],
524
+ request,
525
+ };
526
+
527
+ await dicomWebClient.storeInstances(options);
528
+ }
529
+ },
530
+ },
531
+
532
+ _retrieveSeriesMetadataSync: async (
533
+ StudyInstanceUID,
534
+ filters,
535
+ sortCriteria,
536
+ sortFunction,
537
+ madeInClient
538
+ ) => {
539
+ const enableStudyLazyLoad = false;
540
+ dicomWebClient.headers = generateWadoHeader(excludeTransferSyntax);
541
+ // data is all SOPInstanceUIDs
542
+ const data = await retrieveStudyMetadata(
543
+ dicomWebClient,
544
+ StudyInstanceUID,
545
+ enableStudyLazyLoad,
546
+ filters,
547
+ sortCriteria,
548
+ sortFunction,
549
+ dicomWebConfig
550
+ );
551
+
552
+ // first naturalize the data, attaching bulkdata retrieve methods so that
553
+ // bulkdata-valued tags can be resolved (matching the lazy-load path).
554
+ const naturalizedInstancesMetadata = data.map(addRetrieveBulkData);
555
+
556
+ // Resolve the registered bulkdata tags (e.g. the Philips SUV Scale
557
+ // Factor) delivered as bulkdata into plain numbers BEFORE
558
+ // INSTANCES_ADDED fires. retrieveBulkData is bound to the shared
559
+ // dicomWebClient, so refresh its auth headers first (matching every other
560
+ // qido op here).
561
+ dicomWebClient.headers = getAuthorizationHeader();
562
+ await utils.resolveBulkDataTags(naturalizedInstancesMetadata);
563
+
564
+ const seriesSummaryMetadata = {};
565
+ const instancesPerSeries = {};
566
+
567
+ naturalizedInstancesMetadata.forEach(instance => {
568
+ if (!seriesSummaryMetadata[instance.SeriesInstanceUID]) {
569
+ seriesSummaryMetadata[instance.SeriesInstanceUID] = {
570
+ StudyInstanceUID: instance.StudyInstanceUID,
571
+ StudyDescription: instance.StudyDescription,
572
+ SeriesInstanceUID: instance.SeriesInstanceUID,
573
+ SeriesDescription: instance.SeriesDescription,
574
+ SeriesNumber: instance.SeriesNumber,
575
+ SeriesTime: instance.SeriesTime,
576
+ SOPClassUID: instance.SOPClassUID,
577
+ ProtocolName: instance.ProtocolName,
578
+ Modality: instance.Modality,
579
+ };
580
+ }
581
+
582
+ if (!instancesPerSeries[instance.SeriesInstanceUID]) {
583
+ instancesPerSeries[instance.SeriesInstanceUID] = [];
584
+ }
585
+
586
+ const imageId = implementation.getImageIdsForInstance({
587
+ instance,
588
+ });
589
+
590
+ setNonEnumerableInstanceProperty(instance, 'imageId', imageId);
591
+ setNonEnumerableInstanceProperty(instance, 'wadoRoot', dicomWebConfig.wadoRoot);
592
+ setNonEnumerableInstanceProperty(instance, 'wadoUri', dicomWebConfig.wadoUri);
593
+
594
+ metadataProvider.addImageIdToUIDs(imageId, {
595
+ StudyInstanceUID,
596
+ SeriesInstanceUID: instance.SeriesInstanceUID,
597
+ SOPInstanceUID: instance.SOPInstanceUID,
598
+ });
599
+
600
+ instancesPerSeries[instance.SeriesInstanceUID].push(instance);
601
+ });
602
+
603
+ // grab all the series metadata
604
+ const seriesMetadata = Object.values(seriesSummaryMetadata);
605
+ DicomMetadataStore.addSeriesMetadata(seriesMetadata, madeInClient);
606
+
607
+ Object.keys(instancesPerSeries).forEach(seriesInstanceUID =>
608
+ DicomMetadataStore.addInstances(instancesPerSeries[seriesInstanceUID], madeInClient)
609
+ );
610
+
611
+ return seriesSummaryMetadata;
612
+ },
613
+
614
+ _retrieveSeriesMetadataAsync: async (
615
+ StudyInstanceUID,
616
+ filters,
617
+ sortCriteria,
618
+ sortFunction,
619
+ madeInClient = false,
620
+ returnPromises = false
621
+ ) => {
622
+ const enableStudyLazyLoad = true;
623
+ dicomWebClient.headers = generateWadoHeader(excludeTransferSyntax);
624
+ // Get Series
625
+ const { preLoadData: seriesSummaryMetadata, promises: seriesPromises } =
626
+ await retrieveStudyMetadata(
627
+ dicomWebClient,
628
+ StudyInstanceUID,
629
+ enableStudyLazyLoad,
630
+ filters,
631
+ sortCriteria,
632
+ sortFunction,
633
+ dicomWebConfig
634
+ );
635
+
636
+ // Async load series, store as retrieved
637
+ async function storeInstances(instances) {
638
+ const naturalizedInstances = instances.map(addRetrieveBulkData);
639
+
640
+ // Resolve the registered bulkdata tags (e.g. the Philips SUV Scale
641
+ // Factor) that the server delivered as bulkdata into plain numbers
642
+ // BEFORE INSTANCES_ADDED fires, so SUV scaling and every other
643
+ // subscriber read a fully-resolved value rather than an unresolved
644
+ // { BulkDataURI }. retrieveBulkData is bound to the shared
645
+ // dicomWebClient, so refresh its auth headers first (matching every
646
+ // other qido op here).
647
+ dicomWebClient.headers = getAuthorizationHeader();
648
+ await utils.resolveBulkDataTags(naturalizedInstances);
649
+
650
+ // Adding instanceMetadata to OHIF MetadataProvider
651
+ naturalizedInstances.forEach(instance => {
652
+ setNonEnumerableInstanceProperty(instance, 'wadoRoot', dicomWebConfig.wadoRoot);
653
+ setNonEnumerableInstanceProperty(instance, 'wadoUri', dicomWebConfig.wadoUri);
654
+
655
+ const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
656
+ const numberOfFrames = instance.NumberOfFrames || 1;
657
+ // Process all frames consistently, whether single or multiframe
658
+ for (let i = 0; i < numberOfFrames; i++) {
659
+ const frameNumber = i + 1;
660
+ const frameImageId = implementation.getImageIdsForInstance({
661
+ instance,
662
+ frame: frameNumber,
663
+ });
664
+ // Add imageId specific mapping to this data as the URL isn't necessarily WADO-URI.
665
+ metadataProvider.addImageIdToUIDs(frameImageId, {
666
+ StudyInstanceUID,
667
+ SeriesInstanceUID,
668
+ SOPInstanceUID,
669
+ frameNumber: numberOfFrames > 1 ? frameNumber : undefined,
670
+ });
671
+ }
672
+
673
+ // Adding imageId to each instance
674
+ // Todo: This is not the best way I can think of to let external
675
+ // metadata handlers know about the imageId that is stored in the store
676
+ const imageId = implementation.getImageIdsForInstance({
677
+ instance,
678
+ });
679
+ setNonEnumerableInstanceProperty(instance, 'imageId', imageId);
680
+ });
681
+
682
+ DicomMetadataStore.addInstances(naturalizedInstances, madeInClient);
683
+ }
684
+
685
+ function setSuccessFlag() {
686
+ const study = DicomMetadataStore.getStudy(StudyInstanceUID);
687
+ if (!study) {
688
+ return;
689
+ }
690
+ study.isLoaded = true;
691
+ }
692
+
693
+ // Google Cloud Healthcare doesn't return StudyInstanceUID, so we need to add
694
+ // it manually here
695
+ seriesSummaryMetadata.forEach(aSeries => {
696
+ aSeries.StudyInstanceUID = StudyInstanceUID;
697
+ });
698
+
699
+ DicomMetadataStore.addSeriesMetadata(seriesSummaryMetadata, madeInClient);
700
+
701
+ let completedSeriesCount = 0;
702
+ const seriesDeliveredPromises = seriesPromises.map(promise => {
703
+ let deliveredPromise;
704
+
705
+ return {
706
+ metadata: promise.metadata,
707
+ start: () => {
708
+ if (!deliveredPromise) {
709
+ deliveredPromise = promise.start().then(async instances => {
710
+ await storeInstances(instances);
711
+
712
+ completedSeriesCount++;
713
+ if (returnPromises && completedSeriesCount === seriesPromises.length) {
714
+ setSuccessFlag();
715
+ }
716
+
717
+ return instances;
718
+ });
719
+ }
720
+
721
+ return deliveredPromise;
722
+ },
723
+ };
724
+ });
725
+
726
+ if (returnPromises) {
727
+ if (!seriesDeliveredPromises.length) {
728
+ setSuccessFlag();
729
+ }
730
+
731
+ // The route starts only the series required by the hanging protocol,
732
+ // then starts the remainder in the background. Return wrappers whose
733
+ // start() resolves after async metadata post-processing has stored the
734
+ // instances and fired INSTANCES_ADDED; resolving the raw retrieval here
735
+ // races hanging-protocol application against display-set creation.
736
+ return seriesDeliveredPromises;
737
+ } else {
738
+ await Promise.all(seriesDeliveredPromises.map(promise => promise.start()));
739
+ setSuccessFlag();
740
+ }
741
+
742
+ return seriesSummaryMetadata;
743
+ },
744
+ deleteStudyMetadataPromise,
745
+ getImageIdsForDisplaySet(displaySet) {
746
+ const images = displaySet.images;
747
+ const imageIds = [];
748
+
749
+ if (!images) {
750
+ return imageIds;
751
+ }
752
+
753
+ displaySet.images.forEach(instance => {
754
+ const NumberOfFrames = instance.NumberOfFrames;
755
+
756
+ if (NumberOfFrames > 1) {
757
+ for (let frame = 1; frame <= NumberOfFrames; frame++) {
758
+ const imageId = this.getImageIdsForInstance({
759
+ instance,
760
+ frame,
761
+ });
762
+ imageIds.push(imageId);
763
+ }
764
+ } else {
765
+ const imageId = this.getImageIdsForInstance({ instance });
766
+ imageIds.push(imageId);
767
+ }
768
+ });
769
+
770
+ return imageIds;
771
+ },
772
+ getImageIdsForInstance({ instance, frame = undefined }) {
773
+ const imageIds = getImageId({
774
+ instance,
775
+ frame,
776
+ config: dicomWebConfig,
777
+ });
778
+ return imageIds;
779
+ },
780
+ getConfig() {
781
+ return dicomWebConfigCopy;
782
+ },
783
+ getStudyInstanceUIDs({ params, query }) {
784
+ const paramsStudyInstanceUIDs = params.StudyInstanceUIDs || params.studyInstanceUIDs;
785
+
786
+ const queryStudyInstanceUIDs = utils.splitComma(
787
+ query.getAll('StudyInstanceUIDs').concat(query.getAll('studyInstanceUIDs'))
788
+ );
789
+
790
+ const StudyInstanceUIDs =
791
+ (queryStudyInstanceUIDs.length && queryStudyInstanceUIDs) || paramsStudyInstanceUIDs;
792
+ const StudyInstanceUIDsAsArray =
793
+ StudyInstanceUIDs && Array.isArray(StudyInstanceUIDs)
794
+ ? StudyInstanceUIDs
795
+ : [StudyInstanceUIDs];
796
+
797
+ return StudyInstanceUIDsAsArray;
798
+ },
799
+ };
800
+
801
+ if (dicomWebConfig.supportsReject) {
802
+ implementation.reject = dcm4cheeReject(dicomWebConfig.wadoRoot, getAuthorizationHeader);
803
+ }
804
+
805
+ return IWebApiDataSource.create(implementation);
806
+ }
807
+
808
+ export { createDicomWebApi };