oro-sdk 2.1.4-dev1.0

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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/dist/client.d.ts +464 -0
  4. package/dist/helpers/client.d.ts +23 -0
  5. package/dist/helpers/index.d.ts +4 -0
  6. package/dist/helpers/patient-registration.d.ts +16 -0
  7. package/dist/helpers/vault-grants.d.ts +20 -0
  8. package/dist/helpers/workflow.d.ts +23 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +8 -0
  11. package/dist/models/client.d.ts +28 -0
  12. package/dist/models/consult.d.ts +102 -0
  13. package/dist/models/diagnosis.d.ts +122 -0
  14. package/dist/models/error.d.ts +26 -0
  15. package/dist/models/guard.d.ts +119 -0
  16. package/dist/models/index.d.ts +9 -0
  17. package/dist/models/practice.d.ts +353 -0
  18. package/dist/models/shared.d.ts +8 -0
  19. package/dist/models/vault.d.ts +124 -0
  20. package/dist/models/workflow.d.ts +106 -0
  21. package/dist/oro-sdk.cjs.development.js +7685 -0
  22. package/dist/oro-sdk.cjs.development.js.map +1 -0
  23. package/dist/oro-sdk.cjs.production.min.js +2 -0
  24. package/dist/oro-sdk.cjs.production.min.js.map +1 -0
  25. package/dist/oro-sdk.esm.js +7692 -0
  26. package/dist/oro-sdk.esm.js.map +1 -0
  27. package/dist/sdk-revision/client.d.ts +21 -0
  28. package/dist/sdk-revision/index.d.ts +1 -0
  29. package/dist/services/api.d.ts +11 -0
  30. package/dist/services/axios.d.ts +14 -0
  31. package/dist/services/consult.d.ts +54 -0
  32. package/dist/services/diagnosis.d.ts +44 -0
  33. package/dist/services/external/clinia.d.ts +82 -0
  34. package/dist/services/external/index.d.ts +1 -0
  35. package/dist/services/guard.d.ts +92 -0
  36. package/dist/services/index.d.ts +10 -0
  37. package/dist/services/practice.d.ts +100 -0
  38. package/dist/services/teller.d.ts +9 -0
  39. package/dist/services/vault.d.ts +54 -0
  40. package/dist/services/workflow.d.ts +21 -0
  41. package/package.json +63 -0
  42. package/src/client.ts +1843 -0
  43. package/src/helpers/client.ts +199 -0
  44. package/src/helpers/index.ts +4 -0
  45. package/src/helpers/patient-registration.ts +490 -0
  46. package/src/helpers/vault-grants.ts +51 -0
  47. package/src/helpers/workflow.ts +261 -0
  48. package/src/index.ts +61 -0
  49. package/src/models/client.ts +33 -0
  50. package/src/models/consult.ts +110 -0
  51. package/src/models/diagnosis.ts +141 -0
  52. package/src/models/error.ts +13 -0
  53. package/src/models/guard.ts +136 -0
  54. package/src/models/index.ts +9 -0
  55. package/src/models/practice.ts +411 -0
  56. package/src/models/shared.ts +6 -0
  57. package/src/models/vault.ts +158 -0
  58. package/src/models/workflow.ts +142 -0
  59. package/src/sdk-revision/client.ts +62 -0
  60. package/src/sdk-revision/index.ts +1 -0
  61. package/src/services/api.ts +77 -0
  62. package/src/services/axios.ts +91 -0
  63. package/src/services/consult.ts +265 -0
  64. package/src/services/diagnosis.ts +144 -0
  65. package/src/services/external/clinia.ts +133 -0
  66. package/src/services/external/index.ts +1 -0
  67. package/src/services/guard.ts +228 -0
  68. package/src/services/index.ts +10 -0
  69. package/src/services/practice.ts +537 -0
  70. package/src/services/teller.ts +39 -0
  71. package/src/services/vault.ts +178 -0
  72. package/src/services/workflow.ts +36 -0
