@openmrs/esm-api 3.2.1-pre.972 → 3.3.1-pre.1173

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.
@@ -0,0 +1,19 @@
1
+ @openmrs/esm-api:build: cache hit, replaying output 7c18596787910f43
2
+ @openmrs/esm-api:build: $ webpack --mode=production
3
+ @openmrs/esm-api:build: asset openmrs-esm-api.js 57.2 KiB [emitted] [minimized] (name: main) 1 related asset
4
+ @openmrs/esm-api:build: orphan modules 367 KiB [orphan] 226 modules
5
+ @openmrs/esm-api:build: runtime modules 2.14 KiB 8 modules
6
+ @openmrs/esm-api:build: built modules 183 KiB [built]
7
+ @openmrs/esm-api:build: modules by path ../../../node_modules/fhir.js/src/ 28.9 KiB
8
+ @openmrs/esm-api:build: modules by path ../../../node_modules/fhir.js/src/middlewares/*.js 16.7 KiB 10 modules
9
+ @openmrs/esm-api:build: modules by path ../../../node_modules/fhir.js/src/*.js 12.2 KiB 3 modules
10
+ @openmrs/esm-api:build: modules by path ../../../node_modules/systemjs-webpack-interop/ 3.27 KiB
11
+ @openmrs/esm-api:build: ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
12
+ @openmrs/esm-api:build: ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
13
+ @openmrs/esm-api:build: ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
14
+ @openmrs/esm-api:build: ./src/index.ts + 80 modules 121 KiB [built] [code generated]
15
+ @openmrs/esm-api:build: ../../../node_modules/regenerator-runtime/runtime.js 24.3 KiB [built] [code generated]
16
+ @openmrs/esm-api:build: external "@openmrs/esm-config" 42 bytes [built] [code generated]
17
+ @openmrs/esm-api:build: ../../../node_modules/merge/merge.js 2.85 KiB [built] [code generated]
18
+ @openmrs/esm-api:build: ../../../node_modules/Base64/base64.js 2.17 KiB [built] [code generated]
19
+ @openmrs/esm-api:build: webpack 5.70.0 compiled successfully in 8570 ms
@@ -1,3 +1,2 @@
1
- /*! For license information please see openmrs-esm-api.js.LICENSE.txt */
2
- System.register(["@openmrs/esm-config"],(function(t,e){var r={};return{setters:[function(t){r.Type=t.Type,r.defineConfigSchema=t.defineConfigSchema,r.getConfig=t.getConfig,r.navigate=t.navigate,r.validators=t.validators}],execute:function(){t((()=>{var t={672:(t,e)=>{!function(){var t=e,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function n(t){this.message=t}n.prototype=new Error,n.prototype.name="InvalidCharacterError",t.btoa||(t.btoa=function(t){for(var e,i,o=String(t),s=0,u=r,c="";o.charAt(0|s)||(u="=",s%1);c+=u.charAt(63&e>>8-s%1*8)){if((i=o.charCodeAt(s+=3/4))>255)throw new n("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|i}return c}),t.atob||(t.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,o,s=0,u=0,c="";o=e.charAt(u++);~o&&(i=s%4?64*i+o:o,s++%4)?c+=String.fromCharCode(255&i>>(-2*s&6)):0)o=r.indexOf(o);return c})}()},525:function(t){(function(){var e,r;function n(t,i){var o,s=t.data.entry||[],u=[];for(o=0;o<s.length;o++)u.push(s[o].resource);i(u);var c=r.defer();return e.nextPage({bundle:t.data}).then((function(t){n(t,i).then((function(t){c.resolve()}))}),(function(t){c.resolve()})),c.promise}function i(t,i,o,s){r.defer(),e.search(t).then((function(t){n(t,i).then((function(){o()}),(function(t){s(t)}))}),(function(t){s(t)}))}function o(t){var e=r.defer(),n=[];return i(t,(function(t){t.forEach((function(t){n.push(t)}))}),(function(){e.resolve(n)}),(function(t){e.reject(t)})),e.promise}function s(t,n){var i=r.defer();return e.search(t).then((function(t){var r={},o=[function(){i.resolve(t,r)}];function s(){o.pop()()}var u=t.data;u.entry&&u.entry.forEach((function(t){var i=t.resource,c=i.resourceType;n&&n.forEach((function(t){var n=t.split("."),a=n[0],l=n[1],h=i[l];if(c===a&&h){var f=h.reference;r[f]||function(t,n,i){o.push((function(){!function(t,n,i){var o=i.reference;e.resolve({bundle:t,resource:n,reference:i}).then((function(t){var e=t.data||t.content;r[o]=e,s()}))}(t,n,i)}))}(u,i,h)}}))})),s()}),(function(){i.reject("Could not fetch search results")})),i.promise}t.exports=function(t,n){return e=t,r=n,t.drain=i,t.fetchAll=o,t.fetchAllWithReferences=s,t}}).call(this)},256:function(t,e,r){(function(){r(454);var e=r(801),n=r(921),i=r(294),o=r(821),s=r(442),u=r(856),c=r(719),a=r(29),l=r(723),h=r(249),f=r(525);t.exports=function(t,r){var p=e.Middleware,d=e.$$Attr,b=function(t){return d("method",t)},y=function(t,e){return d("headers."+t,e)},v=p(s),m=p(u(t,r)).and(v).and(i.$Basic).and(i.$Bearer).and(i.$Credentials).and(o.$JsonData).and(y("Accept",t.headers&&t.headers.Accept?t.headers.Accept:"application/json")).and(y("Content-Type",t.headers&&t.headers["Content-Type"]?t.headers["Content-Type"]:"application/json")),g=m.and(b("GET")),w=m.and(b("POST")),_=m.and(b("PUT")),S=m.and(b("DELETE")),E=m.and(b("PATCH")),x=o.Http(t,r),O=h.Path,T=O(t.baseUrl),j=T.slash(":type || :resource.resourceType"),P=j.slash("_history"),$=j.slash(":id || :resource.id"),I=$.slash("_history"),A=$.slash(":versionId || :resource.meta.versionId"),N=T.slash(":target.resourceType || :target.type").slash(":target.id").slash(":target.versionId"),C=y("Prefer","return=representation"),k=p(n.$Paging);return f({conformance:g.and(T.slash("metadata")).end(x),document:w.and(T.slash("Document")).end(x),profile:g.and(T.slash("Profile").slash(":type")).end(x),transaction:w.and(T).end(x),history:g.and(T.slash("_history")).and(k).end(x),typeHistory:g.and(P).and(k).end(x),resourceHistory:g.and(I).and(k).end(x),read:g.and(a.$WithPatient).and($).end(x),vread:g.and(A).end(x),delete:S.and($).and(C).end(x),create:w.and(j).and(C).end(x),validate:w.and(j.slash("_validate")).end(x),meta:{add:w.and(N.slash("$meta-add")).end(x),delete:w.and(N.slash("$meta-delete")).end(x),read:g.and(N.slash("$meta")).end(x)},search:g.and(j).and(a.$WithPatient).and(n.$SearchParams).and(k).end(x),update:_.and($).and(C).end(x),conditionalUpdate:_.and(j).and(n.$SearchParams).and(C).end(x),conditionalDelete:S.and(j).and(n.$SearchParams).and(C).end(x),nextPage:g.and(c.$$BundleLinkUrl("next")).end(x),prevPage:g.and(c.$$BundleLinkUrl("previous")).and(c.$$BundleLinkUrl("prev")).end(x),getBundleByUrl:g.and(O(":url")).end(x),resolve:g.and(l.resolve).end(x),patch:E.and($).and(y("Content-Type","application/json-patch+json")).end(x)},r)}}).call(this)},294:function(t,e,r){(function(){var t,n=r(801),i=r(672).btoa;e.$Basic=n.$$Attr("headers.Authorization",(function(t){if(t.auth&&t.auth.user&&t.auth.pass)return"Basic "+i(t.auth.user+":"+t.auth.pass)})),e.$Bearer=n.$$Attr("headers.Authorization",(function(t){if(t.auth&&t.auth.bearer)return"Bearer "+t.auth.bearer})),e.$Credentials=n.Middleware(n.$$Attr("credentials",(function(e){return t=e.credentials,""}))).and(n.$$Attr("credentials",(function(e){if(["same-origin","include"].indexOf(t)>-1)return t})))}).call(this)},719:(t,e)=>{e.$$BundleLinkUrl=function(t){return function(e){return function(r){var n=r.bundle&&(r.bundle.link||[]).filter((function(e){return e.relation&&e.relation===t}))[0];return n&&n.url&&(r.url=n.url,r.data=null),e(r)}}}},856:function(t){(function(){var e=function(t,e,r){var n=t[r];return n&&!e[r]&&(e[r]=n),t};t.exports=function(t,r){return function(n){return function(i){return e(t,i,"baseUrl"),e(t,i,"cache"),e(t,i,"auth"),e(t,i,"patient"),e(t,i,"debug"),e(t,i,"credentials"),e(t,i,"headers"),e(t,i,"agentOptions"),e(r,i,"defer"),e(r,i,"http"),n(i)}}}}).call(this)},801:function(t,e,r){(function(){var t=r(454),n=function(t){return t.and=function(e){return n((r=t,i=e,function(t){return r(i(t))}));var r,i},t.end=function(e){return t(e)},t};e.$$Simple=function(t){return function(e){return function(r){return e(t(r))}}},e.$$Attr=function(e,r){return n((function(n){return function(i){var o;return o="function"==t.type(r)?r(i):r,n(null==o&&null==o?i:function(t,e,r){for(var n=e.split("."),i=t,o=0;o<n.length-1;o++){var s=n[o];(i=t[s])||(i={},t[s]=i)}return i[n[n.length-1]]=r,t}(i,e,o))}}))};var i=function(t,e){return n((function(r){return function(n){return n[t]=e(n),r(n)}}))};e.Middleware=n,e.Attribute=i,e.Method=function(t){return i("method",(e=t,function(){return e}));var e}}).call(this)},442:t=>{t.exports=function(t){return function(e){try{return t(e)}catch(t){if(e.debug&&(console.log("\nDEBUG: (ERROR in middleware)"),console.log(t.message),console.log(t.stack)),!e.defer)throw console.log("\nDEBUG: (ERROR in middleware)"),console.log(t.message),console.log(t.stack),new Error("I need adapter.defer");var r=e.defer();return r.reject(t),r.promise}}}},821:function(t,e,r){(function(){var t=r(454);e.Http=function(t,e){return function(r){r.debug&&console.log("\nDEBUG (request):",r.method,r.url,r);var n=(r.http||e.http||t.http)(r);return r.debug&&n&&n.then&&n.then((function(t){console.log("\nDEBUG: (responce)",t)})),n}},e.$JsonData=function(e){return function(r){var n,i=r.bundle||r.data||r.resource;return i&&(r.data=(n=i,"object"==t.type(n)||"array"==t.type(n)?JSON.stringify(n):n)),e(r)}}}).call(this)},29:function(t,e,r){(function(){var t=r(801),n=["Account","AllergyIntolerance","BodySite","CarePlan","Claim","ClinicalImpression","Communication","CommunicationRequest","Composition","Condition","Contract","DetectedIssue","Device","DeviceUseRequest","DeviceUseStatement","DiagnosticOrder","DiagnosticReport","DocumentManifest","DocumentReference","Encounter","EnrollmentRequest","EpisodeOfCare","FamilyMemberHistory","Flag","Goal","ImagingObjectSelection","ImagingStudy","Immunization","ImmunizationRecommendation","List","Media","MedicationAdministration","MedicationDispense","MedicationOrder","MedicationStatement","NutritionOrder","Observation","Order","Procedure","ProcedureRequest","QuestionnaireResponse","ReferralRequest","RelatedPerson","RiskAssessment","Specimen","SupplyDelivery","SupplyRequest","VisionPrescription"];e.$WithPatient=t.$$Simple((function(t){var e=t.type;return t.patient&&("Patient"===e?(t.query=t.query||{},t.query._id=t.patient,t.id=t.patient):n.indexOf(e)>=0&&(t.query=t.query||{},t.query.patient=t.patient)),t}))}).call(this)},723:function(t,e,r){(function(){var e=r(454),n=/^#(.*)/,i=function(t){var r=t.cache,i=t.reference,o=t.bundle,s=i;if(!s.reference)return null;if(s.reference.match(n))return function(t,e){var r=t.match(n)[1],i=(e.contained||[]).filter((function(t){return(t.id||t._id)==r}))[0];return i&&{content:i}||null}(s.reference,t.resource);var u=e.absoluteUrl(t.baseUrl,s.reference);return(o&&o.entry||[]).filter((function(t){return t.id===u}))[0]||(null!=r?r[u]:void 0)||null};t.exports.sync=i,t.exports.resolve=function(t){return function(r){var o=i(r),s=r.reference,u=r.defer();if(o){if(!r.defer)throw new Error("I need promise constructor 'adapter.defer' in adapter");return u.resolve(o),u.promise}if(!s)throw new Error("No reference found");if(s&&s.reference.match(n))throw new Error("Contained resource not found");return r.url=e.absoluteUrl(r.baseUrl,s.reference),r.data=null,t(r)}}}).call(this)},921:function(t,e,r){(function(){var t=r(454),n=t.type,i=t.assertArray,o=(t.assertObject,t.reduceMap),s=t.identity,u={$gt:"gt",$lt:"lt",$lte:"lte",$gte:"gte",$ge:"ge",$le:"le"},c={$asc:":asc",$desc:":desc",$exact:":exact",$missing:":missing",$null:":missing",$text:":text"},a=function(t,e){if("$sort"===t)return function(t){var e,r,o,s;for(i(t),o=[],e=0,r=t.length;e<r;e++)switch(s=t[e],n(s)){case"array":o.push({param:"_sort",value:s[0],modifier:":"+s[1]});break;case"string":o.push({param:"_sort",value:s});break;default:o.push(void 0)}return o}(e);if("$has"===t)return o(e,(function(t,e){var r,i;return r=e[0],i=e[1],t.concat(function(){switch(n(i)){case"array":return i.map((function(t){return{param:"_has",value:r+"="+t}}));case"string":return[{param:"_has",value:r+"="+i}]}}())}));if("$include"===t||"$revInclude"===t)return r=t,o(e,(function(t,e){var i,o;return i=e[0],o=e[1],t.concat(function(){switch(n(o)){case"array":return o.map((function(t){return{param:"$include"===r?"_include":"_revinclude",value:i+":"+t}}));case"string":return[{param:"$include"===r?"_include":"_revinclude",value:i+":"+o}]}}())}));var r;switch(n(e)){case"object":return function(t,e){return o(e,(function(r,o){var s,l,h,f;return s=o[0],f=o[1],r.concat("$and"===s?i(f).reduce((function(e,r){return e.concat(a(t,r))}),[]):"$type"===s?[]:function(t){return 0===t.indexOf("$")}(s)?(l={param:t},"$or"===s?l.value=f:(u[s]&&(l.operator=u[s]),c[s]&&(l.modifier=c[s]),"object"===n(f)&&f.$or?l.value=f.$or:l.value=[f]),[l]):(e.$type&&(h=":"+e.$type),a(""+t+(h||"")+"."+s,f)))}))}(t,e);case"string":case"number":return[{param:t,value:[e]}];case"array":return[{param:t,value:[e.join("|")]}];default:throw"could not linearizeParams "+n(e)}},l=function(t){return o(t,(function(t,e){var r,n;return r=e[0],n=e[1],t.concat(a(r,n))}))},h=function(t){var e,r,n=["_include","_revinclude","_has"];return function(){var i,o,u,c;for(c=[],i=0,o=(u=l(t)).length;i<o;i++)e=u[i],r=-1===n.indexOf(e.param)?encodeURIComponent(e.value):e.value,c.push([e.param,e.modifier,"_has"==e.param?":":"=",e.operator,r].filter(s).join(""));return c}().join("&")};e._query=l,e.query=h;var f=r(801);e.$SearchParams=f.$$Attr("url",(function(t){var e=t.url;return t.query?e+"?"+h(t.query):e})),e.$Paging=function(t){return function(e){var r=e.params||{};return e.since&&(r._since=e.since),e.count&&(r._count=e.count),e.params=r,t(e)}}}).call(this)},249:function(t,e,r){(function(){r(454);var t=r(801),n=function(e,r){var i=function(t){return r&&e.includes("target.versionId")&&!t.target.versionId?r(t):(r&&r(t)+"/"||"")+function(t,e){var r=function(t,e){return 0==t.indexOf(":")?function(t,e){for(var r,n=t.split("||").map((function(t){return t.trim().substring(1)})),i=0;i<n.length;i++){var o=(r=e,n[i].split(".").reduce((function(t,e){return"versionId"===e&&t[e]?"_history/"+t[e]:null==t||null==t?null:t[e]}),r));if(o)return o}return null}(t,e):t}(t.trim(),e);if((null==r||void 0===r)&&0==t.includes("target.versionId"))throw new Error("Parameter "+t+" is required: "+JSON.stringify(e));return r}(e,t)},o=t.Attribute("url",i);return o.slash=function(t){return n(t,i)},o};e.Path=n}).call(this)},454:function(t,e,r){(function(){var t=r(651),n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;e.trim=function(t){return t?t.toString().replace(n,""):""};var i=function(t){return null==t&&void 0===t?String(t):{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"}[Object.prototype.toString.call(t)]};e.type=i,e.assertArray=function(t){if("array"!==i(t))throw"not array";return t};var o=function(t){if("object"!==i(t))throw"not object";return t};e.assertObject=o;var s=function(t,e,r){var n,i;return r||(r=[]),o(t),function(){var e;for(n in e=[],t)i=t[n],e.push([n,i]);return e}().reduce(e,r)};e.reduceMap=s,e.identity=function(t){return t};var u=function(){return Array.prototype.slice.call(arguments)};e.argsArray=u,e.mergeLists=function(){var e;return e=function(e,r){var n,i,o;for(n in i=t(!0,e),r)o=r[n],i[n]=(i[n]||[]).concat(o);return i},u.apply(null,arguments).reduce(e,{})},e.absoluteUrl=function(t,e){return e.match(/https?:\/\/./)?e:t+"/"+e},e.relativeUrl=function(t,e){return e.slice(e,t.length+1)===t+"/"?e.slice(t.length+1):e},e.resourceIdToUrl=function(t,e,r){return e=e.replace(/\/$/,""),(t=t.replace(/^\//,"")).indexOf("/")<0?e+"/"+r+"/"+t:0!==t.indexOf(e)?e+"/"+t:t};var c=function(t,e,r,n){var o;switch(i(r)){case"array":return e(r.map((function(e){return t(e,[r,n])})),n);case"object":return o=function(e,i){var o,s;return o=i[0],s=i[1],e[o]=t(s,[r].concat(n)),e},e(s(r,o,{}),n);default:return e(r,n)}};e.walk=c;var a=function(t,e,r){return e?c(a(t),t,e,r):function(e,r){return a(t,e,r)}};e.postwalk=a}).call(this)},651:(t,e,r)=>{!function(e){var r=function(t){return i(!0===t,!1,arguments)};function n(t,e){if("object"!==o(t))return e;for(var r in e)"object"===o(t[r])&&"object"===o(e[r])?t[r]=n(t[r],e[r]):t[r]=e[r];return t}function i(t,e,i){var s=i[0],u=i.length;(t||"object"!==o(s))&&(s={});for(var c=0;c<u;++c){var a=i[c];if("object"===o(a))for(var l in a)if("__proto__"!==l){var h=t?r.clone(a[l]):a[l];s[l]=e?n(s[l],h):h}}return s}function o(t){return{}.toString.call(t).slice(8,-1).toLowerCase()}r.recursive=function(t){return i(!0===t,!0,arguments)},r.clone=function(t){var e,n,i=t,s=o(t);if("array"===s)for(i=[],n=t.length,e=0;e<n;++e)i[e]=r.clone(t[e]);else if("object"===s)for(e in i={},t)i[e]=r.clone(t[e]);return i},e?t.exports=r:window.merge=r}((t=r.nmd(t))&&"object"==typeof t.exports&&t.exports)},968:(t,e,r)=>{const n=r(577).R;e.s=function(t){if(t||(t=1),!r.y.meta||!r.y.meta.url)throw console.error("__system_context__",r.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");r.p=n(r.y.meta.url,t)}},577:(t,e,r)=>{e.R=function(t,e){var r=document.createElement("a");r.href=t;for(var n="/"===r.pathname[0]?r.pathname:"/"+r.pathname,i=0,o=n.length;i!==e&&o>=0;)"/"===n[--o]&&i++;if(i!==e)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+e+") is greater than the number of directories ("+i+") in the URL path "+t);var s=n.slice(0,o+1);return r.protocol+"//"+r.host+s};Number.isInteger},824:t=>{"use strict";t.exports=r}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(o.exports,o,o.exports,i),o.loaded=!0,o.exports}i.y=e,i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;i.g.importScripts&&(t=i.g.location+"");var e=i.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");r.length&&(t=r[r.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=t})();var o={};return(0,i(968).s)(1),(()=>{"use strict";i.r(o),i.d(o,{OpenmrsFetchError:()=>G,VisitMode:()=>ne,VisitStatus:()=>ie,backendDependencies:()=>ae,fetchCurrentPatient:()=>Wt,fhir:()=>z,fhirBaseUrl:()=>W,getCurrentUser:()=>Mt,getLocations:()=>ce,getLoggedInUser:()=>Ht,getSessionLocation:()=>Lt,getStartedVisit:()=>re,getVisitTypes:()=>se,getVisitsForPatient:()=>Zt,makeUrl:()=>H,openmrsFetch:()=>L,openmrsObservableFetch:()=>Y,refetchCurrentUser:()=>Ft,saveVisit:()=>te,sessionEndpoint:()=>q,setSessionLocation:()=>Yt,setupApiModule:()=>Gt,toLocationObject:()=>ue,toVisitTypeObject:()=>oe,updateVisit:()=>ee,userHasAccess:()=>qt});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(t){return"function"==typeof t}var n=!1,s={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,n=t},get useDeprecatedSynchronousErrorHandling(){return n}};function u(t){setTimeout((function(){throw t}),0)}var c={closed:!0,next:function(t){},error:function(t){if(s.useDeprecatedSynchronousErrorHandling)throw t;u(t)},complete:function(){}},a=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function l(t){return null!==t&&"object"==typeof t}var h=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),f=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,i=n._parentOrParents,o=n._ctorUnsubscribe,s=n._unsubscribe,u=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,i instanceof t)i.remove(this);else if(null!==i)for(var c=0;c<i.length;++c)i[c].remove(this);if(r(s)){o&&(this._unsubscribe=void 0);try{s.call(this)}catch(t){e=t instanceof h?p(t.errors):[t]}}if(a(u)){c=-1;for(var f=u.length;++c<f;){var d=u[c];if(l(d))try{d.unsubscribe()}catch(t){e=e||[],t instanceof h?e=e.concat(p(t.errors)):e.push(t)}}}if(e)throw new h(e)}},t.prototype.add=function(e){var r=e;if(!e)return t.EMPTY;switch(typeof e){case"function":r=new t(e);case"object":if(r===this||r.closed||"function"!=typeof r.unsubscribe)return r;if(this.closed)return r.unsubscribe(),r;if(!(r instanceof t)){var n=r;(r=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var i=r._parentOrParents;if(null===i)r._parentOrParents=this;else if(i instanceof t){if(i===this)return r;r._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return r;i.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[r]:o.push(r),r},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function p(t){return t.reduce((function(t,e){return t.concat(e instanceof h?e.errors:e)}),[])}var d=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),b=function(t){function r(e,n,i){var o=t.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=c;break;case 1:if(!e){o.destination=c;break}if("object"==typeof e){e instanceof r?(o.syncErrorThrowable=e.syncErrorThrowable,o.destination=e,e.add(o)):(o.syncErrorThrowable=!0,o.destination=new y(o,e));break}default:o.syncErrorThrowable=!0,o.destination=new y(o,e,n,i)}return o}return e(r,t),r.prototype[d]=function(){return this},r.create=function(t,e,n){var i=new r(t,e,n);return i.syncErrorThrowable=!1,i},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},r.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},r.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},r}(f),y=function(t){function n(e,n,i,o){var s,u=t.call(this)||this;u._parentSubscriber=e;var a=u;return r(n)?s=n:n&&(s=n.next,i=n.error,o=n.complete,n!==c&&(r((a=Object.create(n)).unsubscribe)&&u.add(a.unsubscribe.bind(a)),a.unsubscribe=u.unsubscribe.bind(u))),u._context=a,u._next=s,u._error=i,u._complete=o,u}return e(n,t),n.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;s.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},n.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=s.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):u(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;u(t)}}},n.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};s.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},n.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),s.useDeprecatedSynchronousErrorHandling)throw t;u(t)}},n.prototype.__tryOrSetError=function(t,e,r){if(!s.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return s.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(u(e),!0)}return!1},n.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},n}(b),v=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function m(t){return t}function g(t){return 0===t.length?m:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var w=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this.operator,i=function(t,e,r){if(t){if(t instanceof b)return t;if(t[d])return t[d]()}return t||e||r?new b(t,e,r):new b(c)}(t,e,r);if(n?i.add(n.call(i,this.source)):i.add(this.source||s.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),s.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){s.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){var e=t,r=e.closed,n=e.destination,i=e.isStopped;if(r||i)return!1;t=n&&n instanceof b?n:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=_(e))((function(e,n){var i;i=r.subscribe((function(e){try{t(e)}catch(t){n(t),i&&i.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[v]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:g(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=_(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function _(t){if(t||(t=s.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const S="object"==typeof global&&global&&global.Object===Object&&global;var E="object"==typeof self&&self&&self.Object===Object&&self;const x=(S||E||Function("return this")()).Symbol;var O=Object.prototype,T=O.hasOwnProperty,j=O.toString,P=x?x.toStringTag:void 0;var $=Object.prototype.toString;var I=x?x.toStringTag:void 0;const A=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":I&&I in Object(t)?function(t){var e=T.call(t,P),r=t[P];try{t[P]=void 0;var n=!0}catch(t){}var i=j.call(t);return n&&(e?t[P]=r:delete t[P]),i}(t):function(t){return $.call(t)}(t)},N=(C=Object.getPrototypeOf,k=Object,function(t){return C(k(t))});var C,k;var D=Function.prototype,U=Object.prototype,B=D.toString,V=U.hasOwnProperty,M=B.call(Object);const R=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=A(t))return!1;var e=N(t);if(null===e)return!0;var r=V.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&B.call(r)==M};var F=i(824);const q="/ws/rest/v1/session";function H(t){return window.openmrsBase+t}function L(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof t)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof e)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");const r=H(t);e.headers||(e.headers={}),R(e.body)&&(e.body=JSON.stringify(e.body)),void 0===e.headers.Accept&&(e.headers.Accept="application/json"),null===e.headers.Accept&&delete e.headers.Accept;const n=Error();return window.fetch(r,e).then((async t=>{const e=t;if(e.ok)return 204===e.status?(e.data=null,e):e.text().then((t=>{try{t&&(e.data=JSON.parse(t))}catch(t){}return e}));{const{redirectAuthFailure:t}=await(0,F.getConfig)("@openmrs/esm-api");return r===H(q)&&403===e.status||t.enabled&&t.errors.includes(e.status)?((0,F.navigate)({to:t.url}),t.resolvePromise?Promise.resolve():new Promise((()=>{}))):e.text().then((t=>{let i=t;try{i=JSON.parse(t)}catch(t){}throw new G(r,e,i,n)}),(t=>{throw new G(r,e,null,n)}))}}))}function Y(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");const r=new AbortController;return e.signal=r.signal,new w((n=>{let i=!1;return L(t,e).then((t=>{i=!0,n.next(t),n.complete()}),(t=>{i=!0,n.error(t)})),()=>{i||r.abort()}}))}class G extends Error{constructor(t,e,r,n){super(),this.message=`Server responded with ${e.status} (${e.statusText}) for url ${t}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=e,this.stack=`Stacktrace for outgoing request:\n${n.stack}\nStacktrace for incoming response:\n${this.stack}`}}const W="/ws/fhir2/R4",z=i(256)({baseUrl:W},{http:t=>L(t.url,{method:t.method,headers:t.headers}).then((e=>({status:e.status,headers:e.headers,data:e.data,config:t})),(e=>({status:e.response.status,headers:e.response.headers,data:e.responseBody,config:t})))});var J=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),Q=function(t){function r(e,r){var n=t.call(this)||this;return n.subject=e,n.subscriber=r,n.closed=!1,n}return e(r,t),r.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},r}(f),K=function(t){function r(e){var r=t.call(this,e)||this;return r.destination=e,r}return e(r,t),r}(b),X=function(t){function r(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return e(r,t),r.prototype[d]=function(){return new K(this)},r.prototype.lift=function(t){var e=new Z(this,this);return e.operator=t,e},r.prototype.next=function(t){if(this.closed)throw new J;if(!this.isStopped)for(var e=this.observers,r=e.length,n=e.slice(),i=0;i<r;i++)n[i].next(t)},r.prototype.error=function(t){if(this.closed)throw new J;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,r=e.length,n=e.slice(),i=0;i<r;i++)n[i].error(t);this.observers.length=0},r.prototype.complete=function(){if(this.closed)throw new J;this.isStopped=!0;for(var t=this.observers,e=t.length,r=t.slice(),n=0;n<e;n++)r[n].complete();this.observers.length=0},r.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},r.prototype._trySubscribe=function(e){if(this.closed)throw new J;return t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(t){if(this.closed)throw new J;return this.hasError?(t.error(this.thrownError),f.EMPTY):this.isStopped?(t.complete(),f.EMPTY):(this.observers.push(t),new Q(this,t))},r.prototype.asObservable=function(){var t=new w;return t.source=this,t},r.create=function(t,e){return new Z(t,e)},r}(w),Z=function(t){function r(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return e(r,t),r.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},r.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},r.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},r.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):f.EMPTY},r}(X),tt=function(t){function r(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return e(r,t),r.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},r.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},r.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):e.flush(this)},r}(function(t){function r(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return e(r,t),r.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var r=this.id,n=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(n,r,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},r.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),setInterval(t.flush.bind(t,this),r)},r.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending)return e;clearInterval(e)},r.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(t,e){var r=!1,n=void 0;try{this.work(t)}catch(t){r=!0,n=!!t&&t||new Error(t)}if(r)return this.unsubscribe(),n},r.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,n=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&r.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},r}(function(t){function r(e,r){return t.call(this)||this}return e(r,t),r.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},r}(f))),et=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t.now=function(){return Date.now()},t}(),rt=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e(r,t),r}(function(t){function r(e,n){void 0===n&&(n=et.now);var i=t.call(this,e,(function(){return r.delegate&&r.delegate!==i?r.delegate.now():n()}))||this;return i.actions=[],i.active=!1,i.scheduled=void 0,i}return e(r,t),r.prototype.schedule=function(e,n,i){return void 0===n&&(n=0),r.delegate&&r.delegate!==this?r.delegate.schedule(e,n,i):t.prototype.schedule.call(this,e,n,i)},r.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var r;this.active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},r}(et)),nt=new rt(tt),it=new w((function(t){return t.complete()}));function ot(t){return t?function(t){return new w((function(e){return t.schedule((function(){return e.complete()}))}))}(t):it}function st(t){return t&&"function"==typeof t.schedule}var ut,ct=function(t){return function(e){for(var r=0,n=t.length;r<n&&!e.closed;r++)e.next(t[r]);e.complete()}};function at(t,e){return new w((function(r){var n=new f,i=0;return n.add(e.schedule((function(){i!==t.length?(r.next(t[i++]),r.closed||n.add(this.schedule())):r.complete()}))),n}))}function lt(t,e){return e?at(t,e):new w(ct(t))}ut||(ut={});var ht=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,r){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return r&&r()}},t.prototype.accept=function(t,e,r){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){var t;switch(this.kind){case"N":return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t[t.length-1];return st(r)?(t.pop(),at(t,r)):lt(t)}(this.value);case"E":return t=this.error,new w((function(e){return e.error(t)}));case"C":return ot()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}(),ft=function(t){function r(e,r,n){void 0===n&&(n=0);var i=t.call(this,e)||this;return i.scheduler=r,i.delay=n,i}return e(r,t),r.dispatch=function(t){var e=t.notification,r=t.destination;e.observe(r),this.unsubscribe()},r.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(r.dispatch,this.delay,new pt(t,this.destination)))},r.prototype._next=function(t){this.scheduleMessage(ht.createNext(t))},r.prototype._error=function(t){this.scheduleMessage(ht.createError(t)),this.unsubscribe()},r.prototype._complete=function(){this.scheduleMessage(ht.createComplete()),this.unsubscribe()},r}(b),pt=function(){return function(t,e){this.notification=t,this.destination=e}}(),dt=function(t){function r(e,r,n){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this)||this;return i.scheduler=n,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=e<1?1:e,i._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return e(r,t),r.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var r=this._events;r.push(e),r.length>this._bufferSize&&r.shift()}t.prototype.next.call(this,e)},r.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new bt(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},r.prototype._subscribe=function(t){var e,r=this._infiniteTimeWindow,n=r?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,o=n.length;if(this.closed)throw new J;if(this.isStopped||this.hasError?e=f.EMPTY:(this.observers.push(t),e=new Q(this,t)),i&&t.add(t=new ft(t,i)),r)for(var s=0;s<o&&!t.closed;s++)t.next(n[s]);else for(s=0;s<o&&!t.closed;s++)t.next(n[s].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},r.prototype._getNow=function(){return(this.scheduler||nt).now()},r.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,r=this._windowTime,n=this._events,i=n.length,o=0;o<i&&!(t-n[o].time<r);)o++;return i>e&&(o=Math.max(o,i-e)),o>0&&n.splice(0,o),n},r}(X),bt=function(){return function(t,e){this.time=t,this.value=e}}();function yt(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new vt(t,e))}}var vt=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new mt(t,this.project,this.thisArg))},t}(),mt=function(t){function r(e,r,n){var i=t.call(this,e)||this;return i.project=r,i.count=0,i.thisArg=n||i,i}return e(r,t),r.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},r}(b);function gt(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var wt=gt(),_t=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function St(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var Et=function(t){if(t&&"function"==typeof t[v])return n=t,function(t){var e=n[v]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if(_t(t))return ct(t);if(St(t))return r=t,function(t){return r.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,u),t};if(t&&"function"==typeof t[wt])return e=t,function(t){for(var r=e[wt]();;){var n=void 0;try{n=r.next()}catch(e){return t.error(e),t}if(n.done){t.complete();break}if(t.next(n.value),t.closed)break}return"function"==typeof r.return&&t.add((function(){r.return&&r.return()})),t};var e,r,n,i=l(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+i+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};var xt=function(t){function r(e){var r=t.call(this)||this;return r.parent=e,r}return e(r,t),r.prototype._next=function(t){this.parent.notifyNext(t)},r.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},r.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},r}(b),Ot=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e(r,t),r.prototype.notifyNext=function(t){this.destination.next(t)},r.prototype.notifyError=function(t){this.destination.error(t)},r.prototype.notifyComplete=function(){this.destination.complete()},r}(b);function Tt(t,e,r){return void 0===r&&(r=Number.POSITIVE_INFINITY),"function"==typeof e?function(n){return n.pipe(Tt((function(r,n){return(i=t(r,n),i instanceof w?i:new w(Et(i))).pipe(yt((function(t,i){return e(r,t,n,i)})));var i}),r))}:("number"==typeof e&&(r=e),function(e){return e.lift(new jt(t,r))})}var jt=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new Pt(t,this.project,this.concurrent))},t}(),Pt=function(t){function r(e,r,n){void 0===n&&(n=Number.POSITIVE_INFINITY);var i=t.call(this,e)||this;return i.project=r,i.concurrent=n,i.hasCompleted=!1,i.buffer=[],i.active=0,i.index=0,i}return e(r,t),r.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},r.prototype._tryNext=function(t){var e,r=this.index++;try{e=this.project(t,r)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},r.prototype._innerSub=function(t){var e=new xt(this),r=this.destination;r.add(e);var n=function(t,e){if(!e.closed){if(t instanceof w)return t.subscribe(e);var r;try{r=Et(t)(e)}catch(t){e.error(t)}return r}}(t,e);n!==e&&r.add(n)},r.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},r.prototype.notifyNext=function(t){this.destination.next(t)},r.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},r}(Ot);function $t(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),Tt(m,t)}function It(){}function At(t,e,r){return function(n){return n.lift(new Nt(t,e,r))}}var Nt=function(){function t(t,e,r){this.nextOrObserver=t,this.error=e,this.complete=r}return t.prototype.call=function(t,e){return e.subscribe(new Ct(t,this.nextOrObserver,this.error,this.complete))},t}(),Ct=function(t){function n(e,n,i,o){var s=t.call(this,e)||this;return s._tapNext=It,s._tapError=It,s._tapComplete=It,s._tapError=i||It,s._tapComplete=o||It,r(n)?(s._context=s,s._tapNext=n):n&&(s._context=n,s._tapNext=n.next||It,s._tapError=n.error||It,s._tapComplete=n.complete||It),s}return e(n,t),n.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},n.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},n.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},n}(b);function kt(t,e){return function(r){return r.lift(new Dt(t,e))}}var Dt=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Ut(t,this.predicate,this.thisArg))},t}(),Ut=function(t){function r(e,r,n){var i=t.call(this,e)||this;return i.predicate=r,i.thisArg=n,i.count=0,i}return e(r,t),r.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},r}(b);const Bt=new dt(1);let Vt=0;function Mt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{includeAuthStatus:!1};return Vt<Date.now()-6e4&&Ft(),Bt.asObservable().pipe($t(),At(Rt),yt((e=>t.includeAuthStatus?e:e.user)),kt(Boolean))}function Rt(t){if(t?.user?.userProperties?.defaultLocale){const e=t.user.userProperties.defaultLocale;e!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",e)}}function Ft(){Vt=Date.now(),Bt.next(L(q).then((t=>"object"==typeof t.data?t.data:Promise.reject())).catch((()=>({sessionId:"",authenticated:!1}))))}function qt(t,e){return function(t,e){return e.privileges.find((e=>t===e.display))}(t,e)||function(t){return t.roles.find((t=>"System Developer"===t.display))}(e)}function Ht(){return new Promise(((t,e)=>{const r=Mt().subscribe((e=>{t(e),r.unsubscribe()}),e)}))}function Lt(){return new Promise(((t,e)=>{const r=Mt({includeAuthStatus:!0}).subscribe((e=>{t(e.sessionLocation),r.unsubscribe()}),e)}))}async function Yt(t,e){await L(q,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal}),Ft()}function Gt(){(0,F.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:F.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:F.Type.String,_default:"${openmrsSpaBase}/login",_validators:[F.validators.isUrl]},errors:{_type:F.Type.Array,_default:[401],_elements:{_type:F.Type.Number,_validators:[F.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:F.Type.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}}}),Ft()}function Wt(t,e){return t?z.read({type:"Patient",patient:t,...e}):Promise.resolve(null)}var zt=function(t){function r(e){var r=t.call(this)||this;return r._value=e,r}return e(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),r.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},r.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new J;return this._value},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(X),Jt=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}();function Qt(t){return function(e){return 0===t?ot():e.lift(new Kt(t))}}var Kt=function(){function t(t){if(this.total=t,this.total<0)throw new Jt}return t.prototype.call=function(t,e){return e.subscribe(new Xt(t,this.total))},t}(),Xt=function(t){function r(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return e(r,t),r.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},r}(b);function Zt(t,e,r){return Y(`/ws/rest/v1/visit?patient=${t}&v=${r||"custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,value),location:(uuid,name,display),startDatetime,stopDatetime)"}`,{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(Qt(1)).pipe(yt((t=>t)))}function te(t,e){return Y("/ws/rest/v1/visit",{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function ee(t,e,r){return Y(`/ws/rest/v1/visit/${t}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}const re=new zt(null);let ne,ie;function oe(t){return{uuid:t.uuid,display:t.display,name:t.name}}function se(){return Y("/ws/rest/v1/visittype").pipe(yt((t=>t.data.results.map(oe)))).pipe(Qt(1))}function ue(t){return{uuid:t.uuid,display:t.display}}function ce(){return Y("/ws/rest/v1/location").pipe(yt((t=>t.data.results.map(ue)))).pipe(Qt(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(ne||(ne={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(ie||(ie={}));const ae={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),o})())}}}));
1
+ System.register(["@openmrs/esm-config"],(function(t,e){var r={};return{setters:[function(t){r.Type=t.Type,r.defineConfigSchema=t.defineConfigSchema,r.getConfig=t.getConfig,r.navigate=t.navigate,r.validators=t.validators}],execute:function(){t((()=>{var t={672:(t,e)=>{!function(){var t=e,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function n(t){this.message=t}n.prototype=new Error,n.prototype.name="InvalidCharacterError",t.btoa||(t.btoa=function(t){for(var e,o,i=String(t),u=0,s=r,c="";i.charAt(0|u)||(s="=",u%1);c+=s.charAt(63&e>>8-u%1*8)){if((o=i.charCodeAt(u+=3/4))>255)throw new n("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|o}return c}),t.atob||(t.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var o,i,u=0,s=0,c="";i=e.charAt(s++);~i&&(o=u%4?64*o+i:i,u++%4)?c+=String.fromCharCode(255&o>>(-2*u&6)):0)i=r.indexOf(i);return c})}()},525:function(t){(function(){var e,r;function n(t,o){var i,u=t.data.entry||[],s=[];for(i=0;i<u.length;i++)s.push(u[i].resource);o(s);var c=r.defer();return e.nextPage({bundle:t.data}).then((function(t){n(t,o).then((function(t){c.resolve()}))}),(function(t){c.resolve()})),c.promise}function o(t,o,i,u){r.defer(),e.search(t).then((function(t){n(t,o).then((function(){i()}),(function(t){u(t)}))}),(function(t){u(t)}))}function i(t){var e=r.defer(),n=[];return o(t,(function(t){t.forEach((function(t){n.push(t)}))}),(function(){e.resolve(n)}),(function(t){e.reject(t)})),e.promise}function u(t,n){var o=r.defer();return e.search(t).then((function(t){var r={},i=[function(){o.resolve(t,r)}];function u(){i.pop()()}var s=t.data;s.entry&&s.entry.forEach((function(t){var o=t.resource,c=o.resourceType;n&&n.forEach((function(t){var n=t.split("."),a=n[0],l=n[1],f=o[l];if(c===a&&f){var h=f.reference;r[h]||function(t,n,o){i.push((function(){!function(t,n,o){var i=o.reference;e.resolve({bundle:t,resource:n,reference:o}).then((function(t){var e=t.data||t.content;r[i]=e,u()}))}(t,n,o)}))}(s,o,f)}}))})),u()}),(function(){o.reject("Could not fetch search results")})),o.promise}t.exports=function(t,n){return e=t,r=n,t.drain=o,t.fetchAll=i,t.fetchAllWithReferences=u,t}}).call(this)},256:function(t,e,r){(function(){r(454);var e=r(801),n=r(921),o=r(294),i=r(821),u=r(442),s=r(856),c=r(719),a=r(29),l=r(723),f=r(249),h=r(525);t.exports=function(t,r){var p=e.Middleware,d=e.$$Attr,y=function(t){return d("method",t)},v=function(t,e){return d("headers."+t,e)},b=p(u),m=p(s(t,r)).and(b).and(o.$Basic).and(o.$Bearer).and(o.$Credentials).and(i.$JsonData).and(v("Accept",t.headers&&t.headers.Accept?t.headers.Accept:"application/json")).and(v("Content-Type",t.headers&&t.headers["Content-Type"]?t.headers["Content-Type"]:"application/json")),g=m.and(y("GET")),w=m.and(y("POST")),_=m.and(y("PUT")),x=m.and(y("DELETE")),E=m.and(y("PATCH")),S=i.Http(t,r),O=f.Path,j=O(t.baseUrl),T=j.slash(":type || :resource.resourceType"),P=T.slash("_history"),I=T.slash(":id || :resource.id"),A=I.slash("_history"),$=I.slash(":versionId || :resource.meta.versionId"),N=j.slash(":target.resourceType || :target.type").slash(":target.id").slash(":target.versionId"),k=v("Prefer","return=representation"),C=p(n.$Paging);return h({conformance:g.and(j.slash("metadata")).end(S),document:w.and(j.slash("Document")).end(S),profile:g.and(j.slash("Profile").slash(":type")).end(S),transaction:w.and(j).end(S),history:g.and(j.slash("_history")).and(C).end(S),typeHistory:g.and(P).and(C).end(S),resourceHistory:g.and(A).and(C).end(S),read:g.and(a.$WithPatient).and(I).end(S),vread:g.and($).end(S),delete:x.and(I).and(k).end(S),create:w.and(T).and(k).end(S),validate:w.and(T.slash("_validate")).end(S),meta:{add:w.and(N.slash("$meta-add")).end(S),delete:w.and(N.slash("$meta-delete")).end(S),read:g.and(N.slash("$meta")).end(S)},search:g.and(T).and(a.$WithPatient).and(n.$SearchParams).and(C).end(S),update:_.and(I).and(k).end(S),conditionalUpdate:_.and(T).and(n.$SearchParams).and(k).end(S),conditionalDelete:x.and(T).and(n.$SearchParams).and(k).end(S),nextPage:g.and(c.$$BundleLinkUrl("next")).end(S),prevPage:g.and(c.$$BundleLinkUrl("previous")).and(c.$$BundleLinkUrl("prev")).end(S),getBundleByUrl:g.and(O(":url")).end(S),resolve:g.and(l.resolve).end(S),patch:E.and(I).and(v("Content-Type","application/json-patch+json")).end(S)},r)}}).call(this)},294:function(t,e,r){(function(){var t,n=r(801),o=r(672).btoa;e.$Basic=n.$$Attr("headers.Authorization",(function(t){if(t.auth&&t.auth.user&&t.auth.pass)return"Basic "+o(t.auth.user+":"+t.auth.pass)})),e.$Bearer=n.$$Attr("headers.Authorization",(function(t){if(t.auth&&t.auth.bearer)return"Bearer "+t.auth.bearer})),e.$Credentials=n.Middleware(n.$$Attr("credentials",(function(e){return t=e.credentials,""}))).and(n.$$Attr("credentials",(function(e){if(["same-origin","include"].indexOf(t)>-1)return t})))}).call(this)},719:(t,e)=>{e.$$BundleLinkUrl=function(t){return function(e){return function(r){var n=r.bundle&&(r.bundle.link||[]).filter((function(e){return e.relation&&e.relation===t}))[0];return n&&n.url&&(r.url=n.url,r.data=null),e(r)}}}},856:function(t){(function(){var e=function(t,e,r){var n=t[r];return n&&!e[r]&&(e[r]=n),t};t.exports=function(t,r){return function(n){return function(o){return e(t,o,"baseUrl"),e(t,o,"cache"),e(t,o,"auth"),e(t,o,"patient"),e(t,o,"debug"),e(t,o,"credentials"),e(t,o,"headers"),e(t,o,"agentOptions"),e(r,o,"defer"),e(r,o,"http"),n(o)}}}}).call(this)},801:function(t,e,r){(function(){var t=r(454),n=function(t){return t.and=function(e){return n((r=t,o=e,function(t){return r(o(t))}));var r,o},t.end=function(e){return t(e)},t};e.$$Simple=function(t){return function(e){return function(r){return e(t(r))}}},e.$$Attr=function(e,r){return n((function(n){return function(o){var i;return i="function"==t.type(r)?r(o):r,n(null==i&&null==i?o:function(t,e,r){for(var n=e.split("."),o=t,i=0;i<n.length-1;i++){var u=n[i];(o=t[u])||(o={},t[u]=o)}return o[n[n.length-1]]=r,t}(o,e,i))}}))};var o=function(t,e){return n((function(r){return function(n){return n[t]=e(n),r(n)}}))};e.Middleware=n,e.Attribute=o,e.Method=function(t){return o("method",(e=t,function(){return e}));var e}}).call(this)},442:t=>{t.exports=function(t){return function(e){try{return t(e)}catch(t){if(e.debug&&(console.log("\nDEBUG: (ERROR in middleware)"),console.log(t.message),console.log(t.stack)),!e.defer)throw console.log("\nDEBUG: (ERROR in middleware)"),console.log(t.message),console.log(t.stack),new Error("I need adapter.defer");var r=e.defer();return r.reject(t),r.promise}}}},821:function(t,e,r){(function(){var t=r(454);e.Http=function(t,e){return function(r){r.debug&&console.log("\nDEBUG (request):",r.method,r.url,r);var n=(r.http||e.http||t.http)(r);return r.debug&&n&&n.then&&n.then((function(t){console.log("\nDEBUG: (responce)",t)})),n}},e.$JsonData=function(e){return function(r){var n,o=r.bundle||r.data||r.resource;return o&&(r.data=(n=o,"object"==t.type(n)||"array"==t.type(n)?JSON.stringify(n):n)),e(r)}}}).call(this)},29:function(t,e,r){(function(){var t=r(801),n=["Account","AllergyIntolerance","BodySite","CarePlan","Claim","ClinicalImpression","Communication","CommunicationRequest","Composition","Condition","Contract","DetectedIssue","Device","DeviceUseRequest","DeviceUseStatement","DiagnosticOrder","DiagnosticReport","DocumentManifest","DocumentReference","Encounter","EnrollmentRequest","EpisodeOfCare","FamilyMemberHistory","Flag","Goal","ImagingObjectSelection","ImagingStudy","Immunization","ImmunizationRecommendation","List","Media","MedicationAdministration","MedicationDispense","MedicationOrder","MedicationStatement","NutritionOrder","Observation","Order","Procedure","ProcedureRequest","QuestionnaireResponse","ReferralRequest","RelatedPerson","RiskAssessment","Specimen","SupplyDelivery","SupplyRequest","VisionPrescription"];e.$WithPatient=t.$$Simple((function(t){var e=t.type;return t.patient&&("Patient"===e?(t.query=t.query||{},t.query._id=t.patient,t.id=t.patient):n.indexOf(e)>=0&&(t.query=t.query||{},t.query.patient=t.patient)),t}))}).call(this)},723:function(t,e,r){(function(){var e=r(454),n=/^#(.*)/,o=function(t){var r=t.cache,o=t.reference,i=t.bundle,u=o;if(!u.reference)return null;if(u.reference.match(n))return function(t,e){var r=t.match(n)[1],o=(e.contained||[]).filter((function(t){return(t.id||t._id)==r}))[0];return o&&{content:o}||null}(u.reference,t.resource);var s=e.absoluteUrl(t.baseUrl,u.reference);return(i&&i.entry||[]).filter((function(t){return t.id===s}))[0]||(null!=r?r[s]:void 0)||null};t.exports.sync=o,t.exports.resolve=function(t){return function(r){var i=o(r),u=r.reference,s=r.defer();if(i){if(!r.defer)throw new Error("I need promise constructor 'adapter.defer' in adapter");return s.resolve(i),s.promise}if(!u)throw new Error("No reference found");if(u&&u.reference.match(n))throw new Error("Contained resource not found");return r.url=e.absoluteUrl(r.baseUrl,u.reference),r.data=null,t(r)}}}).call(this)},921:function(t,e,r){(function(){var t=r(454),n=t.type,o=t.assertArray,i=(t.assertObject,t.reduceMap),u=t.identity,s={$gt:"gt",$lt:"lt",$lte:"lte",$gte:"gte",$ge:"ge",$le:"le"},c={$asc:":asc",$desc:":desc",$exact:":exact",$missing:":missing",$null:":missing",$text:":text"},a=function(t,e){if("$sort"===t)return function(t){var e,r,i,u;for(o(t),i=[],e=0,r=t.length;e<r;e++)switch(u=t[e],n(u)){case"array":i.push({param:"_sort",value:u[0],modifier:":"+u[1]});break;case"string":i.push({param:"_sort",value:u});break;default:i.push(void 0)}return i}(e);if("$has"===t)return i(e,(function(t,e){var r,o;return r=e[0],o=e[1],t.concat(function(){switch(n(o)){case"array":return o.map((function(t){return{param:"_has",value:r+"="+t}}));case"string":return[{param:"_has",value:r+"="+o}]}}())}));if("$include"===t||"$revInclude"===t)return r=t,i(e,(function(t,e){var o,i;return o=e[0],i=e[1],t.concat(function(){switch(n(i)){case"array":return i.map((function(t){return{param:"$include"===r?"_include":"_revinclude",value:o+":"+t}}));case"string":return[{param:"$include"===r?"_include":"_revinclude",value:o+":"+i}]}}())}));var r;switch(n(e)){case"object":return function(t,e){return i(e,(function(r,i){var u,l,f,h;return u=i[0],h=i[1],r.concat("$and"===u?o(h).reduce((function(e,r){return e.concat(a(t,r))}),[]):"$type"===u?[]:function(t){return 0===t.indexOf("$")}(u)?(l={param:t},"$or"===u?l.value=h:(s[u]&&(l.operator=s[u]),c[u]&&(l.modifier=c[u]),"object"===n(h)&&h.$or?l.value=h.$or:l.value=[h]),[l]):(e.$type&&(f=":"+e.$type),a(""+t+(f||"")+"."+u,h)))}))}(t,e);case"string":case"number":return[{param:t,value:[e]}];case"array":return[{param:t,value:[e.join("|")]}];default:throw"could not linearizeParams "+n(e)}},l=function(t){return i(t,(function(t,e){var r,n;return r=e[0],n=e[1],t.concat(a(r,n))}))},f=function(t){var e,r,n=["_include","_revinclude","_has"];return function(){var o,i,s,c;for(c=[],o=0,i=(s=l(t)).length;o<i;o++)e=s[o],r=-1===n.indexOf(e.param)?encodeURIComponent(e.value):e.value,c.push([e.param,e.modifier,"_has"==e.param?":":"=",e.operator,r].filter(u).join(""));return c}().join("&")};e._query=l,e.query=f;var h=r(801);e.$SearchParams=h.$$Attr("url",(function(t){var e=t.url;return t.query?e+"?"+f(t.query):e})),e.$Paging=function(t){return function(e){var r=e.params||{};return e.since&&(r._since=e.since),e.count&&(r._count=e.count),e.params=r,t(e)}}}).call(this)},249:function(t,e,r){(function(){r(454);var t=r(801),n=function(e,r){var o=function(t){return r&&e.includes("target.versionId")&&!t.target.versionId?r(t):(r&&r(t)+"/"||"")+function(t,e){var r=function(t,e){return 0==t.indexOf(":")?function(t,e){for(var r,n=t.split("||").map((function(t){return t.trim().substring(1)})),o=0;o<n.length;o++){var i=(r=e,n[o].split(".").reduce((function(t,e){return"versionId"===e&&t[e]?"_history/"+t[e]:null==t||null==t?null:t[e]}),r));if(i)return i}return null}(t,e):t}(t.trim(),e);if((null==r||void 0===r)&&0==t.includes("target.versionId"))throw new Error("Parameter "+t+" is required: "+JSON.stringify(e));return r}(e,t)},i=t.Attribute("url",o);return i.slash=function(t){return n(t,o)},i};e.Path=n}).call(this)},454:function(t,e,r){(function(){var t=r(651),n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;e.trim=function(t){return t?t.toString().replace(n,""):""};var o=function(t){return null==t&&void 0===t?String(t):{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"}[Object.prototype.toString.call(t)]};e.type=o,e.assertArray=function(t){if("array"!==o(t))throw"not array";return t};var i=function(t){if("object"!==o(t))throw"not object";return t};e.assertObject=i;var u=function(t,e,r){var n,o;return r||(r=[]),i(t),function(){var e;for(n in e=[],t)o=t[n],e.push([n,o]);return e}().reduce(e,r)};e.reduceMap=u,e.identity=function(t){return t};var s=function(){return Array.prototype.slice.call(arguments)};e.argsArray=s,e.mergeLists=function(){var e;return e=function(e,r){var n,o,i;for(n in o=t(!0,e),r)i=r[n],o[n]=(o[n]||[]).concat(i);return o},s.apply(null,arguments).reduce(e,{})},e.absoluteUrl=function(t,e){return e.match(/https?:\/\/./)?e:t+"/"+e},e.relativeUrl=function(t,e){return e.slice(e,t.length+1)===t+"/"?e.slice(t.length+1):e},e.resourceIdToUrl=function(t,e,r){return e=e.replace(/\/$/,""),(t=t.replace(/^\//,"")).indexOf("/")<0?e+"/"+r+"/"+t:0!==t.indexOf(e)?e+"/"+t:t};var c=function(t,e,r,n){var i;switch(o(r)){case"array":return e(r.map((function(e){return t(e,[r,n])})),n);case"object":return i=function(e,o){var i,u;return i=o[0],u=o[1],e[i]=t(u,[r].concat(n)),e},e(u(r,i,{}),n);default:return e(r,n)}};e.walk=c;var a=function(t,e,r){return e?c(a(t),t,e,r):function(e,r){return a(t,e,r)}};e.postwalk=a}).call(this)},651:(t,e,r)=>{!function(e){var r=function(t){return o(!0===t,!1,arguments)};function n(t,e){if("object"!==i(t))return e;for(var r in e)"object"===i(t[r])&&"object"===i(e[r])?t[r]=n(t[r],e[r]):t[r]=e[r];return t}function o(t,e,o){var u=o[0],s=o.length;(t||"object"!==i(u))&&(u={});for(var c=0;c<s;++c){var a=o[c];if("object"===i(a))for(var l in a)if("__proto__"!==l){var f=t?r.clone(a[l]):a[l];u[l]=e?n(u[l],f):f}}return u}function i(t){return{}.toString.call(t).slice(8,-1).toLowerCase()}r.recursive=function(t){return o(!0===t,!0,arguments)},r.clone=function(t){var e,n,o=t,u=i(t);if("array"===u)for(o=[],n=t.length,e=0;e<n;++e)o[e]=r.clone(t[e]);else if("object"===u)for(e in o={},t)o[e]=r.clone(t[e]);return o},e?t.exports=r:window.merge=r}((t=r.nmd(t))&&"object"==typeof t.exports&&t.exports)},602:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function a(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),u=new P(n||[]);return i._invoke=function(t,e,r){var n=f;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var s=O(u,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var c=l(t,e,r);if("normal"===c.type){if(n=r.done?d:h,c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=d,r.method="throw",r.arg=c.arg)}}}(t,r,u),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var f="suspendedStart",h="suspendedYield",p="executing",d="completed",y={};function v(){}function b(){}function m(){}var g={};c(g,i,(function(){return this}));var w=Object.getPrototypeOf,_=w&&w(w(I([])));_&&_!==r&&n.call(_,i)&&(g=_);var x=m.prototype=v.prototype=Object.create(g);function E(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(o,i,u,s){var c=l(t[o],t,i);if("throw"!==c.type){var a=c.arg,f=a.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,u,s)}),(function(t){r("throw",t,u,s)})):e.resolve(f).then((function(t){a.value=t,u(a)}),(function(t){return r("throw",t,u,s)}))}s(c.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function O(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=l(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function j(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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function I(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,u=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return u.next=u}}return{next:A}}function A(){return{value:e,done:!0}}return b.prototype=m,c(x,"constructor",m),c(m,"constructor",b),b.displayName=c(m,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,c(t,s,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},E(S.prototype),c(S.prototype,u,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var u=new S(a(e,r,n,o),i);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},E(x),c(x,s,"Generator"),c(x,i,(function(){return this})),c(x,"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=I,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},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 r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i],s=u.completion;if("root"===u.tryLoc)return o("end");if(u.tryLoc<=this.prev){var c=n.call(u,"catchLoc"),a=n.call(u,"finallyLoc");if(c&&a){if(this.prev<u.catchLoc)return o(u.catchLoc,!0);if(this.prev<u.finallyLoc)return o(u.finallyLoc)}else if(c){if(this.prev<u.catchLoc)return o(u.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return o(u.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(u)},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),y},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),T(r),y}},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 o=n.arg;T(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},968:(t,e,r)=>{const n=r(577).R;e.s=function(t){if(t||(t=1),!r.y.meta||!r.y.meta.url)throw console.error("__system_context__",r.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");r.p=n(r.y.meta.url,t)}},577:(t,e,r)=>{e.R=function(t,e){var r=document.createElement("a");r.href=t;for(var n="/"===r.pathname[0]?r.pathname:"/"+r.pathname,o=0,i=n.length;o!==e&&i>=0;)"/"===n[--i]&&o++;if(o!==e)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+e+") is greater than the number of directories ("+o+") in the URL path "+t);var u=n.slice(0,i+1);return r.protocol+"//"+r.host+u};Number.isInteger},824:t=>{"use strict";t.exports=r}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.y=e,o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");r.length&&(t=r[r.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t})();var i={};return(0,o(968).s)(1),(()=>{"use strict";o.r(i),o.d(i,{OpenmrsFetchError:()=>nt,VisitMode:()=>me,VisitStatus:()=>ge,backendDependencies:()=>Oe,defaultVisitCustomRepresentation:()=>de,fetchCurrentPatient:()=>ce,fhir:()=>it,fhirBaseUrl:()=>ot,getCurrentUser:()=>Xt,getLocations:()=>Se,getLoggedInUser:()=>re,getSessionLocation:()=>ne,getStartedVisit:()=>we,getVisitTypes:()=>xe,getVisitsForPatient:()=>ye,makeUrl:()=>tt,openmrsFetch:()=>et,openmrsObservableFetch:()=>rt,refetchCurrentUser:()=>te,saveVisit:()=>ve,sessionEndpoint:()=>Z,setSessionLocation:()=>oe,setupApiModule:()=>ue,toLocationObject:()=>Ee,toVisitTypeObject:()=>_e,updateVisit:()=>be,userHasAccess:()=>ee});var t=o(602),e=o.n(t),r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},r(t,e)};function n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t){return"function"==typeof t}var s=!1,c={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,s=t},get useDeprecatedSynchronousErrorHandling(){return s}};function a(t){setTimeout((function(){throw t}),0)}var l={closed:!0,next:function(t){},error:function(t){if(c.useDeprecatedSynchronousErrorHandling)throw t;a(t)},complete:function(){}},f=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function h(t){return null!==t&&"object"==typeof t}var p=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),d=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var r=this,n=r._parentOrParents,o=r._ctorUnsubscribe,i=r._unsubscribe,s=r._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof t)n.remove(this);else if(null!==n)for(var c=0;c<n.length;++c)n[c].remove(this);if(u(i)){o&&(this._unsubscribe=void 0);try{i.call(this)}catch(t){e=t instanceof p?y(t.errors):[t]}}if(f(s)){c=-1;for(var a=s.length;++c<a;){var l=s[c];if(h(l))try{l.unsubscribe()}catch(t){e=e||[],t instanceof p?e=e.concat(y(t.errors)):e.push(t)}}}if(e)throw new p(e)}},t.prototype.add=function(e){var r=e;if(!e)return t.EMPTY;switch(typeof e){case"function":r=new t(e);case"object":if(r===this||r.closed||"function"!=typeof r.unsubscribe)return r;if(this.closed)return r.unsubscribe(),r;if(!(r instanceof t)){var n=r;(r=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var o=r._parentOrParents;if(null===o)r._parentOrParents=this;else if(o instanceof t){if(o===this)return r;r._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return r;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[r]:i.push(r),r},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function y(t){return t.reduce((function(t,e){return t.concat(e instanceof p?e.errors:e)}),[])}var v=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),b=function(t){function e(r,n,o){var i=t.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=l;break;case 1:if(!r){i.destination=l;break}if("object"==typeof r){r instanceof e?(i.syncErrorThrowable=r.syncErrorThrowable,i.destination=r,r.add(i)):(i.syncErrorThrowable=!0,i.destination=new m(i,r));break}default:i.syncErrorThrowable=!0,i.destination=new m(i,r,n,o)}return i}return n(e,t),e.prototype[v]=function(){return this},e.create=function(t,r,n){var o=new e(t,r,n);return o.syncErrorThrowable=!1,o},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(d),m=function(t){function e(e,r,n,o){var i,s=t.call(this)||this;s._parentSubscriber=e;var c=s;return u(r)?i=r:r&&(i=r.next,n=r.error,o=r.complete,r!==l&&(u((c=Object.create(r)).unsubscribe)&&s.add(c.unsubscribe.bind(c)),c.unsubscribe=s.unsubscribe.bind(s))),s._context=c,s._next=i,s._error=n,s._complete=o,s}return n(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;c.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=c.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):a(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;a(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};c.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),c.useDeprecatedSynchronousErrorHandling)throw t;a(t)}},e.prototype.__tryOrSetError=function(t,e,r){if(!c.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return c.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(a(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(b),g=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function w(t){return t}function _(t){return 0===t.length?w:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var x=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this.operator,o=function(t,e,r){if(t){if(t instanceof b)return t;if(t[v])return t[v]()}return t||e||r?new b(t,e,r):new b(l)}(t,e,r);if(n?o.add(n.call(o,this.source)):o.add(this.source||c.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),c.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){c.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){var e=t,r=e.closed,n=e.destination,o=e.isStopped;if(r||o)return!1;t=n&&n instanceof b?n:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=E(e))((function(e,n){var o;o=r.subscribe((function(e){try{t(e)}catch(t){n(t),o&&o.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[g]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:_(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=E(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function E(t){if(t||(t=c.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const S="object"==typeof global&&global&&global.Object===Object&&global;var O="object"==typeof self&&self&&self.Object===Object&&self;const j=(S||O||Function("return this")()).Symbol;var T=Object.prototype,P=T.hasOwnProperty,I=T.toString,A=j?j.toStringTag:void 0;var $=Object.prototype.toString;var N=j?j.toStringTag:void 0;const k=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":N&&N in Object(t)?function(t){var e=P.call(t,A),r=t[A];try{t[A]=void 0;var n=!0}catch(t){}var o=I.call(t);return n&&(e?t[A]=r:delete t[A]),o}(t):function(t){return $.call(t)}(t)},C=(L=Object.getPrototypeOf,D=Object,function(t){return L(D(t))});var L,D;var R=Function.prototype,U=Object.prototype,F=R.toString,B=U.hasOwnProperty,M=F.call(Object);const V=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=k(t))return!1;var e=C(t);if(null===e)return!0;var r=B.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&F.call(r)==M};var q=o(824);function H(t,e,r,n,o,i,u){try{var s=t[i](u),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function G(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){H(i,n,o,u,s,"next",t)}function s(t){H(i,n,o,u,s,"throw",t)}u(void 0)}))}}function Y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function W(t,e,r){return W=Y()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Q(o,r.prototype),o},W.apply(null,arguments)}function z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}function J(t,e){return!e||"object"!==K(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Q(t,e){return Q=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Q(t,e)}var K=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};function X(t){var e="function"==typeof Map?new Map:void 0;return X=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;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,n)}function n(){return W(t,arguments,z(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Q(n,t)},X(t)}var Z="/ws/rest/v1/session";function tt(t){return window.openmrsBase+t}function et(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof t)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof r)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");var n=tt(t);r.headers||(r.headers={}),V(r.body)&&(r.body=JSON.stringify(r.body)),void 0===r.headers.Accept&&(r.headers.Accept="application/json"),null===r.headers.Accept&&delete r.headers.Accept;var o,i=Error();return window.fetch(n,r).then((o=G(e().mark((function t(r){var o,u;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(o=r).ok){t.next=10;break}if(204!==o.status){t.next=7;break}return o.data=null,t.abrupt("return",o);case 7:return t.abrupt("return",o.text().then((function(t){try{t&&(o.data=JSON.parse(t))}catch(t){}return o})));case 8:t.next=19;break;case 10:return t.next=12,(0,q.getConfig)("@openmrs/esm-api");case 12:if(u=t.sent.redirectAuthFailure,!(n===tt(Z)&&403===o.status||u.enabled&&u.errors.includes(o.status))){t.next=18;break}return(0,q.navigate)({to:u.url}),t.abrupt("return",u.resolvePromise?Promise.resolve():new Promise((function(){})));case 18:return t.abrupt("return",o.text().then((function(t){var e=t;try{e=JSON.parse(t)}catch(t){}throw new nt(n,o,e,i)}),(function(t){throw new nt(n,o,null,i)})));case 19:case"end":return t.stop()}}),t)}))),function(t){return o.apply(this,arguments)}))}function rt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");var r=new AbortController;return e.signal=r.signal,new x((function(n){var o=!1;return et(t,e).then((function(t){o=!0,n.next(t),n.complete()}),(function(t){o=!0,n.error(t)})),function(){o||r.abort()}}))}var nt=function(t){!function(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}}),e&&Q(t,e)}(o,t);var e,r,n=(e=o,r=function(){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(){var t,n=z(e);if(r){var o=z(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return J(this,t)});function o(t,e,r,i){var u;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(u=n.call(this)).message="Server responded with ".concat(e.status," (").concat(e.statusText,") for url ").concat(t,". Check err.responseBody or network tab in dev tools for more info"),i.message=u.message,u.responseBody=r,u.response=e,u.stack="Stacktrace for outgoing request:\n".concat(i.stack,"\nStacktrace for incoming response:\n").concat(u.stack),u}return o}(X(Error)),ot="/ws/fhir2/R4",it=o(256)({baseUrl:ot},{http:function(t){return et(t.url,{method:t.method,headers:t.headers}).then((function(e){return{status:e.status,headers:e.headers,data:e.data,config:t}}),(function(e){return{status:e.response.status,headers:e.response.headers,data:e.responseBody,config:t}}))}}),ut=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),st=function(t){function e(e,r){var n=t.call(this)||this;return n.subject=e,n.subscriber=r,n.closed=!1,n}return n(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},e}(d),ct=function(t){function e(e){var r=t.call(this,e)||this;return r.destination=e,r}return n(e,t),e}(b),at=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return n(e,t),e.prototype[v]=function(){return new ct(this)},e.prototype.lift=function(t){var e=new lt(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new ut;if(!this.isStopped)for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].next(t)},e.prototype.error=function(t){if(this.closed)throw new ut;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new ut;this.isStopped=!0;for(var t=this.observers,e=t.length,r=t.slice(),n=0;n<e;n++)r[n].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new ut;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new ut;return this.hasError?(t.error(this.thrownError),d.EMPTY):this.isStopped?(t.complete(),d.EMPTY):(this.observers.push(t),new st(this,t))},e.prototype.asObservable=function(){var t=new x;return t.source=this,t},e.create=function(t,e){return new lt(t,e)},e}(x),lt=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return n(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):d.EMPTY},e}(at),ft=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return n(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):e.flush(this)},e}(function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return n(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var r=this.id,n=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(n,r,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r=!1,n=void 0;try{this.work(t)}catch(t){r=!0,n=!!t&&t||new Error(t)}if(r)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,n=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&r.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,r){return t.call(this)||this}return n(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(d))),ht=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t.now=function(){return Date.now()},t}(),pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(function(t){function e(r,n){void 0===n&&(n=ht.now);var o=t.call(this,r,(function(){return e.delegate&&e.delegate!==o?e.delegate.now():n()}))||this;return o.actions=[],o.active=!1,o.scheduled=void 0,o}return n(e,t),e.prototype.schedule=function(r,n,o){return void 0===n&&(n=0),e.delegate&&e.delegate!==this?e.delegate.schedule(r,n,o):t.prototype.schedule.call(this,r,n,o)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var r;this.active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(ht)),dt=new pt(ft),yt=new x((function(t){return t.complete()}));function vt(t){return t?function(t){return new x((function(e){return t.schedule((function(){return e.complete()}))}))}(t):yt}function bt(t){return t&&"function"==typeof t.schedule}var mt,gt=function(t){return function(e){for(var r=0,n=t.length;r<n&&!e.closed;r++)e.next(t[r]);e.complete()}};function wt(t,e){return new x((function(r){var n=new d,o=0;return n.add(e.schedule((function(){o!==t.length?(r.next(t[o++]),r.closed||n.add(this.schedule())):r.complete()}))),n}))}function _t(t,e){return e?wt(t,e):new x(gt(t))}mt||(mt={});var xt=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,r){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return r&&r()}},t.prototype.accept=function(t,e,r){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){var t;switch(this.kind){case"N":return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t[t.length-1];return bt(r)?(t.pop(),wt(t,r)):_t(t)}(this.value);case"E":return t=this.error,new x((function(e){return e.error(t)}));case"C":return vt()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}(),Et=function(t){function e(e,r,n){void 0===n&&(n=0);var o=t.call(this,e)||this;return o.scheduler=r,o.delay=n,o}return n(e,t),e.dispatch=function(t){var e=t.notification,r=t.destination;e.observe(r),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new St(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(xt.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(xt.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(xt.createComplete()),this.unsubscribe()},e}(b),St=function(){return function(t,e){this.notification=t,this.destination=e}}(),Ot=function(t){function e(e,r,n){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var o=t.call(this)||this;return o.scheduler=n,o._events=[],o._infiniteTimeWindow=!1,o._bufferSize=e<1?1:e,o._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(o._infiniteTimeWindow=!0,o.next=o.nextInfiniteTimeWindow):o.next=o.nextTimeWindow,o}return n(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var r=this._events;r.push(e),r.length>this._bufferSize&&r.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new jt(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,r=this._infiniteTimeWindow,n=r?this._events:this._trimBufferThenGetEvents(),o=this.scheduler,i=n.length;if(this.closed)throw new ut;if(this.isStopped||this.hasError?e=d.EMPTY:(this.observers.push(t),e=new st(this,t)),o&&t.add(t=new Et(t,o)),r)for(var u=0;u<i&&!t.closed;u++)t.next(n[u]);else for(u=0;u<i&&!t.closed;u++)t.next(n[u].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||dt).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,r=this._windowTime,n=this._events,o=n.length,i=0;i<o&&!(t-n[i].time<r);)i++;return o>e&&(i=Math.max(i,o-e)),i>0&&n.splice(0,i),n},e}(at),jt=function(){return function(t,e){this.time=t,this.value=e}}();function Tt(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new Pt(t,e))}}var Pt=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new It(t,this.project,this.thisArg))},t}(),It=function(t){function e(e,r,n){var o=t.call(this,e)||this;return o.project=r,o.count=0,o.thisArg=n||o,o}return n(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(b);function At(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var $t=At(),Nt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function kt(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var Ct=function(t){if(t&&"function"==typeof t[g])return n=t,function(t){var e=n[g]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if(Nt(t))return gt(t);if(kt(t))return r=t,function(t){return r.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,a),t};if(t&&"function"==typeof t[$t])return e=t,function(t){for(var r=e[$t]();;){var n=void 0;try{n=r.next()}catch(e){return t.error(e),t}if(n.done){t.complete();break}if(t.next(n.value),t.closed)break}return"function"==typeof r.return&&t.add((function(){r.return&&r.return()})),t};var e,r,n,o=h(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+o+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};var Lt=function(t){function e(e){var r=t.call(this)||this;return r.parent=e,r}return n(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(b),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(b);function Rt(t,e,r){return void 0===r&&(r=Number.POSITIVE_INFINITY),"function"==typeof e?function(n){return n.pipe(Rt((function(r,n){return(o=t(r,n),o instanceof x?o:new x(Ct(o))).pipe(Tt((function(t,o){return e(r,t,n,o)})));var o}),r))}:("number"==typeof e&&(r=e),function(e){return e.lift(new Ut(t,r))})}var Ut=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new Ft(t,this.project,this.concurrent))},t}(),Ft=function(t){function e(e,r,n){void 0===n&&(n=Number.POSITIVE_INFINITY);var o=t.call(this,e)||this;return o.project=r,o.concurrent=n,o.hasCompleted=!1,o.buffer=[],o.active=0,o.index=0,o}return n(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,r=this.index++;try{e=this.project(t,r)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new Lt(this),r=this.destination;r.add(e);var n=function(t,e){if(!e.closed){if(t instanceof x)return t.subscribe(e);var r;try{r=Ct(t)(e)}catch(t){e.error(t)}return r}}(t,e);n!==e&&r.add(n)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(Dt);function Bt(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),Rt(w,t)}function Mt(){}function Vt(t,e,r){return function(n){return n.lift(new qt(t,e,r))}}var qt=function(){function t(t,e,r){this.nextOrObserver=t,this.error=e,this.complete=r}return t.prototype.call=function(t,e){return e.subscribe(new Ht(t,this.nextOrObserver,this.error,this.complete))},t}(),Ht=function(t){function e(e,r,n,o){var i=t.call(this,e)||this;return i._tapNext=Mt,i._tapError=Mt,i._tapComplete=Mt,i._tapError=n||Mt,i._tapComplete=o||Mt,u(r)?(i._context=i,i._tapNext=r):r&&(i._context=r,i._tapNext=r.next||Mt,i._tapError=r.error||Mt,i._tapComplete=r.complete||Mt),i}return n(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(b);function Gt(t,e){return function(r){return r.lift(new Yt(t,e))}}var Yt=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Wt(t,this.predicate,this.thisArg))},t}(),Wt=function(t){function e(e,r,n){var o=t.call(this,e)||this;return o.predicate=r,o.thisArg=n,o.count=0,o}return n(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(b);function zt(t,e,r,n,o,i,u){try{var s=t[i](u),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function Jt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){zt(i,n,o,u,s,"next",t)}function s(t){zt(i,n,o,u,s,"throw",t)}u(void 0)}))}}var Qt=new Ot(1),Kt=0;function Xt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{includeAuthStatus:!1};return Kt<Date.now()-6e4&&te(),Qt.asObservable().pipe(Bt(),Vt(Zt),Tt((function(e){return t.includeAuthStatus?e:e.user})),Gt(Boolean))}function Zt(t){var e,r,n,o=null!==(n=null==t||null===(e=t.user)||void 0===e||null===(r=e.userProperties)||void 0===r?void 0:r.defaultLocale)&&void 0!==n?n:t.locale;o!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",o)}function te(){Kt=Date.now(),Qt.next(et(Z).then((function(t){return"object"==typeof t.data?t.data:Promise.reject()})).catch((function(){return{sessionId:"",authenticated:!1}})))}function ee(t,e){return function(t,e){return e.privileges.find((function(e){return t===e.display}))}(t,e)||function(t){return t.roles.find((function(t){return"System Developer"===t.display}))}(e)}function re(){return new Promise((function(t,e){var r=Xt().subscribe((function(e){t(e),r.unsubscribe()}),e)}))}function ne(){return new Promise((function(t,e){var r=Xt({includeAuthStatus:!0}).subscribe((function(e){t(e.sessionLocation),r.unsubscribe()}),e)}))}function oe(t,e){return ie.apply(this,arguments)}function ie(){return(ie=Jt(e().mark((function t(r,n){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,et(Z,{method:"POST",body:{sessionLocation:r},headers:{"Content-Type":"application/json"},signal:n.signal});case 2:te();case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ue(){(0,q.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:q.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:q.Type.String,_default:"${openmrsSpaBase}/login",_validators:[q.validators.isUrl]},errors:{_type:q.Type.Array,_default:[401],_elements:{_type:q.Type.Number,_validators:[q.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:q.Type.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}}}),te()}function se(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ce(t,e){return t?it.read(function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){se(t,e,r[e])}))}return t}({type:"Patient",patient:t},e)):Promise.resolve(null)}var ae=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return n(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new ut;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(at),le=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}();function fe(t){return function(e){return 0===t?vt():e.lift(new he(t))}}var he=function(){function t(t){if(this.total=t,this.total<0)throw new le}return t.prototype.call=function(t,e){return e.subscribe(new pe(t,this.total))},t}(),pe=function(t){function e(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return n(e,t),e.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},e}(b),de="custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,value),location:(uuid,name,display),startDatetime,stopDatetime)";function ye(t,e,r){var n=null!=r?r:de;return rt("/ws/rest/v1/visit?patient=".concat(t,"&v=").concat(n),{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(fe(1)).pipe(Tt((function(t){return t})))}function ve(t,e){return rt("/ws/rest/v1/visit",{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function be(t,e,r){return rt("/ws/rest/v1/visit/".concat(t),{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}var me,ge,we=new ae(null);function _e(t){return{uuid:t.uuid,display:t.display,name:t.name}}function xe(){return rt("/ws/rest/v1/visittype").pipe(Tt((function(t){return t.data.results.map(_e)}))).pipe(fe(1))}function Ee(t){return{uuid:t.uuid,display:t.display}}function Se(){return rt("/ws/rest/v1/location").pipe(Tt((function(t){return t.data.results.map(Ee)}))).pipe(fe(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(me||(me={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(ge||(ge={}));var Oe={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),i})())}}}));
3
2
  //# sourceMappingURL=openmrs-esm-api.js.map