@ohif/app 3.9.0-beta.76 → 3.9.0-beta.78

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 (44) hide show
  1. package/dist/{1169.bundle.a3d3d310f1d8d7e335bf.js → 1169.bundle.d32f38ab5aa329346850.js} +46 -106
  2. package/dist/{1202.bundle.1468f0e71fea0c593081.js → 1202.bundle.55f140afb05e1ad5512c.js} +503 -153
  3. package/dist/{2568.css → 1540.css} +1 -0
  4. package/dist/{1994.bundle.d347a831c1be751d0627.js → 1994.bundle.083fb36bc0648f2dbda6.js} +3 -3
  5. package/dist/{9824.bundle.e16a5ef35eedfa74b3be.js → 2119.bundle.3446480f91f1200cd45c.js} +4 -4
  6. package/dist/{9824.css → 2119.css} +1 -0
  7. package/dist/{2650.bundle.1f7d90198b9e361dfb9c.js → 2650.bundle.feb3b241748314884ae4.js} +57 -35
  8. package/dist/{3117.bundle.c83d0f403d17104a7c4c.js → 3117.bundle.463d5fa4671a93939d36.js} +8 -7
  9. package/dist/{4210.bundle.fb376c67d110f8177eea.js → 4210.bundle.38eb5056ac41a0b04d21.js} +2 -2
  10. package/dist/{4842.bundle.619edd60983634d9f8dd.js → 4842.bundle.0427b8aa1b52aa050ed2.js} +12 -8
  11. package/dist/{5888.bundle.91227a2efe569869fdd0.js → 5888.bundle.ebca6329037cf353968f.js} +14 -7
  12. package/dist/{2417.bundle.4a0334c8c4047005979e.js → 5898.bundle.be696e0b355efc1c7f05.js} +1947 -1
  13. package/dist/{2281.bundle.216a0d86eaed7f4870ae.js → 655.bundle.28f107410332c62993a3.js} +170 -66
  14. package/dist/{6591.bundle.ace15b11ac7df3edf1bb.js → 6591.bundle.92a28f98c3f45ac3b3f1.js} +15 -1
  15. package/dist/{7502.bundle.abf1ade64f101ba01596.js → 7502.bundle.550aee57ecd221eab7c1.js} +4 -6
  16. package/dist/{3424.bundle.1b6101d721148c04242b.js → 79.bundle.b03daeeef3e6faf9dca3.js} +5 -47
  17. package/dist/{8993.bundle.256bb3c84d2564a5f3cf.js → 8993.bundle.23cd5f8560800a97d798.js} +39 -32
  18. package/dist/{2065.bundle.5d8f4c26b1fa393e26a4.js → 8999.bundle.e23beb310b14ca9ded76.js} +13 -133
  19. package/dist/{9579.bundle.7212d7a737a71bb61502.js → 9579.bundle.f9c9be0c5ab6cddbde3d.js} +8 -7
  20. package/dist/{5516.bundle.074fac92088b103bf0e3.js → 962.bundle.04afab064299df16f869.js} +408 -179
  21. package/dist/app-config.js +1 -0
  22. package/dist/{app.bundle.016cbb7783086e131b26.js → app.bundle.53faac5b01b67714fad2.js} +658 -352
  23. package/dist/index.html +1 -1
  24. package/dist/{polySeg.bundle.40b9a8c9006bb15691ee.js → polySeg.bundle.0a70e65fe89169ec7508.js} +1 -1
  25. package/dist/{suv-peak-worker.bundle.a70e70b9ef87c18b896c.js → suv-peak-worker.bundle.54d68bc1808ad3d77994.js} +1 -1
  26. package/dist/sw.js +1 -1
  27. package/package.json +18 -18
  28. package/dist/7604.bundle.42d3f08efb3a9eae4581.js +0 -1950
  29. package/dist/{1498.bundle.d8f5281952d09c57ef87.js → 1498.bundle.a2d05ac1f27d0c2d2c9f.js} +0 -0
  30. package/dist/{153.bundle.35f9f8c81db7a40221cf.js → 153.bundle.3ba838ef3c08a266ae35.js} +0 -0
  31. package/dist/{2791.bundle.29069810b8cf85d6aa0f.js → 2791.bundle.cfa27e4347069ab301b7.js} +0 -0
  32. package/dist/{3497.bundle.a04a2444975bf50fddf8.js → 3497.bundle.512610422a2862584c55.js} +0 -0
  33. package/dist/{3962.bundle.9a463bda1035e46ebbba.js → 3962.bundle.31bfadcde7f5a2dd8932.js} +0 -0
  34. package/dist/{4353.bundle.ac8577aa909c2c56db16.js → 4353.bundle.c13a0c72c607850ea3c0.js} +0 -0
  35. package/dist/{4978.bundle.19b43e91a7fe302599c6.js → 4978.bundle.655344cfd52d9f0641e5.js} +0 -0
  36. package/dist/{5793.bundle.eed3fe9019c31999efff.js → 5793.bundle.d1b4e887564bbb98752d.js} +0 -0
  37. package/dist/{6904.bundle.27abf08c0f2e4fe5e06d.js → 6904.bundle.da0d83fcd48a48cfaac1.js} +0 -0
  38. package/dist/{7246.bundle.11a6fa77c63c0df329bc.js → 7246.bundle.f1cbdd5ec9387bb6f8fe.js} +0 -0
  39. package/dist/{7360.bundle.114b1294460b2d9bfeb9.js → 7360.bundle.d0bdb43af1494bccc433.js} +0 -0
  40. package/dist/{7376.bundle.e9fea4789985d4409171.js → 7376.bundle.d6b445de2d468ab2e8b3.js} +0 -0
  41. package/dist/{3424.css → 79.css} +1 -1
  42. /package/dist/{7913.bundle.dc45c449f89985c7dd7c.js → 7913.bundle.353baac2e2a5b4bb330d.js} +0 -0
  43. /package/dist/{818.bundle.b64fae7e982e16a82ca2.js → 818.bundle.b6027359846cc90e32ff.js} +0 -0
  44. /package/dist/{8944.bundle.a3cecebcc7b2ca3c7259.js → 8944.bundle.29926bb653a467c7e7d8.js} +0 -0
@@ -1,1950 +0,0 @@
1
- "use strict";
2
- (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[7604],{
3
-
4
- /***/ 97604:
5
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6
-
7
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8
- /* harmony export */ api: () => (/* binding */ api)
9
- /* harmony export */ });
10
- /* unused harmony exports utils, version */
11
- function _typeof(obj) {
12
- "@babel/helpers - typeof";
13
-
14
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
15
- return typeof obj;
16
- } : function (obj) {
17
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
18
- }, _typeof(obj);
19
- }
20
- function _classCallCheck(instance, Constructor) {
21
- if (!(instance instanceof Constructor)) {
22
- throw new TypeError("Cannot call a class as a function");
23
- }
24
- }
25
- function _defineProperties(target, props) {
26
- for (var i = 0; i < props.length; i++) {
27
- var descriptor = props[i];
28
- descriptor.enumerable = descriptor.enumerable || false;
29
- descriptor.configurable = true;
30
- if ("value" in descriptor) descriptor.writable = true;
31
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
32
- }
33
- }
34
- function _createClass(Constructor, protoProps, staticProps) {
35
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
36
- if (staticProps) _defineProperties(Constructor, staticProps);
37
- Object.defineProperty(Constructor, "prototype", {
38
- writable: false
39
- });
40
- return Constructor;
41
- }
42
- function _toConsumableArray(arr) {
43
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
44
- }
45
- function _arrayWithoutHoles(arr) {
46
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
47
- }
48
- function _iterableToArray(iter) {
49
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
50
- }
51
- function _unsupportedIterableToArray(o, minLen) {
52
- if (!o) return;
53
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
54
- var n = Object.prototype.toString.call(o).slice(8, -1);
55
- if (n === "Object" && o.constructor) n = o.constructor.name;
56
- if (n === "Map" || n === "Set") return Array.from(o);
57
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
58
- }
59
- function _arrayLikeToArray(arr, len) {
60
- if (len == null || len > arr.length) len = arr.length;
61
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
62
- return arr2;
63
- }
64
- function _nonIterableSpread() {
65
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
66
- }
67
- function _toPrimitive(input, hint) {
68
- if (typeof input !== "object" || input === null) return input;
69
- var prim = input[Symbol.toPrimitive];
70
- if (prim !== undefined) {
71
- var res = prim.call(input, hint || "default");
72
- if (typeof res !== "object") return res;
73
- throw new TypeError("@@toPrimitive must return a primitive value.");
74
- }
75
- return (hint === "string" ? String : Number)(input);
76
- }
77
- function _toPropertyKey(arg) {
78
- var key = _toPrimitive(arg, "string");
79
- return typeof key === "symbol" ? key : String(key);
80
- }
81
-
82
- /**
83
- * Converts a Uint8Array to a String.
84
- * @param {Uint8Array} array that should be converted
85
- * @param {Number} offset array offset in case only subset of array items should
86
- be extracted (default: 0)
87
- * @param {Number} limit maximum number of array items that should be extracted
88
- (defaults to length of array)
89
- * @returns {String}
90
- */
91
- function uint8ArrayToString(arr) {
92
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
93
- var limit = arguments.length > 2 ? arguments[2] : undefined;
94
- var itemLimit = limit || arr.length - offset;
95
- var str = '';
96
- for (var i = offset; i < offset + itemLimit; i++) {
97
- str += String.fromCharCode(arr[i]);
98
- }
99
- return str;
100
- }
101
-
102
- /**
103
- * Converts a String to a Uint8Array.
104
- * @param {String} str string that should be converted
105
- * @returns {Uint8Array}
106
- */
107
- function stringToUint8Array(str) {
108
- var arr = new Uint8Array(str.length);
109
- for (var i = 0, j = str.length; i < j; i++) {
110
- arr[i] = str.charCodeAt(i);
111
- }
112
- return arr;
113
- }
114
-
115
- /**
116
- * Identifies the boundary in a multipart/related message header.
117
- * @param {String} header message header
118
- * @returns {String} boundary
119
- */
120
- function identifyBoundary(header) {
121
- var parts = header.split('\r\n');
122
- for (var i = 0; i < parts.length; i++) {
123
- if (parts[i].substr(0, 2) === '--') {
124
- return parts[i];
125
- }
126
- }
127
- return null;
128
- }
129
-
130
- /**
131
- * Checks whether a given token is contained by a message at a given offset.
132
- * @param {Uint8Array} message message content
133
- * @param {Uint8Array} token substring that should be present
134
- * @param {Number} offset offset in message content from where search should start
135
- * @returns {Boolean} whether message contains token at offset
136
- */
137
- function containsToken(message, token) {
138
- var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
139
- if (offset + token.length > message.length) {
140
- return false;
141
- }
142
- var index = offset;
143
- for (var i = 0; i < token.length; i++) {
144
- if (token[i] !== message[index]) {
145
- return false;
146
- }
147
- index += 1;
148
- }
149
- return true;
150
- }
151
-
152
- /**
153
- * Finds a given token in a message at a given offset.
154
- * @param {Uint8Array} message message content
155
- * @param {Uint8Array} token substring that should be found
156
- * @param {String} offset message body offset from where search should start
157
- * @returns {Boolean} whether message has a part at given offset or not
158
- */
159
- function findToken(message, token) {
160
- var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
161
- var maxSearchLength = arguments.length > 3 ? arguments[3] : undefined;
162
- var searchLength = message.length;
163
- if (maxSearchLength) {
164
- searchLength = Math.min(offset + maxSearchLength, message.length);
165
- }
166
- for (var i = offset; i < searchLength; i++) {
167
- // If the first value of the message matches
168
- // the first value of the token, check if
169
- // this is the full token.
170
- if (message[i] === token[0]) {
171
- if (containsToken(message, token, i)) {
172
- return i;
173
- }
174
- }
175
- }
176
- return -1;
177
- }
178
-
179
- /**
180
- * Create a random GUID
181
- *
182
- * @return {string}
183
- */
184
- function guid() {
185
- function s4() {
186
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
187
- }
188
- return "".concat(s4() + s4(), "-").concat(s4(), "-").concat(s4(), "-").concat(s4(), "-").concat(s4()).concat(s4()).concat(s4());
189
- }
190
-
191
- /**
192
- * @typedef {Object} MultipartEncodedData
193
- * @property {ArrayBuffer} data The encoded Multipart Data
194
- * @property {String} boundary The boundary used to divide pieces of the encoded data
195
- */
196
-
197
- /**
198
- * Encode one or more DICOM datasets into a single body so it can be
199
- * sent using the Multipart Content-Type.
200
- *
201
- * @param {ArrayBuffer[]} datasets Array containing each file to be encoded in the
202
- multipart body, passed as ArrayBuffers.
203
- * @param {String} [boundary] Optional string to define a boundary between each part
204
- of the multipart body. If this is not specified, a random
205
- GUID will be generated.
206
- * @return {MultipartEncodedData} The Multipart encoded data returned as an Object. This
207
- contains both the data itself, and the boundary string
208
- used to divide it.
209
- */
210
- function multipartEncode(datasets) {
211
- var boundary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : guid();
212
- var contentType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/dicom';
213
- var contentTypeString = "Content-Type: ".concat(contentType);
214
- var header = "\r\n--".concat(boundary, "\r\n").concat(contentTypeString, "\r\n\r\n");
215
- var footer = "\r\n--".concat(boundary, "--");
216
- var headerArray = stringToUint8Array(header);
217
- var footerArray = stringToUint8Array(footer);
218
- var headerLength = headerArray.length;
219
- var footerLength = footerArray.length;
220
- var length = 0;
221
-
222
- // Calculate the total length for the final array
223
- var contentArrays = datasets.map(function (datasetBuffer) {
224
- var contentArray = new Uint8Array(datasetBuffer);
225
- var contentLength = contentArray.length;
226
- length += headerLength + contentLength + footerLength;
227
- return contentArray;
228
- });
229
-
230
- // Allocate the array
231
- var multipartArray = new Uint8Array(length);
232
-
233
- // Set the initial header
234
- multipartArray.set(headerArray, 0);
235
-
236
- // Write each dataset into the multipart array
237
- var position = 0;
238
- contentArrays.forEach(function (contentArray) {
239
- multipartArray.set(headerArray, position);
240
- multipartArray.set(contentArray, position + headerLength);
241
- position += headerLength + contentArray.length;
242
- });
243
- multipartArray.set(footerArray, position);
244
- return {
245
- data: multipartArray.buffer,
246
- boundary: boundary
247
- };
248
- }
249
-
250
- /**
251
- * Decode a Multipart encoded ArrayBuffer and return the components as an Array.
252
- *
253
- * @param {ArrayBuffer} response Data encoded as a 'multipart/related' message
254
- * @returns {Array} The content
255
- */
256
- function multipartDecode(response) {
257
- // Use the raw data if it is provided in an appropriate format
258
- var message = ArrayBuffer.isView(response) ? response : new Uint8Array(response);
259
-
260
- /* Set a maximum length to search for the header boundaries, otherwise
261
- findToken can run for a long time
262
- */
263
- var maxSearchLength = 1000;
264
-
265
- // First look for the multipart mime header
266
- var separator = stringToUint8Array('\r\n\r\n');
267
- var headerIndex = findToken(message, separator, 0, maxSearchLength);
268
- if (headerIndex === -1) {
269
- throw new Error('Response message has no multipart mime header');
270
- }
271
- var header = uint8ArrayToString(message, 0, headerIndex);
272
- var boundaryString = identifyBoundary(header);
273
- if (!boundaryString) {
274
- throw new Error('Header of response message does not specify boundary');
275
- }
276
- var boundary = stringToUint8Array(boundaryString);
277
- var boundaryLength = boundary.length;
278
- var components = [];
279
- var offset = boundaryLength;
280
-
281
- // Loop until we cannot find any more boundaries
282
- var boundaryIndex;
283
- while (boundaryIndex !== -1) {
284
- // Search for the next boundary in the message, starting
285
- // from the current offset position
286
- boundaryIndex = findToken(message, boundary, offset);
287
-
288
- // If no further boundaries are found, stop here.
289
- if (boundaryIndex === -1) {
290
- break;
291
- }
292
- var headerTokenIndex = findToken(message, separator, offset, maxSearchLength);
293
- if (headerTokenIndex === -1) {
294
- throw new Error('Response message part has no mime header');
295
- }
296
- offset = headerTokenIndex + separator.length;
297
-
298
- // Extract data from response message, excluding "\r\n"
299
- var spacingLength = 2;
300
- var data = response.slice(offset, boundaryIndex - spacingLength);
301
-
302
- // Add the data to the array of results
303
- components.push(data);
304
-
305
- // Move the offset to the end of the current section,
306
- // plus the identified boundary
307
- offset = boundaryIndex + boundaryLength;
308
- }
309
- return components;
310
- }
311
-
312
- function isObject(obj) {
313
- return _typeof(obj) === 'object' && obj !== null;
314
- }
315
- function isEmptyObject(obj) {
316
- return Object.keys(obj).length === 0 && obj.constructor === Object;
317
- }
318
- function areValidRequestHooks(requestHooks) {
319
- var isValid = Array.isArray(requestHooks) && requestHooks.every(function (requestHook) {
320
- return typeof requestHook === 'function' && requestHook.length === 2;
321
- });
322
- if (!isValid) {
323
- console.warn('Request hooks should have the following signature: ' + 'function requestHook(request, metadata) { return request; }');
324
- }
325
- return isValid;
326
- }
327
- var getFirstResult = function getFirstResult(result) {
328
- return result[0];
329
- };
330
- var MEDIATYPES = {
331
- DICOM: 'application/dicom',
332
- DICOM_JSON: 'application/dicom+json',
333
- OCTET_STREAM: 'application/octet-stream',
334
- PDF: 'application/pdf',
335
- JPEG: 'image/jpeg',
336
- PNG: 'image/png'
337
- };
338
-
339
- /**
340
- * debugLog is a function that can be called with console.log arguments, and will
341
- * be conditionally displayed, only when debug logging is enabled.
342
- */
343
- var debugLog = function debugLog() {};
344
-
345
- /**
346
- * @typedef { import("../types/types").InstanceMetadata } InstanceMetadata
347
- */
348
-
349
- /**
350
- * A callback with the request instance and metadata information
351
- * of the currently request being executed that should necessarily
352
- * return the given request optionally modified.
353
- * @typedef {function} RequestHook
354
- * @param {XMLHttpRequest} request - The original XMLHttpRequest instance.
355
- * @param {object} metadata - The metadata used by the request.
356
- */
357
-
358
- /**
359
- * Class for interacting with DICOMweb RESTful services.
360
- */
361
- var DICOMwebClient = /*#__PURE__*/function () {
362
- /**
363
- * @constructor
364
- * @param {Object} options
365
- * @param {String} options.url - URL of the DICOMweb RESTful Service endpoint
366
- * @param {String=} options.qidoURLPrefix - URL path prefix for QIDO-RS
367
- * @param {String=} options.wadoURLPrefix - URL path prefix for WADO-RS
368
- * @param {String=} options.stowURLPrefix - URL path prefix for STOW-RS
369
- * @param {String=} options.username - Username
370
- * @param {String=} options.password - Password
371
- * @param {Object=} options.headers - HTTP headers
372
- * @param {Array.<RequestHook>=} options.requestHooks - Request hooks.
373
- * @param {Object=} options.verbose - print to console request warnings and errors, default true
374
- * @param {Object=} options.debug - print to the console debug level information/status updates.
375
- * @param {boolean|String} options.singlepart - retrieve singlepart for the named types.
376
- * The available types are: bulkdata, video, image. true means all.
377
- */
378
- function DICOMwebClient(options) {
379
- _classCallCheck(this, DICOMwebClient);
380
- this.baseURL = options.url;
381
- if (!this.baseURL) {
382
- console.error('no DICOMweb base url provided - calls that require a URL will fail');
383
- }
384
- if ('username' in options) {
385
- this.username = options.username;
386
- if (!('password' in options)) {
387
- console.error('no password provided to authenticate with DICOMweb service');
388
- }
389
- this.password = options.password;
390
- }
391
- if ('qidoURLPrefix' in options) {
392
- debugLog("use URL prefix for QIDO-RS: ".concat(options.qidoURLPrefix));
393
- this.qidoURL = "".concat(this.baseURL, "/").concat(options.qidoURLPrefix);
394
- } else {
395
- this.qidoURL = this.baseURL;
396
- }
397
- if ('wadoURLPrefix' in options) {
398
- debugLog("use URL prefix for WADO-RS: ".concat(options.wadoURLPrefix));
399
- this.wadoURL = "".concat(this.baseURL, "/").concat(options.wadoURLPrefix);
400
- } else {
401
- this.wadoURL = this.baseURL;
402
- }
403
- if ('stowURLPrefix' in options) {
404
- debugLog("use URL prefix for STOW-RS: ".concat(options.stowURLPrefix));
405
- this.stowURL = "".concat(this.baseURL, "/").concat(options.stowURLPrefix);
406
- } else {
407
- this.stowURL = this.baseURL;
408
- }
409
- if (options.singlepart) {
410
- debugLog('use singlepart', options.singlepart);
411
- this.singlepart = options.singlepart === true ? 'bulkdata,video,image' : options.singlepart;
412
- } else {
413
- this.singlepart = '';
414
- }
415
- if ('requestHooks' in options) {
416
- this.requestHooks = options.requestHooks;
417
- }
418
-
419
- // Headers to pass to requests.
420
- this.headers = options.headers || {};
421
-
422
- // Optional error interceptor callback to handle any failed request.
423
- this.errorInterceptor = options.errorInterceptor || function () {
424
- return undefined;
425
- };
426
-
427
- // Verbose - print to console request warnings and errors, default true
428
- this.verbose = options.verbose !== false;
429
- this.setDebug(options.debug);
430
- }
431
-
432
- /**
433
- * Allows setting the debug log information.
434
- * Note this is different from verbose in that verbose is whether to include warning/error information, defaulting to true
435
- *
436
- * @param {boolean} debugLevel
437
- * @param {function} debugLogFunction to call with the debug output arguments.
438
- */
439
- _createClass(DICOMwebClient, [{
440
- key: "setDebug",
441
- value: function setDebug() {
442
- var debugLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
443
- var debugLogFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
444
- this.debugLevel = !!debugLevel;
445
- debugLog = debugLogFunction || debugLevel ? console.log : function () {};
446
- }
447
- /**
448
- * Gets debug flag
449
- *
450
- * @returns true if debug logging is enabled
451
- */
452
- }, {
453
- key: "getDebug",
454
- value: function getDebug() {
455
- return this.debugLevel;
456
- }
457
- /**
458
- * Sets verbose flag.
459
- *
460
- * @param {Boolean} verbose
461
- */
462
- }, {
463
- key: "setVerbose",
464
- value: function setVerbose(verbose) {
465
- this.verbose = verbose;
466
- }
467
- /**
468
- * Gets verbose flag.
469
- *
470
- * @return {Boolean} verbose
471
- */
472
- }, {
473
- key: "getVerbose",
474
- value: function getVerbose() {
475
- return this.verbose;
476
- }
477
- }, {
478
- key: "_httpRequest",
479
- /**
480
- * Performs an HTTP request.
481
- *
482
- * @param {String} url
483
- * @param {String} method
484
- * @param {Object} headers
485
- * @param {Object} options
486
- * @param {Array.<RequestHook>} options.requestHooks - Request hooks.
487
- * @param {XMLHttpRequest} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
488
- * @return {*}
489
- * @private
490
- */
491
- value: function _httpRequest(url, method) {
492
- var _this = this;
493
- var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
494
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
495
- var errorInterceptor = this.errorInterceptor,
496
- requestHooks = this.requestHooks;
497
- return new Promise(function (resolve, reject) {
498
- var request = options.request ? options.request : new XMLHttpRequest();
499
- request.open(method, url, true);
500
- if ('responseType' in options) {
501
- request.responseType = options.responseType;
502
- }
503
- if (_typeof(headers) === 'object') {
504
- Object.keys(headers).forEach(function (key) {
505
- request.setRequestHeader(key, headers[key]);
506
- });
507
- }
508
-
509
- // now add custom headers from the user
510
- // (e.g. access tokens)
511
- var userHeaders = _this.headers;
512
- Object.keys(userHeaders).forEach(function (key) {
513
- request.setRequestHeader(key, userHeaders[key]);
514
- });
515
-
516
- // Event triggered when upload starts
517
- request.onloadstart = function onloadstart() {
518
- debugLog('upload started: ', url);
519
- };
520
-
521
- // Event triggered when upload ends
522
- request.onloadend = function onloadend() {
523
- debugLog('upload finished');
524
- };
525
-
526
- // Handle response message
527
- request.onreadystatechange = function () {
528
- if (request.readyState === 4) {
529
- if (request.status === 200) {
530
- var contentType = request.getResponseHeader('Content-Type');
531
- // Automatically distinguishes between multipart and singlepart in an array buffer, and
532
- // converts them into a consistent type.
533
- if (contentType && contentType.indexOf('multipart') !== -1) {
534
- resolve(multipartDecode(request.response));
535
- } else if (request.responseType === 'arraybuffer') {
536
- resolve([request.response]);
537
- } else {
538
- resolve(request.response);
539
- }
540
- } else if (request.status === 202) {
541
- if (_this.verbose) {
542
- console.warn('some resources already existed: ', request);
543
- }
544
- resolve(request.response);
545
- } else if (request.status === 204) {
546
- if (_this.verbose) {
547
- console.warn('empty response for request: ', request);
548
- }
549
- resolve([]);
550
- } else {
551
- var error = new Error('request failed');
552
- error.request = request;
553
- error.response = request.response;
554
- error.status = request.status;
555
- if (_this.verbose) {
556
- console.error('request failed: ', request);
557
- console.error(error);
558
- console.error(error.response);
559
- }
560
- errorInterceptor(error);
561
- reject(error);
562
- }
563
- }
564
- };
565
-
566
- // Event triggered while download progresses
567
- if ('progressCallback' in options) {
568
- if (typeof options.progressCallback === 'function') {
569
- request.onprogress = options.progressCallback;
570
- }
571
- }
572
- if (requestHooks && areValidRequestHooks(requestHooks)) {
573
- var combinedHeaders = Object.assign({}, headers, _this.headers);
574
- var metadata = {
575
- method: method,
576
- url: url,
577
- headers: combinedHeaders
578
- };
579
- var pipeRequestHooks = function pipeRequestHooks(functions) {
580
- return function (args) {
581
- return functions.reduce(function (props, fn) {
582
- return fn(props, metadata);
583
- }, args);
584
- };
585
- };
586
- var pipedRequest = pipeRequestHooks(requestHooks);
587
- request = pipedRequest(request);
588
- }
589
-
590
- // Add withCredentials to request if needed
591
- if ('withCredentials' in options) {
592
- if (options.withCredentials) {
593
- request.withCredentials = true;
594
- }
595
- }
596
- if ('data' in options) {
597
- request.send(options.data);
598
- } else {
599
- request.send();
600
- }
601
- });
602
- }
603
- /**
604
- * Performs an HTTP GET request.
605
- *
606
- * @param {String} url
607
- * @param {Object} headers
608
- * @param {Object} responseType
609
- * @param {Function} progressCallback
610
- * @return {*}
611
- * @private
612
- */
613
- }, {
614
- key: "_httpGet",
615
- value: function _httpGet(url, headers, responseType, progressCallback, withCredentials) {
616
- return this._httpRequest(url, 'get', headers, {
617
- responseType: responseType,
618
- progressCallback: progressCallback,
619
- withCredentials: withCredentials
620
- });
621
- }
622
- /**
623
- * Performs an HTTP GET request that accepts a message with application/json
624
- * media type.
625
- *
626
- * @param {String} url
627
- * @param {Object} params
628
- * @param {Function} progressCallback
629
- * @return {*}
630
- * @private
631
- */
632
- }, {
633
- key: "_httpGetApplicationJson",
634
- value: function _httpGetApplicationJson(url) {
635
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
636
- var progressCallback = arguments.length > 2 ? arguments[2] : undefined;
637
- var withCredentials = arguments.length > 3 ? arguments[3] : undefined;
638
- var urlWithQueryParams = url;
639
- if (_typeof(params) === 'object') {
640
- if (!isEmptyObject(params)) {
641
- urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
642
- }
643
- }
644
- var headers = {
645
- Accept: MEDIATYPES.DICOM_JSON
646
- };
647
- var responseType = 'json';
648
- return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
649
- }
650
- /**
651
- * Performs an HTTP GET request that accepts a message with application/pdf
652
- * media type.
653
- *
654
- * @param {String} url
655
- * @param {Object} params
656
- * @param {Function} progressCallback
657
- * @return {*}
658
- * @private
659
- */
660
- }, {
661
- key: "_httpGetApplicationPdf",
662
- value: function _httpGetApplicationPdf(url) {
663
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
664
- var progressCallback = arguments.length > 2 ? arguments[2] : undefined;
665
- var withCredentials = arguments.length > 3 ? arguments[3] : undefined;
666
- var urlWithQueryParams = url;
667
- if (_typeof(params) === 'object') {
668
- if (!isEmptyObject(params)) {
669
- urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
670
- }
671
- }
672
- var headers = {
673
- Accept: MEDIATYPES.PDF
674
- };
675
- var responseType = 'json';
676
- return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
677
- }
678
- /**
679
- * Performs an HTTP GET request that accepts a message with an image
680
- media type.
681
- *
682
- * @param {String} url
683
- * @param {Object[]} mediaTypes
684
- * @param {Object} params
685
- * @param {Function} progressCallback
686
- * @return {*}
687
- * @private
688
- */
689
- }, {
690
- key: "_httpGetImage",
691
- value: function _httpGetImage(url, mediaTypes) {
692
- var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
693
- var progressCallback = arguments.length > 3 ? arguments[3] : undefined;
694
- var withCredentials = arguments.length > 4 ? arguments[4] : undefined;
695
- var urlWithQueryParams = url;
696
- if (_typeof(params) === 'object') {
697
- if (!isEmptyObject(params)) {
698
- urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
699
- }
700
- }
701
- var supportedMediaTypes = ['image/', 'image/*', 'image/jpeg', 'image/jp2', 'image/gif', 'image/png'];
702
- var acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
703
- var headers = {
704
- Accept: acceptHeaderFieldValue
705
- };
706
- var responseType = 'arraybuffer';
707
- return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
708
- }
709
- /**
710
- * Performs an HTTP GET request that accepts a message with a text
711
- media type.
712
- *
713
- * @param {String} url
714
- * @param {Object[]} mediaTypes
715
- * @param {Object} params
716
- * @param {Function} progressCallback
717
- * @return {*}
718
- * @private
719
- */
720
- }, {
721
- key: "_httpGetText",
722
- value: function _httpGetText(url, mediaTypes) {
723
- var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
724
- var progressCallback = arguments.length > 3 ? arguments[3] : undefined;
725
- var withCredentials = arguments.length > 4 ? arguments[4] : undefined;
726
- var urlWithQueryParams = url;
727
- if (_typeof(params) === 'object') {
728
- if (!isEmptyObject(params)) {
729
- urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
730
- }
731
- }
732
- var supportedMediaTypes = ['text/', 'text/*', 'text/html', 'text/plain', 'text/rtf', 'text/xml'];
733
- var acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
734
- var headers = {
735
- Accept: acceptHeaderFieldValue
736
- };
737
- var responseType = 'arraybuffer';
738
- return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
739
- }
740
- /**
741
- * Performs an HTTP GET request that accepts a message with a video
742
- media type.
743
- *
744
- * @param {String} url
745
- * @param {Object[]} mediaTypes
746
- * @param {Object} params
747
- * @param {Function} progressCallback
748
- * @return {*}
749
- * @private
750
- */
751
- }, {
752
- key: "_httpGetVideo",
753
- value: function _httpGetVideo(url, mediaTypes) {
754
- var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
755
- var progressCallback = arguments.length > 3 ? arguments[3] : undefined;
756
- var withCredentials = arguments.length > 4 ? arguments[4] : undefined;
757
- var urlWithQueryParams = url;
758
- if (_typeof(params) === 'object') {
759
- if (!isEmptyObject(params)) {
760
- urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
761
- }
762
- }
763
- var supportedMediaTypes = ['video/', 'video/*', 'video/mpeg', 'video/mp4', 'video/H265'];
764
- var acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
765
- var headers = {
766
- Accept: acceptHeaderFieldValue
767
- };
768
- var responseType = 'arraybuffer';
769
- return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
770
- }
771
- /**
772
- * Asserts that a given media type is valid.
773
- *
774
- * @params {String} mediaType media type
775
- */
776
- }, {
777
- key: "_httpGetMultipartImage",
778
- /**
779
- * Performs an HTTP GET request that accepts a multipart message with an image media type.
780
- *
781
- * @param {String} url - Unique resource locator
782
- * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
783
- corresponding transfer syntaxes
784
- * @param {Array} byteRange - Start and end of byte range
785
- * @param {Object} params - Additional HTTP GET query parameters
786
- * @param {Boolean} rendered - Whether resource should be requested using rendered media types
787
- * @param {Function} progressCallback
788
- * @private
789
- * @returns {Promise<Array>} Content of HTTP message body parts
790
- */
791
- value: function _httpGetMultipartImage(url, mediaTypes, byteRange, params) {
792
- var rendered = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
793
- var progressCallback = arguments.length > 5 ? arguments[5] : undefined;
794
- var withCredentials = arguments.length > 6 ? arguments[6] : undefined;
795
- var headers = {};
796
- var supportedMediaTypes;
797
- if (rendered) {
798
- supportedMediaTypes = ['image/jpeg', 'image/gif', 'image/png', 'image/jp2'];
799
- } else {
800
- supportedMediaTypes = {
801
- '1.2.840.10008.1.2.5': ['image/x-dicom-rle'],
802
- '1.2.840.10008.1.2.4.50': ['image/jpeg'],
803
- '1.2.840.10008.1.2.4.51': ['image/jpeg'],
804
- '1.2.840.10008.1.2.4.57': ['image/jpeg'],
805
- '1.2.840.10008.1.2.4.70': ['image/jpeg'],
806
- '1.2.840.10008.1.2.4.80': ['image/x-jls', 'image/jls'],
807
- '1.2.840.10008.1.2.4.81': ['image/x-jls', 'image/jls'],
808
- '1.2.840.10008.1.2.4.90': ['image/jp2'],
809
- '1.2.840.10008.1.2.4.91': ['image/jp2'],
810
- '1.2.840.10008.1.2.4.92': ['image/jpx'],
811
- '1.2.840.10008.1.2.4.93': ['image/jpx']
812
- };
813
- if (byteRange) {
814
- headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);
815
- }
816
- }
817
- headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
818
- return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
819
- }
820
- /**
821
- * Performs an HTTP GET request that accepts a multipart message with a video media type.
822
- *
823
- * @param {String} url - Unique resource locator
824
- * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
825
- corresponding transfer syntaxes
826
- * @param {Array} byteRange - Start and end of byte range
827
- * @param {Object} params - Additional HTTP GET query parameters
828
- * @param {Boolean} rendered - Whether resource should be requested using rendered media types
829
- * @param {Function} progressCallback
830
- * @private
831
- * @returns {Promise<Array>} Content of HTTP message body parts
832
- */
833
- }, {
834
- key: "_httpGetMultipartVideo",
835
- value: function _httpGetMultipartVideo(url, mediaTypes, byteRange, params) {
836
- var rendered = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
837
- var progressCallback = arguments.length > 5 ? arguments[5] : undefined;
838
- var withCredentials = arguments.length > 6 ? arguments[6] : undefined;
839
- var headers = {};
840
- var supportedMediaTypes;
841
- if (rendered) {
842
- supportedMediaTypes = ['video/', 'video/*', 'video/mpeg2', 'video/mp4', 'video/H265'];
843
- } else {
844
- supportedMediaTypes = {
845
- '1.2.840.10008.1.2.4.100': ['video/mpeg2'],
846
- '1.2.840.10008.1.2.4.101': ['video/mpeg2'],
847
- '1.2.840.10008.1.2.4.102': ['video/mp4'],
848
- '1.2.840.10008.1.2.4.103': ['video/mp4'],
849
- '1.2.840.10008.1.2.4.104': ['video/mp4'],
850
- '1.2.840.10008.1.2.4.105': ['video/mp4'],
851
- '1.2.840.10008.1.2.4.106': ['video/mp4']
852
- };
853
- if (byteRange) {
854
- headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);
855
- }
856
- }
857
- headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
858
- return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
859
- }
860
- /**
861
- * Performs an HTTP GET request that accepts a multipart message
862
- * with a application/dicom media type.
863
- *
864
- * @param {String} url - Unique resource locator
865
- * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
866
- corresponding transfer syntaxes
867
- * @param {Object} params - Additional HTTP GET query parameters
868
- * @param {Function} progressCallback
869
- * @private
870
- * @returns {Promise<Array>} Content of HTTP message body parts
871
- */
872
- }, {
873
- key: "_httpGetMultipartApplicationDicom",
874
- value: function _httpGetMultipartApplicationDicom(url, mediaTypes, params, progressCallback, withCredentials) {
875
- var headers = {};
876
- var defaultMediaType = 'application/dicom';
877
- var supportedMediaTypes = {
878
- '1.2.840.10008.1.2.1': [defaultMediaType],
879
- '1.2.840.10008.1.2.5': [defaultMediaType],
880
- '1.2.840.10008.1.2.4.50': [defaultMediaType],
881
- '1.2.840.10008.1.2.4.51': [defaultMediaType],
882
- '1.2.840.10008.1.2.4.57': [defaultMediaType],
883
- '1.2.840.10008.1.2.4.70': [defaultMediaType],
884
- '1.2.840.10008.1.2.4.80': [defaultMediaType],
885
- '1.2.840.10008.1.2.4.81': [defaultMediaType],
886
- '1.2.840.10008.1.2.4.90': [defaultMediaType],
887
- '1.2.840.10008.1.2.4.91': [defaultMediaType],
888
- '1.2.840.10008.1.2.4.92': [defaultMediaType],
889
- '1.2.840.10008.1.2.4.93': [defaultMediaType],
890
- '1.2.840.10008.1.2.4.100': [defaultMediaType],
891
- '1.2.840.10008.1.2.4.101': [defaultMediaType],
892
- '1.2.840.10008.1.2.4.102': [defaultMediaType],
893
- '1.2.840.10008.1.2.4.103': [defaultMediaType],
894
- '1.2.840.10008.1.2.4.104': [defaultMediaType],
895
- '1.2.840.10008.1.2.4.105': [defaultMediaType],
896
- '1.2.840.10008.1.2.4.106': [defaultMediaType]
897
- };
898
- var acceptableMediaTypes = mediaTypes;
899
- if (!mediaTypes) {
900
- acceptableMediaTypes = [{
901
- mediaType: defaultMediaType
902
- }];
903
- }
904
- headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(acceptableMediaTypes, supportedMediaTypes);
905
- return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
906
- }
907
- /**
908
- * Performs an HTTP GET request that accepts a multipart message
909
- * with a application/octet-stream, OR any of the equivalencies for that (eg
910
- * application/pdf etc)
911
- *
912
- * @param {String} url - Unique resource locator
913
- * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
914
- corresponding transfer syntaxes
915
- * @param {Array} byteRange start and end of byte range
916
- * @param {Object} params - Additional HTTP GET query parameters
917
- * @param {Function} progressCallback
918
- * @private
919
- * @returns {Promise<Array>} Content of HTTP message body parts
920
- */
921
- }, {
922
- key: "_httpGetMultipartApplicationOctetStream",
923
- value: function _httpGetMultipartApplicationOctetStream(url, mediaTypes, byteRange, params, progressCallback, withCredentials) {
924
- var headers = {};
925
- var defaultMediaType = 'application/octet-stream';
926
- var supportedMediaTypes = {
927
- '1.2.840.10008.1.2.1': _toConsumableArray(Object.values(MEDIATYPES))
928
- };
929
- var acceptableMediaTypes = mediaTypes;
930
- if (!mediaTypes) {
931
- acceptableMediaTypes = [{
932
- mediaType: defaultMediaType
933
- }];
934
- }
935
- if (byteRange) {
936
- headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);
937
- }
938
- headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(acceptableMediaTypes, supportedMediaTypes);
939
- return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
940
- }
941
- /**
942
- * Performs an HTTP POST request.
943
- *
944
- * @param {String} url - Unique resource locator
945
- * @param {Object} headers - HTTP header fields
946
- * @param {Array} data - Data that should be stored
947
- * @param {Function} progressCallback
948
- * @param {Function} progressCallback
949
- * @param {XMLHttpRequest} request - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
950
- * @private
951
- * @returns {Promise} Response
952
- */
953
- }, {
954
- key: "_httpPost",
955
- value: function _httpPost(url, headers, data, progressCallback, withCredentials, request) {
956
- return this._httpRequest(url, 'post', headers, {
957
- data: data,
958
- progressCallback: progressCallback,
959
- withCredentials: withCredentials,
960
- request: request
961
- });
962
- }
963
- /**
964
- * Performs an HTTP POST request with content-type application/dicom+json.
965
- *
966
- * @param {String} url - Unique resource locator
967
- * @param {Object} headers - HTTP header fields
968
- * @param {Array} data - Data that should be stored
969
- * @param {Function} progressCallback
970
- * @private
971
- * @returns {Promise} Response
972
- */
973
- }, {
974
- key: "_httpPostApplicationJson",
975
- value: function _httpPostApplicationJson(url, data, progressCallback, withCredentials) {
976
- var headers = {
977
- 'Content-Type': MEDIATYPES.DICOM_JSON
978
- };
979
- return this._httpPost(url, headers, data, progressCallback, withCredentials);
980
- }
981
- /**
982
- * Parses media type and extracts its type and subtype.
983
- *
984
- * @param {String} mediaType - HTTP media type (e.g. image/jpeg)
985
- * @private
986
- * @returns {String[]} Media type and subtype
987
- */
988
- }, {
989
- key: "searchForStudies",
990
- /**
991
- * Searches for DICOM studies.
992
- *
993
- * @param {Object} options
994
- * @param {Object} [options.queryParams] - HTTP query parameters
995
- * @return {Object[]} Study representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2)
996
- */
997
- value: function searchForStudies() {
998
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
999
- debugLog('search for studies');
1000
- var withCredentials = false;
1001
- var url = "".concat(this.qidoURL, "/studies");
1002
- if ('queryParams' in options) {
1003
- url += DICOMwebClient._parseQueryParameters(options.queryParams);
1004
- }
1005
- if ('withCredentials' in options) {
1006
- if (options.withCredentials) {
1007
- withCredentials = options.withCredentials;
1008
- }
1009
- }
1010
- return this._httpGetApplicationJson(url, {}, false, withCredentials);
1011
- }
1012
- /**
1013
- * Retrieves metadata for a DICOM study.
1014
- *
1015
- * @param {Object} options
1016
- * @param {String} options.studyInstanceUID - Study Instance UID
1017
- * @returns {Promise<InstanceMetadata[]>} Metadata elements in DICOM JSON format for each instance
1018
- belonging to the study
1019
- */
1020
- }, {
1021
- key: "retrieveStudyMetadata",
1022
- value: function retrieveStudyMetadata(options) {
1023
- if (!('studyInstanceUID' in options)) {
1024
- throw new Error('Study Instance UID is required for retrieval of study metadata');
1025
- }
1026
- debugLog("retrieve metadata of study ".concat(options.studyInstanceUID));
1027
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/metadata");
1028
- var withCredentials = false;
1029
- if ('withCredentials' in options) {
1030
- if (options.withCredentials) {
1031
- withCredentials = options.withCredentials;
1032
- }
1033
- }
1034
- return this._httpGetApplicationJson(url, {}, false, withCredentials);
1035
- }
1036
- /**
1037
- * Searches for DICOM series.
1038
- *
1039
- * @param {Object} options
1040
- * @param {Object} [options.studyInstanceUID] - Study Instance UID
1041
- * @param {Object} [options.queryParams] - HTTP query parameters
1042
- * @returns {Object[]} Series representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2a)
1043
- */
1044
- }, {
1045
- key: "searchForSeries",
1046
- value: function searchForSeries() {
1047
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1048
- var url = this.qidoURL;
1049
- if ('studyInstanceUID' in options) {
1050
- debugLog("search series of study ".concat(options.studyInstanceUID));
1051
- url += "/studies/".concat(options.studyInstanceUID);
1052
- }
1053
- url += '/series';
1054
- if ('queryParams' in options) {
1055
- url += DICOMwebClient._parseQueryParameters(options.queryParams);
1056
- }
1057
- var withCredentials = false;
1058
- if ('withCredentials' in options) {
1059
- if (options.withCredentials) {
1060
- withCredentials = options.withCredentials;
1061
- }
1062
- }
1063
- return this._httpGetApplicationJson(url, {}, false, withCredentials);
1064
- }
1065
- /**
1066
- * Retrieves metadata for a DICOM series.
1067
- *
1068
- * @param {Object} options
1069
- * @param {String} options.studyInstanceUID - Study Instance UID
1070
- * @param {String} options.seriesInstanceUID - Series Instance UID
1071
- * @returns {Promise<InstanceMetadata[]>} Metadata elements in DICOM JSON format for each instance
1072
- belonging to the series
1073
- */
1074
- }, {
1075
- key: "retrieveSeriesMetadata",
1076
- value: function retrieveSeriesMetadata(options) {
1077
- if (!('studyInstanceUID' in options)) {
1078
- throw new Error('Study Instance UID is required for retrieval of series metadata');
1079
- }
1080
- if (!('seriesInstanceUID' in options)) {
1081
- throw new Error('Series Instance UID is required for retrieval of series metadata');
1082
- }
1083
- debugLog("retrieve metadata of series ".concat(options.seriesInstanceUID));
1084
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/metadata");
1085
- var withCredentials = false;
1086
- if ('withCredentials' in options) {
1087
- if (options.withCredentials) {
1088
- withCredentials = options.withCredentials;
1089
- }
1090
- }
1091
- return this._httpGetApplicationJson(url, {}, false, withCredentials);
1092
- }
1093
- /**
1094
- * Searches for DICOM Instances.
1095
- *
1096
- * @param {Object} options
1097
- * @param {String} [options.studyInstanceUID] - Study Instance UID
1098
- * @param {String} [options.seriesInstanceUID] - Series Instance UID
1099
- * @param {Object} [options.queryParams] - HTTP query parameters
1100
- * @returns {Object[]} Instance representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2b)
1101
- */
1102
- }, {
1103
- key: "searchForInstances",
1104
- value: function searchForInstances() {
1105
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1106
- var url = this.qidoURL;
1107
- var withCredentials = false;
1108
- if ('studyInstanceUID' in options) {
1109
- url += "/studies/".concat(options.studyInstanceUID);
1110
- if ('seriesInstanceUID' in options) {
1111
- debugLog("search for instances of series ".concat(options.seriesInstanceUID));
1112
- url += "/series/".concat(options.seriesInstanceUID);
1113
- } else {
1114
- debugLog("search for instances of study ".concat(options.studyInstanceUID));
1115
- }
1116
- } else {
1117
- debugLog('search for instances');
1118
- }
1119
- url += '/instances';
1120
- if ('queryParams' in options) {
1121
- url += DICOMwebClient._parseQueryParameters(options.queryParams);
1122
- }
1123
- if ('withCredentials' in options) {
1124
- if (options.withCredentials) {
1125
- withCredentials = options.withCredentials;
1126
- }
1127
- }
1128
- return this._httpGetApplicationJson(url, {}, false, withCredentials);
1129
- }
1130
- /** Returns a WADO-URI URL for an instance
1131
- *
1132
- * @param {Object} options
1133
- * @param {String} options.studyInstanceUID - Study Instance UID
1134
- * @param {String} options.seriesInstanceUID - Series Instance UID
1135
- * @param {String} options.sopInstanceUID - SOP Instance UID
1136
- * @returns {String} WADO-URI URL
1137
- */
1138
- }, {
1139
- key: "buildInstanceWadoURIUrl",
1140
- value: function buildInstanceWadoURIUrl(options) {
1141
- if (!('studyInstanceUID' in options)) {
1142
- throw new Error('Study Instance UID is required.');
1143
- }
1144
- if (!('seriesInstanceUID' in options)) {
1145
- throw new Error('Series Instance UID is required.');
1146
- }
1147
- if (!('sopInstanceUID' in options)) {
1148
- throw new Error('SOP Instance UID is required.');
1149
- }
1150
- var contentType = options.contentType || MEDIATYPES.DICOM;
1151
- var transferSyntax = options.transferSyntax || '*';
1152
- var params = [];
1153
- params.push('requestType=WADO');
1154
- params.push("studyUID=".concat(options.studyInstanceUID));
1155
- params.push("seriesUID=".concat(options.seriesInstanceUID));
1156
- params.push("objectUID=".concat(options.sopInstanceUID));
1157
- params.push("contentType=".concat(contentType));
1158
- params.push("transferSyntax=".concat(transferSyntax));
1159
- var paramString = params.join('&');
1160
- return "".concat(this.wadoURL, "?").concat(paramString);
1161
- }
1162
- /**
1163
- * Retrieves metadata for a DICOM Instance.
1164
- *
1165
- * @param {Object} options object
1166
- * @param {String} options.studyInstanceUID - Study Instance UID
1167
- * @param {String} options.seriesInstanceUID - Series Instance UID
1168
- * @param {String} options.sopInstanceUID - SOP Instance UID
1169
- * @returns {Promise<InstanceMetadata>} metadata elements in DICOM JSON format
1170
- */
1171
- }, {
1172
- key: "retrieveInstanceMetadata",
1173
- value: function retrieveInstanceMetadata(options) {
1174
- if (!('studyInstanceUID' in options)) {
1175
- throw new Error('Study Instance UID is required for retrieval of instance metadata');
1176
- }
1177
- if (!('seriesInstanceUID' in options)) {
1178
- throw new Error('Series Instance UID is required for retrieval of instance metadata');
1179
- }
1180
- if (!('sopInstanceUID' in options)) {
1181
- throw new Error('SOP Instance UID is required for retrieval of instance metadata');
1182
- }
1183
- debugLog("retrieve metadata of instance ".concat(options.sopInstanceUID));
1184
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/metadata");
1185
- var withCredentials = false;
1186
- if ('withCredentials' in options) {
1187
- if (options.withCredentials) {
1188
- withCredentials = options.withCredentials;
1189
- }
1190
- }
1191
- return this._httpGetApplicationJson(url, {}, false, withCredentials);
1192
- }
1193
- /**
1194
- * Retrieves frames for a DICOM Instance.
1195
- * @param {Object} options options object
1196
- * @param {String} options.studyInstanceUID - Study Instance UID
1197
- * @param {String} options.seriesInstanceUID - Series Instance UID
1198
- * @param {String} options.sopInstanceUID - SOP Instance UID
1199
- * @param {String} options.frameNumbers - One-based indices of Frame Items
1200
- * @returns {Array} frame items as byte arrays of the pixel data element
1201
- */
1202
- }, {
1203
- key: "retrieveInstanceFrames",
1204
- value: function retrieveInstanceFrames(options) {
1205
- if (!('studyInstanceUID' in options)) {
1206
- throw new Error('Study Instance UID is required for retrieval of instance frames');
1207
- }
1208
- if (!('seriesInstanceUID' in options)) {
1209
- throw new Error('Series Instance UID is required for retrieval of instance frames');
1210
- }
1211
- if (!('sopInstanceUID' in options)) {
1212
- throw new Error('SOP Instance UID is required for retrieval of instance frames');
1213
- }
1214
- if (!('frameNumbers' in options)) {
1215
- throw new Error('frame numbers are required for retrieval of instance frames');
1216
- }
1217
- debugLog("retrieve frames ".concat(options.frameNumbers.toString(), " of instance ").concat(options.sopInstanceUID));
1218
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/frames/").concat(options.frameNumbers.toString());
1219
- var mediaTypes = options.mediaTypes;
1220
- var withCredentials = false;
1221
- if ('withCredentials' in options) {
1222
- if (options.withCredentials) {
1223
- withCredentials = options.withCredentials;
1224
- }
1225
- }
1226
- var progressCallback = false;
1227
- if ('progressCallback' in options) {
1228
- progressCallback = options.progressCallback;
1229
- }
1230
- if (!mediaTypes) {
1231
- return this._httpGetMultipartApplicationOctetStream(url, false, false, false, progressCallback, withCredentials);
1232
- }
1233
- var sharedMediaTypes = DICOMwebClient._getSharedMediaTypes(mediaTypes);
1234
- if (sharedMediaTypes.length > 1) {
1235
- /**
1236
- * Enable request of frames that are stored either compressed
1237
- * (image/* media type) or uncompressed (application/octet-stream
1238
- * media type).
1239
- */
1240
- var supportedMediaTypes = {
1241
- '1.2.840.10008.1.2.1': ['application/octet-stream'],
1242
- '1.2.840.10008.1.2.5': ['image/x-dicom-rle'],
1243
- '1.2.840.10008.1.2.4.50': ['image/jpeg'],
1244
- '1.2.840.10008.1.2.4.51': ['image/jpeg'],
1245
- '1.2.840.10008.1.2.4.57': ['image/jpeg'],
1246
- '1.2.840.10008.1.2.4.70': ['image/jpeg'],
1247
- '1.2.840.10008.1.2.4.80': ['image/x-jls', 'image/jls'],
1248
- '1.2.840.10008.1.2.4.81': ['image/x-jls', 'image/jls'],
1249
- '1.2.840.10008.1.2.4.90': ['image/jp2'],
1250
- '1.2.840.10008.1.2.4.91': ['image/jp2'],
1251
- '1.2.840.10008.1.2.4.92': ['image/jpx'],
1252
- '1.2.840.10008.1.2.4.93': ['image/jpx'],
1253
- '1.2.840.10008.1.2.4.201': ['image/jhc'],
1254
- '1.2.840.10008.1.2.4.202': ['image/jhc']
1255
- };
1256
- var headers = {
1257
- Accept: DICOMwebClient._buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes)
1258
- };
1259
- return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
1260
- }
1261
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1262
- if (commonMediaType.startsWith('application')) {
1263
- return this._httpGetMultipartApplicationOctetStream(url, mediaTypes, false, false, progressCallback, withCredentials);
1264
- }
1265
- if (commonMediaType.startsWith('image')) {
1266
- return this._httpGetMultipartImage(url, mediaTypes, false, false, false, progressCallback, withCredentials);
1267
- }
1268
- if (commonMediaType.startsWith('video')) {
1269
- return this._httpGetMultipartVideo(url, mediaTypes, false, false, false, progressCallback, withCredentials);
1270
- }
1271
- throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of frames."));
1272
- }
1273
- /**
1274
- * Element in mediaTypes parameter
1275
- * @typedef {Object} MediaType
1276
- * @param {String} [MediaType.mediaType] - ie 'image/jpeg', 'image/png'...
1277
- */
1278
- /**
1279
- * Retrieves an individual, server-side rendered DICOM Instance.
1280
- *
1281
- * @param {Object} options
1282
- * @param {String} options.studyInstanceUID - Study Instance UID
1283
- * @param {String} options.seriesInstanceUID - Series Instance UID
1284
- * @param {String} options.sopInstanceUID - SOP Instance UID
1285
- * @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
1286
- * @param {Object} [options.queryParams] - HTTP query parameters
1287
- * @returns {Promise<ArrayBuffer>} Rendered DICOM Instance
1288
- */
1289
- }, {
1290
- key: "retrieveInstanceRendered",
1291
- value: function retrieveInstanceRendered(options) {
1292
- if (!('studyInstanceUID' in options)) {
1293
- throw new Error('Study Instance UID is required for retrieval of rendered instance');
1294
- }
1295
- if (!('seriesInstanceUID' in options)) {
1296
- throw new Error('Series Instance UID is required for retrieval of rendered instance');
1297
- }
1298
- if (!('sopInstanceUID' in options)) {
1299
- throw new Error('SOP Instance UID is required for retrieval of rendered instance');
1300
- }
1301
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/rendered");
1302
- var mediaTypes = options.mediaTypes,
1303
- queryParams = options.queryParams;
1304
- var headers = {};
1305
- var withCredentials = false;
1306
- if ('withCredentials' in options) {
1307
- if (options.withCredentials) {
1308
- withCredentials = options.withCredentials;
1309
- }
1310
- }
1311
- var progressCallback = false;
1312
- if ('progressCallback' in options) {
1313
- progressCallback = options.progressCallback;
1314
- }
1315
- if (!mediaTypes) {
1316
- var responseType = 'arraybuffer';
1317
- if (queryParams) {
1318
- url += DICOMwebClient._parseQueryParameters(queryParams);
1319
- }
1320
- return this._httpGet(url, headers, responseType, progressCallback, withCredentials);
1321
- }
1322
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1323
- if (commonMediaType.startsWith('image')) {
1324
- return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
1325
- }
1326
- if (commonMediaType.startsWith('video')) {
1327
- return this._httpGetVideo(url, mediaTypes, queryParams, progressCallback, withCredentials);
1328
- }
1329
- if (commonMediaType.startsWith('text')) {
1330
- return this._httpGetText(url, mediaTypes, queryParams, progressCallback, withCredentials);
1331
- }
1332
- if (commonMediaType === MEDIATYPES.PDF) {
1333
- return this._httpGetApplicationPdf(url, queryParams, progressCallback, withCredentials);
1334
- }
1335
- throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered instance.');
1336
- }
1337
- /**
1338
- * Retrieves a thumbnail of an DICOM Instance.
1339
- *
1340
- * @param {Object} options
1341
- * @param {String} options.studyInstanceUID - Study Instance UID
1342
- * @param {String} options.seriesInstanceUID - Series Instance UID
1343
- * @param {String} options.sopInstanceUID - SOP Instance UID
1344
- * @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
1345
- * @param {Object} [options.queryParams] - HTTP query parameters
1346
- * @returns {ArrayBuffer} Thumbnail
1347
- */
1348
- }, {
1349
- key: "retrieveInstanceThumbnail",
1350
- value: function retrieveInstanceThumbnail(options) {
1351
- if (!('studyInstanceUID' in options)) {
1352
- throw new Error('Study Instance UID is required for retrieval of rendered instance');
1353
- }
1354
- if (!('seriesInstanceUID' in options)) {
1355
- throw new Error('Series Instance UID is required for retrieval of rendered instance');
1356
- }
1357
- if (!('sopInstanceUID' in options)) {
1358
- throw new Error('SOP Instance UID is required for retrieval of rendered instance');
1359
- }
1360
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/thumbnail");
1361
- var mediaTypes = options.mediaTypes,
1362
- queryParams = options.queryParams;
1363
- var headers = {};
1364
- var withCredentials = false;
1365
- if ('withCredentials' in options) {
1366
- if (options.withCredentials) {
1367
- withCredentials = options.withCredentials;
1368
- }
1369
- }
1370
- var progressCallback = false;
1371
- if ('progressCallback' in options) {
1372
- progressCallback = options.progressCallback;
1373
- }
1374
- if (!mediaTypes) {
1375
- var responseType = 'arraybuffer';
1376
- if (queryParams) {
1377
- url += DICOMwebClient._parseQueryParameters(queryParams);
1378
- }
1379
- return this._httpGet(url, headers, responseType, progressCallback, withCredentials);
1380
- }
1381
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1382
- if (commonMediaType.startsWith('image')) {
1383
- return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
1384
- }
1385
- throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered instance.');
1386
- }
1387
- /**
1388
- * Retrieves rendered frames for a DICOM Instance.
1389
- *
1390
- * @param {Object} options
1391
- * @param {String} options.studyInstanceUID - Study Instance UID
1392
- * @param {String} options.seriesInstanceUID - Series Instance UID
1393
- * @param {String} options.sopInstanceUID - SOP Instance UID
1394
- * @param {String} options.frameNumbers - One-based indices of Frame Items
1395
- * @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
1396
- * @param {Object} [options.queryParams] - HTTP query parameters
1397
- * @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays
1398
- */
1399
- }, {
1400
- key: "retrieveInstanceFramesRendered",
1401
- value: function retrieveInstanceFramesRendered(options) {
1402
- if (!('studyInstanceUID' in options)) {
1403
- throw new Error('Study Instance UID is required for retrieval of rendered instance frames');
1404
- }
1405
- if (!('seriesInstanceUID' in options)) {
1406
- throw new Error('Series Instance UID is required for retrieval of rendered instance frames');
1407
- }
1408
- if (!('sopInstanceUID' in options)) {
1409
- throw new Error('SOP Instance UID is required for retrieval of rendered instance frames');
1410
- }
1411
- if (!('frameNumbers' in options)) {
1412
- throw new Error('frame numbers are required for retrieval of rendered instance frames');
1413
- }
1414
- debugLog("retrieve rendered frames ".concat(options.frameNumbers.toString(), " of instance ").concat(options.sopInstanceUID));
1415
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/frames/").concat(options.frameNumbers.toString(), "/rendered");
1416
- var mediaTypes = options.mediaTypes,
1417
- queryParams = options.queryParams;
1418
- var headers = {};
1419
- var withCredentials = false;
1420
- if ('withCredentials' in options) {
1421
- if (options.withCredentials) {
1422
- withCredentials = options.withCredentials;
1423
- }
1424
- }
1425
- var progressCallback = false;
1426
- if ('progressCallback' in options) {
1427
- progressCallback = options.progressCallback;
1428
- }
1429
- if (!mediaTypes) {
1430
- var responseType = 'arraybuffer';
1431
- if (queryParams) {
1432
- url += DICOMwebClient._parseQueryParameters(queryParams);
1433
- }
1434
- return this._httpGet(url, headers, responseType, false, withCredentials);
1435
- }
1436
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1437
- if (commonMediaType.startsWith('image')) {
1438
- return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
1439
- }
1440
- if (commonMediaType.startsWith('video')) {
1441
- return this._httpGetVideo(url, mediaTypes, queryParams, progressCallback, withCredentials);
1442
- }
1443
- throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered frame.');
1444
- }
1445
- /**
1446
- * Retrieves thumbnail of frames for a DICOM Instance.
1447
- *
1448
- * @param {Object} options
1449
- * @param {String} options.studyInstanceUID - Study Instance UID
1450
- * @param {String} options.seriesInstanceUID - Series Instance UID
1451
- * @param {String} options.sopInstanceUID - SOP Instance UID
1452
- * @param {String} options.frameNumbers - One-based indices of Frame Items
1453
- * @param {Object} [options.queryParams] - HTTP query parameters
1454
- * @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays
1455
- */
1456
- }, {
1457
- key: "retrieveInstanceFramesThumbnail",
1458
- value: function retrieveInstanceFramesThumbnail(options) {
1459
- if (!('studyInstanceUID' in options)) {
1460
- throw new Error('Study Instance UID is required for retrieval of rendered instance frames');
1461
- }
1462
- if (!('seriesInstanceUID' in options)) {
1463
- throw new Error('Series Instance UID is required for retrieval of rendered instance frames');
1464
- }
1465
- if (!('sopInstanceUID' in options)) {
1466
- throw new Error('SOP Instance UID is required for retrieval of rendered instance frames');
1467
- }
1468
- if (!('frameNumbers' in options)) {
1469
- throw new Error('frame numbers are required for retrieval of rendered instance frames');
1470
- }
1471
- console.debug("retrieve rendered frames ".concat(options.frameNumbers.toString(), " of instance ").concat(options.sopInstanceUID));
1472
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/frames/").concat(options.frameNumbers.toString(), "/thumbnail");
1473
- var mediaTypes = options.mediaTypes,
1474
- queryParams = options.queryParams;
1475
- var headers = {};
1476
- var withCredentials = false;
1477
- if ('withCredentials' in options) {
1478
- if (options.withCredentials) {
1479
- withCredentials = options.withCredentials;
1480
- }
1481
- }
1482
- var progressCallback = false;
1483
- if ('progressCallback' in options) {
1484
- progressCallback = options.progressCallback;
1485
- }
1486
- if (!mediaTypes) {
1487
- var responseType = 'arraybuffer';
1488
- if (queryParams) {
1489
- url += DICOMwebClient._parseQueryParameters(queryParams);
1490
- }
1491
- return this._httpGet(url, headers, responseType, progressCallback, withCredentials);
1492
- }
1493
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1494
- if (commonMediaType.startsWith('image')) {
1495
- return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
1496
- }
1497
- throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered frame.');
1498
- }
1499
- /**
1500
- * Retrieves a DICOM Instance.
1501
- *
1502
- * @param {Object} options
1503
- * @param {String} options.studyInstanceUID - Study Instance UID
1504
- * @param {String} options.seriesInstanceUID - Series Instance UID
1505
- * @param {String} options.sopInstanceUID - SOP Instance UID
1506
- * @returns {Promise<ArrayBuffer>} DICOM Part 10 file as Arraybuffer
1507
- */
1508
- }, {
1509
- key: "retrieveInstance",
1510
- value: function retrieveInstance(options) {
1511
- if (!('studyInstanceUID' in options)) {
1512
- throw new Error('Study Instance UID is required');
1513
- }
1514
- if (!('seriesInstanceUID' in options)) {
1515
- throw new Error('Series Instance UID is required');
1516
- }
1517
- if (!('sopInstanceUID' in options)) {
1518
- throw new Error('SOP Instance UID is required');
1519
- }
1520
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID);
1521
- var mediaTypes = options.mediaTypes;
1522
- var _options$withCredenti = options.withCredentials,
1523
- withCredentials = _options$withCredenti === void 0 ? false : _options$withCredenti;
1524
- var _options$progressCall = options.progressCallback,
1525
- progressCallback = _options$progressCall === void 0 ? false : _options$progressCall;
1526
- if (!mediaTypes) {
1527
- return this._httpGetMultipartApplicationDicom(url, false, false, progressCallback, withCredentials).then(getFirstResult);
1528
- }
1529
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1530
- if (commonMediaType === MEDIATYPES.DICOM) {
1531
- return this._httpGetMultipartApplicationDicom(url, mediaTypes, false, progressCallback, withCredentials).then(getFirstResult);
1532
- }
1533
- throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of instance."));
1534
- }
1535
- /**
1536
- * Retrieves all DICOM Instances of a Series.
1537
- *
1538
- * @param {Object} options
1539
- * @param {String} options.studyInstanceUID - Study Instance UID
1540
- * @param {String} options.seriesInstanceUID - Series Instance UID
1541
- * @param {Function} options.progressCallback
1542
- * @returns {Promise<ArrayBuffer[]>} DICOM Instances
1543
- */
1544
- }, {
1545
- key: "retrieveSeries",
1546
- value: function retrieveSeries(options) {
1547
- if (!('studyInstanceUID' in options)) {
1548
- throw new Error('Study Instance UID is required');
1549
- }
1550
- if (!('seriesInstanceUID' in options)) {
1551
- throw new Error('Series Instance UID is required');
1552
- }
1553
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID);
1554
- var mediaTypes = options.mediaTypes;
1555
- var withCredentials = false;
1556
- if ('withCredentials' in options) {
1557
- if (options.withCredentials) {
1558
- withCredentials = options.withCredentials;
1559
- }
1560
- }
1561
- var progressCallback = false;
1562
- if ('progressCallback' in options) {
1563
- progressCallback = options.progressCallback;
1564
- }
1565
- if (!mediaTypes) {
1566
- return this._httpGetMultipartApplicationDicom(url, false, false, progressCallback, withCredentials);
1567
- }
1568
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1569
- if (commonMediaType === MEDIATYPES.DICOM) {
1570
- return this._httpGetMultipartApplicationDicom(url, mediaTypes, false, progressCallback, withCredentials);
1571
- }
1572
- throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of series."));
1573
- }
1574
- /**
1575
- * Retrieves all DICOM Instances of a Study.
1576
- *
1577
- * @param {Object} options
1578
- * @param {String} options.studyInstanceUID - Study Instance UID
1579
- * @returns {ArrayBuffer[]} DICOM Instances
1580
- */
1581
- }, {
1582
- key: "retrieveStudy",
1583
- value: function retrieveStudy(options) {
1584
- if (!('studyInstanceUID' in options)) {
1585
- throw new Error('Study Instance UID is required');
1586
- }
1587
- var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID);
1588
- var mediaTypes = options.mediaTypes;
1589
- var _options$withCredenti2 = options.withCredentials,
1590
- withCredentials = _options$withCredenti2 === void 0 ? false : _options$withCredenti2;
1591
- var _options$progressCall2 = options.progressCallback,
1592
- progressCallback = _options$progressCall2 === void 0 ? false : _options$progressCall2;
1593
- if (!mediaTypes) {
1594
- return this._httpGetMultipartApplicationDicom(url, false, false, progressCallback, withCredentials);
1595
- }
1596
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1597
- if (commonMediaType === MEDIATYPES.DICOM) {
1598
- return this._httpGetMultipartApplicationDicom(url, mediaTypes, false, progressCallback, withCredentials);
1599
- }
1600
- throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of study."));
1601
- }
1602
- /**
1603
- * Retrieves and parses BulkData from a BulkDataURI location.
1604
- * Decodes the multipart encoded data and returns the resulting data
1605
- * as an ArrayBuffer.
1606
- *
1607
- * See http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.5.5.html
1608
- *
1609
- * @param {Object} options
1610
- * @param {string} options.BulkDataURI to retrieve
1611
- * @param {Array} options.mediaTypes to use to fetch the URI
1612
- * @param {string} options.byteRange to request a sub-range (only valid on single part)
1613
- * @returns {Promise<Array>} Bulkdata parts
1614
- */
1615
- }, {
1616
- key: "retrieveBulkData",
1617
- value: function retrieveBulkData(options) {
1618
- if (!('BulkDataURI' in options)) {
1619
- throw new Error('BulkDataURI is required.');
1620
- }
1621
- var url = options.BulkDataURI;
1622
- var mediaTypes = options.mediaTypes,
1623
- byteRange = options.byteRange;
1624
- var _options$withCredenti3 = options.withCredentials,
1625
- withCredentials = _options$withCredenti3 === void 0 ? false : _options$withCredenti3;
1626
- var _options$progressCall3 = options.progressCallback,
1627
- progressCallback = _options$progressCall3 === void 0 ? false : _options$progressCall3;
1628
- if (this.singlepart.indexOf('bulkdata') !== -1) {
1629
- return this._httpGet(url, options.headers, 'arraybuffer', null, withCredentials);
1630
- }
1631
- if (mediaTypes) {
1632
- try {
1633
- var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1634
- if (commonMediaType === 'image/') {
1635
- return this._httpGetMultipartImage(url, mediaTypes, byteRange, false, false, progressCallback, withCredentials);
1636
- }
1637
- } catch (e) {
1638
- // No-op - this happens sometimes if trying to fetch the specific desired type but want to fallback to octet-stream
1639
- }
1640
- }
1641
-
1642
- // Just use the media types provided
1643
- return this._httpGetMultipartApplicationOctetStream(url, mediaTypes, byteRange, false, progressCallback, withCredentials);
1644
- }
1645
- /**
1646
- * Stores DICOM Instances.
1647
- *
1648
- * @param {Object} options
1649
- * @param {ArrayBuffer[]} options.datasets - DICOM Instances in PS3.10 format
1650
- * @param {String} [options.studyInstanceUID] - Study Instance UID
1651
- * @param {XMLHttpRequest} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1652
- * @returns {Promise} Response message
1653
- */
1654
- }, {
1655
- key: "storeInstances",
1656
- value: function storeInstances(options) {
1657
- if (!('datasets' in options)) {
1658
- throw new Error('datasets are required for storing');
1659
- }
1660
- var url = "".concat(this.stowURL, "/studies");
1661
- if ('studyInstanceUID' in options) {
1662
- url += "/".concat(options.studyInstanceUID);
1663
- }
1664
- var _multipartEncode = multipartEncode(options.datasets),
1665
- data = _multipartEncode.data,
1666
- boundary = _multipartEncode.boundary;
1667
- var headers = {
1668
- 'Content-Type': "multipart/related; type=\"application/dicom\"; boundary=\"".concat(boundary, "\"")
1669
- };
1670
- var _options$withCredenti4 = options.withCredentials,
1671
- withCredentials = _options$withCredenti4 === void 0 ? false : _options$withCredenti4;
1672
- return this._httpPost(url, headers, data, options.progressCallback, withCredentials, options.request);
1673
- }
1674
- }], [{
1675
- key: "_parseQueryParameters",
1676
- value: function _parseQueryParameters() {
1677
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1678
- var queryString = '?';
1679
- Object.keys(params).forEach(function (key, index) {
1680
- if (index !== 0) {
1681
- queryString += '&';
1682
- }
1683
- queryString += "".concat(key, "=").concat(encodeURIComponent(params[key]));
1684
- });
1685
- return queryString;
1686
- }
1687
- }, {
1688
- key: "_assertMediaTypeIsValid",
1689
- value: function _assertMediaTypeIsValid(mediaType) {
1690
- if (!mediaType) {
1691
- throw new Error("Not a valid media type: ".concat(mediaType));
1692
- }
1693
- var sepIndex = mediaType.indexOf('/');
1694
- if (sepIndex === -1) {
1695
- throw new Error("Not a valid media type: ".concat(mediaType));
1696
- }
1697
- var mediaTypeType = mediaType.slice(0, sepIndex);
1698
- var types = ['application', 'image', 'text', 'video'];
1699
- if (!types.includes(mediaTypeType)) {
1700
- throw new Error("Not a valid media type: ".concat(mediaType));
1701
- }
1702
- if (mediaType.slice(sepIndex + 1).includes('/')) {
1703
- throw new Error("Not a valid media type: ".concat(mediaType));
1704
- }
1705
- }
1706
- }, {
1707
- key: "_parseMediaType",
1708
- value: function _parseMediaType(mediaType) {
1709
- DICOMwebClient._assertMediaTypeIsValid(mediaType);
1710
- return mediaType.split('/');
1711
- }
1712
- /**
1713
- * Builds an accept header field value for HTTP GET request messages.
1714
- *
1715
- * @param {Object[]} mediaTypes - Acceptable media types
1716
- * @param {Object[]} supportedMediaTypes - Supported media types
1717
- * @return {*}
1718
- * @private
1719
- */
1720
- }, {
1721
- key: "_buildAcceptHeaderFieldValue",
1722
- value: function _buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes) {
1723
- if (!Array.isArray(mediaTypes)) {
1724
- throw new Error('Acceptable media types must be provided as an Array');
1725
- }
1726
- var fieldValueParts = mediaTypes.map(function (item) {
1727
- var mediaType = item.mediaType;
1728
- DICOMwebClient._assertMediaTypeIsValid(mediaType);
1729
- if (!supportedMediaTypes.includes(mediaType)) {
1730
- throw new Error("Media type ".concat(mediaType, " is not supported for requested resource"));
1731
- }
1732
- return mediaType;
1733
- });
1734
- return fieldValueParts.join(', ');
1735
- }
1736
- /**
1737
- * Builds an accept header field value for HTTP GET multipart request
1738
- * messages. Will throw an exception if no media types are found which are acceptable,
1739
- * but will only log a verbose level message when types are specified which are
1740
- * not acceptable. This allows requesting several types with having to know
1741
- * whether they are all acceptable or not.
1742
- *
1743
- * @param {Object[]} mediaTypes - Acceptable media types
1744
- * @param {Object[]} supportedMediaTypes - Supported media types
1745
- * @private
1746
- */
1747
- }, {
1748
- key: "_buildMultipartAcceptHeaderFieldValue",
1749
- value: function _buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes) {
1750
- var _this2 = this;
1751
- if (!Array.isArray(mediaTypes)) {
1752
- throw new Error('Acceptable media types must be provided as an Array');
1753
- }
1754
- if (!Array.isArray(supportedMediaTypes) && !isObject(supportedMediaTypes)) {
1755
- throw new Error('Supported media types must be provided as an Array or an Object');
1756
- }
1757
- var fieldValueParts = [];
1758
- mediaTypes.forEach(function (item) {
1759
- var transferSyntaxUID = item.transferSyntaxUID,
1760
- mediaType = item.mediaType;
1761
- DICOMwebClient._assertMediaTypeIsValid(mediaType);
1762
- var fieldValue = "multipart/related; type=\"".concat(mediaType, "\"");
1763
- if (isObject(supportedMediaTypes)) {
1764
- // SupportedMediaTypes is a lookup table that maps Transfer Syntax UID
1765
- // to one or more Media Types
1766
- if (!Object.values(supportedMediaTypes).flat(1).includes(mediaType)) {
1767
- if (!mediaType.endsWith('/*') || !mediaType.endsWith('/')) {
1768
- debugLog("Media type ".concat(mediaType, " is not supported for requested resource"));
1769
- return;
1770
- }
1771
- }
1772
- if (transferSyntaxUID) {
1773
- if (transferSyntaxUID !== '*') {
1774
- if (!Object.keys(supportedMediaTypes).includes(transferSyntaxUID)) {
1775
- throw new Error("Transfer syntax ".concat(transferSyntaxUID, " is not supported for requested resource"));
1776
- }
1777
- var expectedMediaTypes = supportedMediaTypes[transferSyntaxUID];
1778
- if (!expectedMediaTypes.includes(mediaType)) {
1779
- var actualType = DICOMwebClient._parseMediaType(mediaType)[0];
1780
- expectedMediaTypes.map(function (expectedMediaType) {
1781
- var expectedType = DICOMwebClient._parseMediaType(expectedMediaType)[0];
1782
- var haveSameType = actualType === expectedType;
1783
- if (haveSameType && (mediaType.endsWith('/*') || mediaType.endsWith('/'))) {
1784
- return;
1785
- }
1786
- throw new Error("Transfer syntax ".concat(transferSyntaxUID, " is not supported for requested resource"));
1787
- });
1788
- }
1789
- }
1790
- fieldValue += "; transfer-syntax=".concat(transferSyntaxUID);
1791
- }
1792
- } else if (Array.isArray(supportedMediaTypes) && !supportedMediaTypes.includes(mediaType)) {
1793
- if (_this2.verbose) {
1794
- console.warn("Media type ".concat(mediaType, " is not supported for requested resource"));
1795
- }
1796
- return;
1797
- }
1798
- fieldValueParts.push(fieldValue);
1799
- });
1800
- if (!fieldValueParts.length) {
1801
- throw new Error("No acceptable media types found among ".concat(JSON.stringify(mediaTypes)));
1802
- }
1803
- return fieldValueParts.join(', ');
1804
- }
1805
- /**
1806
- * Builds a range header field value for HTTP GET request messages.
1807
- *
1808
- * @param {Array} byteRange - Start and end of byte range
1809
- * @returns {String} Range header field value
1810
- * @private
1811
- */
1812
- }, {
1813
- key: "_buildRangeHeaderFieldValue",
1814
- value: function _buildRangeHeaderFieldValue() {
1815
- var byteRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1816
- if (byteRange.length === 1) {
1817
- return "bytes=".concat(byteRange[0], "-");
1818
- }
1819
- if (byteRange.length === 2) {
1820
- return "bytes=".concat(byteRange[0], "-").concat(byteRange[1]);
1821
- }
1822
- return 'bytes=0-';
1823
- }
1824
- /**
1825
- * Gets types that are shared among acceptable media types.
1826
- *
1827
- * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
1828
- corresponding transfer syntaxes
1829
- * @private
1830
- * @returns {String[]} Types that are shared among acceptable media types
1831
- */
1832
- }, {
1833
- key: "_getSharedMediaTypes",
1834
- value: function _getSharedMediaTypes(mediaTypes) {
1835
- var types = new Set();
1836
- if (!mediaTypes || !mediaTypes.length) {
1837
- return types;
1838
- }
1839
- mediaTypes.forEach(function (item) {
1840
- var mediaType = item.mediaType;
1841
- var type = DICOMwebClient._parseMediaType(mediaType)[0];
1842
- types.add("".concat(type, "/"));
1843
- });
1844
- return Array.from(types);
1845
- }
1846
- /**
1847
- * Gets common base type of acceptable media types and asserts that only
1848
- one type is specified. For example, ``("image/jpeg", "image/jp2")``
1849
- will pass, but ``("image/jpeg", "video/mpeg2")`` will raise an
1850
- exception.
1851
- *
1852
- * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
1853
- corresponding transfer syntaxes
1854
- * @private
1855
- * @returns {String[]} Common media type, eg `image/` for the above example.
1856
- */
1857
- }, {
1858
- key: "_getCommonMediaType",
1859
- value: function _getCommonMediaType(mediaTypes) {
1860
- if (!mediaTypes || !mediaTypes.length) {
1861
- throw new Error('No acceptable media types provided');
1862
- }
1863
- var sharedMediaTypes = DICOMwebClient._getSharedMediaTypes(mediaTypes);
1864
- if (sharedMediaTypes.length === 0) {
1865
- throw new Error('No common acceptable media type could be identified.');
1866
- } else if (sharedMediaTypes.length > 1) {
1867
- throw new Error('Acceptable media types must have the same type.');
1868
- }
1869
- return sharedMediaTypes[0];
1870
- }
1871
- }]);
1872
- return DICOMwebClient;
1873
- }();
1874
-
1875
- function findSubstring(str, before, after) {
1876
- var beforeIndex = str.lastIndexOf(before) + before.length;
1877
- if (beforeIndex < before.length) {
1878
- return null;
1879
- }
1880
- if (after !== undefined) {
1881
- var afterIndex = str.lastIndexOf(after);
1882
- if (afterIndex < 0) {
1883
- return null;
1884
- }
1885
- return str.substring(beforeIndex, afterIndex);
1886
- }
1887
- return str.substring(beforeIndex);
1888
- }
1889
- function getStudyInstanceUIDFromUri(uri) {
1890
- var uid = findSubstring(uri, 'studies/', '/series');
1891
- if (!uid) {
1892
- uid = findSubstring(uri, 'studies/');
1893
- }
1894
- if (!uid) {
1895
- console.debug("Study Instance UID could not be dertermined from URI \"".concat(uri, "\""));
1896
- }
1897
- return uid;
1898
- }
1899
- function getSeriesInstanceUIDFromUri(uri) {
1900
- var uid = findSubstring(uri, 'series/', '/instances');
1901
- if (!uid) {
1902
- uid = findSubstring(uri, 'series/');
1903
- }
1904
- if (!uid) {
1905
- console.debug("Series Instance UID could not be dertermined from URI \"".concat(uri, "\""));
1906
- }
1907
- return uid;
1908
- }
1909
- function getSOPInstanceUIDFromUri(uri) {
1910
- var uid = findSubstring(uri, '/instances/', '/frames');
1911
- if (!uid) {
1912
- uid = findSubstring(uri, '/instances/', '/metadata');
1913
- }
1914
- if (!uid) {
1915
- uid = findSubstring(uri, '/instances/');
1916
- }
1917
- if (!uid) {
1918
- console.debug("SOP Instance UID could not be dertermined from URI\"".concat(uri, "\""));
1919
- }
1920
- return uid;
1921
- }
1922
- function getFrameNumbersFromUri(uri) {
1923
- var numbers = findSubstring(uri, '/frames/', '/rendered');
1924
- if (!numbers) {
1925
- numbers = findSubstring(uri, '/frames/');
1926
- }
1927
- if (numbers === undefined) {
1928
- console.debug("Frame Numbers could not be dertermined from URI\"".concat(uri, "\""));
1929
- }
1930
- return numbers.split(',');
1931
- }
1932
-
1933
- var version = '0.5.2';
1934
-
1935
- var api = {
1936
- DICOMwebClient: DICOMwebClient
1937
- };
1938
- var utils = {
1939
- getStudyInstanceUIDFromUri: getStudyInstanceUIDFromUri,
1940
- getSeriesInstanceUIDFromUri: getSeriesInstanceUIDFromUri,
1941
- getSOPInstanceUIDFromUri: getSOPInstanceUIDFromUri,
1942
- getFrameNumbersFromUri: getFrameNumbersFromUri
1943
- };
1944
-
1945
-
1946
-
1947
-
1948
- /***/ })
1949
-
1950
- }]);