@@ -0,0 +1,2 @@
1
+ "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("axios")),r=t(require("axios-auth-refresh")),n=require("oro-toolbox"),a=require("idb-keyval");function o(){o=function(t,e){return new r(t,void 0,e)};var t=RegExp.prototype,e=new WeakMap;function r(t,n,a){var o=new RegExp(t,n);return e.set(o,a||e.get(t)),h(o,r.prototype)}function n(t,r){var n=e.get(r);return Object.keys(n).reduce((function(e,r){return e[r]=t[n[r]],e}),Object.create(null))}return c(r,RegExp),r.prototype.exec=function(e){var r=t.exec.call(this,e);return r&&(r.groups=n(r,this)),r},r.prototype[Symbol.replace]=function(r,a){if("string"==typeof a){var o=e.get(this);return t[Symbol.replace].call(this,r,a.replace(/\$<([^>]+)>/g,(function(t,e){return"$"+o[e]})))}if("function"==typeof a){var i=this;return t[Symbol.replace].call(this,r,(function(){var t=arguments;return"object"!=typeof t[t.length-1]&&(t=[].slice.call(t)).push(n(t,i)),a.apply(this,t)}))}return t[Symbol.replace].call(this,r,a)},o.apply(this,arguments)}function i(t,e,r,n,a,o,i){try{var s=t[o](i),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,a)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function s(t){i(o,n,a,s,u,"next",t)}function u(t){i(o,n,a,s,u,"throw",t)}s(void 0)}))}}function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function p(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,h(t,e)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function d(t,e,r){return(d=f()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var a=new(Function.bind.apply(t,n));return r&&h(a,r.prototype),a}).apply(null,arguments)}function x(t){var e="function"==typeof Map?new Map:void 0;return(x=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return d(t,arguments,l(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)})(t)}function y(t,e){if(null==t)return{};var r,n,a={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(a[r]=t[r]);return a}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function b(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return v(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var m,g,w,k,C,P,R,U,T,I,L=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var a=Object.create((e&&e.prototype instanceof l?e:l).prototype),o=new C(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var s=g(i,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,o),a}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p={};function l(){}function h(){}function f(){}var d={};s(d,a,(function(){return this}));var x=Object.getPrototypeOf,y=x&&x(x(P([])));y&&y!==e&&r.call(y,a)&&(d=y);var v=f.prototype=l.prototype=Object.create(d);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var n;this._invoke=function(a,o){function i(){return new e((function(n,i){!function n(a,o,i,s){var u=c(t[a],t,o);if("throw"!==u.type){var p=u.arg,l=p.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(l).then((function(t){p.value=t,i(p)}),(function(t){return n("throw",t,i,s)}))}s(u.arg)}(a,o,n,i)}))}return n=n?n.then(i,i):i()}}function g(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,g(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var a=n.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return h.prototype=f,s(v,"constructor",f),s(f,"constructor",h),h.displayName=s(f,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,s(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},b(m.prototype),s(m.prototype,o,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new m(u(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},b(v),s(v,i,"Generator"),s(v,a,(function(){return this})),s(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var a=n.arg;k(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(I={exports:{}}),I.exports),D=function(){function t(t){t||(t={}),this.axios=e.create(t)}var r=t.prototype;return r.apiRequest=function(){var t=s(L.mark((function t(e,r,n){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.headers||(e.headers={}),e.headers["Content-Type"]="application/json",t.abrupt("return",this.axios(u({},e,{url:r,data:n})).then((function(t){return t.data})));case 3:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.apiRequestHeader=function(){var t=s(L.mark((function t(e,r,n,a){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.headers||(e.headers={}),e.headers["Content-Type"]="application/json",t.abrupt("return",this.axios(u({},e,{url:r,data:a})).then((function(t){var e;return n?null!=(e=t.headers[n])?e:t.headers[n.toLowerCase()]:t.headers})));case 3:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),r.get=function(t,e){return this.apiRequest(u({},e,{method:"get"}),t)},r.deleteRequest=function(t,e){return this.apiRequest(u({},e,{method:"delete"}),t)},r.post=function(t,e,r){return this.apiRequest(u({},r,{method:"post"}),t,e)},r.put=function(t,e,r){return this.apiRequest(u({},r,{method:"put"}),t,e)},r.patch=function(t,e,r){return this.apiRequest(u({},r,{method:"patch"}),t,e)},r.head=function(t,e,r,n){return this.apiRequestHeader(u({},e,{method:"head"}),t,r,n)},t}(),S=function(t){function e(e,n){var a;(a=t.call(this,e)||this).tokenRefreshFailureCallback=n;var o=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(a);return a.axios.interceptors.request.use((function(t){var e=t.useRefreshToken?o.getTokens().refreshToken:o.getTokens().accessToken;return t.headers=u({},t.headers,{Authorization:"Bearer "+e}),t}),(function(t){Promise.reject(t)})),r(a.axios,function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!o.authRefreshFn){t.next=15;break}return t.prev=1,t.next=4,o.authRefreshFn(o.getTokens().refreshToken);case 4:return o.setTokens({accessToken:(r=t.sent).accessToken,refreshToken:r.refreshToken}),e.response.config.headers.Authorization="Bearer "+o.getTokens().accessToken,t.abrupt("return",Promise.resolve());case 10:return t.prev=10,t.t0=t.catch(1),console.error("an error occured while refreshing tokens (notifying callback)",t.t0),o.tokenRefreshFailureCallback&&o.tokenRefreshFailureCallback(e),t.abrupt("return",Promise.resolve());case 15:return console.error("The request could not refresh the token (authRefreshFn was not set)",e),t.abrupt("return",Promise.resolve());case 17:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e){return t.apply(this,arguments)}}(),{statusCodes:[401,403]}),a}p(e,t);var n=e.prototype;return n.setAuthRefreshFn=function(t){this.authRefreshFn=t},n.setTokens=function(t){localStorage.setItem("tokens",JSON.stringify(t))},n.getTokens=function(){var t={},e=localStorage.getItem("tokens");return e&&(t=JSON.parse(e)),t},e}(D);(m=exports.AssistantType||(exports.AssistantType={})).MedicalSecretary="MedicalSecretary",m.Nurse="Nurse",m.Specialist="Specialist",m.Administrative="Administrative",m.Other="Other",(g=exports.TransmissionKind||(exports.TransmissionKind={})).Fax="Fax",g.Email="Email",g.SMS="SMS",g.EncryptedEmail="EncryptedEmail",g.Logs="Logs",g.API="API",g.Other="Other",(w=exports.TransmissionStatus||(exports.TransmissionStatus={})).Preparing="Preparing",w.Sending="Sending",w.Sent="Sent",w.Retrying="Retrying",w.Failed="Failed",w.DriverError="DriverError",w.TimedOut="TimedOut",w.ReceiverNotExist="ReceiverNotExist",w.ReceiverNotAnswering="ReceiverNotAnswering",w.ReceiverIncompatible="ReceiverIncompatible",(k=exports.FeeStatus||(exports.FeeStatus={})).NoFee="NoFee",k.Pending="Pending",k.Paid="Paid",k.Reimbursed="Reimbursed",k.Cancelled="Cancelled",k.Contested="Contested",(C=exports.MedicalStatus||(exports.MedicalStatus={})).Creating="Creating",C.New="New",C.ToAnswer="ToAnswer",C.Answered="Answered",C.Closed="Closed",C.Reopened="Reopened",C.Archived="Archived",(P=exports.TaskStatus||(exports.TaskStatus={})).None="None",P.ToDo="ToDo",P.InProgress="InProgress",P.Blocked="Blocked",P.Done="Done",(R=exports.DiagnosisType||(exports.DiagnosisType={})).Generic="Generic",R.Private="Private",R.Instance="Instance",(U=exports.DrugType||(exports.DrugType={})).Generic="Generic",U.Instance="Instance",(T=exports.PlanStatus||(exports.PlanStatus={})).Pending="Pending",T.Accepted="Accepted",T.Rejected="Rejected";var O,A,M,E,G,F,B,j,N,_,K,q,W,J,H,Q,V,z=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),Y=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),Z=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),$=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),X=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),tt=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),et=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),rt=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),nt=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),at=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),ot=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),it=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error)),st=function(t){function e(){return t.apply(this,arguments)||this}return p(e,t),e}(x(Error));(O=exports.WorkflowType||(exports.WorkflowType={})).Onboard="Onboard",O.Followup="Followup",O.Renew="Renew",O.DataRetrieve="DataRetrieve",(A=exports.RateDimension||(exports.RateDimension={})).RatioOnTotal="RatioOnTotal",A.FixedOnTotal="FixedOnTotal",A.RatioPlatformFee="RatioPlatformFee",A.FixedPlatformFee="FixedPlatformFee",A.RatioOnPlatformFeeTotal="RatioOnPlatformFeeTotal",A.FixedOnPlatformFeeTotal="FixedOnPlatformFeeTotal",A.RatioOnItem="RatioOnItem",A.FixedOnItem="FixedOnItem",(M=exports.PlanType||(exports.PlanType={})).Onboard="Onboard",M.Followup="Followup",M.Renew="Renew",M.DataRetrieve="DataRetrieve",(E=exports.PaymentStatus||(exports.PaymentStatus={})).Pending="Pending",E.Success="Success",E.Failure="Failure",E.Canceled="Canceled",(G=exports.PractitionerStatus||(exports.PractitionerStatus={})).Practicing="Practicing",G.Retired="Retired",G.NotInvolvedAnymore="NotInvolvedAnymore",G.Deactivated="Deactivated",G.Flagged="Flagged",G.InConflict="InConflict",G.Delicensed="Delicensed",(F=exports.AssignmentStatus||(exports.AssignmentStatus={})).Assigned="Assigned",F.Reassigned="Reassigned",F.Cancelled="Cancelled",(B=exports.PractitionnerRoleType||(exports.PractitionnerRoleType={})).Doctor="Doctor",B.MedicalAssistant="MedicalAssistant",B.MedicalSecretary="MedicalSecretary",B.Nurse="Nurse",B.Specialist="Specialist",B.LabAssistant="LabAssistant",B.Administrative="Administrative",B.ManualDispatcher="ManualDispatcher",B.Other="Other",(j=exports.OtherRoleType||(exports.OtherRoleType={})).Patient="Patient",j.User="User",j.System="System",(N=exports.LicenseStatus||(exports.LicenseStatus={})).Valid="Valid",N.Invalid="Invalid",N.Expired="Expired",N.NA="NA",N.Removed="Removed",(_=exports.PeriodType||(exports.PeriodType={})).PerYear="PerYear",_.PerQuarter="PerQuarter",_.PerMonth="PerMonth",_.PerWeek="PerWeek",_.PerBusinessDay="PerBusinessDay",_.PerDay="PerDay",_.PerHour="PerHour",(K=exports.SyncStatus||(exports.SyncStatus={})).Requested="Requested",K.Started="Started",K.Succeeded="Succeeded",K.Failed="Failed",K.Cancelled="Cancelled",(q=exports.PracticeEmailKind||(exports.PracticeEmailKind={})).SignedUp="SignedUp",q.Onboarded="Onboarded",q.OnboardedPractitioner="OnboardedPractitioner",q.OnboardedPatient="OnboardedPatient",q.Answered="Answered",q.ToAnswer="ToAnswer",q.FollowedUp="FollowedUp",q.Renewed="Renewed",q.DataRetrieved="DataRetrieved",(W=exports.PracticeConfigKind||(exports.PracticeConfigKind={})).PractitionerConsultList="PractitionerConsultList",W.PractitionerChatbox="PractitionerChatbox",W.PracticeTheme="PracticeTheme",W.PracticeLocaleSwitcher="PracticeLocaleSwitcher",W.PracticeCookieBanner="PracticeCookieBanner",(J=exports.StripePriceType||(exports.StripePriceType={})).Default="Default",J.Discount="Discount",(H=exports.IndexKey||(exports.IndexKey={})).Consultation="Consultation",H.IndexSnapshot="IndexSnapshot",H.ConsultationLockbox="ConsultationLockbox",(Q=exports.DocumentType||(exports.DocumentType={})).Message="Message",Q.Note="Note",Q.DoctorsNote="DoctorsNote",Q.Prescription="Prescription",Q.ExamRequest="ExamRequest",Q.Result="Result",Q.Attachment="Attachment",Q.BigFile="BigFile",Q.MeetingRequest="MeetingRequest",Q.AudioNote="AudioNote",Q.VideoNote="VideoNote",Q.PopulatedWorkflowData="PopulatedWorkflowData",Q.TreatmentPlan="TreatmentPlan",Q.ImageAlias="ImageAlias",(V=exports.MetadataCategory||(exports.MetadataCategory={})).ChildPersonal="ChildPersonal",V.Consultation="Consultation",V.DataRetrieval="DataRetrieval",V.Followup="Followup",V.Recovery="Recovery",V.Medical="Medical",V.OtherPersonal="OtherPersonal",V.Personal="Personal",V.Preference="Preference",V.Prescription="Prescription",V.Raw="Raw";var ut,ct=function(){function t(t,e){this.api=t,this.baseURL=e}var e=t.prototype;return e.consultCreate=function(t){return this.api.post(this.baseURL+"/v1/consults",t)},e.countConsults=function(t,e,r,n,a,o,i,s,u,c,p,l){return this.api.head(this.baseURL+"/v1/consults",{params:{uuidPractice:t,uuidRequester:e,statusesMedical:r,statusesExclude:n,shortId:a,perPage:s,page:u,sortColumns:o,orderColumns:i,filterAssignedDoctor:c,filterCurrentPractitioner:p,filterIsoLocality:l}},"Content-Range").then((function(t){return!t||"string"!=typeof t&&"number"!=typeof t?0:"number"==typeof t?t:parseInt(t)}))},e.getConsults=function(t,e,r,n,a,o,i,s,u,c,p,l){return this.api.get(this.baseURL+"/v1/consults",{params:{uuidPractice:t,uuidRequester:e,statusesMedical:r,statusesExclude:n,shortId:a,perPage:s,page:u,sortColumns:o,orderColumns:i,filterAssignedDoctor:c,filterCurrentPractitioner:p,filterIsoLocality:l}})},e.getConsultByUUID=function(t,e){return this.api.get(this.baseURL+"/v1/consults/"+t,{params:{uuidPractice:e}})},e.updateConsultByUUID=function(t,e,r,n){return this.api.put(this.baseURL+"/v1/consults/"+t,e,{params:{uuidPractice:r,uuidRequester:n}})},e.getConsultFaxStatuses=function(t){return this.api.get(this.baseURL+"/v1/consults/"+t+"/transmissions",{params:{kind:exports.TransmissionKind.Fax}})},e.postConsultTransmission=function(t,e,r,n,a,o,i){void 0===e&&(e="Documo");var s=new FormData;return s.append("nameDriverReceiver",e),r&&s.append("addressReceiver",r),n&&s.append("file",n),a&&s.append("nameReceiver",a),o&&s.append("txtTransmissionTitle",o),i&&s.append("txtTransmissionNotes",i),this.api.post(this.baseURL+"/v1/consults/"+t+"/transmissions",s,{headers:{"Content-Type":"multipart/form-data;"}})},e.postConsultFax=function(t,e,r){return this.postConsultTransmission(t,"Documo",e,r)},e.postConsultEmail=function(t,e){return this.postConsultTransmission(t,"Pharmacierge",void 0,e)},e.retryConsultFax=function(t,e){return this.api.put(this.baseURL+"/v1/consults/"+t+"/transmissions/"+e,{status:exports.TransmissionStatus.Retrying})},e.updateConsultTransmissionStatus=function(t,e,r){return this.api.put(this.baseURL+"/v1/consults/"+e+"/transmissions/"+t,{status:r})},t}(),pt=function(){function t(t,e){this.api=t,this.baseURL=e}var e=t.prototype;return e.getDiagnoses=function(){return this.api.get(this.baseURL+"/v1/diagnoses")},e.getDiagnosisByUuid=function(t){return this.api.get(this.baseURL+"/v1/diagnoses/"+t)},e.createDiagnosis=function(t){return this.api.post(this.baseURL+"/v1/diagnoses",t)},e.updateDiagnosis=function(t,e){return this.api.put(this.baseURL+"/v1/diagnoses/"+t,e)},e.getTreatmentsFromDiagnosisUuid=function(t){return this.api.get(this.baseURL+"/v1/diagnoses/"+t+"/treatments")},e.getTreatmentPlansFromConsultUuid=function(t){return this.api.get(this.baseURL+"/v1/treatment-plans/",{params:{uuidConsult:t}})},e.createTreatment=function(t,e){return this.api.post(this.baseURL+"/v1/diagnoses/"+t+"/treatments",e)},e.getTreatmentPlansPopulatedFromConsultUuid=function(t){return this.api.get(this.baseURL+"/v1/treatment-plans/",{params:{uuidConsult:t,populated:!0}})},e.postPlans=function(t){return this.api.post(this.baseURL+"/v1/treatment-plans",t)},e.updateTreatmentPlan=function(t,e,r,n){return this.api.put(this.baseURL+"/v1/treatment-plans/"+t,{uuidConsult:e,diagnosis:r,plan:n})},e.acceptTreatmentPlan=function(t,e){return this.api.put(this.baseURL+"/v1/treatment-plans/"+t+"/accept",{uuidConsult:e})},e.getAllDrugs=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.api.get(this.baseURL+"/v1/drugs/practice/"+e);case 2:if(!(r=t.sent)||!r.foundDrugs){t.next=5;break}return t.abrupt("return",r.foundDrugs);case 5:return t.abrupt("return",void 0);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),lt=function(){function t(t,e){this.api=t,this.baseURL=e,this.api.setAuthRefreshFn(this.authRefresh.bind(this)),this.identityCache={},this.whoAmICache={}}var e=t.prototype;return e.setTokens=function(t){this.api.setTokens(u({},this.api.getTokens(),t))},e.authToken=function(){var t=s(L.mark((function t(e){var r,n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n={skipAuthRefresh:!0},t.next=4,this.api.post(this.baseURL+"/v1/auth/token",e,n);case 4:this.api.setTokens({accessToken:(r=t.sent).accessToken,refreshToken:r.refreshToken}),t.next=19;break;case 8:if(t.prev=8,t.t0=t.catch(0),!t.t0.isAxiosError){t.next=18;break}o=null==(a=t.t0.response)?void 0:a.status,t.t1=o,t.next=400===t.t1?15:500===t.t1?16:17;break;case 15:throw new nt;case 16:throw new at;case 17:case 18:throw new rt;case 19:return t.abrupt("return",r);case 20:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(e){return t.apply(this,arguments)}}(),e.authRefresh=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.put(this.baseURL+"/v1/auth/token",null,{skipAuthRefresh:!0,useRefreshToken:!0}));case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.authLogout=function(){var t=s(L.mark((function t(){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.get(this.baseURL+"/v1/auth/logout"));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.authRecover=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.post(this.baseURL+"/v1/auth/recover",e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.identityCreate=function(){var t=s(L.mark((function t(e){var r,n,a;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.api.post(this.baseURL+"/v1/identities",e);case 3:this.api.setTokens({refreshToken:(r=t.sent).refreshToken}),t.next=18;break;case 7:if(t.prev=7,t.t0=t.catch(0),!t.t0.isAxiosError){t.next=17;break}a=null==(n=t.t0.response)?void 0:n.status,t.t1=a,t.next=400===t.t1?14:409===t.t1?15:16;break;case 14:throw new it;case 15:throw new st;case 16:case 17:throw new ot;case 18:return t.abrupt("return",r);case 19:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),e.identityGet=function(){var t=s(L.mark((function t(e){var r,n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=this.api.getTokens(),o=(null!=(r=a.accessToken)?r:"")+(null!=(n=a.refreshToken)?n:"")+e,a.accessToken&&this.identityCache[o]){t.next=6;break}return t.next=5,this.api.get(this.baseURL+"/v1/identities/"+e);case 5:this.identityCache[o]=t.sent;case 6:return t.abrupt("return",this.identityCache[o]);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.whoAmI=function(){var t=s(L.mark((function t(e){var r,n;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e=!1),n=null!=(r=this.api.getTokens().accessToken)?r:"",this.whoAmICache[n]&&!e){t.next=6;break}return t.next=5,this.api.get(this.baseURL+"/v1/auth/whoami");case 5:this.whoAmICache[n]=t.sent;case 6:return t.abrupt("return",this.whoAmICache[n]);case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.identityUpdate=function(){var t=s(L.mark((function t(e,r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.put(this.baseURL+"/v1/identities/"+e,r));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.identityMFAQRCode=function(){var t=s(L.mark((function t(e,r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.post(this.baseURL+"/v1/identities/"+e+"/mfa",{password:r},{headers:{Accept:"application/json"}}));case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),t}(),ht=function(){function t(t,e,r){this.toolbox=t,this.api=e,this.baseURL=r}var e=t.prototype;return e.practiceGetFromURL=function(t,e){return this.api.get(this.baseURL+"/v1/practices",{params:u({url_practice:t},e)})},e.practiceGetFromUuid=function(t,e,r){return this.api.get(this.baseURL+"/v1/practices/"+t,{params:{locale:e,accounts:r}})},e.practiceConfigGetFromPracticeUuid=function(t){return this.api.get(this.baseURL+"/v1/practices/"+t+"/configs")},e.practiceConfigGetByKindForPracticeUuid=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/configs/"+e)},e.practiceConfigCreateForPracticeUuid=function(t,e){return this.api.post(this.baseURL+"/v1/practices/"+t+"/configs",e)},e.practiceConfigUpdate=function(t){return this.api.put(this.baseURL+"/v1/practices/"+t.uuidPractice+"/configs/"+t.kind,t)},e.practiceGetAccounts=function(t){return this.api.get(this.baseURL+"/v1/practices/"+t+"/accounts")},e.practiceGetAccount=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/accounts/"+e)},e.practiceGetWorkflows=function(t){return this.api.get(this.baseURL+"/v1/practices/"+t+"/workflows")},e.practiceGetWorkflow=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/workflows/"+e)},e.practiceGetPlans=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/plans",{params:{kind:e}})},e.practiceGetPlan=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/plans/"+e)},e.practiceGetPlanPrices=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/plans/"+e+"/prices")},e.practiceGetPayments=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/payments",{params:{kind:e}})},e.practiceGetPayment=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/payments/"+e)},e.practiceGetPaymentForStripePaymentIntentWithID=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/payments/"+e)},e.practiceGetPaymentsIntents=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/payments/intents",{params:{kind:e}})},e.getPaymentIntentHashedEmail=function(t){return this.toolbox.hashStringToBase64(t.toLowerCase())},e.practiceCreatePaymentsIntent=function(t,e,r,n,a,o){return this.api.post(this.baseURL+"/v1/practices/"+t+"/payments/intents/",{idPlan:e,hashUserEmail:r?this.getPaymentIntentHashedEmail(r):void 0,isoLocality:n},{params:{url_subdomain:a,promotionCode:o}})},e.practiceGetPaymentsIntent=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/payments/intents/"+e)},e.practiceUpdatePaymentsIntent=function(t,e,r,n,a){return this.api.put(this.baseURL+"/v1/practices/"+t+"/payments/intents/"+e,u({},r,{hashUserEmail:n?this.getPaymentIntentHashedEmail(n):void 0}),{params:{promotionCode:a}})},e.practiceGetPractitioners=function(t){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners")},e.practiceUpdatePractitioner=function(t,e,r){return this.api.put(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e,r)},e.practiceGetPractitioner=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e)},e.practiceGetPractitionerLicenses=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/licenses")},e.practiceCreatePractitionerLicense=function(t,e,r){return this.api.post(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/licenses",r)},e.practiceUpdatePractitionerLicense=function(t,e,r,n){return this.api.put(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/licenses/"+r,n)},e.practiceGetPractitionerLicense=function(t,e,r){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/licenses/"+r)},e.practiceGetPractitionerPreferences=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/preferences")},e.practiceCreatePractitionerPreference=function(t,e,r){return this.api.post(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/preferences",r)},e.practiceUpdatePractitionerPreference=function(t,e,r,n){return this.api.put(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/preferences/"+r,n)},e.practiceGetPractitionerPreference=function(t,e,r){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/preferences/"+r)},e.practiceGetPractitionerRoles=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/roles")},e.practiceCreatePractitionerRole=function(t,e,r){return this.api.post(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/roles",r)},e.practiceDeletePractitionerRoles=function(t,e){return this.api.deleteRequest(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/roles")},e.practiceUpdatePractitionerRole=function(t,e,r,n){return this.api.put(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/roles/"+r,n)},e.practiceGetPractitionerRole=function(t,e,r){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/roles/"+r)},e.practiceDeletePractitionerRole=function(t,e,r){return this.api.deleteRequest(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/roles/"+r)},e.practiceGetPractitionerSignature=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/practitioners/"+e+"/signature",{responseType:"blob"})},e.practiceGetAssignments=function(t){return this.api.get(this.baseURL+"/v1/practices/"+t+"/assignments")},e.practiceCreateAssignment=function(t,e){return this.api.post(this.baseURL+"/v1/practices/"+t+"/assignments",e)},e.practiceUpdateAssignment=function(t,e,r){return this.api.put(this.baseURL+"/v1/practices/"+t+"/assignments/"+e,r)},e.practiceGetAssignment=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/assignments/"+e)},e.practiceGetQuotas=function(t){return this.api.get(this.baseURL+"/v1/practices/"+t+"/quotas")},e.practiceGetQuota=function(t,e){return this.api.get(this.baseURL+"/v1/practices/"+t+"/quotas/"+e)},t}(),ft=function(){function t(t,e){this.api=t,this.baseURL=e}var e=t.prototype;return e.lockboxDataStore=function(){var t=s(L.mark((function t(e,r,n,a){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.post(this.baseURL+"/v1/lockboxes/"+e+"/data",r,{params:{lockbox_owner_uuid:n,data_uuid:a}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.updateConsultByUUID=function(t,e,r,n){return this.api.put(this.baseURL+"/v1/consults/"+e,{patientUuid:t,statusMedical:r,neverExpires:n})},t}(),dt=function(){function t(t,e){this.api=t,this.baseURL=e}var e=t.prototype;return e.lockboxCreate=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.post(this.baseURL+"/v1/lockbox",e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.lockboxMetadataAdd=function(){var t=s(L.mark((function t(e,r,n){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.put(this.baseURL+"/v1/lockbox/"+e,r,{params:{lockbox_owner_uuid:n}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.lockboxSecretGet=function(){var t=s(L.mark((function t(e,r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.get(this.baseURL+"/v1/lockboxes/"+e+"/secret",{params:{lockbox_owner_uuid:r}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.lockboxGrant=function(){var t=s(L.mark((function t(e,r,n){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.post(this.baseURL+"/v1/lockboxes/"+e+"/grant",r,{params:{lockbox_owner_uuid:n}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.grantsGet=function(){var t=s(L.mark((function t(){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.get(this.baseURL+"/v1/grants"));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.lockboxDataStore=function(){var t=s(L.mark((function t(e,r,n,a){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.post(this.baseURL+"/v1/lockboxes/"+e+"/data",r,{params:{lockbox_owner_uuid:n,data_uuid:a}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.lockboxDataGet=function(){var t=s(L.mark((function t(e,r,n,a){var o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===a&&(a=!0),t.next=3,this.api.get(this.baseURL+"/v1/lockboxes/"+e+"/data/"+r,{params:{lockbox_owner_uuid:n,stream:a}});case 3:if(o=t.sent,!a){t.next=6;break}return t.abrupt("return",{data:o});case 6:return t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.lockboxManifestGet=function(){var t=s(L.mark((function t(e,r,n){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.get(this.baseURL+"/v1/lockboxes/"+e,{params:{lockbox_owner_uuid:n,filter:r}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.lockboxMetadataGet=function(){var t=s(L.mark((function t(e,r,n,a,o){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.get(this.baseURL+"/v1/lockboxes/"+e+"/metadata",{params:{lockbox_owner_uuid:o,fields:r,groupby:n,filter:a}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o){return t.apply(this,arguments)}}(),e.vaultIndexPut=function(){var t=s(L.mark((function t(e,r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.put(this.baseURL+"/v1/index",e,{params:{index_owner_uuid:r}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.vaultIndexSnapshotPut=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.put(this.baseURL+"/v1/index-snapshot",e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.vaultIndexGet=function(){var t=s(L.mark((function t(e,r,n){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.api.get(this.baseURL+"/v1/index",{params:{index_keys:e,identifiers:r,timestamp:n}}));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),t}(),xt=function(){function t(t,e){this.api=t,this.v1Url=e+"/v1"}var e=t.prototype;return e.getWorkflows=function(){return this.api.get(this.v1Url+"/workflows")},e.getWorkflow=function(t,e,r){return this.api.get(this.v1Url+"/workflows/"+t,{params:{locale:e,createdAt:r}})},t}(),yt=["locale"],vt=["locale"],bt=function(){function t(t,e,r){this.url=t,this.locale=r,this.api=new D({headers:{"X-Clinia-API-Key":e}})}var e=t.prototype;return e.placeSearch=function(t){var e=t.locale,r=y(t,yt);return this.api.post(this.url+"/search/v1/indexes/health_facility/query",r,{params:{locale:null!=e?e:this.locale}})},e.placeMatch=function(t,e){var r=t.locale,n=y(t,vt),a=this.api.post(this.url+"/search/v1/matches",n,{params:{locale:null!=r?r:this.locale}});return e&&(a=a.then((function(t){return t.filter((function(t){return t.type===e}))}))),a},t}(),mt=((ut={})[exports.MetadataCategory.Personal]="you",ut[exports.MetadataCategory.ChildPersonal]="child",ut[exports.MetadataCategory.OtherPersonal]="other",ut);function gt(t){return"sess-pkey"+t}function wt(t,e){return kt.apply(this,arguments)}function kt(){return(kt=s(L.mark((function t(e,r){var n,a,o,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.selectedAnswers){t.next=2;break}throw et;case 2:return n=Dt(e.selectedAnswers),a=Object.fromEntries(e.pages.map((function(t){return Object.entries(t.questions).filter((function(t){var e=t[1];return Lt(e.triggers||[],n)&&e.kind===r}))})).flat()),o=e.selectedAnswers.reduce((function(t,e){return u({},t,e)}),{}),i=Object.keys(a).map((function(t){return o[t]})),t.abrupt("return",i);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ct(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=s(L.mark((function t(e,r){var n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.selectedAnswers){t.next=2;break}throw et;case 2:return n=Dt(e.selectedAnswers),a=Object.fromEntries(e.pages.map((function(t){return Object.entries(t.questions).filter((function(t){return Lt(t[1].triggers||[],n)}))})).flat()),o={},t.abrupt("return",Promise.all(e.selectedAnswers.map((function(t){return Object.entries(t)})).flat().filter((function(t){var e=t[0];return a[e]&&a[e].metaCategory===r})).map((function(t){var e=t[0];return Tt(a[e],t[1]).then((function(t){o[e]=t}))}))).then((function(){return{workflowCreatedAt:e.createdAt,workflowId:e.id,locale:e.locale,fields:o}})).catch((function(t){throw console.error("Error while extracting "+r+" data from workflow",t),t})));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Rt(t){return Ut.apply(this,arguments)}function Ut(){return(Ut=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.getMany(e.map((function(t){var e;return null!=(e=t.id)?e:t})));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Tt(t,e){return It.apply(this,arguments)}function It(){return(It=s(L.mark((function t(e,r){var n,a;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=void 0,t.t0=e.kind,t.next="radio"===t.t0||"radio-card"===t.t0||"select"===t.t0?4:"multiple"===t.t0||"checkbox-group"===t.t0?7:"images"===t.t0?10:14;break;case 4:return e.answers&&(a=e.answers[r].text),n=r,t.abrupt("break",15);case 7:return a=r.map((function(t){if(e.answers)return e.answers[t].text;throw new et})),n=r,t.abrupt("break",15);case 10:return t.next=12,Rt(r).then((function(t){return t.map((function(t){return{name:t.name,imageData:t.imageData}}))}));case 12:return n=t.sent,t.abrupt("break",15);case 14:n=r;case 15:return t.abrupt("return",Promise.resolve({answer:n,displayedAnswer:a,kind:e.kind}));case 16:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Lt(t,e){for(var r,n=b(t);!(r=n()).done;)if(!e.includes(r.value))return!1;return!0}function Dt(t){for(var e,r=[],n=b(t);!(e=n()).done;)r.push.apply(r,Object.values(e.value));return r.flat(1)}function St(t,e){return void 0===e&&(e=!0),t.pages.map((function(t){for(var r={},n=0,a=Object.entries(t.questions);n<a.length;n++){var o=a[n],i=o[1];r[o[0]]="body-parts"===i.kind?e?[]:void 0:e&&i.defaultValue?i.defaultValue:void 0}return r}))}function Ot(t,e,r,n,a,o){return At.apply(this,arguments)}function At(){return(At=s(L.mark((function t(e,r,n,a,o,i){var u,c,p,l,h;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:u=void 0,c=void 0,p=void 0,l=15,h=!1;case 5:if(!(l>0)){t.next=20;break}return t.prev=6,t.delegateYield(L.mark((function t(){var f,d,x,y,v,b,m,g;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){return setTimeout(t,2e3)}));case 2:if(p){t.next=6;break}return t.next=5,a.practiceClient.practiceGetFromUuid(r.uuidPractice);case 5:p=t.sent.uuidAdmin;case 6:return t.next=8,a.practiceClient.practiceGetPractitioners(r.uuidPractice).catch((function(t){return console.log("Error retrieving practitioners",t),[]}));case 8:if(x=t.sent,u){t.next=13;break}return t.next=12,Gt(r,a);case 12:u=t.sent;case 13:if(c){t.next=17;break}return t.next=16,Bt(a);case 16:c=t.sent;case 17:return t.next=19,Mt(u,c,a).catch((function(t){return console.error("Error when retrieving existing consults "+t),!1}));case 19:return h=t.sent,t.next=22,a.grantLockbox(p,c).catch((function(t){throw console.error("Error while granting lockbox to practitioner admin "+p,t),t}));case 22:return y=x.filter((function(t){return t.uuid!==p})).map(function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a.grantLockbox(e.uuid,c).catch((function(t){if(console.error("Error while granting lockbox to practitioner",t),!(l<=1))throw t})));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.next=25,Nt(u.uuid,r.isoLanguageRequired,c,n,a);case 25:if((f={})[exports.IndexKey.ConsultationLockbox]=[{grant:{lockboxUuid:c,lockboxOwnerUuid:e},consultationId:u.uuid}],v=f,b=x.map(function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a.vaultIndexAdd(v,e.uuid).catch((function(t){console.error("Error while adding to the practitioner's index "+e.uuid,t)})));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),(d={})[exports.IndexKey.Consultation]=[{grant:{lockboxUuid:c,lockboxOwnerUuid:e},consultationId:u.uuid}],m=d,g=x.map(function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a.vaultIndexAdd(m,e.uuid).catch((function(t){console.error("Error while adding to the practitioner's index "+e.uuid,t)})));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),!o||h){t.next=34;break}return t.next=32,a.updateMasterKey(e,o,c).catch((function(t){console.error("Error while updating master key",t)}));case 32:t.next=35;break;case 34:o=void 0;case 35:if(!i||h){t.next=38;break}return t.next=38,a.updateSecurityQuestions(e,i.recoverySecurityQuestions,i.recoverySecurityAnswers,2).catch((function(t){console.error("Error while updating security questions",t)}));case 38:return t.next=40,Promise.all([].concat(y,b,g));case 40:return t.next=42,a.consultClient.updateConsultByUUID(u.uuid,{statusMedical:exports.MedicalStatus.New});case 42:return t.abrupt("return","break");case 43:case"end":return t.stop()}}),t)}))(),"t0",8);case 8:if("break"!==t.t0){t.next=11;break}return t.abrupt("break",20);case 11:t.next=17;break;case 13:return t.prev=13,t.t1=t.catch(6),console.error("Error occured during registration, retrying... Retries remaining: "+l),t.abrupt("continue",17);case 17:l--,t.next=5;break;case 20:if(!(l<=0)){t.next=23;break}throw console.error("registration failed: MAX_RETRIES reached"),"RegistrationFailed";case 23:return console.log("Successfully Registered"),t.next=26,a.cleanIndex();case 26:return t.abrupt("return",{masterKey:o,consultationId:u.uuid,lockboxUuid:c});case 27:case"end":return t.stop()}}),t,null,[[6,13]])})))).apply(this,arguments)}function Mt(t,e,r){return Et.apply(this,arguments)}function Et(){return(Et=s(L.mark((function t(e,r,n){var a;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.PopulatedWorkflowData},t.next=3,n.vaultClient.lockboxMetadataGet(r,["consultationId"],[],a);case 3:return t.abrupt("return",-1!==t.sent[0].findIndex((function(t){return null!=t.consultationId&&t.consultationId!==e.uuid})));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Gt(t,e){return Ft.apply(this,arguments)}function Ft(){return(Ft=s(L.mark((function t(e,r){var n;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.practiceClient.practiceGetPayment(e.uuidPractice,e.idStripeInvoiceOrPaymentIntent);case 2:if(!(n=t.sent)||!n.uuidConsult){t.next=7;break}return t.abrupt("return",r.consultClient.getConsultByUUID(n.uuidConsult).catch((function(t){throw console.error("Error while retrieving consult",t),t})));case 7:return t.next=9,r.consultClient.consultCreate(e).catch((function(t){throw console.error("Error while creating consult",t),t}));case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t){return jt.apply(this,arguments)}function jt(){return(jt=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getGrants(void 0,!0);case 2:if(!((r=t.sent).length>0)){t.next=8;break}return console.log("The grant has already been created, skipping lockbox create step"),t.abrupt("return",r[0].lockboxUuid);case 8:return t.next=10,e.vaultClient.lockboxCreate().catch((function(t){throw console.error("Error while creating lockbox",t),t}));case 10:return t.abrupt("return",t.sent.lockboxUuid);case 11:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Nt(t,e,r,n,a){return _t.apply(this,arguments)}function _t(){return(_t=s(L.mark((function t(e,r,n,a,o){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Promise.all([Kt(e,n,a,o).catch((function(t){console.error("[SDK] Some errors happened during image upload",t)})),o.getOrInsertJsonData(n,a,{category:exports.MetadataCategory.Raw,contentType:"application/json",consultationId:e},{}),Ct(a,exports.MetadataCategory.Consultation).then((function(t){return o.getOrInsertJsonData(n,t,{category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.PopulatedWorkflowData,consultationId:e},{consultationId:e})})),Ct(a,exports.MetadataCategory.Medical).then((function(t){return o.getOrInsertJsonData(n,t,{category:exports.MetadataCategory.Medical,documentType:exports.DocumentType.PopulatedWorkflowData,consultationIds:[e]},{})})),Wt(a,n,e,exports.MetadataCategory.Personal,o),Wt(a,n,e,exports.MetadataCategory.ChildPersonal,o),Wt(a,n,e,exports.MetadataCategory.OtherPersonal,o),o.getOrInsertJsonData(n,{isoLanguage:r},{category:exports.MetadataCategory.Preference,contentType:"application/json"},{})]).then((function(t){return t.flat()})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Kt(t,e,r,n){return qt.apply(this,arguments)}function qt(){return(qt=s(L.mark((function t(e,r,n,a){var o,i,s;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=Rt,t.next=3,wt(n,"images-alias");case 3:return t.t1=t.sent.flat(),t.next=6,(0,t.t0)(t.t1);case 6:return i=(o=t.sent).filter((function(t){return!!t})),o.length!==i.length&&console.error("[SDK] Some images have not been found, they have been skipped."),s=i.map((function(t){return a.getOrInsertJsonData(r,t,{category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.ImageAlias,consultationId:e,idbId:t.idbId},{})})),t.abrupt("return",Promise.all(s));case 11:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Wt(t,e,r,n,a){return Jt.apply(this,arguments)}function Jt(){return(Jt=s(L.mark((function t(e,r,n,a,o){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Ct(e,a).then((function(t){if(0!==Object.keys(t.fields).length)return o.getOrInsertJsonData(r,t,{category:a,documentType:exports.DocumentType.PopulatedWorkflowData,consultationIds:[n]},{})})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ht(t,e){return t.map((function(t){if(t.encryptedLockbox&&!t.lockboxUuid)try{t.lockboxUuid=n.uuidParse(e.base64DecryptToBytes(t.encryptedLockbox))}catch(t){console.error("[sdk:index] The grant could not be decrypted or was not a valid UUID: ",t)}return t})).filter((function(t){return t.lockboxUuid}))}function Qt(t,e){return t.map((function(t){try{return[!0,e.base64DecryptToJson(t.encryptedIndexEntry).grant]}catch(t){return console.error("[sdk:index] The consult lockbox grant could not be decrypted: ",t),[!1,void 0]}})).filter((function(t){return t[0]})).map((function(t){return t[1]}))}function Vt(t,e,r,n){return zt.apply(this,arguments)}function zt(){return(zt=s(L.mark((function t(e,r,n,a){var o,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===a&&(a=!1),n&&!a){t.next=5;break}return t.next=4,Yt(e);case 4:n=t.sent;case 5:if(!n[exports.IndexKey.Consultation]||!r){t.next=10;break}return i=(null!=(o=n[exports.IndexKey.Consultation])?o:[]).filter((function(t){return t.consultationId===r.consultationId})).map((function(t){return t.grant})),t.abrupt("return",i);case 10:return t.abrupt("return",[]);case 11:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Yt(t){return Zt.apply(this,arguments)}function Zt(){return(Zt=s(L.mark((function t(e){var r,n,a,o,i,s,c;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getGrants();case 2:n=t.sent,a=[],o=L.mark((function t(){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=s.value,t.next=3,e.vaultClient.lockboxMetadataGet(r.lockboxUuid,["consultationId"],[],{category:exports.MetadataCategory.Consultation});case 3:a=[].concat(a,t.sent[0].map((function(t){return u({},t,{grant:{lockboxOwnerUuid:r.lockboxOwnerUuid,lockboxUuid:r.lockboxUuid}})})));case 5:case"end":return t.stop()}}),t)})),i=b(n);case 6:if((s=i()).done){t.next=10;break}return t.delegateYield(o(),"t0",8);case 8:t.next=6;break;case 10:return(r={})[exports.IndexKey.Consultation]=a,e.setVaultIndex(c=r),console.info("[sdk:index] Successfully Built Vault Index"),t.abrupt("return",c);case 14:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var $t=function(){function t(t,e,r,n,a,o,i,s,u){this.toolbox=t,this.tellerClient=e,this.vaultClient=r,this.guardClient=n,this.practiceClient=a,this.consultClient=o,this.workflowClient=i,this.diagnosisClient=s,this.authenticationCallback=u,this.secrets=[],this.cachedMetadataGrants={},this.cachedManifest={}}var e=t.prototype;return e.cleanIndex=function(){var t=s(L.mark((function t(){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.vaultIndex=void 0,this.cachedMetadataGrants={},this.cachedManifest={};case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.signUp=function(){var t=s(L.mark((function t(e,r,a,o,i,s){var u,c,p,l,h,f,d;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.rsa=new n.CryptoRSA,u=this.rsa.private(),c=this.toolbox.CryptoChaCha.fromPassphrase(r),p=c.bytesEncryptToBase64Payload(u),l=this.toolbox.hashStringToBase64(this.toolbox.hashStringToBase64(r)),h={practiceUuid:a.uuid,email:e.toLowerCase(),password:l,publicKey:this.toolbox.encodeToBase64(this.rsa.public()),recoveryPassword:p,tosAndCpAcceptance:o,tokenData:i,subscription:s},t.next=8,this.guardClient.identityCreate(h);case 8:return(f=t.sent).recoveryLogin&&(d=this.toolbox.CryptoChaCha.fromPassphrase(f.recoveryLogin),sessionStorage.setItem(gt(f.id),d.bytesEncryptToBase64Payload(u))),t.abrupt("return",f);case 11:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o,i){return t.apply(this,arguments)}}(),e.confirmEmail=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.guardClient.setTokens({accessToken:e}),t.next=3,this.guardClient.whoAmI();case 3:return t.abrupt("return",this.guardClient.identityUpdate(t.sent.sub,{emailConfirmed:!0}));case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.signIn=function(){var t=s(L.mark((function t(e,r,n,a){var o,i,s;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=this.toolbox.hashStringToBase64(this.toolbox.hashStringToBase64(n)),i={practiceUuid:e,email:r.toLowerCase(),password:o,otp:a},t.next=4,this.guardClient.authToken(i);case 4:return t.next=6,this.guardClient.whoAmI();case 6:return s=t.sent.sub,t.next=9,this.recoverPrivateKeyFromPassword(s,n);case 9:return t.next=11,this.guardClient.identityGet(s);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.resumeSession=function(){var t=s(L.mark((function t(){var e,r,n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.guardClient.whoAmI();case 2:return e=t.sent.sub,r=sessionStorage.getItem(gt(e)),t.next=6,this.guardClient.identityGet(e);case 6:if((n=t.sent.recoveryLogin)&&r){t.next=9;break}throw z;case 9:a=this.toolbox.CryptoChaCha.fromPassphrase(n),o=a.base64PayloadDecryptToBytes(r),this.rsa=this.toolbox.CryptoRSA.fromKey(o);case 12:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.localEncryptToJsonPayload=function(t){if(!this.rsa)throw this.authenticationCallback&&this.authenticationCallback(new z),new z;var e=new this.toolbox.CryptoChaCha;return{encryptedData:e.jsonEncryptToBase64Payload(t),encryptedKey:this.toolbox.encodeToBase64(this.rsa.encryptToBytes(e.key()))}},e.localDecryptJsonPayload=function(t){var e=t.encryptedKey,r=t.encryptedData;if(!this.rsa)throw this.authenticationCallback&&this.authenticationCallback(new z),new z;var n=this.rsa.base64DecryptToBytes(e);return this.toolbox.CryptoChaCha.fromKey(n).base64PayloadDecryptToJson(r)},e.signOut=function(){var t=s(L.mark((function t(){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.rsa=void 0,this.secrets=[],this.guardClient.setTokens({accessToken:void 0,refreshToken:void 0}),t.next=5,this.guardClient.authLogout();case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.registerPatient=function(){var t=s(L.mark((function t(e,r,n,a){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.abrupt("return",Ot(e,r,n,this,this.toolbox.uuid(),a));case 3:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.buildVaultIndex=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e=!1),this.vaultIndex&&!e){t.next=4;break}return t.next=4,Yt(this);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.setVaultIndex=function(t){this.vaultIndex=t},e.forceUpdateIndexEntries=function(){var t=s(L.mark((function t(){var e,r,n=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants();case 2:return r=t.sent,t.next=5,Promise.all(r.map(function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.vaultClient.lockboxMetadataGet(e.lockboxUuid,["consultationId"],[],{category:exports.MetadataCategory.Consultation},e.lockboxOwnerUuid).then((function(t){try{return t[0].map((function(t){return u({},t,{grant:{lockboxOwnerUuid:e.lockboxOwnerUuid,lockboxUuid:e.lockboxUuid}})}))}catch(t){return[]}})).catch((function(){return[]}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())).then((function(t){return t.flat()}));case 5:this.vaultIndexAdd((e={},e[exports.IndexKey.Consultation]=t.sent,e)).then((function(){return alert("The Index was successfully updated!")})).catch((function(){return console.error("The index failed to update!")}));case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.vaultIndexAdd=function(){var t=s(L.mark((function t(e,r){var a,o,i,s,c,p=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:if(!r){t.next=9;break}return t.next=5,this.guardClient.identityGet(r);case 5:a=this.toolbox.decodeFromBase64(t.sent.publicKey),t.next=10;break;case 9:a=this.rsa.public();case 10:o={},i=0,s=Object.keys(e);case 12:if(!(i<s.length)){t.next=25;break}t.t0=c=s[i],t.next=t.t0===exports.IndexKey.ConsultationLockbox?18:t.t0===exports.IndexKey.Consultation?20:22;break;case 18:return o[c]=e[c].map((function(t){return u({},t,{uniqueHash:t.consultationId})})).map((function(t){return{uuid:t.uuid,timestamp:t.timestamp,uniqueHash:t.uniqueHash,encryptedIndexEntry:n.CryptoRSA.jsonWithPubEncryptToBase64({consultationId:t.consultationId,grant:t.grant},a)}})),t.abrupt("break",22);case 20:return o[c]=e[c].map((function(t){return u({},t,{uniqueHash:p.toolbox.hashStringToBase64(JSON.stringify({consultationId:t.consultationId,grant:t.grant}))})})).filter((function(t){var e;return!p.vaultIndex||!(null!=(e=p.vaultIndex[exports.IndexKey.Consultation])&&e.find((function(e){return e.uniqueHash===t.uniqueHash})))})).map((function(t){return{uuid:t.uuid,timestamp:t.timestamp,uniqueHash:t.uniqueHash,encryptedIndexEntry:n.CryptoRSA.jsonWithPubEncryptToBase64({consultationId:t.consultationId,grant:t.grant},a)}})),t.abrupt("break",22);case 22:i++,t.next=12;break;case 25:return t.next=27,this.vaultClient.vaultIndexPut(o,r);case 27:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.indexSnapshotAdd=function(){var t=s(L.mark((function t(e){var r,a,o,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:o=this.rsa.public(),(a={})[exports.IndexKey.Consultation]=null==(r=e[exports.IndexKey.Consultation])?void 0:r.filter((function(t){return t})).map((function(t){return{grant:t.grant,consultationId:t.consultationId}})),i=n.CryptoRSA.jsonWithPubEncryptToBase64(a,o),this.vaultClient.vaultIndexSnapshotPut({uuid:e.uuid,timestamp:e.timestamp,encryptedIndexEntry:i});case 7:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.grantLockbox=function(){var t=s(L.mark((function t(e,r,a){var o,i,s,u;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,this.getCachedSecretCryptor(r,a);case 4:return o=t.sent.key(),t.next=7,this.guardClient.identityGet(e);case 7:return i=this.toolbox.decodeFromBase64(t.sent.publicKey),s=n.CryptoRSA.bytesWithPubEncryptToBase64(o,i),u={encryptedSecret:s,granteeUuid:e},t.next=13,this.vaultClient.lockboxGrant(r,u,a);case 13:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.createMessageData=function(){var t=s(L.mark((function t(e,r,n,a,o){var i,s,u,c;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,this.getCachedSecretCryptor(e,a);case 4:return s=(i=t.sent).jsonEncryptToBase64Payload(r),t.t0=i,t.next=9,this.guardClient.whoAmI();case 9:return t.t1=t.sent.sub,t.t2={author:t.t1},u=t.t0.jsonEncryptToBase64Payload.call(t.t0,t.t2),c={consultationId:n,category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.Message,contentType:"text/plain"},t.abrupt("return",this.tellerClient.lockboxDataStore(e,{data:s,publicMetadata:c,privateMetadata:u},a,o));case 15:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o){return t.apply(this,arguments)}}(),e.createMessageAttachmentData=function(){var t=s(L.mark((function t(e,r,n,a,o){var i,s,u,c;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,this.getCachedSecretCryptor(e,a);case 4:return t.t0=i=t.sent,t.t1=Uint8Array,t.next=9,r.arrayBuffer();case 9:return t.t2=t.sent,t.t3=new t.t1(t.t2),s=t.t0.bytesEncryptToBase64Payload.call(t.t0,t.t3),t.t4=i,t.next=15,this.guardClient.whoAmI();case 15:return t.t5=t.sent.sub,t.t6=r.name,t.t7=r.lastModified,t.t8=r.size,t.t9={author:t.t5,fileName:t.t6,lastModified:t.t7,size:t.t8},u=t.t4.jsonEncryptToBase64Payload.call(t.t4,t.t9),c={consultationId:n,category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.Message,contentType:r.type},t.abrupt("return",this.tellerClient.lockboxDataStore(e,{data:s,publicMetadata:c,privateMetadata:u},a,o));case 24:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o){return t.apply(this,arguments)}}(),e.createConsultationAttachmentData=function(){var t=s(L.mark((function t(e,r,n,a,o,i){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.t0=this,t.t1=e,t.t2=Uint8Array,t.next=7,r.arrayBuffer();case 7:return t.t3=t.sent,t.t4=new t.t2(t.t3),t.t5={consultationId:n,category:exports.MetadataCategory.Consultation,documentType:a,contentType:r.type},t.next=12,this.guardClient.whoAmI();case 12:return t.t6=t.sent.sub,t.t7=r.name,t.t8={author:t.t6,fileName:t.t7},t.t9=o,t.t10=i,t.abrupt("return",t.t0.createBytesData.call(t.t0,t.t1,t.t4,t.t5,t.t8,t.t9,t.t10));case 18:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o,i){return t.apply(this,arguments)}}(),e.createJsonData=function(){var t=s(L.mark((function t(e,r,n,a,o,i){var s,u,c;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,this.getCachedSecretCryptor(e,o);case 4:return u=(s=t.sent).jsonEncryptToBase64Payload(r),c=s.jsonEncryptToBase64Payload(a),t.abrupt("return",this.tellerClient.lockboxDataStore(e,{data:u,publicMetadata:n,privateMetadata:c},o,i));case 9:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o,i){return t.apply(this,arguments)}}(),e.getOrInsertJsonData=function(){var t=s(L.mark((function t(e,r,n,a,o){var i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===o&&(o=!1),t.next=3,this.vaultClient.lockboxManifestGet(e,n);case 3:if(i=t.sent,o||!(i.length>0)){t.next=9;break}return console.log("The data for "+JSON.stringify(n)+" already exist"),t.abrupt("return",i[0].dataUuid);case 9:return t.next=11,this.createJsonData(e,r,n,a,void 0,o&&i.length>0?i[0].dataUuid:void 0).catch((function(t){throw console.error("Error while upserting data "+JSON.stringify(n)+" data",t),t}));case 11:return t.abrupt("return",t.sent.dataUuid);case 12:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o){return t.apply(this,arguments)}}(),e.createBytesData=function(){var t=s(L.mark((function t(e,r,n,a,o,i){var s,u,c;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,this.getCachedSecretCryptor(e,o);case 4:return u=(s=t.sent).bytesEncryptToBase64Payload(r),c=s.jsonEncryptToBase64Payload(a),t.abrupt("return",this.tellerClient.lockboxDataStore(e,{data:u,publicMetadata:n,privateMetadata:c},o,i));case 9:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o,i){return t.apply(this,arguments)}}(),e.getJsonData=function(){var t=s(L.mark((function t(e,r,n){var a;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,Promise.all([this.vaultClient.lockboxDataGet(e,r,n),this.getCachedSecretCryptor(e,n)]);case 4:return t.abrupt("return",(a=t.sent)[1].base64PayloadDecryptToJson(a[0].data));case 8:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getBytesData=function(){var t=s(L.mark((function t(e,r,n){var a;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return t.next=4,Promise.all([this.vaultClient.lockboxDataGet(e,r,n),this.getCachedSecretCryptor(e,n)]);case 4:return t.abrupt("return",(a=t.sent)[1].base64PayloadDecryptToBytes(a[0].data));case 8:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getGrants=function(){var t=s(L.mark((function t(e,r){var n,a,o,i,s;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=!1),this.rsa){t.next=3;break}throw z;case 3:if(n=JSON.stringify(e),r||!this.cachedMetadataGrants[n]){t.next=6;break}return t.abrupt("return",this.cachedMetadataGrants[n]);case 6:return t.next=8,this.vaultClient.vaultIndexGet([exports.IndexKey.ConsultationLockbox],[null==e?void 0:e.consultationId]);case 8:if(t.t0=exports.IndexKey.ConsultationLockbox,!((o=Qt(null!=(a=t.sent[t.t0])?a:[],this.rsa)).length>0)){t.next=15;break}return console.info("[sdk:index] Grants found in user`s constant time secure index"),this.cachedMetadataGrants[JSON.stringify(e)]=o,t.abrupt("return",this.cachedMetadataGrants[n]);case 15:if(!e){t.next=21;break}return t.next=18,Vt(this,e,this.vaultIndex,r);case 18:i=t.sent,t.next=24;break;case 21:return t.next=23,this.vaultClient.grantsGet();case 23:i=t.sent.grants;case 24:return t.next=26,Ht(i,this.rsa);case 26:return this.cachedMetadataGrants[n]=s=t.sent,t.abrupt("return",s);case 29:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getCachedSecretCryptor=function(){var t=s(L.mark((function t(e,r){var n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:if(-1!==(n=this.secrets.findIndex((function(t){return t.lockboxUuid===e})))){t.next=13;break}return t.next=6,this.vaultClient.lockboxSecretGet(e,r);case 6:return a=this.rsa.base64DecryptToBytes(t.sent.sharedSecret),o=this.toolbox.CryptoChaCha.fromKey(a),this.secrets.push({lockboxUuid:e,cryptor:o}),t.abrupt("return",o);case 13:return t.abrupt("return",this.secrets[n].cryptor);case 14:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getPersonalInformationsFromConsultId=function(){var t=s(L.mark((function t(e,r,n){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=!1),t.abrupt("return",this.getMetaCategoryFromConsultId(e,r,n));case 2:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getMedicalDataFromConsultId=function(){var t=s(L.mark((function t(e,r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),t.abrupt("return",this.getMetaCategoryFromConsultId(e,exports.MetadataCategory.Medical,r));case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getMetaCategoryFromConsultId=function(){var t=s(L.mark((function t(e,r,n){var a,o,i,c,p,l=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n=!1),t.next=3,this.getGrants({consultationId:e});case 3:a=t.sent,o=[],i=L.mark((function t(){var a,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=p.value,t.next=3,l.getLockboxManifest(a.lockboxUuid,{category:r,documentType:exports.DocumentType.PopulatedWorkflowData,consultationIds:[e]},!0,a.lockboxOwnerUuid,n);case 3:if(0!==(i=t.sent).length){t.next=8;break}return t.next=7,l.getLockboxManifest(a.lockboxUuid,{category:r,documentType:exports.DocumentType.PopulatedWorkflowData},!0,a.lockboxOwnerUuid,n);case 7:i=t.sent.filter((function(t){return!t.metadata.consultationIds}));case 8:return t.next=10,Promise.all(i.map(function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=a.lockboxOwnerUuid,t.t1=a.lockboxUuid,t.t2=e.dataUuid,t.next=5,l.getJsonData(a.lockboxUuid,e.dataUuid);case 5:return t.t3=t.sent,t.abrupt("return",{lockboxOwnerUuid:t.t0,lockboxUuid:t.t1,dataUuid:t.t2,data:t.t3});case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 10:o=u({},o,t.sent);case 12:case"end":return t.stop()}}),t)})),c=b(a);case 7:if((p=c()).done){t.next=11;break}return t.delegateYield(i(),"t0",9);case 9:t.next=7;break;case 11:return t.abrupt("return",o);case 12:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getPersonalInformations=function(){var t=s(L.mark((function t(e){var r,n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants();case 2:if(r=t.sent.find((function(t){return t.lockboxOwnerUuid===e}))){t.next=5;break}throw Y;case 5:if(a=r.lockboxOwnerUuid,n=r.lockboxUuid){t.next=8;break}throw Z;case 8:if(a){t.next=10;break}throw $;case 10:return t.next=12,this.getLockboxManifest(n,{category:exports.MetadataCategory.Personal,documentType:exports.DocumentType.PopulatedWorkflowData},!1,e);case 12:return o=t.sent[0].dataUuid,t.t0=a,t.t1=n,t.t2=o,t.next=18,this.getJsonData(n,o);case 18:return t.t3=t.sent,t.abrupt("return",{lockboxOwnerUuid:t.t0,lockboxUuid:t.t1,dataUuid:t.t2,data:t.t3});case 20:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getGrantFromConsultId=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants({consultationId:e});case 2:if(0!==(r=t.sent).length){t.next=5;break}throw tt;case 5:return t.abrupt("return",r[0]);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getIdentityFromConsultId=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrantFromConsultId(e);case 2:if(!(r=t.sent)||!r.lockboxOwnerUuid){t.next=9;break}return t.next=6,this.guardClient.identityGet(r.lockboxOwnerUuid);case 6:return t.abrupt("return",t.sent);case 9:return t.abrupt("return",void 0);case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getLockboxManifest=function(){var t=s(L.mark((function t(e,r,n,a,o){var i,c=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===o&&(o=!1),i=JSON.stringify({lockboxUuid:e,filter:r,expandPrivateMetadata:n,lockboxOwnerUuid:a}),o||!this.cachedManifest[i]){t.next=4;break}return t.abrupt("return",this.cachedManifest[i]);case 4:return t.abrupt("return",this.vaultClient.lockboxManifestGet(e,r,a).then((function(t){return Promise.all(t.map(function(){var t=s(L.mark((function t(r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n||!r.metadata.privateMetadata){t.next=5;break}return t.next=3,c.getJsonData(e,r.metadata.privateMetadata,a);case 3:r.metadata=u({},r.metadata,t.sent);case 5:return t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())).then((function(t){return c.cachedManifest[i]=t}))})));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a,o){return t.apply(this,arguments)}}(),e.createPersonalInformations=function(){var t=s(L.mark((function t(e,r,n){var a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants();case 2:if(t.t0=a=t.sent.find((function(t){return t.lockboxOwnerUuid===e.id})),null!=t.t0){t.next=7;break}t.t1=void 0,t.next=8;break;case 7:t.t1=a.lockboxUuid;case 8:if(!(o=t.t1)){t.next=13;break}return t.abrupt("return",this.createJsonData(o,r,{category:exports.MetadataCategory.Personal,documentType:exports.DocumentType.PopulatedWorkflowData},{},void 0,n));case 13:throw Z;case 14:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.createUserPreference=function(){var t=s(L.mark((function t(e,r,n){var a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants();case 2:if(t.t0=a=t.sent.find((function(t){return t.lockboxOwnerUuid===e.id})),null!=t.t0){t.next=7;break}t.t1=void 0,t.next=8;break;case 7:t.t1=a.lockboxUuid;case 8:if(!(o=t.t1)){t.next=13;break}return t.abrupt("return",this.createJsonData(o,r,{category:exports.MetadataCategory.Preference,contentType:"application/json"},{},void 0,n));case 13:throw Z;case 14:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.getDataFromGrant=function(){var t=s(L.mark((function t(e,r){var n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=e.lockboxOwnerUuid,n=e.lockboxUuid){t.next=3;break}throw Z;case 3:if(a){t.next=5;break}throw $;case 5:return t.next=7,this.getLockboxManifest(n,r,!1,e.lockboxOwnerUuid,!0);case 7:return o=t.sent[0].dataUuid,t.t0=a,t.t1=n,t.t2=o,t.next=13,this.getJsonData(n,o);case 13:return t.t3=t.sent,t.abrupt("return",{lockboxOwnerUuid:t.t0,lockboxUuid:t.t1,dataUuid:t.t2,data:t.t3});case 15:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getUserPreferenceFromConsultId=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrantFromConsultId(e);case 2:if(r=t.sent){t.next=5;break}throw Y;case 5:return t.abrupt("return",this.getDataFromGrant(r,{category:exports.MetadataCategory.Preference,contentType:"application/json"}));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getUserPreference=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants();case 2:if(r=t.sent.find((function(t){return t.lockboxOwnerUuid===e.id}))){t.next=5;break}throw Y;case 5:return t.abrupt("return",this.getDataFromGrant(r,{category:exports.MetadataCategory.Preference,contentType:"application/json"}));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getRecoveryDataFromConsultId=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrantFromConsultId(e);case 2:if(r=t.sent){t.next=5;break}throw Y;case 5:return t.abrupt("return",this.getDataFromGrant(r,{category:exports.MetadataCategory.Recovery,contentType:"application/json"}));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getRecoveryData=function(){var t=s(L.mark((function t(e){var r;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrants();case 2:if(r=t.sent.find((function(t){return t.lockboxOwnerUuid===e.id}))){t.next=5;break}throw Y;case 5:return t.abrupt("return",this.getDataFromGrant(r,{category:exports.MetadataCategory.Recovery,contentType:"application/json"}));case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getAssignedConsultations=function(){var t=s(L.mark((function t(e,r){var n=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),t.t0=Promise,t.next=4,this.getGrants(void 0,r);case 4:return t.t1=t.sent.map((function(t){return n.getLockboxManifest(t.lockboxUuid,{category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.PopulatedWorkflowData},!0,void 0,r).then((function(t){return Promise.all(t.map(function(){var t=s(L.mark((function t(r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.consultClient.getConsultByUUID(r.metadata.consultationId,e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())).then((function(t){return t.flat()}))}))})),t.abrupt("return",t.t0.all.call(t.t0,t.t1).then((function(t){return t.flat()})));case 6:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getPastConsultationsFromConsultId=function(){var t=s(L.mark((function t(e,r){var n,a,o=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getGrantFromConsultId(e);case 2:if(n=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.next=7,this.vaultClient.lockboxMetadataGet(n.lockboxUuid,["consultationId"],["consultationId"],{category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.PopulatedWorkflowData},n.lockboxOwnerUuid);case 7:if(0!=(a=t.sent.flat().map((function(t){return t.consultationId}))).length){t.next=10;break}return t.abrupt("return",[]);case 10:return t.next=12,Promise.all(a.map(function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.consultClient.getConsultByUUID(e,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 12:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getPatientConsultationData=function(){var t=s(L.mark((function t(e,r){var n=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===r&&(r=!1),t.t0=Promise,t.next=4,this.getGrants({consultationId:e},r);case 4:return t.t1=t.sent.map((function(t){return n.getLockboxManifest(t.lockboxUuid,{category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.PopulatedWorkflowData,consultationId:e},!0,t.lockboxOwnerUuid,r).then((function(e){return Promise.all(e.map((function(e){return n.getJsonData(t.lockboxUuid,e.dataUuid,t.lockboxOwnerUuid)})))}))})).flat(),t.abrupt("return",t.t0.all.call(t.t0,t.t1).then((function(t){return t.flat()})));case 6:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getPatientPrescriptionsList=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getPatientDocumentsList({category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.Prescription},!0,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getPatientResultsList=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getPatientDocumentsList({category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.Result},!0,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getPatientTreatmentPlans=function(){var t=s(L.mark((function t(e){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getPatientDocumentsList({category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.TreatmentPlan},!0,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.getPatientTreatmentPlanByUuid=function(){var t=s(L.mark((function t(e,r){return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getPatientDocumentsList({category:exports.MetadataCategory.Consultation,documentType:exports.DocumentType.TreatmentPlan,treatmentPlanId:r},!0,e));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.getPatientDocumentsList=function(){var t=s(L.mark((function t(e,r,n){var a=this;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=Promise,t.next=3,this.getGrants({consultationId:n});case 3:return t.t1=t.sent.map((function(t){return a.getLockboxManifest(t.lockboxUuid,u({},e,{consultationId:n}),r,t.lockboxOwnerUuid,!0).then((function(e){return Promise.all(e.map(function(){var e=s(L.mark((function e(r){return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",u({lockboxOwnerUuid:t.lockboxOwnerUuid,lockboxUuid:t.lockboxUuid},r));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()))}))})).flat(),t.abrupt("return",t.t0.all.call(t.t0,t.t1).then((function(t){return t.flat()})));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.recoverPrivateKeyFromSecurityQuestions=function(){var t=s(L.mark((function t(e,r,n,a){var o,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.guardClient.identityGet(e);case 2:o=t.sent.recoverySecurityQuestions.filter((function(t){var e=r.indexOf(t.securityQuestion);return-1!==e&&n[e]&&""!=n[e]})).map((function(t){var e=r.indexOf(t.securityQuestion);return t.securityAnswer=n[e],t}));try{i=this.toolbox.reconstructSecret(o,a),this.rsa=this.toolbox.CryptoRSA.fromKey(i)}catch(t){console.error(t)}case 5:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.recoverPrivateKeyFromPassword=function(){var t=s(L.mark((function t(e,r){var n,a,o,i,s;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.guardClient.identityGet(e);case 2:a=(n=t.sent).recoveryPassword,o=this.toolbox.CryptoChaCha.fromPassphrase(r),i=o.base64PayloadDecryptToBytes(a),n.recoveryLogin&&(s=this.toolbox.CryptoChaCha.fromPassphrase(n.recoveryLogin),sessionStorage.setItem(gt(e),s.bytesEncryptToBase64Payload(i))),this.rsa=this.toolbox.CryptoRSA.fromKey(i);case 8:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.recoverPrivateKeyFromMasterKey=function(){var t=s(L.mark((function t(e,r){var n,a,o;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.guardClient.identityGet(e);case 2:n=t.sent.recoveryMasterKey,a=this.toolbox.CryptoChaCha.fromPassphrase(r),o=a.base64PayloadDecryptToBytes(n),this.rsa=this.toolbox.CryptoRSA.fromKey(o);case 6:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.updateSecurityQuestions=function(){var t=s(L.mark((function t(e,r,n,a){var o,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return o=this.toolbox.breakSecretIntoShards(r,n,this.rsa.private(),a),i={recoverySecurityQuestions:o},t.next=6,this.guardClient.identityUpdate(e,i);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)})));return function(e,r,n,a){return t.apply(this,arguments)}}(),e.updatePassword=function(){var t=s(L.mark((function t(e,r,n){var a,o,i;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return a=this.toolbox.CryptoChaCha.fromPassphrase(r),o=a.bytesEncryptToBase64Payload(this.rsa.private()),n&&(n=this.toolbox.hashStringToBase64(this.toolbox.hashStringToBase64(n))),r=this.toolbox.hashStringToBase64(this.toolbox.hashStringToBase64(r)),i={password:{oldPassword:n,newPassword:r},recoveryPassword:o},t.next=9,this.guardClient.identityUpdate(e,i);case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.updateMasterKey=function(){var t=s(L.mark((function t(e,r,n){var a,o,i,s;return L.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.rsa){t.next=2;break}throw z;case 2:return a=this.toolbox.CryptoChaCha.fromPassphrase(r),o=a.bytesEncryptToBase64Payload(this.rsa.private()),i={recoveryMasterKey:o},t.next=7,this.guardClient.identityUpdate(e,i);case 7:return s=t.sent,t.next=10,this.getOrInsertJsonData(n,{masterKey:r},{category:exports.MetadataCategory.Recovery,contentType:"application/json"},{},!0);case 10:return t.abrupt("return",s);case 11:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),t}();exports.OroToolboxNamespace=n,exports.APIService=S,exports.AssociatedLockboxNotFound=tt,exports.AuthenticationBadRequest=nt,exports.AuthenticationFailed=rt,exports.AuthenticationServerError=at,exports.AxiosService=D,exports.CliniaService=bt,exports.ConsultService=ct,exports.DiagnosisService=pt,exports.GuardService=lt,exports.IdentityCreationBadRequest=it,exports.IdentityCreationConflict=st,exports.IdentityCreationFailed=ot,exports.IncompleteAuthentication=z,exports.IndexBuildError=X,exports.MissingGrant=Y,exports.MissingLockbox=Z,exports.MissingLockboxOwner=$,exports.OroClient=$t,exports.PracticeService=ht,exports.TellerService=ft,exports.VaultService=dt,exports.WorkflowAnswersMissingError=et,exports.WorkflowService=xt,exports.decryptConsultLockboxGrants=Qt,exports.decryptGrants=Ht,exports.default=function(t,e,r,n,a,o,i,s,u){var c=new S(void 0,u),p=new ft(c,e),l=new ht(t,c,a),h=new ct(c,o),f=new dt(c,r),d=new lt(c,n),x=new xt(c,i),y=new pt(c,s);return new $t(t,p,f,d,l,h,x,y,u)},exports.extractAndStorePersonalWorkflowData=Wt,exports.extractISOLocalityForConsult=function(t){if(t){var e=t.flatMap((function(t){var e=Object.keys(t).filter((function(t){return-1!==t.indexOf("Country")})).flat(),r=Object.keys(t).filter((function(t){return-1!==t.indexOf("Province")})).flat(),n=Object.keys(t).filter((function(t){return-1!==t.indexOf("Locality")})).flat();return[].concat(e.map((function(e){return"string"==typeof t[e]?t[e]:void 0})),r.map((function(e){return"string"==typeof t[e]?t[e]:void 0})),n.map((function(e){return"string"==typeof t[e]?t[e]:void 0})))})).filter((function(t){return void 0!==t})).filter((function(t){return t.startsWith("isoLocalityConsult")}));if(e&&0!==e.length){var r=o(/isoLocalityConsult(?:_(\d*))?\x2D([a-zA-Z0-9]{2}\x2D[a-zA-Z0-9]{1,3})/,{indexPriority:1,isoValue:2}),n=e.reduce((function(t,e){var n=r.exec(e),a=null!=n?n:[],o=a[1],i=a[2];if(!t)return i;var s=r.exec(t),u=null!=s?s:[],c=u[1];return!o||c&&c>o?u[2]:i}),void 0);return console.log("Picking locality "+n),n}console.log("no locality found in "+e)}},exports.fillWorkflowFromPopulatedWorkflow=function(t,e){var r=JSON.parse(JSON.stringify(t));return r.selectedAnswers||(r.selectedAnswers=St(r,!1)),r.pages.forEach((function(t,n){for(var a=0,o=Object.entries(t.questions);a<o.length;a++){var i=o[a][0];e.fields[i]&&r.selectedAnswers&&(r.selectedAnswers[n][i]=e.fields[i].answer)}})),r},exports.filterTriggeredAnsweredWithKind=wt,exports.flattenSelectedAnswers=Dt,exports.getImagesFromIndexDb=Rt,exports.getInitialisedSelectedAnswers=St,exports.getWorkflowDataByCategory=Ct,exports.identificationToPersonalInformations=function(t,e){var r,n=mt[e];return{birthday:t[n+"Birthday"],firstname:t[n+"Firstname"],gender:t[n+"Gender"],name:t[n+"Name"],phone:t[n+"Phone"],zip:t[n+"Zip"],hid:null!=(r=t[n+"HID"])?r:t[n+"ID"],pharmacy:t[n+"Pharmacy"],address:t[n+"Address"]}},exports.isTriggered=Lt,exports.registerPatient=Ot,exports.sessionStorePrivateKeyName=gt,exports.toActualObject=function(t){var e={};return Object.entries(t.fields).forEach((function(t){var r=t[1];e[t[0]]=r.displayedAnswer?r.displayedAnswer:r.answer})),e},exports.updatePersonalIntoPopulatedWorkflowData=function(t,e,r){var n=mt[r],a=JSON.parse(JSON.stringify(e));return t.birthday&&a.fields[n+"Birthday"]&&(a.fields[n+"Birthday"].answer=t.birthday),t.firstname&&a.fields[n+"Firstname"]&&(a.fields[n+"Firstname"].answer=t.firstname),t.gender&&a.fields[n+"Gender"]&&(a.fields[n+"Gender"].answer=t.gender),t.name&&a.fields[n+"Name"]&&(a.fields[n+"Name"].answer=t.name),t.phone&&a.fields[n+"Phone"]&&(a.fields[n+"Phone"].answer=t.phone),t.zip&&a.fields[n+"Zip"]&&(a.fields[n+"Zip"].answer=t.zip),t.hid&&(a.fields[n+"HID"]?a.fields[n+"HID"].answer=t.hid:a.fields[n+"ID"]?a.fields[n+"ID"].answer=t.hid:a.fields[n+"HID"]={kind:"text",answer:t.hid}),a},exports.wasmPath="node_modules/oro-toolbox";
2
+ //# sourceMappingURL=oro-sdk.cjs.production.min.js.map