fluent-cerner-js 1.0.0-1 → 1.0.0-2

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.
@@ -112,7 +112,7 @@ function _regeneratorRuntime() {
112
112
  function makeInvokeMethod(e, r, n) {
113
113
  var o = h;
114
114
  return function (i, a) {
115
- if (o === f) throw new Error("Generator is already running");
115
+ if (o === f) throw Error("Generator is already running");
116
116
  if (o === s) {
117
117
  if ("throw" === i) throw a;
118
118
  return {
@@ -254,7 +254,7 @@ function _regeneratorRuntime() {
254
254
  } else if (c) {
255
255
  if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
256
256
  } else {
257
- if (!u) throw new Error("try statement without catch or finally");
257
+ if (!u) throw Error("try statement without catch or finally");
258
258
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
259
259
  }
260
260
  }
@@ -294,7 +294,7 @@ function _regeneratorRuntime() {
294
294
  return o;
295
295
  }
296
296
  }
297
- throw new Error("illegal catch attempt");
297
+ throw Error("illegal catch attempt");
298
298
  },
299
299
  delegateYield: function (e, r, n) {
300
300
  return this.delegate = {
@@ -343,7 +343,7 @@ function _asyncToGenerator(fn) {
343
343
  * from being outside of Cerner PowerChart.
344
344
  */
345
345
  function outsideOfPowerChartError(e) {
346
- return e instanceof TypeError && e.message === 'window.external.MPAGES_EVENT is not a function' || e instanceof TypeError && e.message === 'window.external.XMLCclRequest is not a function' || e instanceof TypeError && e.message === 'window.external.APPLINK is not a function' || e instanceof TypeError && e.message === 'window.external.DiscernObjectFactory is not a function';
346
+ return e instanceof TypeError && /(MPAGES_EVENT|XMLCclRequest|APPLINK|DiscernObjectFactory) is not a function/i.test(e.message);
347
347
  }
348
348
  /**
349
349
  * A wrapper function for the `console.warn` function which logs a warning message.
@@ -921,7 +921,11 @@ var launchPowerNoteAsync = /*#__PURE__*/function () {
921
921
  * @param excludeMine {boolean} - (optional) determines whether or not to include the "MINE" parameter as the
922
922
  * first parameter in the CCL request's argument list.
923
923
  * @resolves `CclRequestResponse<T>`.
924
+ * @rejects {Error} if the `prg` parameter is an empty string.
925
+ * @rejects {Error} if the request fails for any reason.
924
926
  */
927
+ // For more information on the XMLCclRequest object, see the Cerner PowerChart
928
+ // documentation at https://wiki.cerner.com/pages/releaseview.action?spaceKey=MPDEVWIKI&title=XMLCCLREQUEST#Browsers--827740610
925
929
  function makeCclRequestAsync(_x, _x2, _x3) {
926
930
  return _makeCclRequestAsync.apply(this, arguments);
927
931
  }
@@ -935,52 +939,60 @@ function makeCclRequestAsync(_x, _x2, _x3) {
935
939
  */
936
940
  function _makeCclRequestAsync() {
937
941
  _makeCclRequestAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(prg, params, excludeMine) {
938
- var res, req;
939
942
  return _regeneratorRuntime().wrap(function _callee$(_context) {
940
943
  while (1) switch (_context.prev = _context.next) {
941
944
  case 0:
942
945
  if (params === void 0) {
943
946
  params = [];
944
947
  }
945
- res = {
946
- inPowerChart: true
947
- };
948
- _context.prev = 2;
949
- _context.next = 5;
950
- return window.external.XMLCclRequest();
951
- case 5:
952
- req = _context.sent;
953
- req.open('GET', prg);
954
- req.send(formattedParams(params, excludeMine));
955
- req.onreadystatechange = function () {
956
- res.code = req.status;
957
- res.result = statusCodeMap.get(req.status);
958
- res.status = readyStateMap.get(req.readyState);
959
- res.details = req.statusText;
960
- res.data = parsedResponseText(req.responseText);
961
- res.__request = req;
962
- };
963
- _context.next = 18;
964
- break;
965
- case 11:
966
- _context.prev = 11;
967
- _context.t0 = _context["catch"](2);
968
- if (!outsideOfPowerChartError(_context.t0)) {
969
- _context.next = 17;
948
+ if (!(prg.trim() === '')) {
949
+ _context.next = 3;
970
950
  break;
971
951
  }
972
- res.inPowerChart = false;
973
- _context.next = 18;
974
- break;
975
- case 17:
976
- throw _context.t0;
977
- case 18:
978
- return _context.abrupt("return", res);
979
- case 19:
952
+ throw new Error('The CCL program name cannot be empty.');
953
+ case 3:
954
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
955
+ try {
956
+ var req = window.external.XMLCclRequest();
957
+ req.onreadystatechange = function () {
958
+ var requestComplete = req.readyState === 4;
959
+ if (!requestComplete) return;
960
+ var successfulRequest = req.status >= 200 && req.status < 300;
961
+ if (successfulRequest) {
962
+ var res = {
963
+ inPowerChart: true,
964
+ code: req.status,
965
+ result: statusCodeMap.get(req.status),
966
+ status: readyStateMap.get(req.readyState),
967
+ details: req.statusText,
968
+ data: parsedResponseText(req.responseText),
969
+ __request: req
970
+ };
971
+ resolve(res);
972
+ } else {
973
+ reject(new Error("Request failed with status: " + req.status + " and status text: " + req.statusText));
974
+ }
975
+ };
976
+ req.onerror = function () {
977
+ reject(new Error('XMLCclRequest encountered a network error.'));
978
+ };
979
+ req.open('GET', "" + prg);
980
+ req.send(formattedParams(params, excludeMine));
981
+ } catch (e) {
982
+ if (outsideOfPowerChartError(e)) {
983
+ resolve({
984
+ inPowerChart: false
985
+ });
986
+ } else {
987
+ reject(e);
988
+ }
989
+ }
990
+ }));
991
+ case 4:
980
992
  case "end":
981
993
  return _context.stop();
982
994
  }
983
- }, _callee, null, [[2, 11]]);
995
+ }, _callee);
984
996
  }));
985
997
  return _makeCclRequestAsync.apply(this, arguments);
986
998
  }
@@ -1202,7 +1214,7 @@ function _openApplicationAsync() {
1202
1214
  retVal.eventString = argString;
1203
1215
  _context.prev = 10;
1204
1216
  _context.next = 13;
1205
- return window.external.APPLINK(modeValue, target, argString);
1217
+ return window.APPLINK(modeValue, target, argString);
1206
1218
  case 13:
1207
1219
  response = _context.sent;
1208
1220
  retVal.badInput = response === null ? true : false;