@openmrs/esm-api 3.2.1-pre.947 → 3.2.1-pre.957
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.
- package/dist/openmrs-esm-api.js +1 -1
- package/dist/openmrs-esm-api.js.map +1 -1
- package/package.json +5 -5
- package/src/fhir.ts +4 -0
- package/src/index.ts +0 -1
- package/src/openmrs-fetch.ts +5 -0
- package/src/shared-api-objects/current-patient.ts +5 -3
- package/src/shared-api-objects/current-user.ts +5 -4
- package/src/shared-api-objects/location.ts +5 -0
- package/src/shared-api-objects/visit-type.ts +5 -0
- package/src/shared-api-objects/visit-utils.ts +5 -12
- package/src/workspace/workspace.resource.tsx +0 -30
package/dist/openmrs-esm-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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,o,i=String(t),s=0,u=r,c="";i.charAt(0|s)||(u="=",s%1);c+=u.charAt(63&e>>8-s%1*8)){if((o=i.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|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,s=0,u=0,c="";i=e.charAt(u++);~i&&(o=s%4?64*o+i:i,s++%4)?c+=String.fromCharCode(255&o>>(-2*s&6)):0)i=r.indexOf(i);return c})}()},525:function(t){(function(){var e,r;function n(t,o){var i,s=t.data.entry||[],u=[];for(i=0;i<s.length;i++)u.push(s[i].resource);o(u);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,s){r.defer(),e.search(t).then((function(t){n(t,o).then((function(){i()}),(function(t){s(t)}))}),(function(t){s(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 s(t,n){var o=r.defer();return e.search(t).then((function(t){var r={},i=[function(){o.resolve(t,r)}];function s(){i.pop()()}var u=t.data;u.entry&&u.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],h=o[l];if(c===a&&h){var f=h.reference;r[f]||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,s()}))}(t,n,o)}))}(u,o,h)}}))})),s()}),(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=s,t}}).call(this)},256:function(t,e,r){(function(){r(454);var e=r(801),n=r(921),o=r(294),i=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(o.$Basic).and(o.$Bearer).and(o.$Credentials).and(i.$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=i.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),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 s=n[i];(o=t[s])||(o={},t[s]=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,s=o;if(!s.reference)return null;if(s.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}(s.reference,t.resource);var u=e.absoluteUrl(t.baseUrl,s.reference);return(i&&i.entry||[]).filter((function(t){return t.id===u}))[0]||(null!=r?r[u]:void 0)||null};t.exports.sync=o,t.exports.resolve=function(t){return function(r){var i=o(r),s=r.reference,u=r.defer();if(i){if(!r.defer)throw new Error("I need promise constructor 'adapter.defer' in adapter");return u.resolve(i),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,o=t.assertArray,i=(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,i,s;for(o(t),i=[],e=0,r=t.length;e<r;e++)switch(s=t[e],n(s)){case"array":i.push({param:"_sort",value:s[0],modifier:":"+s[1]});break;case"string":i.push({param:"_sort",value:s});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 s,l,h,f;return s=i[0],f=i[1],r.concat("$and"===s?o(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 i(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 o,i,u,c;for(c=[],o=0,i=(u=l(t)).length;o<i;o++)e=u[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(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 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 s=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=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,o,i;for(n in o=t(!0,e),r)i=r[n],o[n]=(o[n]||[]).concat(i);return o},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 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,s;return i=o[0],s=o[1],e[i]=t(s,[r].concat(n)),e},e(s(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 s=o[0],u=o.length;(t||"object"!==i(s))&&(s={});for(var c=0;c<u;++c){var a=o[c];if("object"===i(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 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,s=i(t);if("array"===s)for(o=[],n=t.length,e=0;e<n;++e)o[e]=r.clone(t[e]);else if("object"===s)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)},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 s=n.slice(0,i+1);return r.protocol+"//"+r.host+s};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.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:()=>Y,VisitMode:()=>ue,VisitStatus:()=>ce,backendDependencies:()=>pe,fetchCurrentPatient:()=>Gt,fhir:()=>z,fhirBaseUrl:()=>G,getCurrentUser:()=>Mt,getLocations:()=>fe,getLoggedInUser:()=>Ht,getNewWorkspaceItem:()=>ee,getSessionLocation:()=>Lt,getStartedVisit:()=>se,getVisitTypes:()=>le,getVisitsForPatient:()=>ne,makeUrl:()=>H,newWorkspaceItem:()=>te,openVisitsNoteWorkspace:()=>re,openmrsFetch:()=>L,openmrsObservableFetch:()=>W,refetchCurrentUser:()=>Ft,saveVisit:()=>oe,sessionEndpoint:()=>q,setSessionLocation:()=>Wt,setupApiModule:()=>Yt,toLocationObject:()=>he,toVisitTypeObject:()=>ae,updateVisit:()=>ie,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,o=n._parentOrParents,i=n._ctorUnsubscribe,s=n._unsubscribe,u=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,o instanceof t)o.remove(this);else if(null!==o)for(var c=0;c<o.length;++c)o[c].remove(this);if(r(s)){i&&(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 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 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,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=c;break;case 1:if(!e){i.destination=c;break}if("object"==typeof e){e instanceof r?(i.syncErrorThrowable=e.syncErrorThrowable,i.destination=e,e.add(i)):(i.syncErrorThrowable=!0,i.destination=new y(i,e));break}default:i.syncErrorThrowable=!0,i.destination=new y(i,e,n,o)}return i}return e(r,t),r.prototype[d]=function(){return this},r.create=function(t,e,n){var o=new r(t,e,n);return o.syncErrorThrowable=!1,o},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,o,i){var s,u=t.call(this)||this;u._parentSubscriber=e;var a=u;return r(n)?s=n:n&&(s=n.next,o=n.error,i=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=o,u._complete=i,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,o=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?o.add(n.call(o,this.source)):o.add(this.source||s.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),s.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){s.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))((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[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 o=j.call(t);return n&&(e?t[P]=r:delete t[P]),o}(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=o(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 o=t;try{o=JSON.parse(t)}catch(t){}throw new Y(r,e,o,n)}),(t=>{throw new Y(r,e,null,n)}))}}))}function W(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 o=!1;return L(t,e).then((t=>{o=!0,n.next(t),n.complete()}),(t=>{o=!0,n.error(t)})),()=>{o||r.abort()}}))}class Y 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 G="/ws/fhir2/R4",z=o(256)({baseUrl:G},{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(),o=0;o<r;o++)n[o].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(),o=0;o<r;o++)n[o].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 o=t.call(this,e,(function(){return r.delegate&&r.delegate!==o?r.delegate.now():n()}))||this;return o.actions=[],o.active=!1,o.scheduled=void 0,o}return e(r,t),r.prototype.schedule=function(e,n,o){return void 0===n&&(n=0),r.delegate&&r.delegate!==this?r.delegate.schedule(e,n,o):t.prototype.schedule.call(this,e,n,o)},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),ot=new w((function(t){return t.complete()}));function it(t){return t?function(t){return new w((function(e){return t.schedule((function(){return e.complete()}))}))}(t):ot}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,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 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 it()}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 o=t.call(this,e)||this;return o.scheduler=r,o.delay=n,o}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 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 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(),o=this.scheduler,i=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)),o&&t.add(t=new ft(t,o)),r)for(var s=0;s<i&&!t.closed;s++)t.next(n[s]);else for(s=0;s<i&&!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,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},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 o=t.call(this,e)||this;return o.project=r,o.count=0,o.thisArg=n||o,o}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,o=l(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 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(o=t(r,n),o instanceof w?o:new w(Et(o))).pipe(yt((function(t,o){return e(r,t,n,o)})));var o}),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 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 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,o,i){var s=t.call(this,e)||this;return s._tapNext=It,s._tapError=It,s._tapComplete=It,s._tapError=o||It,s._tapComplete=i||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 o=t.call(this,e)||this;return o.predicate=r,o.thisArg=n,o.count=0,o}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 Wt(t,e){await L(q,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal}),Ft()}function Yt(){(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 Gt(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?it():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);const Zt=new X;function te(t){Zt.next(t)}function ee(){return Zt.asObservable()}function re(t,e){te({component:t,name:e,props:{},inProgress:!1,validations:e=>e.findIndex((e=>e.component===t))})}function ne(t,e,r){return W(`/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 oe(t,e){return W("/ws/rest/v1/visit",{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function ie(t,e,r){return W(`/ws/rest/v1/visit/${t}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}const se=new zt(null);let ue,ce;function ae(t){return{uuid:t.uuid,display:t.display,name:t.name}}function le(){return W("/ws/rest/v1/visittype").pipe(yt((t=>t.data.results.map(ae)))).pipe(Qt(1))}function he(t){return{uuid:t.uuid,display:t.display}}function fe(){return W("/ws/rest/v1/location").pipe(yt((t=>t.data.results.map(he)))).pipe(Qt(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(ue||(ue={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(ce||(ce={}));const pe={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),i})())}}}));
|
|
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})())}}}));
|
|
3
3
|
//# sourceMappingURL=openmrs-esm-api.js.map
|