@ohif/app 3.9.0-beta.77 → 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.39ea4d1a48d42cdca49b.js → 1994.bundle.083fb36bc0648f2dbda6.js} +3 -3
  5. package/dist/{9824.bundle.8e8afc799f0534014fa9.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.f1af90765358215ca053.js → 4210.bundle.38eb5056ac41a0b04d21.js} +2 -2
  10. package/dist/{4842.bundle.11abbf3f8699b84a7537.js → 4842.bundle.0427b8aa1b52aa050ed2.js} +12 -8
  11. package/dist/{5888.bundle.f48daf22ce156ac4956a.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.b20397636c4b681f4463.js → 655.bundle.28f107410332c62993a3.js} +170 -66
  14. package/dist/{6591.bundle.092858f2e84426bc0010.js → 6591.bundle.92a28f98c3f45ac3b3f1.js} +15 -1
  15. package/dist/{7502.bundle.7f3a72a5571a00fda890.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.fc147f9fde903e0768f4.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.f61b8aebe75f7bafd5b1.js → 962.bundle.04afab064299df16f869.js} +408 -179
  21. package/dist/app-config.js +1 -0
  22. package/dist/{app.bundle.e3ce3b1cf2fae5cedcd3.js → app.bundle.53faac5b01b67714fad2.js} +646 -349
  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.94f93195fab889e0add8.js → 153.bundle.3ba838ef3c08a266ae35.js} +0 -0
  31. package/dist/{2791.bundle.597dca661f5f08060ad3.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.db07d757866d3a3b20b3.js → 3962.bundle.31bfadcde7f5a2dd8932.js} +0 -0
  34. package/dist/{4353.bundle.c835b4ea70768a207c59.js → 4353.bundle.c13a0c72c607850ea3c0.js} +0 -0
  35. package/dist/{4978.bundle.c5d6cac06bcc9656c900.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.d3f1bb1a40801b133810.js → 7246.bundle.f1cbdd5ec9387bb6f8fe.js} +0 -0
  39. package/dist/{7360.bundle.b28c83aa3910eaa427ee.js → 7360.bundle.d0bdb43af1494bccc433.js} +0 -0
  40. package/dist/{7376.bundle.1173819ab2acd8610f1e.js → 7376.bundle.d6b445de2d468ab2e8b3.js} +0 -0
  41. package/dist/{3424.css → 79.css} +1 -1
  42. /package/dist/{7913.bundle.5702ee8798da273c0c5d.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.3bf7ef09ea87195b9e23.js → 8944.bundle.29926bb653a467c7e7d8.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[2417],{
2
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[5898],{
3
3
 
4
4
  /***/ 15747:
5
5
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
@@ -639,6 +639,1952 @@ function calculateSUVScalingFactors(instances) {
639
639
 
640
640
 
641
641
 
642
+ /***/ }),
643
+
644
+ /***/ 97604:
645
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
646
+
647
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
648
+ /* harmony export */ api: () => (/* binding */ api)
649
+ /* harmony export */ });
650
+ /* unused harmony exports utils, version */
651
+ function _typeof(obj) {
652
+ "@babel/helpers - typeof";
653
+
654
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
655
+ return typeof obj;
656
+ } : function (obj) {
657
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
658
+ }, _typeof(obj);
659
+ }
660
+ function _classCallCheck(instance, Constructor) {
661
+ if (!(instance instanceof Constructor)) {
662
+ throw new TypeError("Cannot call a class as a function");
663
+ }
664
+ }
665
+ function _defineProperties(target, props) {
666
+ for (var i = 0; i < props.length; i++) {
667
+ var descriptor = props[i];
668
+ descriptor.enumerable = descriptor.enumerable || false;
669
+ descriptor.configurable = true;
670
+ if ("value" in descriptor) descriptor.writable = true;
671
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
672
+ }
673
+ }
674
+ function _createClass(Constructor, protoProps, staticProps) {
675
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
676
+ if (staticProps) _defineProperties(Constructor, staticProps);
677
+ Object.defineProperty(Constructor, "prototype", {
678
+ writable: false
679
+ });
680
+ return Constructor;
681
+ }
682
+ function _toConsumableArray(arr) {
683
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
684
+ }
685
+ function _arrayWithoutHoles(arr) {
686
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
687
+ }
688
+ function _iterableToArray(iter) {
689
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
690
+ }
691
+ function _unsupportedIterableToArray(o, minLen) {
692
+ if (!o) return;
693
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
694
+ var n = Object.prototype.toString.call(o).slice(8, -1);
695
+ if (n === "Object" && o.constructor) n = o.constructor.name;
696
+ if (n === "Map" || n === "Set") return Array.from(o);
697
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
698
+ }
699
+ function _arrayLikeToArray(arr, len) {
700
+ if (len == null || len > arr.length) len = arr.length;
701
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
702
+ return arr2;
703
+ }
704
+ function _nonIterableSpread() {
705
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
706
+ }
707
+ function _toPrimitive(input, hint) {
708
+ if (typeof input !== "object" || input === null) return input;
709
+ var prim = input[Symbol.toPrimitive];
710
+ if (prim !== undefined) {
711
+ var res = prim.call(input, hint || "default");
712
+ if (typeof res !== "object") return res;
713
+ throw new TypeError("@@toPrimitive must return a primitive value.");
714
+ }
715
+ return (hint === "string" ? String : Number)(input);
716
+ }
717
+ function _toPropertyKey(arg) {
718
+ var key = _toPrimitive(arg, "string");
719
+ return typeof key === "symbol" ? key : String(key);
720
+ }
721
+
722
+ /**
723
+ * Converts a Uint8Array to a String.
724
+ * @param {Uint8Array} array that should be converted
725
+ * @param {Number} offset array offset in case only subset of array items should
726
+ be extracted (default: 0)
727
+ * @param {Number} limit maximum number of array items that should be extracted
728
+ (defaults to length of array)
729
+ * @returns {String}
730
+ */
731
+ function uint8ArrayToString(arr) {
732
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
733
+ var limit = arguments.length > 2 ? arguments[2] : undefined;
734
+ var itemLimit = limit || arr.length - offset;
735
+ var str = '';
736
+ for (var i = offset; i < offset + itemLimit; i++) {
737
+ str += String.fromCharCode(arr[i]);
738
+ }
739
+ return str;
740
+ }
741
+
742
+ /**
743
+ * Converts a String to a Uint8Array.
744
+ * @param {String} str string that should be converted
745
+ * @returns {Uint8Array}
746
+ */
747
+ function stringToUint8Array(str) {
748
+ var arr = new Uint8Array(str.length);
749
+ for (var i = 0, j = str.length; i < j; i++) {
750
+ arr[i] = str.charCodeAt(i);
751
+ }
752
+ return arr;
753
+ }
754
+
755
+ /**
756
+ * Identifies the boundary in a multipart/related message header.
757
+ * @param {String} header message header
758
+ * @returns {String} boundary
759
+ */
760
+ function identifyBoundary(header) {
761
+ var parts = header.split('\r\n');
762
+ for (var i = 0; i < parts.length; i++) {
763
+ if (parts[i].substr(0, 2) === '--') {
764
+ return parts[i];
765
+ }
766
+ }
767
+ return null;
768
+ }
769
+
770
+ /**
771
+ * Checks whether a given token is contained by a message at a given offset.
772
+ * @param {Uint8Array} message message content
773
+ * @param {Uint8Array} token substring that should be present
774
+ * @param {Number} offset offset in message content from where search should start
775
+ * @returns {Boolean} whether message contains token at offset
776
+ */
777
+ function containsToken(message, token) {
778
+ var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
779
+ if (offset + token.length > message.length) {
780
+ return false;
781
+ }
782
+ var index = offset;
783
+ for (var i = 0; i < token.length; i++) {
784
+ if (token[i] !== message[index]) {
785
+ return false;
786
+ }
787
+ index += 1;
788
+ }
789
+ return true;
790
+ }
791
+
792
+ /**
793
+ * Finds a given token in a message at a given offset.
794
+ * @param {Uint8Array} message message content
795
+ * @param {Uint8Array} token substring that should be found
796
+ * @param {String} offset message body offset from where search should start
797
+ * @returns {Boolean} whether message has a part at given offset or not
798
+ */
799
+ function findToken(message, token) {
800
+ var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
801
+ var maxSearchLength = arguments.length > 3 ? arguments[3] : undefined;
802
+ var searchLength = message.length;
803
+ if (maxSearchLength) {
804
+ searchLength = Math.min(offset + maxSearchLength, message.length);
805
+ }
806
+ for (var i = offset; i < searchLength; i++) {
807
+ // If the first value of the message matches
808
+ // the first value of the token, check if
809
+ // this is the full token.
810
+ if (message[i] === token[0]) {
811
+ if (containsToken(message, token, i)) {
812
+ return i;
813
+ }
814
+ }
815
+ }
816
+ return -1;
817
+ }
818
+
819
+ /**
820
+ * Create a random GUID
821
+ *
822
+ * @return {string}
823
+ */
824
+ function guid() {
825
+ function s4() {
826
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
827
+ }
828
+ return "".concat(s4() + s4(), "-").concat(s4(), "-").concat(s4(), "-").concat(s4(), "-").concat(s4()).concat(s4()).concat(s4());
829
+ }
830
+
831
+ /**
832
+ * @typedef {Object} MultipartEncodedData
833
+ * @property {ArrayBuffer} data The encoded Multipart Data
834
+ * @property {String} boundary The boundary used to divide pieces of the encoded data
835
+ */
836
+
837
+ /**
838
+ * Encode one or more DICOM datasets into a single body so it can be
839
+ * sent using the Multipart Content-Type.
840
+ *
841
+ * @param {ArrayBuffer[]} datasets Array containing each file to be encoded in the
842
+ multipart body, passed as ArrayBuffers.
843
+ * @param {String} [boundary] Optional string to define a boundary between each part
844
+ of the multipart body. If this is not specified, a random
845
+ GUID will be generated.
846
+ * @return {MultipartEncodedData} The Multipart encoded data returned as an Object. This
847
+ contains both the data itself, and the boundary string
848
+ used to divide it.
849
+ */
850
+ function multipartEncode(datasets) {
851
+ var boundary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : guid();
852
+ var contentType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/dicom';
853
+ var contentTypeString = "Content-Type: ".concat(contentType);
854
+ var header = "\r\n--".concat(boundary, "\r\n").concat(contentTypeString, "\r\n\r\n");
855
+ var footer = "\r\n--".concat(boundary, "--");
856
+ var headerArray = stringToUint8Array(header);
857
+ var footerArray = stringToUint8Array(footer);
858
+ var headerLength = headerArray.length;
859
+ var footerLength = footerArray.length;
860
+ var length = 0;
861
+
862
+ // Calculate the total length for the final array
863
+ var contentArrays = datasets.map(function (datasetBuffer) {
864
+ var contentArray = new Uint8Array(datasetBuffer);
865
+ var contentLength = contentArray.length;
866
+ length += headerLength + contentLength + footerLength;
867
+ return contentArray;
868
+ });
869
+
870
+ // Allocate the array
871
+ var multipartArray = new Uint8Array(length);
872
+
873
+ // Set the initial header
874
+ multipartArray.set(headerArray, 0);
875
+
876
+ // Write each dataset into the multipart array
877
+ var position = 0;
878
+ contentArrays.forEach(function (contentArray) {
879
+ multipartArray.set(headerArray, position);
880
+ multipartArray.set(contentArray, position + headerLength);
881
+ position += headerLength + contentArray.length;
882
+ });
883
+ multipartArray.set(footerArray, position);
884
+ return {
885
+ data: multipartArray.buffer,
886
+ boundary: boundary
887
+ };
888
+ }
889
+
890
+ /**
891
+ * Decode a Multipart encoded ArrayBuffer and return the components as an Array.
892
+ *
893
+ * @param {ArrayBuffer} response Data encoded as a 'multipart/related' message
894
+ * @returns {Array} The content
895
+ */
896
+ function multipartDecode(response) {
897
+ // Use the raw data if it is provided in an appropriate format
898
+ var message = ArrayBuffer.isView(response) ? response : new Uint8Array(response);
899
+
900
+ /* Set a maximum length to search for the header boundaries, otherwise
901
+ findToken can run for a long time
902
+ */
903
+ var maxSearchLength = 1000;
904
+
905
+ // First look for the multipart mime header
906
+ var separator = stringToUint8Array('\r\n\r\n');
907
+ var headerIndex = findToken(message, separator, 0, maxSearchLength);
908
+ if (headerIndex === -1) {
909
+ throw new Error('Response message has no multipart mime header');
910
+ }
911
+ var header = uint8ArrayToString(message, 0, headerIndex);
912
+ var boundaryString = identifyBoundary(header);
913
+ if (!boundaryString) {
914
+ throw new Error('Header of response message does not specify boundary');
915
+ }
916
+ var boundary = stringToUint8Array(boundaryString);
917
+ var boundaryLength = boundary.length;
918
+ var components = [];
919
+ var offset = boundaryLength;
920
+
921
+ // Loop until we cannot find any more boundaries
922
+ var boundaryIndex;
923
+ while (boundaryIndex !== -1) {
924
+ // Search for the next boundary in the message, starting
925
+ // from the current offset position
926
+ boundaryIndex = findToken(message, boundary, offset);
927
+
928
+ // If no further boundaries are found, stop here.
929
+ if (boundaryIndex === -1) {
930
+ break;
931
+ }
932
+ var headerTokenIndex = findToken(message, separator, offset, maxSearchLength);
933
+ if (headerTokenIndex === -1) {
934
+ throw new Error('Response message part has no mime header');
935
+ }
936
+ offset = headerTokenIndex + separator.length;
937
+
938
+ // Extract data from response message, excluding "\r\n"
939
+ var spacingLength = 2;
940
+ var data = response.slice(offset, boundaryIndex - spacingLength);
941
+
942
+ // Add the data to the array of results
943
+ components.push(data);
944
+
945
+ // Move the offset to the end of the current section,
946
+ // plus the identified boundary
947
+ offset = boundaryIndex + boundaryLength;
948
+ }
949
+ return components;
950
+ }
951
+
952
+ function isObject(obj) {
953
+ return _typeof(obj) === 'object' && obj !== null;
954
+ }
955
+ function isEmptyObject(obj) {
956
+ return Object.keys(obj).length === 0 && obj.constructor === Object;
957
+ }
958
+ function areValidRequestHooks(requestHooks) {
959
+ var isValid = Array.isArray(requestHooks) && requestHooks.every(function (requestHook) {
960
+ return typeof requestHook === 'function' && requestHook.length === 2;
961
+ });
962
+ if (!isValid) {
963
+ console.warn('Request hooks should have the following signature: ' + 'function requestHook(request, metadata) { return request; }');
964
+ }
965
+ return isValid;
966
+ }
967
+ var getFirstResult = function getFirstResult(result) {
968
+ return result[0];
969
+ };
970
+ var MEDIATYPES = {
971
+ DICOM: 'application/dicom',
972
+ DICOM_JSON: 'application/dicom+json',
973
+ OCTET_STREAM: 'application/octet-stream',
974
+ PDF: 'application/pdf',
975
+ JPEG: 'image/jpeg',
976
+ PNG: 'image/png'
977
+ };
978
+
979
+ /**
980
+ * debugLog is a function that can be called with console.log arguments, and will
981
+ * be conditionally displayed, only when debug logging is enabled.
982
+ */
983
+ var debugLog = function debugLog() {};
984
+
985
+ /**
986
+ * @typedef { import("../types/types").InstanceMetadata } InstanceMetadata
987
+ */
988
+
989
+ /**
990
+ * A callback with the request instance and metadata information
991
+ * of the currently request being executed that should necessarily
992
+ * return the given request optionally modified.
993
+ * @typedef {function} RequestHook
994
+ * @param {XMLHttpRequest} request - The original XMLHttpRequest instance.
995
+ * @param {object} metadata - The metadata used by the request.
996
+ */
997
+
998
+ /**
999
+ * Class for interacting with DICOMweb RESTful services.
1000
+ */
1001
+ var DICOMwebClient = /*#__PURE__*/function () {
1002
+ /**
1003
+ * @constructor
1004
+ * @param {Object} options
1005
+ * @param {String} options.url - URL of the DICOMweb RESTful Service endpoint
1006
+ * @param {String=} options.qidoURLPrefix - URL path prefix for QIDO-RS
1007
+ * @param {String=} options.wadoURLPrefix - URL path prefix for WADO-RS
1008
+ * @param {String=} options.stowURLPrefix - URL path prefix for STOW-RS
1009
+ * @param {String=} options.username - Username
1010
+ * @param {String=} options.password - Password
1011
+ * @param {Object=} options.headers - HTTP headers
1012
+ * @param {Array.<RequestHook>=} options.requestHooks - Request hooks.
1013
+ * @param {Object=} options.verbose - print to console request warnings and errors, default true
1014
+ * @param {Object=} options.debug - print to the console debug level information/status updates.
1015
+ * @param {boolean|String} options.singlepart - retrieve singlepart for the named types.
1016
+ * The available types are: bulkdata, video, image. true means all.
1017
+ */
1018
+ function DICOMwebClient(options) {
1019
+ _classCallCheck(this, DICOMwebClient);
1020
+ this.baseURL = options.url;
1021
+ if (!this.baseURL) {
1022
+ console.error('no DICOMweb base url provided - calls that require a URL will fail');
1023
+ }
1024
+ if ('username' in options) {
1025
+ this.username = options.username;
1026
+ if (!('password' in options)) {
1027
+ console.error('no password provided to authenticate with DICOMweb service');
1028
+ }
1029
+ this.password = options.password;
1030
+ }
1031
+ if ('qidoURLPrefix' in options) {
1032
+ debugLog("use URL prefix for QIDO-RS: ".concat(options.qidoURLPrefix));
1033
+ this.qidoURL = "".concat(this.baseURL, "/").concat(options.qidoURLPrefix);
1034
+ } else {
1035
+ this.qidoURL = this.baseURL;
1036
+ }
1037
+ if ('wadoURLPrefix' in options) {
1038
+ debugLog("use URL prefix for WADO-RS: ".concat(options.wadoURLPrefix));
1039
+ this.wadoURL = "".concat(this.baseURL, "/").concat(options.wadoURLPrefix);
1040
+ } else {
1041
+ this.wadoURL = this.baseURL;
1042
+ }
1043
+ if ('stowURLPrefix' in options) {
1044
+ debugLog("use URL prefix for STOW-RS: ".concat(options.stowURLPrefix));
1045
+ this.stowURL = "".concat(this.baseURL, "/").concat(options.stowURLPrefix);
1046
+ } else {
1047
+ this.stowURL = this.baseURL;
1048
+ }
1049
+ if (options.singlepart) {
1050
+ debugLog('use singlepart', options.singlepart);
1051
+ this.singlepart = options.singlepart === true ? 'bulkdata,video,image' : options.singlepart;
1052
+ } else {
1053
+ this.singlepart = '';
1054
+ }
1055
+ if ('requestHooks' in options) {
1056
+ this.requestHooks = options.requestHooks;
1057
+ }
1058
+
1059
+ // Headers to pass to requests.
1060
+ this.headers = options.headers || {};
1061
+
1062
+ // Optional error interceptor callback to handle any failed request.
1063
+ this.errorInterceptor = options.errorInterceptor || function () {
1064
+ return undefined;
1065
+ };
1066
+
1067
+ // Verbose - print to console request warnings and errors, default true
1068
+ this.verbose = options.verbose !== false;
1069
+ this.setDebug(options.debug);
1070
+ }
1071
+
1072
+ /**
1073
+ * Allows setting the debug log information.
1074
+ * Note this is different from verbose in that verbose is whether to include warning/error information, defaulting to true
1075
+ *
1076
+ * @param {boolean} debugLevel
1077
+ * @param {function} debugLogFunction to call with the debug output arguments.
1078
+ */
1079
+ _createClass(DICOMwebClient, [{
1080
+ key: "setDebug",
1081
+ value: function setDebug() {
1082
+ var debugLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1083
+ var debugLogFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1084
+ this.debugLevel = !!debugLevel;
1085
+ debugLog = debugLogFunction || debugLevel ? console.log : function () {};
1086
+ }
1087
+ /**
1088
+ * Gets debug flag
1089
+ *
1090
+ * @returns true if debug logging is enabled
1091
+ */
1092
+ }, {
1093
+ key: "getDebug",
1094
+ value: function getDebug() {
1095
+ return this.debugLevel;
1096
+ }
1097
+ /**
1098
+ * Sets verbose flag.
1099
+ *
1100
+ * @param {Boolean} verbose
1101
+ */
1102
+ }, {
1103
+ key: "setVerbose",
1104
+ value: function setVerbose(verbose) {
1105
+ this.verbose = verbose;
1106
+ }
1107
+ /**
1108
+ * Gets verbose flag.
1109
+ *
1110
+ * @return {Boolean} verbose
1111
+ */
1112
+ }, {
1113
+ key: "getVerbose",
1114
+ value: function getVerbose() {
1115
+ return this.verbose;
1116
+ }
1117
+ }, {
1118
+ key: "_httpRequest",
1119
+ /**
1120
+ * Performs an HTTP request.
1121
+ *
1122
+ * @param {String} url
1123
+ * @param {String} method
1124
+ * @param {Object} headers
1125
+ * @param {Object} options
1126
+ * @param {Array.<RequestHook>} options.requestHooks - Request hooks.
1127
+ * @param {XMLHttpRequest} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1128
+ * @return {*}
1129
+ * @private
1130
+ */
1131
+ value: function _httpRequest(url, method) {
1132
+ var _this = this;
1133
+ var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1134
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1135
+ var errorInterceptor = this.errorInterceptor,
1136
+ requestHooks = this.requestHooks;
1137
+ return new Promise(function (resolve, reject) {
1138
+ var request = options.request ? options.request : new XMLHttpRequest();
1139
+ request.open(method, url, true);
1140
+ if ('responseType' in options) {
1141
+ request.responseType = options.responseType;
1142
+ }
1143
+ if (_typeof(headers) === 'object') {
1144
+ Object.keys(headers).forEach(function (key) {
1145
+ request.setRequestHeader(key, headers[key]);
1146
+ });
1147
+ }
1148
+
1149
+ // now add custom headers from the user
1150
+ // (e.g. access tokens)
1151
+ var userHeaders = _this.headers;
1152
+ Object.keys(userHeaders).forEach(function (key) {
1153
+ request.setRequestHeader(key, userHeaders[key]);
1154
+ });
1155
+
1156
+ // Event triggered when upload starts
1157
+ request.onloadstart = function onloadstart() {
1158
+ debugLog('upload started: ', url);
1159
+ };
1160
+
1161
+ // Event triggered when upload ends
1162
+ request.onloadend = function onloadend() {
1163
+ debugLog('upload finished');
1164
+ };
1165
+
1166
+ // Handle response message
1167
+ request.onreadystatechange = function () {
1168
+ if (request.readyState === 4) {
1169
+ if (request.status === 200) {
1170
+ var contentType = request.getResponseHeader('Content-Type');
1171
+ // Automatically distinguishes between multipart and singlepart in an array buffer, and
1172
+ // converts them into a consistent type.
1173
+ if (contentType && contentType.indexOf('multipart') !== -1) {
1174
+ resolve(multipartDecode(request.response));
1175
+ } else if (request.responseType === 'arraybuffer') {
1176
+ resolve([request.response]);
1177
+ } else {
1178
+ resolve(request.response);
1179
+ }
1180
+ } else if (request.status === 202) {
1181
+ if (_this.verbose) {
1182
+ console.warn('some resources already existed: ', request);
1183
+ }
1184
+ resolve(request.response);
1185
+ } else if (request.status === 204) {
1186
+ if (_this.verbose) {
1187
+ console.warn('empty response for request: ', request);
1188
+ }
1189
+ resolve([]);
1190
+ } else {
1191
+ var error = new Error('request failed');
1192
+ error.request = request;
1193
+ error.response = request.response;
1194
+ error.status = request.status;
1195
+ if (_this.verbose) {
1196
+ console.error('request failed: ', request);
1197
+ console.error(error);
1198
+ console.error(error.response);
1199
+ }
1200
+ errorInterceptor(error);
1201
+ reject(error);
1202
+ }
1203
+ }
1204
+ };
1205
+
1206
+ // Event triggered while download progresses
1207
+ if ('progressCallback' in options) {
1208
+ if (typeof options.progressCallback === 'function') {
1209
+ request.onprogress = options.progressCallback;
1210
+ }
1211
+ }
1212
+ if (requestHooks && areValidRequestHooks(requestHooks)) {
1213
+ var combinedHeaders = Object.assign({}, headers, _this.headers);
1214
+ var metadata = {
1215
+ method: method,
1216
+ url: url,
1217
+ headers: combinedHeaders
1218
+ };
1219
+ var pipeRequestHooks = function pipeRequestHooks(functions) {
1220
+ return function (args) {
1221
+ return functions.reduce(function (props, fn) {
1222
+ return fn(props, metadata);
1223
+ }, args);
1224
+ };
1225
+ };
1226
+ var pipedRequest = pipeRequestHooks(requestHooks);
1227
+ request = pipedRequest(request);
1228
+ }
1229
+
1230
+ // Add withCredentials to request if needed
1231
+ if ('withCredentials' in options) {
1232
+ if (options.withCredentials) {
1233
+ request.withCredentials = true;
1234
+ }
1235
+ }
1236
+ if ('data' in options) {
1237
+ request.send(options.data);
1238
+ } else {
1239
+ request.send();
1240
+ }
1241
+ });
1242
+ }
1243
+ /**
1244
+ * Performs an HTTP GET request.
1245
+ *
1246
+ * @param {String} url
1247
+ * @param {Object} headers
1248
+ * @param {Object} responseType
1249
+ * @param {Function} progressCallback
1250
+ * @return {*}
1251
+ * @private
1252
+ */
1253
+ }, {
1254
+ key: "_httpGet",
1255
+ value: function _httpGet(url, headers, responseType, progressCallback, withCredentials) {
1256
+ return this._httpRequest(url, 'get', headers, {
1257
+ responseType: responseType,
1258
+ progressCallback: progressCallback,
1259
+ withCredentials: withCredentials
1260
+ });
1261
+ }
1262
+ /**
1263
+ * Performs an HTTP GET request that accepts a message with application/json
1264
+ * media type.
1265
+ *
1266
+ * @param {String} url
1267
+ * @param {Object} params
1268
+ * @param {Function} progressCallback
1269
+ * @return {*}
1270
+ * @private
1271
+ */
1272
+ }, {
1273
+ key: "_httpGetApplicationJson",
1274
+ value: function _httpGetApplicationJson(url) {
1275
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1276
+ var progressCallback = arguments.length > 2 ? arguments[2] : undefined;
1277
+ var withCredentials = arguments.length > 3 ? arguments[3] : undefined;
1278
+ var urlWithQueryParams = url;
1279
+ if (_typeof(params) === 'object') {
1280
+ if (!isEmptyObject(params)) {
1281
+ urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
1282
+ }
1283
+ }
1284
+ var headers = {
1285
+ Accept: MEDIATYPES.DICOM_JSON
1286
+ };
1287
+ var responseType = 'json';
1288
+ return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
1289
+ }
1290
+ /**
1291
+ * Performs an HTTP GET request that accepts a message with application/pdf
1292
+ * media type.
1293
+ *
1294
+ * @param {String} url
1295
+ * @param {Object} params
1296
+ * @param {Function} progressCallback
1297
+ * @return {*}
1298
+ * @private
1299
+ */
1300
+ }, {
1301
+ key: "_httpGetApplicationPdf",
1302
+ value: function _httpGetApplicationPdf(url) {
1303
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1304
+ var progressCallback = arguments.length > 2 ? arguments[2] : undefined;
1305
+ var withCredentials = arguments.length > 3 ? arguments[3] : undefined;
1306
+ var urlWithQueryParams = url;
1307
+ if (_typeof(params) === 'object') {
1308
+ if (!isEmptyObject(params)) {
1309
+ urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
1310
+ }
1311
+ }
1312
+ var headers = {
1313
+ Accept: MEDIATYPES.PDF
1314
+ };
1315
+ var responseType = 'json';
1316
+ return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
1317
+ }
1318
+ /**
1319
+ * Performs an HTTP GET request that accepts a message with an image
1320
+ media type.
1321
+ *
1322
+ * @param {String} url
1323
+ * @param {Object[]} mediaTypes
1324
+ * @param {Object} params
1325
+ * @param {Function} progressCallback
1326
+ * @return {*}
1327
+ * @private
1328
+ */
1329
+ }, {
1330
+ key: "_httpGetImage",
1331
+ value: function _httpGetImage(url, mediaTypes) {
1332
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1333
+ var progressCallback = arguments.length > 3 ? arguments[3] : undefined;
1334
+ var withCredentials = arguments.length > 4 ? arguments[4] : undefined;
1335
+ var urlWithQueryParams = url;
1336
+ if (_typeof(params) === 'object') {
1337
+ if (!isEmptyObject(params)) {
1338
+ urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
1339
+ }
1340
+ }
1341
+ var supportedMediaTypes = ['image/', 'image/*', 'image/jpeg', 'image/jp2', 'image/gif', 'image/png'];
1342
+ var acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
1343
+ var headers = {
1344
+ Accept: acceptHeaderFieldValue
1345
+ };
1346
+ var responseType = 'arraybuffer';
1347
+ return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
1348
+ }
1349
+ /**
1350
+ * Performs an HTTP GET request that accepts a message with a text
1351
+ media type.
1352
+ *
1353
+ * @param {String} url
1354
+ * @param {Object[]} mediaTypes
1355
+ * @param {Object} params
1356
+ * @param {Function} progressCallback
1357
+ * @return {*}
1358
+ * @private
1359
+ */
1360
+ }, {
1361
+ key: "_httpGetText",
1362
+ value: function _httpGetText(url, mediaTypes) {
1363
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1364
+ var progressCallback = arguments.length > 3 ? arguments[3] : undefined;
1365
+ var withCredentials = arguments.length > 4 ? arguments[4] : undefined;
1366
+ var urlWithQueryParams = url;
1367
+ if (_typeof(params) === 'object') {
1368
+ if (!isEmptyObject(params)) {
1369
+ urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
1370
+ }
1371
+ }
1372
+ var supportedMediaTypes = ['text/', 'text/*', 'text/html', 'text/plain', 'text/rtf', 'text/xml'];
1373
+ var acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
1374
+ var headers = {
1375
+ Accept: acceptHeaderFieldValue
1376
+ };
1377
+ var responseType = 'arraybuffer';
1378
+ return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
1379
+ }
1380
+ /**
1381
+ * Performs an HTTP GET request that accepts a message with a video
1382
+ media type.
1383
+ *
1384
+ * @param {String} url
1385
+ * @param {Object[]} mediaTypes
1386
+ * @param {Object} params
1387
+ * @param {Function} progressCallback
1388
+ * @return {*}
1389
+ * @private
1390
+ */
1391
+ }, {
1392
+ key: "_httpGetVideo",
1393
+ value: function _httpGetVideo(url, mediaTypes) {
1394
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1395
+ var progressCallback = arguments.length > 3 ? arguments[3] : undefined;
1396
+ var withCredentials = arguments.length > 4 ? arguments[4] : undefined;
1397
+ var urlWithQueryParams = url;
1398
+ if (_typeof(params) === 'object') {
1399
+ if (!isEmptyObject(params)) {
1400
+ urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);
1401
+ }
1402
+ }
1403
+ var supportedMediaTypes = ['video/', 'video/*', 'video/mpeg', 'video/mp4', 'video/H265'];
1404
+ var acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
1405
+ var headers = {
1406
+ Accept: acceptHeaderFieldValue
1407
+ };
1408
+ var responseType = 'arraybuffer';
1409
+ return this._httpGet(urlWithQueryParams, headers, responseType, progressCallback, withCredentials);
1410
+ }
1411
+ /**
1412
+ * Asserts that a given media type is valid.
1413
+ *
1414
+ * @params {String} mediaType media type
1415
+ */
1416
+ }, {
1417
+ key: "_httpGetMultipartImage",
1418
+ /**
1419
+ * Performs an HTTP GET request that accepts a multipart message with an image media type.
1420
+ *
1421
+ * @param {String} url - Unique resource locator
1422
+ * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
1423
+ corresponding transfer syntaxes
1424
+ * @param {Array} byteRange - Start and end of byte range
1425
+ * @param {Object} params - Additional HTTP GET query parameters
1426
+ * @param {Boolean} rendered - Whether resource should be requested using rendered media types
1427
+ * @param {Function} progressCallback
1428
+ * @private
1429
+ * @returns {Promise<Array>} Content of HTTP message body parts
1430
+ */
1431
+ value: function _httpGetMultipartImage(url, mediaTypes, byteRange, params) {
1432
+ var rendered = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1433
+ var progressCallback = arguments.length > 5 ? arguments[5] : undefined;
1434
+ var withCredentials = arguments.length > 6 ? arguments[6] : undefined;
1435
+ var headers = {};
1436
+ var supportedMediaTypes;
1437
+ if (rendered) {
1438
+ supportedMediaTypes = ['image/jpeg', 'image/gif', 'image/png', 'image/jp2'];
1439
+ } else {
1440
+ supportedMediaTypes = {
1441
+ '1.2.840.10008.1.2.5': ['image/x-dicom-rle'],
1442
+ '1.2.840.10008.1.2.4.50': ['image/jpeg'],
1443
+ '1.2.840.10008.1.2.4.51': ['image/jpeg'],
1444
+ '1.2.840.10008.1.2.4.57': ['image/jpeg'],
1445
+ '1.2.840.10008.1.2.4.70': ['image/jpeg'],
1446
+ '1.2.840.10008.1.2.4.80': ['image/x-jls', 'image/jls'],
1447
+ '1.2.840.10008.1.2.4.81': ['image/x-jls', 'image/jls'],
1448
+ '1.2.840.10008.1.2.4.90': ['image/jp2'],
1449
+ '1.2.840.10008.1.2.4.91': ['image/jp2'],
1450
+ '1.2.840.10008.1.2.4.92': ['image/jpx'],
1451
+ '1.2.840.10008.1.2.4.93': ['image/jpx']
1452
+ };
1453
+ if (byteRange) {
1454
+ headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);
1455
+ }
1456
+ }
1457
+ headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
1458
+ return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
1459
+ }
1460
+ /**
1461
+ * Performs an HTTP GET request that accepts a multipart message with a video media type.
1462
+ *
1463
+ * @param {String} url - Unique resource locator
1464
+ * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
1465
+ corresponding transfer syntaxes
1466
+ * @param {Array} byteRange - Start and end of byte range
1467
+ * @param {Object} params - Additional HTTP GET query parameters
1468
+ * @param {Boolean} rendered - Whether resource should be requested using rendered media types
1469
+ * @param {Function} progressCallback
1470
+ * @private
1471
+ * @returns {Promise<Array>} Content of HTTP message body parts
1472
+ */
1473
+ }, {
1474
+ key: "_httpGetMultipartVideo",
1475
+ value: function _httpGetMultipartVideo(url, mediaTypes, byteRange, params) {
1476
+ var rendered = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1477
+ var progressCallback = arguments.length > 5 ? arguments[5] : undefined;
1478
+ var withCredentials = arguments.length > 6 ? arguments[6] : undefined;
1479
+ var headers = {};
1480
+ var supportedMediaTypes;
1481
+ if (rendered) {
1482
+ supportedMediaTypes = ['video/', 'video/*', 'video/mpeg2', 'video/mp4', 'video/H265'];
1483
+ } else {
1484
+ supportedMediaTypes = {
1485
+ '1.2.840.10008.1.2.4.100': ['video/mpeg2'],
1486
+ '1.2.840.10008.1.2.4.101': ['video/mpeg2'],
1487
+ '1.2.840.10008.1.2.4.102': ['video/mp4'],
1488
+ '1.2.840.10008.1.2.4.103': ['video/mp4'],
1489
+ '1.2.840.10008.1.2.4.104': ['video/mp4'],
1490
+ '1.2.840.10008.1.2.4.105': ['video/mp4'],
1491
+ '1.2.840.10008.1.2.4.106': ['video/mp4']
1492
+ };
1493
+ if (byteRange) {
1494
+ headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);
1495
+ }
1496
+ }
1497
+ headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes);
1498
+ return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
1499
+ }
1500
+ /**
1501
+ * Performs an HTTP GET request that accepts a multipart message
1502
+ * with a application/dicom media type.
1503
+ *
1504
+ * @param {String} url - Unique resource locator
1505
+ * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
1506
+ corresponding transfer syntaxes
1507
+ * @param {Object} params - Additional HTTP GET query parameters
1508
+ * @param {Function} progressCallback
1509
+ * @private
1510
+ * @returns {Promise<Array>} Content of HTTP message body parts
1511
+ */
1512
+ }, {
1513
+ key: "_httpGetMultipartApplicationDicom",
1514
+ value: function _httpGetMultipartApplicationDicom(url, mediaTypes, params, progressCallback, withCredentials) {
1515
+ var headers = {};
1516
+ var defaultMediaType = 'application/dicom';
1517
+ var supportedMediaTypes = {
1518
+ '1.2.840.10008.1.2.1': [defaultMediaType],
1519
+ '1.2.840.10008.1.2.5': [defaultMediaType],
1520
+ '1.2.840.10008.1.2.4.50': [defaultMediaType],
1521
+ '1.2.840.10008.1.2.4.51': [defaultMediaType],
1522
+ '1.2.840.10008.1.2.4.57': [defaultMediaType],
1523
+ '1.2.840.10008.1.2.4.70': [defaultMediaType],
1524
+ '1.2.840.10008.1.2.4.80': [defaultMediaType],
1525
+ '1.2.840.10008.1.2.4.81': [defaultMediaType],
1526
+ '1.2.840.10008.1.2.4.90': [defaultMediaType],
1527
+ '1.2.840.10008.1.2.4.91': [defaultMediaType],
1528
+ '1.2.840.10008.1.2.4.92': [defaultMediaType],
1529
+ '1.2.840.10008.1.2.4.93': [defaultMediaType],
1530
+ '1.2.840.10008.1.2.4.100': [defaultMediaType],
1531
+ '1.2.840.10008.1.2.4.101': [defaultMediaType],
1532
+ '1.2.840.10008.1.2.4.102': [defaultMediaType],
1533
+ '1.2.840.10008.1.2.4.103': [defaultMediaType],
1534
+ '1.2.840.10008.1.2.4.104': [defaultMediaType],
1535
+ '1.2.840.10008.1.2.4.105': [defaultMediaType],
1536
+ '1.2.840.10008.1.2.4.106': [defaultMediaType]
1537
+ };
1538
+ var acceptableMediaTypes = mediaTypes;
1539
+ if (!mediaTypes) {
1540
+ acceptableMediaTypes = [{
1541
+ mediaType: defaultMediaType
1542
+ }];
1543
+ }
1544
+ headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(acceptableMediaTypes, supportedMediaTypes);
1545
+ return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
1546
+ }
1547
+ /**
1548
+ * Performs an HTTP GET request that accepts a multipart message
1549
+ * with a application/octet-stream, OR any of the equivalencies for that (eg
1550
+ * application/pdf etc)
1551
+ *
1552
+ * @param {String} url - Unique resource locator
1553
+ * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
1554
+ corresponding transfer syntaxes
1555
+ * @param {Array} byteRange start and end of byte range
1556
+ * @param {Object} params - Additional HTTP GET query parameters
1557
+ * @param {Function} progressCallback
1558
+ * @private
1559
+ * @returns {Promise<Array>} Content of HTTP message body parts
1560
+ */
1561
+ }, {
1562
+ key: "_httpGetMultipartApplicationOctetStream",
1563
+ value: function _httpGetMultipartApplicationOctetStream(url, mediaTypes, byteRange, params, progressCallback, withCredentials) {
1564
+ var headers = {};
1565
+ var defaultMediaType = 'application/octet-stream';
1566
+ var supportedMediaTypes = {
1567
+ '1.2.840.10008.1.2.1': _toConsumableArray(Object.values(MEDIATYPES))
1568
+ };
1569
+ var acceptableMediaTypes = mediaTypes;
1570
+ if (!mediaTypes) {
1571
+ acceptableMediaTypes = [{
1572
+ mediaType: defaultMediaType
1573
+ }];
1574
+ }
1575
+ if (byteRange) {
1576
+ headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);
1577
+ }
1578
+ headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(acceptableMediaTypes, supportedMediaTypes);
1579
+ return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
1580
+ }
1581
+ /**
1582
+ * Performs an HTTP POST request.
1583
+ *
1584
+ * @param {String} url - Unique resource locator
1585
+ * @param {Object} headers - HTTP header fields
1586
+ * @param {Array} data - Data that should be stored
1587
+ * @param {Function} progressCallback
1588
+ * @param {Function} progressCallback
1589
+ * @param {XMLHttpRequest} request - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1590
+ * @private
1591
+ * @returns {Promise} Response
1592
+ */
1593
+ }, {
1594
+ key: "_httpPost",
1595
+ value: function _httpPost(url, headers, data, progressCallback, withCredentials, request) {
1596
+ return this._httpRequest(url, 'post', headers, {
1597
+ data: data,
1598
+ progressCallback: progressCallback,
1599
+ withCredentials: withCredentials,
1600
+ request: request
1601
+ });
1602
+ }
1603
+ /**
1604
+ * Performs an HTTP POST request with content-type application/dicom+json.
1605
+ *
1606
+ * @param {String} url - Unique resource locator
1607
+ * @param {Object} headers - HTTP header fields
1608
+ * @param {Array} data - Data that should be stored
1609
+ * @param {Function} progressCallback
1610
+ * @private
1611
+ * @returns {Promise} Response
1612
+ */
1613
+ }, {
1614
+ key: "_httpPostApplicationJson",
1615
+ value: function _httpPostApplicationJson(url, data, progressCallback, withCredentials) {
1616
+ var headers = {
1617
+ 'Content-Type': MEDIATYPES.DICOM_JSON
1618
+ };
1619
+ return this._httpPost(url, headers, data, progressCallback, withCredentials);
1620
+ }
1621
+ /**
1622
+ * Parses media type and extracts its type and subtype.
1623
+ *
1624
+ * @param {String} mediaType - HTTP media type (e.g. image/jpeg)
1625
+ * @private
1626
+ * @returns {String[]} Media type and subtype
1627
+ */
1628
+ }, {
1629
+ key: "searchForStudies",
1630
+ /**
1631
+ * Searches for DICOM studies.
1632
+ *
1633
+ * @param {Object} options
1634
+ * @param {Object} [options.queryParams] - HTTP query parameters
1635
+ * @return {Object[]} Study representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2)
1636
+ */
1637
+ value: function searchForStudies() {
1638
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1639
+ debugLog('search for studies');
1640
+ var withCredentials = false;
1641
+ var url = "".concat(this.qidoURL, "/studies");
1642
+ if ('queryParams' in options) {
1643
+ url += DICOMwebClient._parseQueryParameters(options.queryParams);
1644
+ }
1645
+ if ('withCredentials' in options) {
1646
+ if (options.withCredentials) {
1647
+ withCredentials = options.withCredentials;
1648
+ }
1649
+ }
1650
+ return this._httpGetApplicationJson(url, {}, false, withCredentials);
1651
+ }
1652
+ /**
1653
+ * Retrieves metadata for a DICOM study.
1654
+ *
1655
+ * @param {Object} options
1656
+ * @param {String} options.studyInstanceUID - Study Instance UID
1657
+ * @returns {Promise<InstanceMetadata[]>} Metadata elements in DICOM JSON format for each instance
1658
+ belonging to the study
1659
+ */
1660
+ }, {
1661
+ key: "retrieveStudyMetadata",
1662
+ value: function retrieveStudyMetadata(options) {
1663
+ if (!('studyInstanceUID' in options)) {
1664
+ throw new Error('Study Instance UID is required for retrieval of study metadata');
1665
+ }
1666
+ debugLog("retrieve metadata of study ".concat(options.studyInstanceUID));
1667
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/metadata");
1668
+ var withCredentials = false;
1669
+ if ('withCredentials' in options) {
1670
+ if (options.withCredentials) {
1671
+ withCredentials = options.withCredentials;
1672
+ }
1673
+ }
1674
+ return this._httpGetApplicationJson(url, {}, false, withCredentials);
1675
+ }
1676
+ /**
1677
+ * Searches for DICOM series.
1678
+ *
1679
+ * @param {Object} options
1680
+ * @param {Object} [options.studyInstanceUID] - Study Instance UID
1681
+ * @param {Object} [options.queryParams] - HTTP query parameters
1682
+ * @returns {Object[]} Series representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2a)
1683
+ */
1684
+ }, {
1685
+ key: "searchForSeries",
1686
+ value: function searchForSeries() {
1687
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1688
+ var url = this.qidoURL;
1689
+ if ('studyInstanceUID' in options) {
1690
+ debugLog("search series of study ".concat(options.studyInstanceUID));
1691
+ url += "/studies/".concat(options.studyInstanceUID);
1692
+ }
1693
+ url += '/series';
1694
+ if ('queryParams' in options) {
1695
+ url += DICOMwebClient._parseQueryParameters(options.queryParams);
1696
+ }
1697
+ var withCredentials = false;
1698
+ if ('withCredentials' in options) {
1699
+ if (options.withCredentials) {
1700
+ withCredentials = options.withCredentials;
1701
+ }
1702
+ }
1703
+ return this._httpGetApplicationJson(url, {}, false, withCredentials);
1704
+ }
1705
+ /**
1706
+ * Retrieves metadata for a DICOM series.
1707
+ *
1708
+ * @param {Object} options
1709
+ * @param {String} options.studyInstanceUID - Study Instance UID
1710
+ * @param {String} options.seriesInstanceUID - Series Instance UID
1711
+ * @returns {Promise<InstanceMetadata[]>} Metadata elements in DICOM JSON format for each instance
1712
+ belonging to the series
1713
+ */
1714
+ }, {
1715
+ key: "retrieveSeriesMetadata",
1716
+ value: function retrieveSeriesMetadata(options) {
1717
+ if (!('studyInstanceUID' in options)) {
1718
+ throw new Error('Study Instance UID is required for retrieval of series metadata');
1719
+ }
1720
+ if (!('seriesInstanceUID' in options)) {
1721
+ throw new Error('Series Instance UID is required for retrieval of series metadata');
1722
+ }
1723
+ debugLog("retrieve metadata of series ".concat(options.seriesInstanceUID));
1724
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/metadata");
1725
+ var withCredentials = false;
1726
+ if ('withCredentials' in options) {
1727
+ if (options.withCredentials) {
1728
+ withCredentials = options.withCredentials;
1729
+ }
1730
+ }
1731
+ return this._httpGetApplicationJson(url, {}, false, withCredentials);
1732
+ }
1733
+ /**
1734
+ * Searches for DICOM Instances.
1735
+ *
1736
+ * @param {Object} options
1737
+ * @param {String} [options.studyInstanceUID] - Study Instance UID
1738
+ * @param {String} [options.seriesInstanceUID] - Series Instance UID
1739
+ * @param {Object} [options.queryParams] - HTTP query parameters
1740
+ * @returns {Object[]} Instance representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2b)
1741
+ */
1742
+ }, {
1743
+ key: "searchForInstances",
1744
+ value: function searchForInstances() {
1745
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1746
+ var url = this.qidoURL;
1747
+ var withCredentials = false;
1748
+ if ('studyInstanceUID' in options) {
1749
+ url += "/studies/".concat(options.studyInstanceUID);
1750
+ if ('seriesInstanceUID' in options) {
1751
+ debugLog("search for instances of series ".concat(options.seriesInstanceUID));
1752
+ url += "/series/".concat(options.seriesInstanceUID);
1753
+ } else {
1754
+ debugLog("search for instances of study ".concat(options.studyInstanceUID));
1755
+ }
1756
+ } else {
1757
+ debugLog('search for instances');
1758
+ }
1759
+ url += '/instances';
1760
+ if ('queryParams' in options) {
1761
+ url += DICOMwebClient._parseQueryParameters(options.queryParams);
1762
+ }
1763
+ if ('withCredentials' in options) {
1764
+ if (options.withCredentials) {
1765
+ withCredentials = options.withCredentials;
1766
+ }
1767
+ }
1768
+ return this._httpGetApplicationJson(url, {}, false, withCredentials);
1769
+ }
1770
+ /** Returns a WADO-URI URL for an instance
1771
+ *
1772
+ * @param {Object} options
1773
+ * @param {String} options.studyInstanceUID - Study Instance UID
1774
+ * @param {String} options.seriesInstanceUID - Series Instance UID
1775
+ * @param {String} options.sopInstanceUID - SOP Instance UID
1776
+ * @returns {String} WADO-URI URL
1777
+ */
1778
+ }, {
1779
+ key: "buildInstanceWadoURIUrl",
1780
+ value: function buildInstanceWadoURIUrl(options) {
1781
+ if (!('studyInstanceUID' in options)) {
1782
+ throw new Error('Study Instance UID is required.');
1783
+ }
1784
+ if (!('seriesInstanceUID' in options)) {
1785
+ throw new Error('Series Instance UID is required.');
1786
+ }
1787
+ if (!('sopInstanceUID' in options)) {
1788
+ throw new Error('SOP Instance UID is required.');
1789
+ }
1790
+ var contentType = options.contentType || MEDIATYPES.DICOM;
1791
+ var transferSyntax = options.transferSyntax || '*';
1792
+ var params = [];
1793
+ params.push('requestType=WADO');
1794
+ params.push("studyUID=".concat(options.studyInstanceUID));
1795
+ params.push("seriesUID=".concat(options.seriesInstanceUID));
1796
+ params.push("objectUID=".concat(options.sopInstanceUID));
1797
+ params.push("contentType=".concat(contentType));
1798
+ params.push("transferSyntax=".concat(transferSyntax));
1799
+ var paramString = params.join('&');
1800
+ return "".concat(this.wadoURL, "?").concat(paramString);
1801
+ }
1802
+ /**
1803
+ * Retrieves metadata for a DICOM Instance.
1804
+ *
1805
+ * @param {Object} options object
1806
+ * @param {String} options.studyInstanceUID - Study Instance UID
1807
+ * @param {String} options.seriesInstanceUID - Series Instance UID
1808
+ * @param {String} options.sopInstanceUID - SOP Instance UID
1809
+ * @returns {Promise<InstanceMetadata>} metadata elements in DICOM JSON format
1810
+ */
1811
+ }, {
1812
+ key: "retrieveInstanceMetadata",
1813
+ value: function retrieveInstanceMetadata(options) {
1814
+ if (!('studyInstanceUID' in options)) {
1815
+ throw new Error('Study Instance UID is required for retrieval of instance metadata');
1816
+ }
1817
+ if (!('seriesInstanceUID' in options)) {
1818
+ throw new Error('Series Instance UID is required for retrieval of instance metadata');
1819
+ }
1820
+ if (!('sopInstanceUID' in options)) {
1821
+ throw new Error('SOP Instance UID is required for retrieval of instance metadata');
1822
+ }
1823
+ debugLog("retrieve metadata of instance ".concat(options.sopInstanceUID));
1824
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/metadata");
1825
+ var withCredentials = false;
1826
+ if ('withCredentials' in options) {
1827
+ if (options.withCredentials) {
1828
+ withCredentials = options.withCredentials;
1829
+ }
1830
+ }
1831
+ return this._httpGetApplicationJson(url, {}, false, withCredentials);
1832
+ }
1833
+ /**
1834
+ * Retrieves frames for a DICOM Instance.
1835
+ * @param {Object} options options object
1836
+ * @param {String} options.studyInstanceUID - Study Instance UID
1837
+ * @param {String} options.seriesInstanceUID - Series Instance UID
1838
+ * @param {String} options.sopInstanceUID - SOP Instance UID
1839
+ * @param {String} options.frameNumbers - One-based indices of Frame Items
1840
+ * @returns {Array} frame items as byte arrays of the pixel data element
1841
+ */
1842
+ }, {
1843
+ key: "retrieveInstanceFrames",
1844
+ value: function retrieveInstanceFrames(options) {
1845
+ if (!('studyInstanceUID' in options)) {
1846
+ throw new Error('Study Instance UID is required for retrieval of instance frames');
1847
+ }
1848
+ if (!('seriesInstanceUID' in options)) {
1849
+ throw new Error('Series Instance UID is required for retrieval of instance frames');
1850
+ }
1851
+ if (!('sopInstanceUID' in options)) {
1852
+ throw new Error('SOP Instance UID is required for retrieval of instance frames');
1853
+ }
1854
+ if (!('frameNumbers' in options)) {
1855
+ throw new Error('frame numbers are required for retrieval of instance frames');
1856
+ }
1857
+ debugLog("retrieve frames ".concat(options.frameNumbers.toString(), " of instance ").concat(options.sopInstanceUID));
1858
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/frames/").concat(options.frameNumbers.toString());
1859
+ var mediaTypes = options.mediaTypes;
1860
+ var withCredentials = false;
1861
+ if ('withCredentials' in options) {
1862
+ if (options.withCredentials) {
1863
+ withCredentials = options.withCredentials;
1864
+ }
1865
+ }
1866
+ var progressCallback = false;
1867
+ if ('progressCallback' in options) {
1868
+ progressCallback = options.progressCallback;
1869
+ }
1870
+ if (!mediaTypes) {
1871
+ return this._httpGetMultipartApplicationOctetStream(url, false, false, false, progressCallback, withCredentials);
1872
+ }
1873
+ var sharedMediaTypes = DICOMwebClient._getSharedMediaTypes(mediaTypes);
1874
+ if (sharedMediaTypes.length > 1) {
1875
+ /**
1876
+ * Enable request of frames that are stored either compressed
1877
+ * (image/* media type) or uncompressed (application/octet-stream
1878
+ * media type).
1879
+ */
1880
+ var supportedMediaTypes = {
1881
+ '1.2.840.10008.1.2.1': ['application/octet-stream'],
1882
+ '1.2.840.10008.1.2.5': ['image/x-dicom-rle'],
1883
+ '1.2.840.10008.1.2.4.50': ['image/jpeg'],
1884
+ '1.2.840.10008.1.2.4.51': ['image/jpeg'],
1885
+ '1.2.840.10008.1.2.4.57': ['image/jpeg'],
1886
+ '1.2.840.10008.1.2.4.70': ['image/jpeg'],
1887
+ '1.2.840.10008.1.2.4.80': ['image/x-jls', 'image/jls'],
1888
+ '1.2.840.10008.1.2.4.81': ['image/x-jls', 'image/jls'],
1889
+ '1.2.840.10008.1.2.4.90': ['image/jp2'],
1890
+ '1.2.840.10008.1.2.4.91': ['image/jp2'],
1891
+ '1.2.840.10008.1.2.4.92': ['image/jpx'],
1892
+ '1.2.840.10008.1.2.4.93': ['image/jpx'],
1893
+ '1.2.840.10008.1.2.4.201': ['image/jhc'],
1894
+ '1.2.840.10008.1.2.4.202': ['image/jhc']
1895
+ };
1896
+ var headers = {
1897
+ Accept: DICOMwebClient._buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes)
1898
+ };
1899
+ return this._httpGet(url, headers, 'arraybuffer', progressCallback, withCredentials);
1900
+ }
1901
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1902
+ if (commonMediaType.startsWith('application')) {
1903
+ return this._httpGetMultipartApplicationOctetStream(url, mediaTypes, false, false, progressCallback, withCredentials);
1904
+ }
1905
+ if (commonMediaType.startsWith('image')) {
1906
+ return this._httpGetMultipartImage(url, mediaTypes, false, false, false, progressCallback, withCredentials);
1907
+ }
1908
+ if (commonMediaType.startsWith('video')) {
1909
+ return this._httpGetMultipartVideo(url, mediaTypes, false, false, false, progressCallback, withCredentials);
1910
+ }
1911
+ throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of frames."));
1912
+ }
1913
+ /**
1914
+ * Element in mediaTypes parameter
1915
+ * @typedef {Object} MediaType
1916
+ * @param {String} [MediaType.mediaType] - ie 'image/jpeg', 'image/png'...
1917
+ */
1918
+ /**
1919
+ * Retrieves an individual, server-side rendered DICOM Instance.
1920
+ *
1921
+ * @param {Object} options
1922
+ * @param {String} options.studyInstanceUID - Study Instance UID
1923
+ * @param {String} options.seriesInstanceUID - Series Instance UID
1924
+ * @param {String} options.sopInstanceUID - SOP Instance UID
1925
+ * @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
1926
+ * @param {Object} [options.queryParams] - HTTP query parameters
1927
+ * @returns {Promise<ArrayBuffer>} Rendered DICOM Instance
1928
+ */
1929
+ }, {
1930
+ key: "retrieveInstanceRendered",
1931
+ value: function retrieveInstanceRendered(options) {
1932
+ if (!('studyInstanceUID' in options)) {
1933
+ throw new Error('Study Instance UID is required for retrieval of rendered instance');
1934
+ }
1935
+ if (!('seriesInstanceUID' in options)) {
1936
+ throw new Error('Series Instance UID is required for retrieval of rendered instance');
1937
+ }
1938
+ if (!('sopInstanceUID' in options)) {
1939
+ throw new Error('SOP Instance UID is required for retrieval of rendered instance');
1940
+ }
1941
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/rendered");
1942
+ var mediaTypes = options.mediaTypes,
1943
+ queryParams = options.queryParams;
1944
+ var headers = {};
1945
+ var withCredentials = false;
1946
+ if ('withCredentials' in options) {
1947
+ if (options.withCredentials) {
1948
+ withCredentials = options.withCredentials;
1949
+ }
1950
+ }
1951
+ var progressCallback = false;
1952
+ if ('progressCallback' in options) {
1953
+ progressCallback = options.progressCallback;
1954
+ }
1955
+ if (!mediaTypes) {
1956
+ var responseType = 'arraybuffer';
1957
+ if (queryParams) {
1958
+ url += DICOMwebClient._parseQueryParameters(queryParams);
1959
+ }
1960
+ return this._httpGet(url, headers, responseType, progressCallback, withCredentials);
1961
+ }
1962
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
1963
+ if (commonMediaType.startsWith('image')) {
1964
+ return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
1965
+ }
1966
+ if (commonMediaType.startsWith('video')) {
1967
+ return this._httpGetVideo(url, mediaTypes, queryParams, progressCallback, withCredentials);
1968
+ }
1969
+ if (commonMediaType.startsWith('text')) {
1970
+ return this._httpGetText(url, mediaTypes, queryParams, progressCallback, withCredentials);
1971
+ }
1972
+ if (commonMediaType === MEDIATYPES.PDF) {
1973
+ return this._httpGetApplicationPdf(url, queryParams, progressCallback, withCredentials);
1974
+ }
1975
+ throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered instance.');
1976
+ }
1977
+ /**
1978
+ * Retrieves a thumbnail of an DICOM Instance.
1979
+ *
1980
+ * @param {Object} options
1981
+ * @param {String} options.studyInstanceUID - Study Instance UID
1982
+ * @param {String} options.seriesInstanceUID - Series Instance UID
1983
+ * @param {String} options.sopInstanceUID - SOP Instance UID
1984
+ * @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
1985
+ * @param {Object} [options.queryParams] - HTTP query parameters
1986
+ * @returns {ArrayBuffer} Thumbnail
1987
+ */
1988
+ }, {
1989
+ key: "retrieveInstanceThumbnail",
1990
+ value: function retrieveInstanceThumbnail(options) {
1991
+ if (!('studyInstanceUID' in options)) {
1992
+ throw new Error('Study Instance UID is required for retrieval of rendered instance');
1993
+ }
1994
+ if (!('seriesInstanceUID' in options)) {
1995
+ throw new Error('Series Instance UID is required for retrieval of rendered instance');
1996
+ }
1997
+ if (!('sopInstanceUID' in options)) {
1998
+ throw new Error('SOP Instance UID is required for retrieval of rendered instance');
1999
+ }
2000
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/thumbnail");
2001
+ var mediaTypes = options.mediaTypes,
2002
+ queryParams = options.queryParams;
2003
+ var headers = {};
2004
+ var withCredentials = false;
2005
+ if ('withCredentials' in options) {
2006
+ if (options.withCredentials) {
2007
+ withCredentials = options.withCredentials;
2008
+ }
2009
+ }
2010
+ var progressCallback = false;
2011
+ if ('progressCallback' in options) {
2012
+ progressCallback = options.progressCallback;
2013
+ }
2014
+ if (!mediaTypes) {
2015
+ var responseType = 'arraybuffer';
2016
+ if (queryParams) {
2017
+ url += DICOMwebClient._parseQueryParameters(queryParams);
2018
+ }
2019
+ return this._httpGet(url, headers, responseType, progressCallback, withCredentials);
2020
+ }
2021
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2022
+ if (commonMediaType.startsWith('image')) {
2023
+ return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
2024
+ }
2025
+ throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered instance.');
2026
+ }
2027
+ /**
2028
+ * Retrieves rendered frames for a DICOM Instance.
2029
+ *
2030
+ * @param {Object} options
2031
+ * @param {String} options.studyInstanceUID - Study Instance UID
2032
+ * @param {String} options.seriesInstanceUID - Series Instance UID
2033
+ * @param {String} options.sopInstanceUID - SOP Instance UID
2034
+ * @param {String} options.frameNumbers - One-based indices of Frame Items
2035
+ * @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
2036
+ * @param {Object} [options.queryParams] - HTTP query parameters
2037
+ * @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays
2038
+ */
2039
+ }, {
2040
+ key: "retrieveInstanceFramesRendered",
2041
+ value: function retrieveInstanceFramesRendered(options) {
2042
+ if (!('studyInstanceUID' in options)) {
2043
+ throw new Error('Study Instance UID is required for retrieval of rendered instance frames');
2044
+ }
2045
+ if (!('seriesInstanceUID' in options)) {
2046
+ throw new Error('Series Instance UID is required for retrieval of rendered instance frames');
2047
+ }
2048
+ if (!('sopInstanceUID' in options)) {
2049
+ throw new Error('SOP Instance UID is required for retrieval of rendered instance frames');
2050
+ }
2051
+ if (!('frameNumbers' in options)) {
2052
+ throw new Error('frame numbers are required for retrieval of rendered instance frames');
2053
+ }
2054
+ debugLog("retrieve rendered frames ".concat(options.frameNumbers.toString(), " of instance ").concat(options.sopInstanceUID));
2055
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/frames/").concat(options.frameNumbers.toString(), "/rendered");
2056
+ var mediaTypes = options.mediaTypes,
2057
+ queryParams = options.queryParams;
2058
+ var headers = {};
2059
+ var withCredentials = false;
2060
+ if ('withCredentials' in options) {
2061
+ if (options.withCredentials) {
2062
+ withCredentials = options.withCredentials;
2063
+ }
2064
+ }
2065
+ var progressCallback = false;
2066
+ if ('progressCallback' in options) {
2067
+ progressCallback = options.progressCallback;
2068
+ }
2069
+ if (!mediaTypes) {
2070
+ var responseType = 'arraybuffer';
2071
+ if (queryParams) {
2072
+ url += DICOMwebClient._parseQueryParameters(queryParams);
2073
+ }
2074
+ return this._httpGet(url, headers, responseType, false, withCredentials);
2075
+ }
2076
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2077
+ if (commonMediaType.startsWith('image')) {
2078
+ return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
2079
+ }
2080
+ if (commonMediaType.startsWith('video')) {
2081
+ return this._httpGetVideo(url, mediaTypes, queryParams, progressCallback, withCredentials);
2082
+ }
2083
+ throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered frame.');
2084
+ }
2085
+ /**
2086
+ * Retrieves thumbnail of frames for a DICOM Instance.
2087
+ *
2088
+ * @param {Object} options
2089
+ * @param {String} options.studyInstanceUID - Study Instance UID
2090
+ * @param {String} options.seriesInstanceUID - Series Instance UID
2091
+ * @param {String} options.sopInstanceUID - SOP Instance UID
2092
+ * @param {String} options.frameNumbers - One-based indices of Frame Items
2093
+ * @param {Object} [options.queryParams] - HTTP query parameters
2094
+ * @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays
2095
+ */
2096
+ }, {
2097
+ key: "retrieveInstanceFramesThumbnail",
2098
+ value: function retrieveInstanceFramesThumbnail(options) {
2099
+ if (!('studyInstanceUID' in options)) {
2100
+ throw new Error('Study Instance UID is required for retrieval of rendered instance frames');
2101
+ }
2102
+ if (!('seriesInstanceUID' in options)) {
2103
+ throw new Error('Series Instance UID is required for retrieval of rendered instance frames');
2104
+ }
2105
+ if (!('sopInstanceUID' in options)) {
2106
+ throw new Error('SOP Instance UID is required for retrieval of rendered instance frames');
2107
+ }
2108
+ if (!('frameNumbers' in options)) {
2109
+ throw new Error('frame numbers are required for retrieval of rendered instance frames');
2110
+ }
2111
+ console.debug("retrieve rendered frames ".concat(options.frameNumbers.toString(), " of instance ").concat(options.sopInstanceUID));
2112
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID, "/frames/").concat(options.frameNumbers.toString(), "/thumbnail");
2113
+ var mediaTypes = options.mediaTypes,
2114
+ queryParams = options.queryParams;
2115
+ var headers = {};
2116
+ var withCredentials = false;
2117
+ if ('withCredentials' in options) {
2118
+ if (options.withCredentials) {
2119
+ withCredentials = options.withCredentials;
2120
+ }
2121
+ }
2122
+ var progressCallback = false;
2123
+ if ('progressCallback' in options) {
2124
+ progressCallback = options.progressCallback;
2125
+ }
2126
+ if (!mediaTypes) {
2127
+ var responseType = 'arraybuffer';
2128
+ if (queryParams) {
2129
+ url += DICOMwebClient._parseQueryParameters(queryParams);
2130
+ }
2131
+ return this._httpGet(url, headers, responseType, progressCallback, withCredentials);
2132
+ }
2133
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2134
+ if (commonMediaType.startsWith('image')) {
2135
+ return this._httpGetImage(url, mediaTypes, queryParams, progressCallback, withCredentials);
2136
+ }
2137
+ throw new Error("Media type ".concat(commonMediaType, " is not supported ") + 'for retrieval of rendered frame.');
2138
+ }
2139
+ /**
2140
+ * Retrieves a DICOM Instance.
2141
+ *
2142
+ * @param {Object} options
2143
+ * @param {String} options.studyInstanceUID - Study Instance UID
2144
+ * @param {String} options.seriesInstanceUID - Series Instance UID
2145
+ * @param {String} options.sopInstanceUID - SOP Instance UID
2146
+ * @returns {Promise<ArrayBuffer>} DICOM Part 10 file as Arraybuffer
2147
+ */
2148
+ }, {
2149
+ key: "retrieveInstance",
2150
+ value: function retrieveInstance(options) {
2151
+ if (!('studyInstanceUID' in options)) {
2152
+ throw new Error('Study Instance UID is required');
2153
+ }
2154
+ if (!('seriesInstanceUID' in options)) {
2155
+ throw new Error('Series Instance UID is required');
2156
+ }
2157
+ if (!('sopInstanceUID' in options)) {
2158
+ throw new Error('SOP Instance UID is required');
2159
+ }
2160
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID, "/instances/").concat(options.sopInstanceUID);
2161
+ var mediaTypes = options.mediaTypes;
2162
+ var _options$withCredenti = options.withCredentials,
2163
+ withCredentials = _options$withCredenti === void 0 ? false : _options$withCredenti;
2164
+ var _options$progressCall = options.progressCallback,
2165
+ progressCallback = _options$progressCall === void 0 ? false : _options$progressCall;
2166
+ if (!mediaTypes) {
2167
+ return this._httpGetMultipartApplicationDicom(url, false, false, progressCallback, withCredentials).then(getFirstResult);
2168
+ }
2169
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2170
+ if (commonMediaType === MEDIATYPES.DICOM) {
2171
+ return this._httpGetMultipartApplicationDicom(url, mediaTypes, false, progressCallback, withCredentials).then(getFirstResult);
2172
+ }
2173
+ throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of instance."));
2174
+ }
2175
+ /**
2176
+ * Retrieves all DICOM Instances of a Series.
2177
+ *
2178
+ * @param {Object} options
2179
+ * @param {String} options.studyInstanceUID - Study Instance UID
2180
+ * @param {String} options.seriesInstanceUID - Series Instance UID
2181
+ * @param {Function} options.progressCallback
2182
+ * @returns {Promise<ArrayBuffer[]>} DICOM Instances
2183
+ */
2184
+ }, {
2185
+ key: "retrieveSeries",
2186
+ value: function retrieveSeries(options) {
2187
+ if (!('studyInstanceUID' in options)) {
2188
+ throw new Error('Study Instance UID is required');
2189
+ }
2190
+ if (!('seriesInstanceUID' in options)) {
2191
+ throw new Error('Series Instance UID is required');
2192
+ }
2193
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID, "/series/").concat(options.seriesInstanceUID);
2194
+ var mediaTypes = options.mediaTypes;
2195
+ var withCredentials = false;
2196
+ if ('withCredentials' in options) {
2197
+ if (options.withCredentials) {
2198
+ withCredentials = options.withCredentials;
2199
+ }
2200
+ }
2201
+ var progressCallback = false;
2202
+ if ('progressCallback' in options) {
2203
+ progressCallback = options.progressCallback;
2204
+ }
2205
+ if (!mediaTypes) {
2206
+ return this._httpGetMultipartApplicationDicom(url, false, false, progressCallback, withCredentials);
2207
+ }
2208
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2209
+ if (commonMediaType === MEDIATYPES.DICOM) {
2210
+ return this._httpGetMultipartApplicationDicom(url, mediaTypes, false, progressCallback, withCredentials);
2211
+ }
2212
+ throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of series."));
2213
+ }
2214
+ /**
2215
+ * Retrieves all DICOM Instances of a Study.
2216
+ *
2217
+ * @param {Object} options
2218
+ * @param {String} options.studyInstanceUID - Study Instance UID
2219
+ * @returns {ArrayBuffer[]} DICOM Instances
2220
+ */
2221
+ }, {
2222
+ key: "retrieveStudy",
2223
+ value: function retrieveStudy(options) {
2224
+ if (!('studyInstanceUID' in options)) {
2225
+ throw new Error('Study Instance UID is required');
2226
+ }
2227
+ var url = "".concat(this.wadoURL, "/studies/").concat(options.studyInstanceUID);
2228
+ var mediaTypes = options.mediaTypes;
2229
+ var _options$withCredenti2 = options.withCredentials,
2230
+ withCredentials = _options$withCredenti2 === void 0 ? false : _options$withCredenti2;
2231
+ var _options$progressCall2 = options.progressCallback,
2232
+ progressCallback = _options$progressCall2 === void 0 ? false : _options$progressCall2;
2233
+ if (!mediaTypes) {
2234
+ return this._httpGetMultipartApplicationDicom(url, false, false, progressCallback, withCredentials);
2235
+ }
2236
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2237
+ if (commonMediaType === MEDIATYPES.DICOM) {
2238
+ return this._httpGetMultipartApplicationDicom(url, mediaTypes, false, progressCallback, withCredentials);
2239
+ }
2240
+ throw new Error("Media type ".concat(commonMediaType, " is not supported for retrieval of study."));
2241
+ }
2242
+ /**
2243
+ * Retrieves and parses BulkData from a BulkDataURI location.
2244
+ * Decodes the multipart encoded data and returns the resulting data
2245
+ * as an ArrayBuffer.
2246
+ *
2247
+ * See http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.5.5.html
2248
+ *
2249
+ * @param {Object} options
2250
+ * @param {string} options.BulkDataURI to retrieve
2251
+ * @param {Array} options.mediaTypes to use to fetch the URI
2252
+ * @param {string} options.byteRange to request a sub-range (only valid on single part)
2253
+ * @returns {Promise<Array>} Bulkdata parts
2254
+ */
2255
+ }, {
2256
+ key: "retrieveBulkData",
2257
+ value: function retrieveBulkData(options) {
2258
+ if (!('BulkDataURI' in options)) {
2259
+ throw new Error('BulkDataURI is required.');
2260
+ }
2261
+ var url = options.BulkDataURI;
2262
+ var mediaTypes = options.mediaTypes,
2263
+ byteRange = options.byteRange;
2264
+ var _options$withCredenti3 = options.withCredentials,
2265
+ withCredentials = _options$withCredenti3 === void 0 ? false : _options$withCredenti3;
2266
+ var _options$progressCall3 = options.progressCallback,
2267
+ progressCallback = _options$progressCall3 === void 0 ? false : _options$progressCall3;
2268
+ if (this.singlepart.indexOf('bulkdata') !== -1) {
2269
+ return this._httpGet(url, options.headers, 'arraybuffer', null, withCredentials);
2270
+ }
2271
+ if (mediaTypes) {
2272
+ try {
2273
+ var commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);
2274
+ if (commonMediaType === 'image/') {
2275
+ return this._httpGetMultipartImage(url, mediaTypes, byteRange, false, false, progressCallback, withCredentials);
2276
+ }
2277
+ } catch (e) {
2278
+ // No-op - this happens sometimes if trying to fetch the specific desired type but want to fallback to octet-stream
2279
+ }
2280
+ }
2281
+
2282
+ // Just use the media types provided
2283
+ return this._httpGetMultipartApplicationOctetStream(url, mediaTypes, byteRange, false, progressCallback, withCredentials);
2284
+ }
2285
+ /**
2286
+ * Stores DICOM Instances.
2287
+ *
2288
+ * @param {Object} options
2289
+ * @param {ArrayBuffer[]} options.datasets - DICOM Instances in PS3.10 format
2290
+ * @param {String} [options.studyInstanceUID] - Study Instance UID
2291
+ * @param {XMLHttpRequest} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
2292
+ * @returns {Promise} Response message
2293
+ */
2294
+ }, {
2295
+ key: "storeInstances",
2296
+ value: function storeInstances(options) {
2297
+ if (!('datasets' in options)) {
2298
+ throw new Error('datasets are required for storing');
2299
+ }
2300
+ var url = "".concat(this.stowURL, "/studies");
2301
+ if ('studyInstanceUID' in options) {
2302
+ url += "/".concat(options.studyInstanceUID);
2303
+ }
2304
+ var _multipartEncode = multipartEncode(options.datasets),
2305
+ data = _multipartEncode.data,
2306
+ boundary = _multipartEncode.boundary;
2307
+ var headers = {
2308
+ 'Content-Type': "multipart/related; type=\"application/dicom\"; boundary=\"".concat(boundary, "\"")
2309
+ };
2310
+ var _options$withCredenti4 = options.withCredentials,
2311
+ withCredentials = _options$withCredenti4 === void 0 ? false : _options$withCredenti4;
2312
+ return this._httpPost(url, headers, data, options.progressCallback, withCredentials, options.request);
2313
+ }
2314
+ }], [{
2315
+ key: "_parseQueryParameters",
2316
+ value: function _parseQueryParameters() {
2317
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2318
+ var queryString = '?';
2319
+ Object.keys(params).forEach(function (key, index) {
2320
+ if (index !== 0) {
2321
+ queryString += '&';
2322
+ }
2323
+ queryString += "".concat(key, "=").concat(encodeURIComponent(params[key]));
2324
+ });
2325
+ return queryString;
2326
+ }
2327
+ }, {
2328
+ key: "_assertMediaTypeIsValid",
2329
+ value: function _assertMediaTypeIsValid(mediaType) {
2330
+ if (!mediaType) {
2331
+ throw new Error("Not a valid media type: ".concat(mediaType));
2332
+ }
2333
+ var sepIndex = mediaType.indexOf('/');
2334
+ if (sepIndex === -1) {
2335
+ throw new Error("Not a valid media type: ".concat(mediaType));
2336
+ }
2337
+ var mediaTypeType = mediaType.slice(0, sepIndex);
2338
+ var types = ['application', 'image', 'text', 'video'];
2339
+ if (!types.includes(mediaTypeType)) {
2340
+ throw new Error("Not a valid media type: ".concat(mediaType));
2341
+ }
2342
+ if (mediaType.slice(sepIndex + 1).includes('/')) {
2343
+ throw new Error("Not a valid media type: ".concat(mediaType));
2344
+ }
2345
+ }
2346
+ }, {
2347
+ key: "_parseMediaType",
2348
+ value: function _parseMediaType(mediaType) {
2349
+ DICOMwebClient._assertMediaTypeIsValid(mediaType);
2350
+ return mediaType.split('/');
2351
+ }
2352
+ /**
2353
+ * Builds an accept header field value for HTTP GET request messages.
2354
+ *
2355
+ * @param {Object[]} mediaTypes - Acceptable media types
2356
+ * @param {Object[]} supportedMediaTypes - Supported media types
2357
+ * @return {*}
2358
+ * @private
2359
+ */
2360
+ }, {
2361
+ key: "_buildAcceptHeaderFieldValue",
2362
+ value: function _buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes) {
2363
+ if (!Array.isArray(mediaTypes)) {
2364
+ throw new Error('Acceptable media types must be provided as an Array');
2365
+ }
2366
+ var fieldValueParts = mediaTypes.map(function (item) {
2367
+ var mediaType = item.mediaType;
2368
+ DICOMwebClient._assertMediaTypeIsValid(mediaType);
2369
+ if (!supportedMediaTypes.includes(mediaType)) {
2370
+ throw new Error("Media type ".concat(mediaType, " is not supported for requested resource"));
2371
+ }
2372
+ return mediaType;
2373
+ });
2374
+ return fieldValueParts.join(', ');
2375
+ }
2376
+ /**
2377
+ * Builds an accept header field value for HTTP GET multipart request
2378
+ * messages. Will throw an exception if no media types are found which are acceptable,
2379
+ * but will only log a verbose level message when types are specified which are
2380
+ * not acceptable. This allows requesting several types with having to know
2381
+ * whether they are all acceptable or not.
2382
+ *
2383
+ * @param {Object[]} mediaTypes - Acceptable media types
2384
+ * @param {Object[]} supportedMediaTypes - Supported media types
2385
+ * @private
2386
+ */
2387
+ }, {
2388
+ key: "_buildMultipartAcceptHeaderFieldValue",
2389
+ value: function _buildMultipartAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes) {
2390
+ var _this2 = this;
2391
+ if (!Array.isArray(mediaTypes)) {
2392
+ throw new Error('Acceptable media types must be provided as an Array');
2393
+ }
2394
+ if (!Array.isArray(supportedMediaTypes) && !isObject(supportedMediaTypes)) {
2395
+ throw new Error('Supported media types must be provided as an Array or an Object');
2396
+ }
2397
+ var fieldValueParts = [];
2398
+ mediaTypes.forEach(function (item) {
2399
+ var transferSyntaxUID = item.transferSyntaxUID,
2400
+ mediaType = item.mediaType;
2401
+ DICOMwebClient._assertMediaTypeIsValid(mediaType);
2402
+ var fieldValue = "multipart/related; type=\"".concat(mediaType, "\"");
2403
+ if (isObject(supportedMediaTypes)) {
2404
+ // SupportedMediaTypes is a lookup table that maps Transfer Syntax UID
2405
+ // to one or more Media Types
2406
+ if (!Object.values(supportedMediaTypes).flat(1).includes(mediaType)) {
2407
+ if (!mediaType.endsWith('/*') || !mediaType.endsWith('/')) {
2408
+ debugLog("Media type ".concat(mediaType, " is not supported for requested resource"));
2409
+ return;
2410
+ }
2411
+ }
2412
+ if (transferSyntaxUID) {
2413
+ if (transferSyntaxUID !== '*') {
2414
+ if (!Object.keys(supportedMediaTypes).includes(transferSyntaxUID)) {
2415
+ throw new Error("Transfer syntax ".concat(transferSyntaxUID, " is not supported for requested resource"));
2416
+ }
2417
+ var expectedMediaTypes = supportedMediaTypes[transferSyntaxUID];
2418
+ if (!expectedMediaTypes.includes(mediaType)) {
2419
+ var actualType = DICOMwebClient._parseMediaType(mediaType)[0];
2420
+ expectedMediaTypes.map(function (expectedMediaType) {
2421
+ var expectedType = DICOMwebClient._parseMediaType(expectedMediaType)[0];
2422
+ var haveSameType = actualType === expectedType;
2423
+ if (haveSameType && (mediaType.endsWith('/*') || mediaType.endsWith('/'))) {
2424
+ return;
2425
+ }
2426
+ throw new Error("Transfer syntax ".concat(transferSyntaxUID, " is not supported for requested resource"));
2427
+ });
2428
+ }
2429
+ }
2430
+ fieldValue += "; transfer-syntax=".concat(transferSyntaxUID);
2431
+ }
2432
+ } else if (Array.isArray(supportedMediaTypes) && !supportedMediaTypes.includes(mediaType)) {
2433
+ if (_this2.verbose) {
2434
+ console.warn("Media type ".concat(mediaType, " is not supported for requested resource"));
2435
+ }
2436
+ return;
2437
+ }
2438
+ fieldValueParts.push(fieldValue);
2439
+ });
2440
+ if (!fieldValueParts.length) {
2441
+ throw new Error("No acceptable media types found among ".concat(JSON.stringify(mediaTypes)));
2442
+ }
2443
+ return fieldValueParts.join(', ');
2444
+ }
2445
+ /**
2446
+ * Builds a range header field value for HTTP GET request messages.
2447
+ *
2448
+ * @param {Array} byteRange - Start and end of byte range
2449
+ * @returns {String} Range header field value
2450
+ * @private
2451
+ */
2452
+ }, {
2453
+ key: "_buildRangeHeaderFieldValue",
2454
+ value: function _buildRangeHeaderFieldValue() {
2455
+ var byteRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2456
+ if (byteRange.length === 1) {
2457
+ return "bytes=".concat(byteRange[0], "-");
2458
+ }
2459
+ if (byteRange.length === 2) {
2460
+ return "bytes=".concat(byteRange[0], "-").concat(byteRange[1]);
2461
+ }
2462
+ return 'bytes=0-';
2463
+ }
2464
+ /**
2465
+ * Gets types that are shared among acceptable media types.
2466
+ *
2467
+ * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
2468
+ corresponding transfer syntaxes
2469
+ * @private
2470
+ * @returns {String[]} Types that are shared among acceptable media types
2471
+ */
2472
+ }, {
2473
+ key: "_getSharedMediaTypes",
2474
+ value: function _getSharedMediaTypes(mediaTypes) {
2475
+ var types = new Set();
2476
+ if (!mediaTypes || !mediaTypes.length) {
2477
+ return types;
2478
+ }
2479
+ mediaTypes.forEach(function (item) {
2480
+ var mediaType = item.mediaType;
2481
+ var type = DICOMwebClient._parseMediaType(mediaType)[0];
2482
+ types.add("".concat(type, "/"));
2483
+ });
2484
+ return Array.from(types);
2485
+ }
2486
+ /**
2487
+ * Gets common base type of acceptable media types and asserts that only
2488
+ one type is specified. For example, ``("image/jpeg", "image/jp2")``
2489
+ will pass, but ``("image/jpeg", "video/mpeg2")`` will raise an
2490
+ exception.
2491
+ *
2492
+ * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the
2493
+ corresponding transfer syntaxes
2494
+ * @private
2495
+ * @returns {String[]} Common media type, eg `image/` for the above example.
2496
+ */
2497
+ }, {
2498
+ key: "_getCommonMediaType",
2499
+ value: function _getCommonMediaType(mediaTypes) {
2500
+ if (!mediaTypes || !mediaTypes.length) {
2501
+ throw new Error('No acceptable media types provided');
2502
+ }
2503
+ var sharedMediaTypes = DICOMwebClient._getSharedMediaTypes(mediaTypes);
2504
+ if (sharedMediaTypes.length === 0) {
2505
+ throw new Error('No common acceptable media type could be identified.');
2506
+ } else if (sharedMediaTypes.length > 1) {
2507
+ throw new Error('Acceptable media types must have the same type.');
2508
+ }
2509
+ return sharedMediaTypes[0];
2510
+ }
2511
+ }]);
2512
+ return DICOMwebClient;
2513
+ }();
2514
+
2515
+ function findSubstring(str, before, after) {
2516
+ var beforeIndex = str.lastIndexOf(before) + before.length;
2517
+ if (beforeIndex < before.length) {
2518
+ return null;
2519
+ }
2520
+ if (after !== undefined) {
2521
+ var afterIndex = str.lastIndexOf(after);
2522
+ if (afterIndex < 0) {
2523
+ return null;
2524
+ }
2525
+ return str.substring(beforeIndex, afterIndex);
2526
+ }
2527
+ return str.substring(beforeIndex);
2528
+ }
2529
+ function getStudyInstanceUIDFromUri(uri) {
2530
+ var uid = findSubstring(uri, 'studies/', '/series');
2531
+ if (!uid) {
2532
+ uid = findSubstring(uri, 'studies/');
2533
+ }
2534
+ if (!uid) {
2535
+ console.debug("Study Instance UID could not be dertermined from URI \"".concat(uri, "\""));
2536
+ }
2537
+ return uid;
2538
+ }
2539
+ function getSeriesInstanceUIDFromUri(uri) {
2540
+ var uid = findSubstring(uri, 'series/', '/instances');
2541
+ if (!uid) {
2542
+ uid = findSubstring(uri, 'series/');
2543
+ }
2544
+ if (!uid) {
2545
+ console.debug("Series Instance UID could not be dertermined from URI \"".concat(uri, "\""));
2546
+ }
2547
+ return uid;
2548
+ }
2549
+ function getSOPInstanceUIDFromUri(uri) {
2550
+ var uid = findSubstring(uri, '/instances/', '/frames');
2551
+ if (!uid) {
2552
+ uid = findSubstring(uri, '/instances/', '/metadata');
2553
+ }
2554
+ if (!uid) {
2555
+ uid = findSubstring(uri, '/instances/');
2556
+ }
2557
+ if (!uid) {
2558
+ console.debug("SOP Instance UID could not be dertermined from URI\"".concat(uri, "\""));
2559
+ }
2560
+ return uid;
2561
+ }
2562
+ function getFrameNumbersFromUri(uri) {
2563
+ var numbers = findSubstring(uri, '/frames/', '/rendered');
2564
+ if (!numbers) {
2565
+ numbers = findSubstring(uri, '/frames/');
2566
+ }
2567
+ if (numbers === undefined) {
2568
+ console.debug("Frame Numbers could not be dertermined from URI\"".concat(uri, "\""));
2569
+ }
2570
+ return numbers.split(',');
2571
+ }
2572
+
2573
+ var version = '0.5.2';
2574
+
2575
+ var api = {
2576
+ DICOMwebClient: DICOMwebClient
2577
+ };
2578
+ var utils = {
2579
+ getStudyInstanceUIDFromUri: getStudyInstanceUIDFromUri,
2580
+ getSeriesInstanceUIDFromUri: getSeriesInstanceUIDFromUri,
2581
+ getSOPInstanceUIDFromUri: getSOPInstanceUIDFromUri,
2582
+ getFrameNumbersFromUri: getFrameNumbersFromUri
2583
+ };
2584
+
2585
+
2586
+
2587
+
642
2588
  /***/ }),
643
2589
 
644
2590
  /***/ 94614: