@medplum/core 0.9.35 → 0.9.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cjs/client.d.ts +14 -5
  2. package/dist/cjs/fhirlexer/index.d.ts +2 -0
  3. package/dist/cjs/fhirlexer/parse.d.ts +31 -0
  4. package/dist/cjs/fhirlexer/tokenize.d.ts +14 -0
  5. package/dist/cjs/fhirmapper/atoms.d.ts +67 -0
  6. package/dist/cjs/fhirmapper/parse.d.ts +7 -0
  7. package/dist/cjs/fhirmapper/tokenize.d.ts +2 -0
  8. package/dist/cjs/fhirpath/atoms.d.ts +2 -7
  9. package/dist/cjs/fhirpath/functions.d.ts +2 -1
  10. package/dist/cjs/fhirpath/parse.d.ts +8 -5
  11. package/dist/cjs/fhirpath/tokenize.d.ts +3 -4
  12. package/dist/cjs/fhirpath/utils.d.ts +1 -1
  13. package/dist/cjs/index.js +310 -272
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/index.min.js +1 -1
  16. package/dist/cjs/index.min.js.map +1 -1
  17. package/dist/cjs/types.d.ts +4 -0
  18. package/dist/esm/client.d.ts +14 -5
  19. package/dist/esm/client.js +58 -45
  20. package/dist/esm/client.js.map +1 -1
  21. package/dist/esm/fhirlexer/index.d.ts +2 -0
  22. package/dist/esm/fhirlexer/parse.d.ts +31 -0
  23. package/dist/esm/fhirlexer/parse.js +105 -0
  24. package/dist/esm/fhirlexer/parse.js.map +1 -0
  25. package/dist/esm/fhirlexer/tokenize.d.ts +14 -0
  26. package/dist/esm/fhirlexer/tokenize.js +212 -0
  27. package/dist/esm/fhirlexer/tokenize.js.map +1 -0
  28. package/dist/esm/fhirmapper/atoms.d.ts +67 -0
  29. package/dist/esm/fhirmapper/parse.d.ts +7 -0
  30. package/dist/esm/fhirmapper/tokenize.d.ts +2 -0
  31. package/dist/esm/fhirpath/atoms.d.ts +2 -7
  32. package/dist/esm/fhirpath/atoms.js.map +1 -1
  33. package/dist/esm/fhirpath/functions.d.ts +2 -1
  34. package/dist/esm/fhirpath/functions.js.map +1 -1
  35. package/dist/esm/fhirpath/parse.d.ts +8 -5
  36. package/dist/esm/fhirpath/parse.js +57 -169
  37. package/dist/esm/fhirpath/parse.js.map +1 -1
  38. package/dist/esm/fhirpath/tokenize.d.ts +3 -4
  39. package/dist/esm/fhirpath/tokenize.js +5 -180
  40. package/dist/esm/fhirpath/tokenize.js.map +1 -1
  41. package/dist/esm/fhirpath/utils.d.ts +1 -1
  42. package/dist/esm/fhirpath/utils.js.map +1 -1
  43. package/dist/esm/index.js +2 -2
  44. package/dist/esm/index.min.js +1 -1
  45. package/dist/esm/index.min.js.map +1 -1
  46. package/dist/esm/outcomes.js +1 -1
  47. package/dist/esm/outcomes.js.map +1 -1
  48. package/dist/esm/types.d.ts +4 -0
  49. package/dist/esm/types.js.map +1 -1
  50. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.core={}))}(this,(function(e){"use strict";function t(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{c(n.next(e))}catch(e){r(e)}}function s(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}var o,r,a,s;class c{constructor(e=10){o.add(this),r.set(this,void 0),a.set(this,void 0),n(this,r,e,"f"),n(this,a,new Map,"f")}clear(){i(this,a,"f").clear()}get(e){const t=i(this,a,"f").get(e);return t&&(i(this,a,"f").delete(e),i(this,a,"f").set(e,t)),t}set(e,t){i(this,a,"f").has(e)?i(this,a,"f").delete(e):i(this,a,"f").size>=i(this,r,"f")&&i(this,a,"f").delete(i(this,o,"m",s).call(this)),i(this,a,"f").set(e,t)}delete(e){i(this,a,"f").delete(e)}keys(){return i(this,a,"f").keys()}}function d(e,t){const i=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&i.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(" ").trim()}function l(e){return e instanceof Date&&!isNaN(e.getTime())}function u(e,t){if(!e)return"";const i=new Date("2000-01-01T"+e+"Z");return l(i)?i.toLocaleTimeString(void 0,t):""}function m(e,t){if(!e)return"";const i=new Date(e);return l(i)?i.toLocaleString(void 0,t):""}r=new WeakMap,a=new WeakMap,o=new WeakSet,s=function(){return i(this,a,"f").keys().next().value};const p={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},h={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},f={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function y(e){const t=g(e),i=x(e);return i===t?{reference:t}:{reference:t,display:i}}function g(e){return e.resourceType+"/"+e.id}function v(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function x(e){var t,i;if(v(e)){const t=function(e){const t=e.name;if(t&&t.length>0)return d(t[0]);return}(e);if(t)return t}if("Device"===e.resourceType){const t=function(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name;return}(e);if(t)return t}return"Observation"===e.resourceType&&"code"in e&&(null===(t=e.code)||void 0===t?void 0:t.text)?null===(i=e.code)||void 0===i?void 0:i.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:g(e)}function T(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function E(e,t){const i=new Date(e);i.setUTCHours(0,0,0,0);const n=t?new Date(t):new Date;n.setUTCHours(0,0,0,0);const o=i.getUTCFullYear(),r=i.getUTCMonth(),a=i.getUTCDate(),s=n.getUTCFullYear(),c=n.getUTCMonth(),d=n.getUTCDate();let l=s-o;(c<r||c===r&&d<a)&&l--;let u=12*s+c-(12*o+r);d<a&&u--;return{years:l,months:u,days:Math.floor((n.getTime()-i.getTime())/864e5)}}function w(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),w(i.item,t)}function S(e,t){return JSON.stringify(e,b,t?2:void 0)}function b(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&D(t)?void 0:t}function D(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function P(e,t,i){return e===t||(!(!D(e)||!D(t))||!D(e)&&!D(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!P(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(C(e)&&C(t)?function(e,t,i){const n=new Set;Object.keys(e).forEach((e=>n.add(e))),Object.keys(t).forEach((e=>n.add(e))),"meta"===i&&(n.delete("versionId"),n.delete("lastUpdated"),n.delete("author"));for(const i of n){if(!P(e[i],t[i],i))return!1}return!0}(e,t,i):(C(e)||C(t),!1))))}function C(e){return null!==e&&"object"==typeof e}function A(e){return e.every((e=>"string"==typeof e))}const R=[];for(let e=0;e<256;e++)R.push(e.toString(16).padStart(2,"0"));function O(e){const t=new Uint8Array(e),i=new Array(t.length);for(let e=0;e<t.length;e++)i[e]=R[t[e]];return i.join("")}function k(e){const t=new Uint8Array(e),i=[];for(let e=0;e<t.length;e++)i[e]=String.fromCharCode(t[e]);return window.btoa(i.join(""))}function I(e){return e.charAt(0).toUpperCase()+e.substring(1)}function M(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||U(E(t.birthDate).years,e.age)}(e,t)}function U(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||Q(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||_(e,t.high.value,i))}function L(e,t,i){return i?Math.abs(e-t)<Math.pow(10,-i):e===t}function N(e,t,i){return i?e<t&&Math.abs(e-t)>Math.pow(10,-i):e<t}function j(e,t,i){return i?e>t&&Math.abs(e-t)>Math.pow(10,-i):e>t}function _(e,t,i){return N(e,t,i)||L(e,t,i)}function Q(e,t,i){return j(e,t,i)||L(e,t,i)}function B(){const e=new Uint32Array(28);return crypto.getRandomValues(e),O(e.buffer)}var W,q,F,H,$,z,G,V;function X(e){const t=function(e){if("undefined"!=typeof window)return window.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}(e.replace(/-/g,"+").replace(/_/g,"/")),i=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),n=decodeURIComponent(i);return JSON.parse(n)}function Y(e){const[t,i,n]=e.split(".");return X(i)}W=new WeakMap;class J{constructor(e){this[z]="ReadablePromise",q.set(this,void 0),F.set(this,"pending"),H.set(this,void 0),$.set(this,void 0),n(this,q,e.then((e=>(n(this,F,"success","f"),n(this,H,e,"f"),e)),(e=>{throw n(this,F,"error","f"),n(this,$,e,"f"),e})),"f")}isPending(){return"pending"===i(this,F,"f")}isOk(){return"success"===i(this,F,"f")}read(){switch(i(this,F,"f")){case"pending":throw i(this,q,"f");case"error":throw i(this,$,"f");default:return i(this,H,"f")}}then(e,t){return i(this,q,"f").then(e,t)}catch(e){return i(this,q,"f").catch(e)}finally(e){return i(this,q,"f").finally(e)}}q=new WeakMap,F=new WeakMap,H=new WeakMap,$=new WeakMap,z=Symbol.toStringTag;class K{constructor(){G.set(this,void 0),n(this,G,"undefined"!=typeof localStorage?localStorage:new Z,"f")}clear(){i(this,G,"f").clear()}getString(e){return i(this,G,"f").getItem(e)||void 0}setString(e,t){t?i(this,G,"f").setItem(e,t):i(this,G,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?S(t):void 0)}}G=new WeakMap;class Z{constructor(){V.set(this,void 0),n(this,V,new Map,"f")}get length(){return i(this,V,"f").size}clear(){i(this,V,"f").clear()}getItem(e){var t;return null!==(t=i(this,V,"f").get(e))&&void 0!==t?t:null}setItem(e,t){t?i(this,V,"f").set(e,t):i(this,V,"f").delete(e)}removeItem(e){i(this,V,"f").delete(e)}key(e){return Array.from(i(this,V,"f").keys())[e]}}V=new WeakMap;var ee,te={types:{Element:{display:"Element",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]}}},BackboneElement:{display:"BackboneElement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]}}},Address:{display:"Address",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},line:{min:0,max:"*",type:[{code:"string"}]},city:{min:0,max:"1",type:[{code:"string"}]},district:{min:0,max:"1",type:[{code:"string"}]},state:{min:0,max:"1",type:[{code:"string"}]},postalCode:{min:0,max:"1",type:[{code:"string"}]},country:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Age:{display:"Age",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Annotation:{display:"Annotation",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"author[x]":{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{min:0,max:"1",type:[{code:"dateTime"}]},text:{min:1,max:"1",type:[{code:"markdown"}]}}},Attachment:{display:"Attachment",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},contentType:{min:0,max:"1",type:[{code:"code"}]},language:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]},url:{min:0,max:"1",type:[{code:"url"}]},size:{min:0,max:"1",type:[{code:"unsignedInt"}]},hash:{min:0,max:"1",type:[{code:"base64Binary"}]},title:{min:0,max:"1",type:[{code:"string"}]},creation:{min:0,max:"1",type:[{code:"dateTime"}]}}},CodeableConcept:{display:"CodeableConcept",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},coding:{min:0,max:"*",type:[{code:"Coding"}]},text:{min:0,max:"1",type:[{code:"string"}]}}},Coding:{display:"Coding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"uri"}]},version:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"1",type:[{code:"code"}]},display:{min:0,max:"1",type:[{code:"string"}]},userSelected:{min:0,max:"1",type:[{code:"boolean"}]}}},ContactDetail:{display:"ContactDetail",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"string"}]},telecom:{min:0,max:"*",type:[{code:"ContactPoint"}]}}},ContactPoint:{display:"ContactPoint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"code"}]},value:{min:0,max:"1",type:[{code:"string"}]},use:{min:0,max:"1",type:[{code:"code"}]},rank:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Contributor:{display:"Contributor",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:1,max:"1",type:[{code:"string"}]},contact:{min:0,max:"*",type:[{code:"ContactDetail"}]}}},Count:{display:"Count",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},DataRequirement:{display:"DataRequirement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{min:0,max:"1",type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{min:0,max:"*",type:[{code:"string"}]},codeFilter:{min:0,max:"*",type:[{code:"Element"}]},dateFilter:{min:0,max:"*",type:[{code:"Element"}]},limit:{min:0,max:"1",type:[{code:"positiveInt"}]},sort:{min:0,max:"*",type:[{code:"Element"}]}}},DataRequirementCodeFilter:{display:"DataRequirementCodeFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{min:0,max:"*",type:[{code:"Coding"}]}},parentType:"DataRequirement"},DataRequirementDateFilter:{display:"DataRequirementDateFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}},parentType:"DataRequirement"},DataRequirementSort:{display:"DataRequirementSort",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},direction:{min:1,max:"1",type:[{code:"code"}]}},parentType:"DataRequirement"},Distance:{display:"Distance",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Dosage:{display:"Dosage",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},sequence:{min:0,max:"1",type:[{code:"integer"}]},text:{min:0,max:"1",type:[{code:"string"}]},additionalInstruction:{min:0,max:"*",type:[{code:"CodeableConcept"}]},patientInstruction:{min:0,max:"1",type:[{code:"string"}]},timing:{min:0,max:"1",type:[{code:"Timing"}]},"asNeeded[x]":{min:0,max:"1",type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{min:0,max:"1",type:[{code:"CodeableConcept"}]},route:{min:0,max:"1",type:[{code:"CodeableConcept"}]},method:{min:0,max:"1",type:[{code:"CodeableConcept"}]},doseAndRate:{min:0,max:"*",type:[{code:"Element"}]},maxDosePerPeriod:{min:0,max:"1",type:[{code:"Ratio"}]},maxDosePerAdministration:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{display:"DosageDoseAndRate",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},"dose[x]":{min:0,max:"1",type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{min:0,max:"1",type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}},parentType:"Dosage"},Duration:{display:"Duration",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},ElementDefinition:{display:"ElementDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},representation:{min:0,max:"*",type:[{code:"code"}]},sliceName:{min:0,max:"1",type:[{code:"string"}]},sliceIsConstraining:{min:0,max:"1",type:[{code:"boolean"}]},label:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"*",type:[{code:"Coding"}]},slicing:{min:0,max:"1",type:[{code:"Element"}]},short:{min:0,max:"1",type:[{code:"string"}]},definition:{min:0,max:"1",type:[{code:"markdown"}]},comment:{min:0,max:"1",type:[{code:"markdown"}]},requirements:{min:0,max:"1",type:[{code:"markdown"}]},alias:{min:0,max:"*",type:[{code:"string"}]},min:{min:0,max:"1",type:[{code:"unsignedInt"}]},max:{min:0,max:"1",type:[{code:"string"}]},base:{min:0,max:"1",type:[{code:"Element"}]},contentReference:{min:0,max:"1",type:[{code:"uri"}]},type:{min:0,max:"*",type:[{code:"Element"}]},"defaultValue[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{min:0,max:"1",type:[{code:"markdown"}]},orderMeaning:{min:0,max:"1",type:[{code:"string"}]},"fixed[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{min:0,max:"*",type:[{code:"Element"}]},"minValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{min:0,max:"1",type:[{code:"integer"}]},condition:{min:0,max:"*",type:[{code:"id"}]},constraint:{min:0,max:"*",type:[{code:"Element"}]},mustSupport:{min:0,max:"1",type:[{code:"boolean"}]},isModifier:{min:0,max:"1",type:[{code:"boolean"}]},isModifierReason:{min:0,max:"1",type:[{code:"string"}]},isSummary:{min:0,max:"1",type:[{code:"boolean"}]},binding:{min:0,max:"1",type:[{code:"Element"}]},mapping:{min:0,max:"*",type:[{code:"Element"}]}}},ElementDefinitionSlicing:{display:"ElementDefinitionSlicing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},discriminator:{min:0,max:"*",type:[{code:"Element"}]},description:{min:0,max:"1",type:[{code:"string"}]},ordered:{min:0,max:"1",type:[{code:"boolean"}]},rules:{min:1,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionSlicingDiscriminator:{display:"ElementDefinitionSlicingDiscriminator",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},path:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinitionSlicing"},ElementDefinitionBase:{display:"ElementDefinitionBase",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},min:{min:1,max:"1",type:[{code:"unsignedInt"}]},max:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},ElementDefinitionType:{display:"ElementDefinitionType",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{min:0,max:"*",type:[{code:"code"}]},versioning:{min:0,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionExample:{display:"ElementDefinitionExample",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},label:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:1,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}},parentType:"ElementDefinition"},ElementDefinitionConstraint:{display:"ElementDefinitionConstraint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},key:{min:1,max:"1",type:[{code:"id"}]},requirements:{min:0,max:"1",type:[{code:"string"}]},severity:{min:1,max:"1",type:[{code:"code"}]},human:{min:1,max:"1",type:[{code:"string"}]},expression:{min:0,max:"1",type:[{code:"string"}]},xpath:{min:0,max:"1",type:[{code:"string"}]},source:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}},parentType:"ElementDefinition"},ElementDefinitionBinding:{display:"ElementDefinitionBinding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},strength:{min:1,max:"1",type:[{code:"code"}]},description:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}},parentType:"ElementDefinition"},ElementDefinitionMapping:{display:"ElementDefinitionMapping",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},identity:{min:1,max:"1",type:[{code:"id"}]},language:{min:0,max:"1",type:[{code:"code"}]},map:{min:1,max:"1",type:[{code:"string"}]},comment:{min:0,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},Expression:{display:"Expression",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},description:{min:0,max:"1",type:[{code:"string"}]},name:{min:0,max:"1",type:[{code:"id"}]},language:{min:1,max:"1",type:[{code:"code"}]},expression:{min:0,max:"1",type:[{code:"string"}]},reference:{min:0,max:"1",type:[{code:"uri"}]}}},Extension:{display:"Extension",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},url:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},HumanName:{display:"HumanName",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},family:{min:0,max:"1",type:[{code:"string"}]},given:{min:0,max:"*",type:[{code:"string"}]},prefix:{min:0,max:"*",type:[{code:"string"}]},suffix:{min:0,max:"*",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Identifier:{display:"Identifier",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},system:{min:0,max:"1",type:[{code:"uri"}]},value:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]},assigner:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{display:"MarketingStatus",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},country:{min:1,max:"1",type:[{code:"CodeableConcept"}]},jurisdiction:{min:0,max:"1",type:[{code:"CodeableConcept"}]},status:{min:1,max:"1",type:[{code:"CodeableConcept"}]},dateRange:{min:1,max:"1",type:[{code:"Period"}]},restoreDate:{min:0,max:"1",type:[{code:"dateTime"}]}}},Meta:{display:"Meta",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},versionId:{min:0,max:"1",type:[{code:"id"}]},lastUpdated:{min:0,max:"1",type:[{code:"instant"}]},source:{min:0,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{min:0,max:"*",type:[{code:"Coding"}]},tag:{min:0,max:"*",type:[{code:"Coding"}]},project:{min:0,max:"1",type:[{code:"uri"}]},author:{min:0,max:"1",type:[{code:"Reference"}]},account:{min:0,max:"1",type:[{code:"Reference"}]}}},Money:{display:"Money",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},currency:{min:0,max:"1",type:[{code:"code"}]}}},Narrative:{display:"Narrative",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},status:{min:1,max:"1",type:[{code:"code"}]},div:{min:1,max:"1",type:[{code:"xhtml"}]}}},ParameterDefinition:{display:"ParameterDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"code"}]},use:{min:1,max:"1",type:[{code:"code"}]},min:{min:0,max:"1",type:[{code:"integer"}]},max:{min:0,max:"1",type:[{code:"string"}]},documentation:{min:0,max:"1",type:[{code:"string"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{display:"Period",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},start:{min:0,max:"1",type:[{code:"dateTime"}]},end:{min:0,max:"1",type:[{code:"dateTime"}]}}},Population:{display:"Population",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"age[x]":{min:0,max:"1",type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{min:0,max:"1",type:[{code:"CodeableConcept"}]},race:{min:0,max:"1",type:[{code:"CodeableConcept"}]},physiologicalCondition:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{display:"ProdCharacteristic",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},height:{min:0,max:"1",type:[{code:"Quantity"}]},width:{min:0,max:"1",type:[{code:"Quantity"}]},depth:{min:0,max:"1",type:[{code:"Quantity"}]},weight:{min:0,max:"1",type:[{code:"Quantity"}]},nominalVolume:{min:0,max:"1",type:[{code:"Quantity"}]},externalDiameter:{min:0,max:"1",type:[{code:"Quantity"}]},shape:{min:0,max:"1",type:[{code:"string"}]},color:{min:0,max:"*",type:[{code:"string"}]},imprint:{min:0,max:"*",type:[{code:"string"}]},image:{min:0,max:"*",type:[{code:"Attachment"}]},scoring:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{display:"ProductShelfLife",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},type:{min:1,max:"1",type:[{code:"CodeableConcept"}]},period:{min:1,max:"1",type:[{code:"Quantity"}]},specialPrecautionsForStorage:{min:0,max:"*",type:[{code:"CodeableConcept"}]}}},Quantity:{display:"Quantity",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"0",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Range:{display:"Range",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},low:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{display:"Ratio",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},numerator:{min:0,max:"1",type:[{code:"Quantity"}]},denominator:{min:0,max:"1",type:[{code:"Quantity"}]}}},Reference:{display:"Reference",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},reference:{min:0,max:"1",type:[{code:"string"}]},type:{min:0,max:"1",type:[{code:"uri"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},display:{min:0,max:"1",type:[{code:"string"}]}}},RelatedArtifact:{display:"RelatedArtifact",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},label:{min:0,max:"1",type:[{code:"string"}]},display:{min:0,max:"1",type:[{code:"string"}]},citation:{min:0,max:"1",type:[{code:"markdown"}]},url:{min:0,max:"1",type:[{code:"url"}]},document:{min:0,max:"1",type:[{code:"Attachment"}]},resource:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{display:"SampledData",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},origin:{min:1,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,max:"1",type:[{code:"decimal"}]},factor:{min:0,max:"1",type:[{code:"decimal"}]},lowerLimit:{min:0,max:"1",type:[{code:"decimal"}]},upperLimit:{min:0,max:"1",type:[{code:"decimal"}]},dimensions:{min:1,max:"1",type:[{code:"positiveInt"}]},data:{min:0,max:"1",type:[{code:"string"}]}}},Signature:{display:"Signature",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"*",type:[{code:"Coding"}]},when:{min:1,max:"1",type:[{code:"instant"}]},who:{min:1,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{min:0,max:"1",type:[{code:"code"}]},sigFormat:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]}}},SubstanceAmount:{display:"SubstanceAmount",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"amount[x]":{min:0,max:"1",type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{min:0,max:"1",type:[{code:"CodeableConcept"}]},amountText:{min:0,max:"1",type:[{code:"string"}]},referenceRange:{min:0,max:"1",type:[{code:"Element"}]}}},SubstanceAmountReferenceRange:{display:"SubstanceAmountReferenceRange",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},lowLimit:{min:0,max:"1",type:[{code:"Quantity"}]},highLimit:{min:0,max:"1",type:[{code:"Quantity"}]}},parentType:"SubstanceAmount"},Timing:{display:"Timing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},event:{min:0,max:"*",type:[{code:"dateTime"}]},repeat:{min:0,max:"1",type:[{code:"Element"}]},code:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},TimingRepeat:{display:"TimingRepeat",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"bounds[x]":{min:0,max:"1",type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{min:0,max:"1",type:[{code:"positiveInt"}]},countMax:{min:0,max:"1",type:[{code:"positiveInt"}]},duration:{min:0,max:"1",type:[{code:"decimal"}]},durationMax:{min:0,max:"1",type:[{code:"decimal"}]},durationUnit:{min:0,max:"1",type:[{code:"code"}]},frequency:{min:0,max:"1",type:[{code:"positiveInt"}]},frequencyMax:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"decimal"}]},periodMax:{min:0,max:"1",type:[{code:"decimal"}]},periodUnit:{min:0,max:"1",type:[{code:"code"}]},dayOfWeek:{min:0,max:"*",type:[{code:"code"}]},timeOfDay:{min:0,max:"*",type:[{code:"time"}]},when:{min:0,max:"*",type:[{code:"code"}]},offset:{min:0,max:"1",type:[{code:"unsignedInt"}]}},parentType:"Timing"},TriggerDefinition:{display:"TriggerDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:0,max:"1",type:[{code:"string"}]},"timing[x]":{min:0,max:"1",type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{min:0,max:"*",type:[{code:"DataRequirement"}]},condition:{min:0,max:"1",type:[{code:"Expression"}]}}},UsageContext:{display:"UsageContext",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"Coding"}]},"value[x]":{min:1,max:"1",type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}}}};function ie(e){var t;if(!e.name)return;const i=null===(t=e.snapshot)||void 0===t?void 0:t.element;i&&(i.forEach((t=>function(e,t){var i,n;const o=t.path,r=null===(n=null===(i=t.type)||void 0===i?void 0:i[0])||void 0===n?void 0:n.code;if(void 0!==r&&"Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=oe(a);ae.types[s]=function(e,t,i){return{structureDefinition:t,elementDefinition:i,display:e,description:i.definition,properties:{}}}(s,e,t),ae.types[s].parentType=oe(a.slice(0,a.length-1))}(e,t))),i.forEach((e=>function(e){const t=e.path.split(".");if(1===t.length)return;const i=oe(t.slice(0,t.length-1)),n=ae.types[i];if(!n)return;const o=t[t.length-1];n.properties[o]=e}(e))))}function ne(e){if(e.base)for(const t of e.base){const i=ae.types[t];i&&(i.searchParams||(i.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"}}),i.searchParams[e.code]=e)}}function oe(e){return 1===e.length?e[0]:e.map(I).join("")}function re(e,t){var i;const n=ae.types[e];if(!n)return;const o=null!==(i=n.properties[t])&&void 0!==i?i:n.properties[t+"[x]"];if(o){if(o.contentReference){const e=o.contentReference.substring(1).split("."),t=e.pop();return re(oe(e),t)}return o}}e.PropertyType=void 0,(ee=e.PropertyType||(e.PropertyType={})).Address="Address",ee.Age="Age",ee.Annotation="Annotation",ee.Attachment="Attachment",ee.BackboneElement="BackboneElement",ee.CodeableConcept="CodeableConcept",ee.Coding="Coding",ee.ContactDetail="ContactDetail",ee.ContactPoint="ContactPoint",ee.Contributor="Contributor",ee.Count="Count",ee.DataRequirement="DataRequirement",ee.Distance="Distance",ee.Dosage="Dosage",ee.Duration="Duration",ee.Expression="Expression",ee.Extension="Extension",ee.HumanName="HumanName",ee.Identifier="Identifier",ee.MarketingStatus="MarketingStatus",ee.Meta="Meta",ee.Money="Money",ee.Narrative="Narrative",ee.ParameterDefinition="ParameterDefinition",ee.Period="Period",ee.Population="Population",ee.ProdCharacteristic="ProdCharacteristic",ee.ProductShelfLife="ProductShelfLife",ee.Quantity="Quantity",ee.Range="Range",ee.Ratio="Ratio",ee.Reference="Reference",ee.RelatedArtifact="RelatedArtifact",ee.SampledData="SampledData",ee.Signature="Signature",ee.SubstanceAmount="SubstanceAmount",ee.SystemString="http://hl7.org/fhirpath/System.String",ee.Timing="Timing",ee.TriggerDefinition="TriggerDefinition",ee.UsageContext="UsageContext",ee.base64Binary="base64Binary",ee.boolean="boolean",ee.canonical="canonical",ee.code="code",ee.date="date",ee.dateTime="dateTime",ee.decimal="decimal",ee.id="id",ee.instant="instant",ee.integer="integer",ee.markdown="markdown",ee.oid="oid",ee.positiveInt="positiveInt",ee.string="string",ee.time="time",ee.unsignedInt="unsignedInt",ee.uri="uri",ee.url="url",ee.uuid="uuid";const ae=te;var se,ce,de,le,ue,me,pe,he,fe,ye,ge,ve,xe,Te,Ee,we,Se,be,De,Pe,Ce,Ae,Re,Oe,ke,Ie,Me,Ue,Le,Ne,je,_e,Qe;const Be="launch/patient openid fhirUser offline_access user/*.*";function We(){return window.location.protocol+"//"+window.location.host+"/"}function qe(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch(t){return e}}function Fe(t){return[{type:e.PropertyType.boolean,value:t}]}function He(t){return null==t?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:e.PropertyType.integer,value:t}:"number"==typeof t?{type:e.PropertyType.decimal,value:t}:"boolean"==typeof t?{type:e.PropertyType.boolean,value:t}:"string"==typeof t?{type:e.PropertyType.string,value:t}:nt(t)?{type:e.PropertyType.Quantity,value:t}:"object"==typeof t&&"resourceType"in t?{type:t.resourceType,value:t}:{type:e.PropertyType.BackboneElement,value:t}}function $e(e){return 0!==e.length&&!!e[0].value}function ze(t,i){if(!(null==t?void 0:t.value))return;const n=re(t.type,i);if(n){const e=function(e,t,i){var n;const o=i.type;if(!o||0===o.length)return;let r,a="undefined";if(1===o.length)r=e.value[t],a=o[0].code;else for(const i of o){const n=t.replace("[x]","")+I(i.code);if(n in e.value){r=e.value[n],a=i.code;break}}if(D(r))return;"Element"!==a&&"BackboneElement"!==a||(a=oe(null===(n=i.path)||void 0===n?void 0:n.split(".")));return Array.isArray(r)?r.map((e=>Ge(e,a))):Ge(r,a)}(t,i,n);if(e)return e}return function(t,i){const n=t.value;if(!n||"object"!=typeof n)return;let o;if(i in n)o=n[i];else for(const t in e.PropertyType){const e=i+I(t);if(e in n){o=n[e];break}}if(D(o))return;return Array.isArray(o)?o.map(He):He(o)}(t,i)}function Ge(e,t){return"Resource"===t&&"object"==typeof e&&"resourceType"in e&&(t=e.resourceType),{type:t,value:e}}function Ve(e){const t=[];for(const i of e){let e=!1;for(const n of t)if($e(Je(i,n))){e=!0;break}e||t.push(i)}return t}function Xe(e){return Fe(!$e(e))}function Ye(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?Fe(!1):Fe(e.every(((e,i)=>$e(Je(e,t[i])))))}function Je(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Fe(Math.abs(i-n)<1e-8):nt(i)&&nt(n)?Fe(ot(i,n)):Fe("object"==typeof i&&"object"==typeof n?rt(e,t):i===n)}function Ke(e,t){return 0===e.length&&0===t.length?Fe(!0):e.length!==t.length?Fe(!1):(e.sort(et),t.sort(et),Fe(e.every(((e,i)=>$e(Ze(e,t[i]))))))}function Ze(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?Fe(Math.abs(i-n)<.01):nt(i)&&nt(n)?Fe(ot(i,n)):Fe("object"==typeof i&&"object"==typeof n?rt(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function et(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?i-n:"string"==typeof i&&"string"==typeof n?i.localeCompare(n):0}function tt(e,t){const{value:i}=e;if(null==i)return!1;switch(t){case"Boolean":return"boolean"==typeof i;case"Decimal":case"Integer":return"number"==typeof i;case"Date":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof i&&!!i.match(/^T\d/);case"Period":return it(i);case"Quantity":return nt(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function it(e){return!(!e||"object"!=typeof e||!("start"in e))}function nt(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function ot(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function rt(e,t){const i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(const n of i){const i=e[n],o=t[n];if(at(i)&&at(o)){if(!rt(i,o))return!1}else if(i!==o)return!1}return!0}function at(e){return null!==e&&"object"==typeof e}ce=new WeakMap,de=new WeakMap,le=new WeakMap,ue=new WeakMap,me=new WeakMap,pe=new WeakMap,he=new WeakMap,fe=new WeakMap,ye=new WeakMap,ge=new WeakMap,ve=new WeakMap,xe=new WeakMap,Te=new WeakMap,Ee=new WeakMap,we=new WeakMap,Se=new WeakMap,be=new WeakMap,se=new WeakSet,De=function(e){const t=this.getLogins().filter((t=>{var i,n;return(null===(i=t.profile)||void 0===i?void 0:i.reference)!==(null===(n=e.profile)||void 0===n?void 0:n.reference)}));t.push(e),i(this,le,"f").setObject("logins",t)},Pe=function(){return t(this,void 0,void 0,(function*(){return n(this,we,new Promise(((e,t)=>{this.get("auth/me").then((t=>{n(this,we,void 0,"f"),n(this,Se,t.profile,"f"),n(this,be,t.config,"f"),this.dispatchEvent({type:"change"}),e(i(this,Se,"f"))})).catch(t)})),"f"),i(this,we,"f")}))},Ce=function(e,t){if(i(this,me,"f")<=0||"no-cache"===(null==t?void 0:t.cache)||"reload"===(null==t?void 0:t.cache))return;const n=i(this,ue,"f").get(e);return!n||n.requestTime+i(this,me,"f")<Date.now()?void 0:n},Ae=function(e,t){i(this,me,"f")>0&&i(this,ue,"f").set(e,{requestTime:Date.now(),value:t})},Re=function(e,n,o={}){return t(this,void 0,void 0,(function*(){i(this,Ee,"f")&&(yield i(this,Ee,"f")),n.startsWith("http")||(n=i(this,pe,"f")+n),o.method=e,i(this,se,"m",Oe).call(this,o);const t=yield i(this,ce,"f").call(this,n,o);if(401===t.status)return i(this,se,"m",Me).call(this,e,n,o);if(204===t.status||304===t.status)return;const r=yield t.json();if(t.status>=400)throw r;return r}))},Oe=function(e){e.headers||(e.headers={});const t=e.headers;t["X-Medplum"]="extended",t["Content-Type"]||(t["Content-Type"]="application/fhir+json"),i(this,xe,"f")&&(t.Authorization="Bearer "+i(this,xe,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},ke=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},Ie=function(e,t){"string"==typeof t||"undefined"!=typeof Blob&&t instanceof Blob||"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Uint8Array&&t instanceof Uint8Array?e.body=t:t&&(e.body=JSON.stringify(t))},Me=function(e,n,o){return t(this,void 0,void 0,(function*(){return i(this,se,"m",Ne).call(this).then((()=>i(this,se,"m",Re).call(this,e,n,o))).catch((e=>(this.clear(),i(this,ve,"f")&&i(this,ve,"f").call(this),Promise.reject(e))))}))},Ue=function(){return t(this,void 0,void 0,(function*(){const e=B();i(this,le,"f").setString("pkceState",e);const n=B();i(this,le,"f").setString("codeVerifier",n);const o=k(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");i(this,le,"f").setString("codeChallenge",o)}))},Le=function(){return t(this,void 0,void 0,(function*(){yield i(this,se,"m",Ue).call(this);const e=new URL(i(this,fe,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",i(this,le,"f").getString("pkceState")),e.searchParams.set("client_id",i(this,he,"f")),e.searchParams.set("redirect_uri",We()),e.searchParams.set("scope",Be),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",i(this,le,"f").getString("codeChallenge")),window.location.assign(e.toString())}))},Ne=function(){return t(this,void 0,void 0,(function*(){if(i(this,Ee,"f"))return i(this,Ee,"f");if(!i(this,Te,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",i(this,he,"f")),e.set("refresh_token",i(this,Te,"f")),n(this,Ee,i(this,se,"m",je).call(this,e),"f"),yield i(this,Ee,"f")}))},je=function(e){return t(this,void 0,void 0,(function*(){return i(this,ce,"f").call(this,i(this,ye,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>i(this,se,"m",_e).call(this,e))).then((()=>this.getProfile()))}))},_e=function(e){return t(this,void 0,void 0,(function*(){const t=e.access_token,n=Y(t);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(i(this,he,"f")&&n.client_id!==i(this,he,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}))},Qe=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};const st=()=>[],ct={empty:e=>Fe(0===e.length),exists:(e,t)=>Fe(t?e.filter((e=>$e(t.eval([e])))).length>0:e.length>0),all:(e,t)=>Fe(e.every((e=>$e(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return Fe(!1);return Fe(!0)},anyTrue:e=>{for(const t of e)if(t.value)return Fe(!0);return Fe(!1)},allFalse:e=>{for(const t of e)if(t.value)return Fe(!1);return Fe(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return Fe(!0);return Fe(!1)},subsetOf:st,supersetOf:st,count:t=>[{type:e.PropertyType.integer,value:t.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>Fe(e.length===ct.distinct(e).length),where:(e,t)=>e.filter((e=>$e(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:st,ofType:(e,t)=>e.filter((e=>e.type===t.name)),single:e=>{if(e.length>1)throw new Error("Expected input length one for single()");return 0===e.length?[]:e.slice(0,1)},first:e=>0===e.length?[]:e.slice(0,1),last:e=>0===e.length?[]:e.slice(e.length-1,e.length),tail:e=>0===e.length?[]:e.slice(1,e.length),skip:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for skip(num)");return n>=e.length?[]:n<=0?e:e.slice(n,e.length)},take:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for take(num)");return n>=e.length?e:n<=0?[]:e.slice(0,n)},intersect:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)!n.some((e=>e.value===t.value))&&i.some((e=>e.value===t.value))&&n.push(t);return n},exclude:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)i.some((e=>e.value===t.value))||n.push(t);return n},union:(e,t)=>{if(!t)return e;const i=t.eval(e);return Ve([...e,...i])},combine:(e,t)=>{if(!t)return e;const i=t.eval(e);return[...e,...i]},iif:(e,t,i,n)=>{const o=t.eval(e);if(o.length>1||1===o.length&&"boolean"!=typeof o[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return $e(o)?i.eval(e):n?n.eval(e):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);if("boolean"==typeof i)return[{type:e.PropertyType.boolean,value:i}];if("number"==typeof i&&(0===i||1===i))return Fe(!!i);if("string"==typeof i){const e=i.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return Fe(!0);if(["false","f","no","n","0","0.0"].includes(e))return Fe(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:Fe(1===ct.toBoolean(e).length),toInteger:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);return"number"==typeof i?[{type:e.PropertyType.integer,value:i}]:"string"==typeof i&&i.match(/^[+-]?\d+$/)?[{type:e.PropertyType.integer,value:parseInt(i,10)}]:"boolean"==typeof i?[{type:e.PropertyType.integer,value:i?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:Fe(1===ct.toInteger(e).length),toDate:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.date,value:qe(i)}]:[]},convertsToDate:e=>0===e.length?[]:Fe(1===ct.toDate(e).length),toDateTime:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.dateTime,value:qe(i)}]:[]},convertsToDateTime:e=>0===e.length?[]:Fe(1===ct.toDateTime(e).length),toDecimal:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);return"number"==typeof i?[{type:e.PropertyType.decimal,value:i}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:e.PropertyType.decimal,value:parseFloat(i)}]:"boolean"==typeof i?[{type:e.PropertyType.decimal,value:i?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:Fe(1===ct.toDecimal(e).length),toQuantity:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);return nt(i)?[{type:e.PropertyType.Quantity,value:i}]:"number"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i,unit:"1"}}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:e.PropertyType.Quantity,value:{value:parseFloat(i),unit:"1"}}]:"boolean"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:Fe(1===ct.toQuantity(e).length),toString:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);return null==i?[]:nt(i)?[{type:e.PropertyType.string,value:`${i.value} '${i.unit}'`}]:[{type:e.PropertyType.string,value:i.toString()}]},convertsToString:e=>0===e.length?[]:Fe(1===ct.toString(e).length),toTime:t=>{if(0===t.length)return[];const[{value:i}]=ut(t,1);if("string"==typeof i){const t=i.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:e.PropertyType.time,value:qe("T"+t[1])}]}return[]},convertsToTime:e=>0===e.length?[]:Fe(1===ct.toTime(e).length),indexOf:(e,t)=>dt(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>dt(((e,t,i)=>{const n=t,o=i?n+i:e.length;return n<0||n>=e.length?void 0:e.substring(n,o)}),e,t,i),startsWith:(e,t)=>dt(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>dt(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>dt(((e,t)=>e.includes(t)),e,t),upper:e=>dt((e=>e.toUpperCase()),e),lower:e=>dt((e=>e.toLowerCase()),e),replace:(e,t,i)=>dt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>dt(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>dt(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>dt((e=>e.length),e),toChars:e=>dt((e=>e?e.split(""):void 0),e),abs:e=>lt(Math.abs,e),ceiling:e=>lt(Math.ceil,e),exp:e=>lt(Math.exp,e),floor:e=>lt(Math.floor,e),ln:e=>lt(Math.log,e),log:(e,t)=>lt(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>lt(Math.pow,e,t),round:e=>lt(Math.round,e),sqrt:e=>lt(Math.sqrt,e),truncate:e=>lt((e=>0|e),e),children:st,descendants:st,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:e.PropertyType.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:e.PropertyType.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:e.PropertyType.date,value:(new Date).toISOString().substring(0,10)}],between:(t,i,n,o)=>{var r;const a=ct.toDateTime(i.eval(t));if(0===a.length)throw new Error("Invalid start date");const s=ct.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const c=null===(r=o.eval(t)[0])||void 0===r?void 0:r.value;if("years"!==c&&"months"!==c&&"days"!==c)throw new Error("Invalid units");const d=E(a[0].value,s[0].value);return[{type:e.PropertyType.Quantity,value:{value:d[c],unit:c}}]},is:(t,i)=>{let n="";return i instanceof Ut?n=i.name:i instanceof qt&&(n=i.left.name+"."+i.right.name),n?t.map((t=>({type:e.PropertyType.boolean,value:tt(t,n)}))):[]},not:t=>ct.toBoolean(t).map((t=>({type:e.PropertyType.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const i=t.value;let n;if("string"==typeof i)n=i;else if("object"==typeof i){const e=i;if(e.resource)return He(e.resource);n=e.reference}if(!n)return{type:e.PropertyType.BackboneElement,value:null};const[o,r]=n.split("/");return{type:e.PropertyType.BackboneElement,value:{resourceType:o,id:r}}})).filter((e=>!!e.value)),as:e=>e,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:e.PropertyType.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:e.PropertyType.BackboneElement,value:null})),conformsTo:(t,i)=>{const n=i.eval(t)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var i;return{type:e.PropertyType.boolean,value:(null===(i=t.value)||void 0===i?void 0:i.resourceType)===o}}))}};function dt(e,t,...i){if(0===t.length)return[];const[{value:n}]=ut(t,1);if("string"!=typeof n)throw new Error("String function cannot be called with non-string");const o=e(n,...i.map((e=>{var i,n;return e&&(null===(n=null===(i=e.eval(t))||void 0===i?void 0:i[0])||void 0===n?void 0:n.value)})));return void 0===o?[]:Array.isArray(o)?o.map(He):[He(o)]}function lt(t,i,...n){if(0===i.length)return[];const[{value:o}]=ut(i,1),r=nt(o),a=r?o.value:o;if("number"!=typeof a)throw new Error("Math function cannot be called with non-number");const s=t(a,...n.map((e=>{var t,n;return null===(n=null===(t=e.eval(i))||void 0===t?void 0:t[0])||void 0===n?void 0:n.value})));return[{type:r?e.PropertyType.Quantity:i[0].type,value:r?Object.assign(Object.assign({},o),{value:s}):s}]}function ut(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const t of e)if(null==t)throw new Error("Expected non-null argument");return e}var mt,pt,ht,ft,yt,gt,vt,xt,Tt,Et,wt,St,bt,Dt,Pt,Ct,At,Rt,Ot,kt;class It{constructor(e,t){this.original=e,this.child=t}eval(e){try{return e.length>0?e.map((e=>this.child.eval([e]))).flat():this.child.eval([])}catch(e){throw new Error(`FhirPathError on "${this.original}": ${e}`)}}}class Mt{constructor(e){this.value=e}eval(){return[this.value]}}class Ut{constructor(e){this.name=e,mt.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>i(this,mt,"m",pt).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}mt=new WeakSet,pt=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:ze(e,this.name)};class Lt{eval(){return[]}}class Nt{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class jt{constructor(e,t){this.left=e,this.right=t}eval(e){return ct.ofType(this.left.eval(e),this.right)}}class _t{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(t){const i=this.left.eval(t);if(1!==i.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const o=i[0].value,r=n[0].value,a=nt(o)?o.value:o,s=nt(r)?r.value:r,c=this.impl(a,s);return"boolean"==typeof c?Fe(c):nt(o)?[{type:e.PropertyType.Quantity,value:Object.assign(Object.assign({},o),{value:c})}]:[He(c)]}}class Qt{constructor(e,t){this.left=e,this.right=t}eval(t){const i=[...this.left.eval(t),...this.right.eval(t)];return i.length>0&&i.every((e=>"string"==typeof e.value))?[{type:e.PropertyType.string,value:i.map((e=>e.value)).join("")}]:i}}class Bt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return Fe(t.some((e=>e.value===i[0].value)))}}class Wt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);return Fe(this.right.eval(e).some((e=>e.value===t[0].value)))}}class qt{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class Ft{constructor(e,t){this.left=e,this.right=t}eval(e){return Ve([...this.left.eval(e),...this.right.eval(e)])}}class Ht{constructor(e,t){this.left=e,this.right=t}eval(e){return Ye(this.left.eval(e),this.right.eval(e))}}class $t{constructor(e,t){this.left=e,this.right=t}eval(e){return Xe(Ye(this.left.eval(e),this.right.eval(e)))}}class zt{constructor(e,t){this.left=e,this.right=t}eval(e){return Ke(this.left.eval(e),this.right.eval(e))}}class Gt{constructor(e,t){this.left=e,this.right=t}eval(e){return Xe(Ke(this.left.eval(e),this.right.eval(e)))}}class Vt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const i=this.right.name;return Fe(tt(t[0],i))}}class Xt{constructor(e,t){this.left=e,this.right=t}eval(e){var t,i,n,o;const r=this.left.eval(e),a=this.right.eval(e);return!0===(null===(t=r[0])||void 0===t?void 0:t.value)&&!0===(null===(i=a[0])||void 0===i?void 0:i.value)?Fe(!0):!1===(null===(n=r[0])||void 0===n?void 0:n.value)||!1===(null===(o=a[0])||void 0===o?void 0:o.value)?Fe(!1):[]}}class Yt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if($e(t))return t;const i=this.right.eval(e);return $e(i)?i:[]}}class Jt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);if(0===t.length&&0===i.length)return[];const n=0===t.length?null:t[0].value,o=0===i.length?null:i[0].value;return!0===n&&!0!==o||!0!==n&&!0===o?Fe(!0):!0===n&&!0===o||!1===n&&!1===o?Fe(!1):[]}}class Kt{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class Zt{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const i=t[0].value;if("number"!=typeof i)throw new Error("Invalid indexer expression: should return integer}");const n=this.left.eval(e);return i in n?[n[i]]:[]}}function ei(e){return new ni(e).tokenize()}const ti=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],ii=["!=","!~","<=",">=","{}"];class ni{constructor(e){ht.add(this),ft.set(this,void 0),yt.set(this,void 0),n(this,ft,e,"f"),n(this,yt,0,"f")}tokenize(){const e=[];for(;i(this,yt,"f")<i(this,ft,"f").length;){const t=i(this,ht,"m",vt).call(this);t&&e.push(t)}return e}}function oi(e,t){return{id:e,value:t}}var ri,ai,si,ci,di,li,ui,mi,pi;ft=new WeakMap,yt=new WeakMap,ht=new WeakSet,gt=function(){const e=i(this,yt,"f"),t=i(this,ht,"m",vt).call(this);return n(this,yt,e,"f"),t},vt=function(){i(this,ht,"m",xt).call(this);const e=i(this,ht,"m",Rt).call(this);if(!e)return;const t=i(this,ht,"m",kt).call(this);return"/"===e&&"*"===t?i(this,ht,"m",Tt).call(this):"/"===e&&"/"===t?i(this,ht,"m",Et).call(this):"'"===e?i(this,ht,"m",wt).call(this):"`"===e?i(this,ht,"m",St).call(this):"@"===e?i(this,ht,"m",bt).call(this):e.match(/\d/)?i(this,ht,"m",Dt).call(this):e.match(/\w/)||"$"===e&&t.match(/\w/)?i(this,ht,"m",Pt).call(this):i(this,ht,"m",Ct).call(this)},xt=function(){return oi("Whitespace",i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/\s/))))},Tt=function(){const e=i(this,yt,"f");return i(this,ht,"m",At).call(this,(()=>"*"!==i(this,ht,"m",Rt).call(this)||"/"!==i(this,ht,"m",kt).call(this))),n(this,yt,i(this,yt,"f")+2,"f"),oi("Comment",i(this,ft,"f").substring(e,i(this,yt,"f")))},Et=function(){return oi("Comment",i(this,ht,"m",At).call(this,(()=>"\n"!==i(this,ht,"m",Rt).call(this))))},wt=function(){var e,t;n(this,yt,(e=i(this,yt,"f"),++e),"f");const o=oi("String",i(this,ht,"m",At).call(this,(()=>"\\"===i(this,ht,"m",Ot).call(this)||"'"!==i(this,ht,"m",Rt).call(this))));return n(this,yt,(t=i(this,yt,"f"),++t),"f"),o},St=function(){var e,t;n(this,yt,(e=i(this,yt,"f"),++e),"f");const o=oi("Symbol",i(this,ht,"m",At).call(this,(()=>"`"!==i(this,ht,"m",Rt).call(this))));return n(this,yt,(t=i(this,yt,"f"),++t),"f"),o},bt=function(){var e,t,o,r,a;const s=i(this,yt,"f");return n(this,yt,(e=i(this,yt,"f"),++e),"f"),i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/[\d-]/))),"T"===i(this,ht,"m",Rt).call(this)&&(n(this,yt,(t=i(this,yt,"f"),++t),"f"),i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/[\d:]/))),"."===i(this,ht,"m",Rt).call(this)&&i(this,ht,"m",kt).call(this).match(/\d/)&&(n(this,yt,(o=i(this,yt,"f"),++o),"f"),i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/[\d]/)))),"Z"===i(this,ht,"m",Rt).call(this)?n(this,yt,(r=i(this,yt,"f"),++r),"f"):"+"!==i(this,ht,"m",Rt).call(this)&&"-"!==i(this,ht,"m",Rt).call(this)||(n(this,yt,(a=i(this,yt,"f"),++a),"f"),i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/[\d:]/))))),oi("DateTime",i(this,ft,"f").substring(s+1,i(this,yt,"f")))},Dt=function(){var e;const t=i(this,yt,"f");let o="Number";return i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/\d/))),"."===i(this,ht,"m",Rt).call(this)&&i(this,ht,"m",kt).call(this).match(/\d/)&&(n(this,yt,(e=i(this,yt,"f"),++e),"f"),i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/\d/))))," "===i(this,ht,"m",Rt).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&ti.includes(e.value))return!0}return!1}(i(this,ht,"m",gt).call(this))&&(o="Quantity",i(this,ht,"m",vt).call(this)),oi(o,i(this,ft,"f").substring(t,i(this,yt,"f")))},Pt=function(){return oi("Symbol",i(this,ht,"m",At).call(this,(()=>i(this,ht,"m",Rt).call(this).match(/[$\w]/))))},Ct=function(){var e;const t=i(this,ht,"m",Rt).call(this),o=t+i(this,ht,"m",kt).call(this);return ii.includes(o)?(n(this,yt,i(this,yt,"f")+2,"f"),oi(o,o)):(n(this,yt,(e=i(this,yt,"f"),++e),"f"),oi(t,t))},At=function(e){var t;const o=i(this,yt,"f");for(;i(this,yt,"f")<i(this,ft,"f").length&&e();)n(this,yt,(t=i(this,yt,"f"),++t),"f");return i(this,ft,"f").substring(o,i(this,yt,"f"))},Rt=function(){return i(this,ft,"f")[i(this,yt,"f")]},Ot=function(){var e;return null!==(e=i(this,ft,"f")[i(this,yt,"f")-1])&&void 0!==e?e:""},kt=function(){var e;return null!==(e=i(this,ft,"f")[i(this,yt,"f")+1])&&void 0!==e?e:""};ri=new WeakMap,ai=new WeakMap;class hi{constructor(e,t,i){si.add(this),ci.set(this,void 0),di.set(this,void 0),li.set(this,void 0),n(this,ci,e,"f"),n(this,di,t,"f"),n(this,li,i,"f")}match(e){const t=i(this,si,"m",pi).call(this);return(null==t?void 0:t.id)===e&&(i(this,si,"m",mi).call(this),!0)}consumeAndParse(e=100){const t=i(this,si,"m",mi).call(this),n=i(this,di,"f")[t.id];if(!n)throw Error(`Parse error at ${t.value}. No matching prefix parselet.`);let o=n.parse(this,t);for(;e>i(this,si,"m",ui).call(this);){const e=i(this,si,"m",mi).call(this);o=i(this,li,"f")[e.id].parse(this,o,e)}return o}}ci=new WeakMap,di=new WeakMap,li=new WeakMap,si=new WeakSet,ui=function(){const e=i(this,si,"m",pi).call(this);if(!e)return 100;const t=i(this,li,"f")[e.id];return t?t.precedence:100},mi=function(){if(!i(this,ci,"f").length)throw Error("Cant consume unknown more tokens.");return i(this,ci,"f").shift()},pi=function(){return i(this,ci,"f").length>0?i(this,ci,"f")[0]:void 0};const fi={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},yi={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Zt(t,i)},precedence:2},gi={parse(e,t){if(!(t instanceof Ut))throw new Error("Unexpected parentheses");if(!(t.name in ct))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new Kt(t.name,i,ct[t.name])},precedence:0};function vi(e){const t=e.split(" "),i=parseFloat(t[0]);let n=t[1];return n=n&&n.startsWith("'")&&n.endsWith("'")?n.substring(1,n.length-1):"{"+n+"}",{value:i,unit:n}}const xi=(new class{constructor(){ri.set(this,{}),ai.set(this,{})}registerInfix(e,t){return i(this,ai,"f")[e]=t,this}registerPrefix(e,t){return i(this,ri,"f")[e]=t,this}prefix(e,t,i){return this.registerPrefix(e,{parse(e,n){const o=e.consumeAndParse(t);return i(n,o)}})}infixLeft(e,t,i){return this.registerInfix(e,{parse(e,n,o){const r=e.consumeAndParse(t);return i(n,o,r)},precedence:t})}construct(e){return new hi(ei(e),i(this,ri,"f"),i(this,ai,"f"))}}).registerPrefix("String",{parse:(t,i)=>new Mt({type:e.PropertyType.string,value:i.value})}).registerPrefix("DateTime",{parse:(t,i)=>new Mt({type:e.PropertyType.dateTime,value:qe(i.value)})}).registerPrefix("Quantity",{parse:(t,i)=>new Mt({type:e.PropertyType.Quantity,value:vi(i.value)})}).registerPrefix("Number",{parse:(t,i)=>new Mt({type:e.PropertyType.decimal,value:parseFloat(i.value)})}).registerPrefix("Symbol",{parse:(t,i)=>"false"===i.value?new Mt({type:e.PropertyType.boolean,value:!1}):"true"===i.value?new Mt({type:e.PropertyType.boolean,value:!0}):new Ut(i.value)}).registerPrefix("{}",{parse:()=>new Lt}).registerPrefix("(",fi).registerInfix("[",yi).registerInfix("(",gi).prefix("+",3,((e,t)=>new Nt(t,(e=>e)))).prefix("-",3,((e,t)=>new _t(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new qt(e,i))).infixLeft("/",4,((e,t,i)=>new _t(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new _t(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new _t(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new _t(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new Ft(e,i))).infixLeft("=",9,((e,t,i)=>new Ht(e,i))).infixLeft("!=",9,((e,t,i)=>new $t(e,i))).infixLeft("~",9,((e,t,i)=>new zt(e,i))).infixLeft("!~",9,((e,t,i)=>new Gt(e,i))).infixLeft("<",8,((e,t,i)=>new _t(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new _t(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new _t(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new _t(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new Qt(e,i))).infixLeft("Symbol",6,((e,t,i)=>{switch(t.value){case"and":return new Xt(e,i);case"as":return new jt(e,i);case"contains":return new Bt(e,i);case"div":return new _t(e,i,((e,t)=>e/t|0));case"in":return new Wt(e,i);case"is":return new Vt(e,i);case"mod":return new _t(e,i,((e,t)=>e%t));case"or":return new Yt(e,i);case"xor":return new Jt(e,i);default:throw new Error("Cannot use "+t.value+" as infix operator")}}));function Ti(e){try{return new It(e,xi.construct(e).consumeAndParse())}catch(t){throw new Error(`FhirPathError on "${e}": ${t}`)}}function Ei(e,t){return Ti(e).eval(t)}class wi{constructor(e){this.segments=e}get(e){return"number"==typeof e?this.segments[e]:this.segments.find((t=>t.name===e))}getAll(e){return this.segments.filter((t=>t.name===e))}toString(){return this.segments.map((e=>e.toString())).join("\r")}buildAck(){var e,t,i,n,o,r;const a=new Date,s=this.get("MSH"),c=(null===(e=null==s?void 0:s.get(2))||void 0===e?void 0:e.toString())||"",d=(null===(t=null==s?void 0:s.get(3))||void 0===t?void 0:t.toString())||"",l=(null===(i=null==s?void 0:s.get(4))||void 0===i?void 0:i.toString())||"",u=(null===(n=null==s?void 0:s.get(5))||void 0===n?void 0:n.toString())||"",m=(null===(o=null==s?void 0:s.get(9))||void 0===o?void 0:o.toString())||"",p=(null===(r=null==s?void 0:s.get(12))||void 0===r?void 0:r.toString())||"2.5.1";return new wi([new Si(["MSH","^~\\&",l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p]),new Si(["MSA","AA",m,"OK"])])}static parse(e){if(!e.startsWith("MSH|^~\\&")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}return new wi(e.split(/[\r\n]+/).map((e=>Si.parse(e))))}}class Si{constructor(e){A(e)?this.fields=e.map((e=>bi.parse(e))):this.fields=e,this.name=this.fields[0].components[0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join("|")}static parse(e){return new Si(e.split("|").map((e=>bi.parse(e))))}}class bi{constructor(e){this.components=e}get(e){return this.components[e]}toString(){return this.components.join("^")}static parse(e){return new bi(e.split("^"))}}const Di="ok",Pi="created",Ci="gone",Ai="not-modified",Ri="not-found",Oi="unauthorized",ki="forbidden",Ii="too-many-requests",Mi={resourceType:"OperationOutcome",id:Di,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},Ui={resourceType:"OperationOutcome",id:Pi,issue:[{severity:"information",code:"informational",details:{text:"Created"}}]},Li={resourceType:"OperationOutcome",id:Ai,issue:[{severity:"information",code:"informational",details:{text:"Not Modified"}}]},Ni={resourceType:"OperationOutcome",id:Ri,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},ji={resourceType:"OperationOutcome",id:Oi,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},_i={resourceType:"OperationOutcome",id:ki,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]},Qi={resourceType:"OperationOutcome",id:Ci,issue:[{severity:"error",code:"gone",details:{text:"Gone"}}]},Bi={resourceType:"OperationOutcome",id:Ii,issue:[{severity:"error",code:"throttled",details:{text:"Too Many Requests"}}]};function Wi(e){return e.id===Di||e.id===Pi||e.id===Ai}class qi extends Error{constructor(e){var t,i;super(null===(i=null===(t=null==e?void 0:e.issue)||void 0===t?void 0:t[0].details)||void 0===i?void 0:i.text),this.outcome=e}}var Fi;e.Operator=void 0,(Fi=e.Operator||(e.Operator={})).EQUALS="eq",Fi.NOT_EQUALS="ne",Fi.GREATER_THAN="gt",Fi.LESS_THAN="lt",Fi.GREATER_THAN_OR_EQUALS="ge",Fi.LESS_THAN_OR_EQUALS="le",Fi.STARTS_AFTER="sa",Fi.ENDS_BEFORE="eb",Fi.APPROXIMATELY="ap",Fi.CONTAINS="contains",Fi.EXACT="exact",Fi.TEXT="text",Fi.NOT="not",Fi.ABOVE="above",Fi.BELOW="below",Fi.IN="in",Fi.NOT_IN="not-in",Fi.OF_TYPE="of-type",Fi.MISSING="missing";const Hi=[e.Operator.CONTAINS,e.Operator.EXACT,e.Operator.TEXT,e.Operator.NOT,e.Operator.ABOVE,e.Operator.BELOW,e.Operator.IN,e.Operator.NOT_IN,e.Operator.OF_TYPE,e.Operator.MISSING],$i=[e.Operator.NOT_EQUALS,e.Operator.GREATER_THAN,e.Operator.LESS_THAN,e.Operator.GREATER_THAN_OR_EQUALS,e.Operator.LESS_THAN_OR_EQUALS,e.Operator.STARTS_AFTER,e.Operator.ENDS_BEFORE,e.Operator.APPROXIMATELY];var zi;function Gi(t,i){let n=e.SearchParameterType.TEXT;switch(t.type){case"date":n=i===e.PropertyType.dateTime||i===e.PropertyType.instant?e.SearchParameterType.DATETIME:e.SearchParameterType.DATE;break;case"number":n=e.SearchParameterType.NUMBER;break;case"quantity":n=e.SearchParameterType.QUANTITY;break;case"reference":n=e.SearchParameterType.REFERENCE;break;case"token":"boolean"===i&&(n=e.SearchParameterType.BOOLEAN)}return n}function Vi(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=Xi(t);if(i.startsWith(e+"."))return i}var n}function Xi(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const i=[" != "," as ",".as(",".exists(",".where("];for(const e of i)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}e.SearchParameterType=void 0,(zi=e.SearchParameterType||(e.SearchParameterType={})).BOOLEAN="BOOLEAN",zi.NUMBER="NUMBER",zi.QUANTITY="QUANTITY",zi.TEXT="TEXT",zi.REFERENCE="REFERENCE",zi.DATE="DATE",zi.DATETIME="DATETIME",zi.PERIOD="PERIOD",e.AndAtom=Xt,e.ArithemticOperatorAtom=_t,e.AsAtom=jt,e.COMPONENT_SEPARATOR="^",e.ConcatAtom=Qt,e.ContainsAtom=Bt,e.DEFAULT_SEARCH_COUNT=20,e.DotAtom=qt,e.EmptySetAtom=Lt,e.EqualsAtom=Ht,e.EquivalentAtom=zt,e.FIELD_SEPARATOR="|",e.FhirPathAtom=It,e.FunctionAtom=Kt,e.Hl7Field=bi,e.Hl7Message=wi,e.Hl7Segment=Si,e.InAtom=Wt,e.IndexerAtom=Zt,e.IsAtom=Vt,e.LRUCache=c,e.LiteralAtom=Mt,e.MedplumClient=class extends class{constructor(){W.set(this,void 0),n(this,W,{},"f")}addEventListener(e,t){i(this,W,"f")[e]||(i(this,W,"f")[e]=[]),i(this,W,"f")[e].push(t)}removeEventListeneer(e,t){const n=i(this,W,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===t)return void n.splice(e,1)}dispatchEvent(e){const t=i(this,W,"f")[e.type];return t&&t.forEach((t=>t.call(this,e))),!e.defaultPrevented}}{constructor(e){var t,o;if(super(),se.add(this),ce.set(this,void 0),de.set(this,void 0),le.set(this,void 0),ue.set(this,void 0),me.set(this,void 0),pe.set(this,void 0),he.set(this,void 0),fe.set(this,void 0),ye.set(this,void 0),ge.set(this,void 0),ve.set(this,void 0),xe.set(this,void 0),Te.set(this,void 0),Ee.set(this,void 0),we.set(this,void 0),Se.set(this,void 0),be.set(this,void 0),(null==e?void 0:e.baseUrl)&&!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");n(this,ce,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),n(this,de,null==e?void 0:e.createPdf,"f"),n(this,le,new K,"f"),n(this,ue,new c(null!==(t=null==e?void 0:e.resourceCacheSize)&&void 0!==t?t:1e3),"f"),n(this,me,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:6e4,"f"),n(this,pe,function(e){if(!e)return e;return e.endsWith("/")?e:e+"/"}(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),n(this,he,(null==e?void 0:e.clientId)||"","f"),n(this,fe,(null==e?void 0:e.authorizeUrl)||i(this,pe,"f")+"oauth2/authorize","f"),n(this,ye,(null==e?void 0:e.tokenUrl)||i(this,pe,"f")+"oauth2/token","f"),n(this,ge,(null==e?void 0:e.logoutUrl)||i(this,pe,"f")+"oauth2/logout","f"),n(this,ve,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,xe,r.accessToken,"f"),n(this,Te,r.refreshToken,"f"),i(this,se,"m",Pe).call(this).catch(console.log)),i(this,se,"m",Qe).call(this)}getBaseUrl(){return i(this,pe,"f")}clear(){i(this,le,"f").clear(),i(this,ue,"f").clear(),n(this,xe,void 0,"f"),n(this,Te,void 0,"f"),n(this,Se,void 0,"f"),n(this,be,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),i(this,ue,"f").delete(e)}invalidateSearches(e){const t="fhir/R4/"+e;for(const e of i(this,ue,"f").keys())(e.endsWith(t)||e.includes(t+"?"))&&i(this,ue,"f").delete(e)}get(e,t={}){e=e.toString();const n=i(this,se,"m",Ce).call(this,e,t);if(n)return n.value;const o=new J(i(this,se,"m",Re).call(this,"GET",e,t));return i(this,se,"m",Ae).call(this,e,o),o}post(e,t,n,o={}){return e=e.toString(),t&&i(this,se,"m",Ie).call(this,o,t),n&&i(this,se,"m",ke).call(this,o,n),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"POST",e,o)}put(e,t,n,o={}){return e=e.toString(),t&&i(this,se,"m",Ie).call(this,o,t),n&&i(this,se,"m",ke).call(this,o,n),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"PUT",e,o)}patch(e,t,n={}){return e=e.toString(),i(this,se,"m",Ie).call(this,n,t),i(this,se,"m",ke).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"PATCH",e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"DELETE",e,t)}startNewUser(e){return t(this,void 0,void 0,(function*(){return yield i(this,se,"m",Ue).call(this),this.post("auth/newuser",Object.assign(Object.assign({},e),{codeChallengeMethod:"S256",codeChallenge:i(this,le,"f").getString("codeChallenge")}))}))}startNewProject(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newproject",e)}))}startNewPatient(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newpatient",e)}))}startLogin(e){var n,o;return t(this,void 0,void 0,(function*(){return e.codeChallenge&&e.codeChallengeMethod||(yield i(this,se,"m",Ue).call(this)),this.post("auth/login",Object.assign(Object.assign({},e),{clientId:null!==(n=e.clientId)&&void 0!==n?n:i(this,he,"f"),scope:null!==(o=e.scope)&&void 0!==o?o:Be,codeChallengeMethod:e.codeChallengeMethod||"S256",codeChallenge:e.codeChallenge||i(this,le,"f").getString("codeChallenge")}))}))}startGoogleLogin(e){var n,o;return t(this,void 0,void 0,(function*(){return e.codeChallenge&&e.codeChallengeMethod||(yield i(this,se,"m",Ue).call(this)),this.post("auth/google",Object.assign(Object.assign({},e),{clientId:null!==(n=e.clientId)&&void 0!==n?n:i(this,he,"f"),scope:null!==(o=e.scope)&&void 0!==o?o:Be,codeChallengeMethod:e.codeChallengeMethod||"S256",codeChallenge:e.codeChallenge||i(this,le,"f").getString("codeChallenge")}))}))}signOut(){this.clear()}signInWithRedirect(){return t(this,void 0,void 0,(function*(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void(yield i(this,se,"m",Le).call(this))}))}signOutWithRedirect(){window.location.assign(i(this,ge,"f"))}fhirUrl(...e){return new URL(i(this,pe,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const i=this.fhirUrl(e);return t&&(i.search=t.toString()),i}search(e,t,i={}){return this.get(this.fhirSearchUrl(e,t),i)}searchOne(e,t,n={}){const o=this.fhirSearchUrl(e,t);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=i(this,se,"m",Ce).call(this,r,n);if(a)return a.value;const s=new J(this.search(e,o.searchParams,n).then((e=>{var t,i;return null===(i=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===i?void 0:i.resource})));return i(this,se,"m",Ae).call(this,r,s),s}searchResources(e,t,n={}){const o=this.fhirSearchUrl(e,t).toString()+"-searchResources",r=i(this,se,"m",Ce).call(this,o,n);if(r)return r.value;const a=new J(this.search(e,t,n).then((e=>{var t,i;return null!==(i=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==i?i:[]})));return i(this,se,"m",Ae).call(this,o,a),a}searchValueSet(e,t,i={}){const n=this.fhirUrl("ValueSet","$expand");return n.searchParams.set("url",e),n.searchParams.set("filter",t),this.get(n.toString(),i)}getCached(e,t){var n;const o=null===(n=i(this,ue,"f").get(this.fhirUrl(e,t).toString()))||void 0===n?void 0:n.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[i,n]=t.split("/");return i&&n?this.getCached(i,n):void 0}readResource(e,t){return this.get(this.fhirUrl(e,t))}readReference(e){const t=null==e?void 0:e.reference;if(!t)return new J(Promise.reject(new Error("Missing reference")));const[i,n]=t.split("/");return i&&n?this.readResource(i,n):new J(Promise.reject(new Error("Invalid reference")))}getSchema(){return ae}requestSchema(e){return t(this,void 0,void 0,(function*(){if(e in ae.types)return ae;const t=`{\n StructureDefinitionList(name: "${e}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const e of i.data.StructureDefinitionList)ie(e);for(const e of i.data.SearchParameterList)ne(e);return ae}))}readHistory(e,t){return this.get(this.fhirUrl(e,t,"_history"))}readVersion(e,t,i){return this.get(this.fhirUrl(e,t,"_history",i))}readPatientEverything(e){return this.get(this.fhirUrl("Patient",e,"$everything"))}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(e,i){var n;return t(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(e.resourceType,i))&&void 0!==n?n:this.createResource(e)}))}createBinary(e,t,i){const n=this.fhirUrl("Binary");return t&&n.searchParams.set("_filename",t),this.post(n,e,i)}createPdf(e,n,o,r){return t(this,void 0,void 0,(function*(){if(!i(this,de,"f"))throw new Error("PDF creation not enabled");const t=yield i(this,de,"f").call(this,e,o,r);return this.createBinary(t,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=y(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=y(e)),this.createResource({resourceType:"Communication",basedOn:[y(e)],encounter:n,subject:o,sender:i?y(i):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(e){return t(this,void 0,void 0,(function*(){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");this.invalidateSearches(e.resourceType);const t=yield this.put(this.fhirUrl(e.resourceType,e.id),e);return null!=t?t:e}))}patchResource(e,t,i){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),i)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}executeBatch(e){return this.post("fhir/R4",e)}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t,i,n){return this.post(this.fhirUrl("$graphql"),{query:e,operationName:t,variables:i},"application/json",n)}readResourceGraph(e,t,i){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${i}`)}getActiveLogin(){return i(this,le,"f").getObject("activeLogin")}setActiveLogin(e){return t(this,void 0,void 0,(function*(){n(this,xe,e.accessToken,"f"),n(this,Te,e.refreshToken,"f"),n(this,Se,void 0,"f"),n(this,be,void 0,"f"),i(this,le,"f").setObject("activeLogin",e),i(this,se,"m",De).call(this,e),i(this,ue,"f").clear(),n(this,Ee,void 0,"f"),yield i(this,se,"m",Pe).call(this)}))}getAccessToken(){return i(this,xe,"f")}setAccessToken(e){n(this,xe,e,"f"),n(this,Te,void 0,"f"),n(this,Se,void 0,"f"),n(this,be,void 0,"f")}getLogins(){var e;return null!==(e=i(this,le,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!i(this,we,"f")}getProfile(){return i(this,Se,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return i(this,we,"f")&&(yield i(this,we,"f")),this.getProfile()}))}getUserConfiguration(){return i(this,be,"f")}download(e,n={}){return t(this,void 0,void 0,(function*(){i(this,Ee,"f")&&(yield i(this,Ee,"f")),i(this,se,"m",Oe).call(this,n);return(yield i(this,ce,"f").call(this,e.toString(),n)).blob()}))}processCode(e){if(!i(this,le,"f").getString("pkceState"))throw this.clear(),new Error("Invalid PCKE state");const t=i(this,le,"f").getString("codeVerifier");if(!t)throw this.clear(),new Error("Invalid PCKE code verifier");const n=new URLSearchParams;return n.set("grant_type","authorization_code"),n.set("client_id",i(this,he,"f")),n.set("code_verifier",t),n.set("code",e),n.set("redirect_uri",We()),i(this,se,"m",je).call(this,n)}startClientLogin(e,n){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",e),t.set("client_secret",n),i(this,se,"m",je).call(this,t)}))}},e.NotEqualsAtom=$t,e.NotEquivalentAtom=Gt,e.OperationOutcomeError=qi,e.OrAtom=Yt,e.ReadablePromise=J,e.SEGMENT_SEPARATOR="\r",e.SymbolAtom=Ut,e.UnaryOperatorAtom=Nt,e.UnionAtom=Ft,e.XorAtom=Jt,e.allOk=Mi,e.arrayBufferToBase64=k,e.arrayBufferToHex=O,e.assertOk=function(e,t){if(!Wi(e)||void 0===t)throw new qi(e)},e.badRequest=function(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}},e.booleanToTypedValue=Fe,e.buildTypeName=oe,e.calculateAge=E,e.calculateAgeString=function(e,t){const{years:i,months:n,days:o}=E(e,t);return i>=2?i.toString().padStart(3,"0")+"Y":n>=1?n.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"},e.capitalize=I,e.createReference=y,e.createSchema=function(){return{types:{}}},e.created=Ui,e.deepClone=function(e){return JSON.parse(JSON.stringify(e))},e.deepEquals=P,e.evalFhirPath=function(e,t){const i=Array.isArray(t)?t:[t];for(let e=0;e<i.length;e++){const t=i[e];"object"==typeof t&&"type"in t&&"value"in t||(i[e]=He(i[e]))}return Ei(e,i).map((e=>e.value))},e.evalFhirPathTyped=Ei,e.fhirPathArrayEquals=Ye,e.fhirPathArrayEquivalent=Ke,e.fhirPathEquals=Je,e.fhirPathEquivalent=Ze,e.fhirPathIs=tt,e.fhirPathNot=Xe,e.findObservationInterval=function(e,t,i,n){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return M(o,t)&&function(e,t,i){return!!e.range&&U(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))},e.findObservationReferenceRange=function(e,t,i){var n;return null===(n=e.qualifiedInterval)||void 0===n?void 0:n.find((e=>M(e,t)&&i.includes(e.condition)))},e.forbidden=_i,e.formatAddress=function(e,t){const i=[];return e.line&&i.push(...e.line),e.city&&i.push(e.city),e.state&&i.push(e.state),e.postalCode&&i.push(e.postalCode),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(", ").trim()},e.formatDate=function(e,t){if(!e)return"";const i=new Date(e);return l(i)?i.toLocaleDateString(void 0,t):""},e.formatDateTime=m,e.formatFamilyName=function(e){return e.family||""},e.formatGivenName=function(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()},e.formatHumanName=d,e.formatPeriod=function(e){return e&&(e.start||e.end)?m(e.start)+" - "+m(e.end):""},e.formatSearchQuery=function(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=Hi.includes(e.operator)?":"+e.operator:"",i=$i.includes(e.operator)?e.operator:"";return`${e.code}${t}=${i}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))},e.formatTime=u,e.formatTiming=function(e){var t;if(!e)return"";const i=[];if(null===(t=e.repeat)||void 0===t?void 0:t.periodUnit){const t=e.repeat.frequency||1,n=e.repeat.period||1,o=e.repeat.periodUnit;1===t&&1===n?i.push(p[o]):(1===t?i.push("once"):i.push(t+" times"),1===n?i.push("per "+h[o]):i.push("per "+n+" "+f[o])),e.repeat.dayOfWeek&&i.push("on "+e.repeat.dayOfWeek.map(I).join(", ")),e.repeat.timeOfDay&&i.push("at "+e.repeat.timeOfDay.map((e=>u(e))).join(", "))}return e.event&&i.push(e.event.map((e=>m(e))).join(", ")),I(i.join(" ").trim())},e.getCodeBySystem=function(e,t){var i,n;return null===(n=null===(i=null==e?void 0:e.coding)||void 0===i?void 0:i.find((e=>e.system===t)))||void 0===n?void 0:n.code},e.getDateProperty=function(e){return e?new Date(e):void 0},e.getDisplayString=x,e.getElementDefinition=re,e.getExpressionForResourceType=Vi,e.getExtensionValue=function(e,...t){var i;let n=e;for(let e=0;e<t.length&&n;e++)n=null===(i=null==n?void 0:n.extension)||void 0===i?void 0:i.find((i=>i.url===t[e]));return null==n?void 0:n.valueString},e.getIdentifier=function(e,t){const i=e.identifier;if(!i)return;const n=Array.isArray(i)?i:[i];for(const e of n)if(e.system===t)return e.value},e.getImageSrc=function(e){if(v(e)){const t=e.photo;if(t)for(const e of t){const t=T(e);if(t)return t}}if("Bot"===e.resourceType&&e.photo){const t=T(e.photo);if(t)return t}},e.getPropertyDisplayName=function(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(I).join(" ").replace("_"," ").replace(/\s+/g," ")},e.getQuestionnaireAnswers=function(e){const t={};return w(e.item,t),t},e.getReferenceString=g,e.getSearchParameterDetails=function(t,i){var n,o;let r=null===(o=null===(n=ae.types[t])||void 0===n?void 0:n.searchParamsDetails)||void 0===o?void 0:o[i.code];return r||(r=function(t,i){var n,o,r,a,s,c,d;if("_lastUpdated"===i.code)return{columnName:"lastUpdated",type:e.SearchParameterType.DATETIME};const l=i.code,u=function(e){return e.split("-").reduce(((e,t,i)=>e+(i?I(t):t)),"")}(l),m=null===(n=Vi(t,i.expression))||void 0===n?void 0:n.split(".");if(!m)return{columnName:u,type:e.SearchParameterType.TEXT};const p=Gi(i);let h,f,y=t,g=!1;for(let e=1;e<m.length;e++){const n=m[e];if(h=null!==(a=null===(r=null===(o=ae.types[y])||void 0===o?void 0:o.properties)||void 0===r?void 0:r[n])&&void 0!==a?a:null===(c=null===(s=ae.types[y])||void 0===s?void 0:s.properties)||void 0===c?void 0:c[n+"[x]"],!h)throw new Error(`Element definition not found for ${t} ${i.code}`);if("*"===h.max&&(g=!0),f=null===(d=h.type)||void 0===d?void 0:d[0].code,!f)return{columnName:u,type:p,array:g};e<m.length-1&&("Element"===f||"BackboneElement"===f?y+=I(n):y=f)}const v=Gi(i,f),x={columnName:u,type:v,elementDefinition:h,array:g};return function(e,t,i){const n=ae.types[e];n.searchParamsDetails||(n.searchParamsDetails={});n.searchParamsDetails[t]=i}(t,l,x),x}(t,i)),r},e.getStatus=function(e){return e.id===Di?200:e.id===Pi?201:e.id===Ai?304:e.id===Oi?401:e.id===ki?403:e.id===Ri?404:e.id===Ci?410:e.id===Ii?429:400},e.getTypedPropertyValue=ze,e.globalSchema=ae,e.gone=Qi,e.indexSearchParameter=ne,e.indexStructureDefinition=ie,e.indexStructureDefinitionBundle=function(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&ie(e)}},e.isEmpty=D,e.isGone=function(e){return e.id===Ci},e.isLowerCase=function(e){return e===e.toLowerCase()&&e!==e.toUpperCase()},e.isNotFound=function(e){return e.id===Ri},e.isObject=C,e.isOk=Wi,e.isPeriod=it,e.isProfileResource=v,e.isQuantity=nt,e.isQuantityEquivalent=ot,e.isStringArray=A,e.isUUID=function(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)},e.isValidDate=l,e.matchesRange=U,e.normalizeErrorString=function(e){var t,i,n,o;if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message;if("object"==typeof e&&"resourceType"in e){return null!==(o=null===(n=null===(i=null===(t=e.issue)||void 0===t?void 0:t[0])||void 0===i?void 0:i.details)||void 0===n?void 0:n.text)&&void 0!==o?o:"Unknown error"}return JSON.stringify(e)},e.notFound=Ni,e.notModified=Li,e.parseFhirPath=Ti,e.parseJWTPayload=Y,e.parseSearchDefinition=function(t){const i=new URL(t,"https://example.com/"),n=i.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let o,r,a,s,c,d;return new URLSearchParams(i.search).forEach(((t,i)=>{"_fields"===i?a=t.split(","):"_offset"===i?s=parseInt(t):"_count"===i?c=parseInt(t):"_total"===i?d=t:"_sort"===i?(r=r||[],r.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(t))):(o=o||[],o.push(function(t,i){let n=t,o=e.Operator.EQUALS;for(const e of Hi){const t=n.indexOf(":"+e);-1!==t&&(o=e,n=n.substring(0,t))}for(const e of $i)i.match(new RegExp("^"+e+"\\d"))&&(o=e,i=i.substring(e.length));return{code:n,operator:o,value:i}}(i,t)))})),{resourceType:n,filters:o,fields:a,offset:s,count:c,total:d,sortRules:r}},e.preciseEquals=L,e.preciseGreaterThan=j,e.preciseGreaterThanOrEquals=Q,e.preciseLessThan=N,e.preciseLessThanOrEquals=_,e.removeDuplicates=Ve,e.resolveId=function(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]},e.setCodeBySystem=function(e,t,i){var n,o;e.coding||(e.coding=[]);const r=null===(n=e.coding)||void 0===n?void 0:n.find((e=>e.system===t));r?r.code=i:null===(o=e.coding)||void 0===o||o.push({system:t,code:i})},e.stringify=S,e.toJsBoolean=$e,e.toTypedValue=He,e.tokenize=ei,e.tooManyRequests=Bi,e.unauthorized=ji,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.core={}))}(this,(function(e){"use strict";function t(e,t,i,n){return new(i||(i=Promise))((function(o,r){function a(e){try{c(n.next(e))}catch(e){r(e)}}function s(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}var o,r,a,s;class c{constructor(e=10){o.add(this),r.set(this,void 0),a.set(this,void 0),n(this,r,e,"f"),n(this,a,new Map,"f")}clear(){i(this,a,"f").clear()}get(e){const t=i(this,a,"f").get(e);return t&&(i(this,a,"f").delete(e),i(this,a,"f").set(e,t)),t}set(e,t){i(this,a,"f").has(e)?i(this,a,"f").delete(e):i(this,a,"f").size>=i(this,r,"f")&&i(this,a,"f").delete(i(this,o,"m",s).call(this)),i(this,a,"f").set(e,t)}delete(e){i(this,a,"f").delete(e)}keys(){return i(this,a,"f").keys()}}function d(e,t){const i=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&i.push(...e.prefix),e.given&&i.push(...e.given),e.family&&i.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&i.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(" ").trim()}function l(e){return e instanceof Date&&!isNaN(e.getTime())}function u(e,t){if(!e)return"";const i=new Date("2000-01-01T"+e+"Z");return l(i)?i.toLocaleTimeString(void 0,t):""}function m(e,t){if(!e)return"";const i=new Date(e);return l(i)?i.toLocaleString(void 0,t):""}r=new WeakMap,a=new WeakMap,o=new WeakSet,s=function(){return i(this,a,"f").keys().next().value};const p={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},h={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},f={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function y(e){const t=g(e),i=v(e);return i===t?{reference:t}:{reference:t,display:i}}function g(e){return e.resourceType+"/"+e.id}function x(e){return"Patient"===e.resourceType||"Practitioner"===e.resourceType||"RelatedPerson"===e.resourceType}function v(e){var t,i;if(x(e)){const t=function(e){const t=e.name;if(t&&t.length>0)return d(t[0]);return}(e);if(t)return t}if("Device"===e.resourceType){const t=function(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name;return}(e);if(t)return t}return"Observation"===e.resourceType&&"code"in e&&(null===(t=e.code)||void 0===t?void 0:t.text)?null===(i=e.code)||void 0===i?void 0:i.text:"User"===e.resourceType&&e.email?e.email:"name"in e&&e.name&&"string"==typeof e.name?e.name:g(e)}function T(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function E(e,t){const i=new Date(e);i.setUTCHours(0,0,0,0);const n=t?new Date(t):new Date;n.setUTCHours(0,0,0,0);const o=i.getUTCFullYear(),r=i.getUTCMonth(),a=i.getUTCDate(),s=n.getUTCFullYear(),c=n.getUTCMonth(),d=n.getUTCDate();let l=s-o;(c<r||c===r&&d<a)&&l--;let u=12*s+c-(12*o+r);d<a&&u--;return{years:l,months:u,days:Math.floor((n.getTime()-i.getTime())/864e5)}}function w(e,t){if(e)for(const i of e)i.linkId&&i.answer&&i.answer.length>0&&(t[i.linkId]=i.answer[0]),w(i.item,t)}function S(e,t){return JSON.stringify(e,b,t?2:void 0)}function b(e,t){return!function(e){return!!e.match(/\d+$/)}(e)&&P(t)?void 0:t}function P(e){if(null==e)return!0;const t=typeof e;return"string"===t&&""===e||"object"===t&&0===Object.keys(e).length}function D(e,t,i){return e===t||(!(!P(e)||!P(t))||!P(e)&&!P(t)&&(Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!D(e[i],t[i]))return!1;return!0}(e,t):!Array.isArray(e)&&!Array.isArray(t)&&(C(e)&&C(t)?function(e,t,i){const n=new Set;Object.keys(e).forEach((e=>n.add(e))),Object.keys(t).forEach((e=>n.add(e))),"meta"===i&&(n.delete("versionId"),n.delete("lastUpdated"),n.delete("author"));for(const i of n){if(!D(e[i],t[i],i))return!1}return!0}(e,t,i):(C(e)||C(t),!1))))}function C(e){return null!==e&&"object"==typeof e}function A(e){return e.every((e=>"string"==typeof e))}const R=[];for(let e=0;e<256;e++)R.push(e.toString(16).padStart(2,"0"));function O(e){const t=new Uint8Array(e),i=new Array(t.length);for(let e=0;e<t.length;e++)i[e]=R[t[e]];return i.join("")}function k(e){const t=new Uint8Array(e),i=[];for(let e=0;e<t.length;e++)i[e]=String.fromCharCode(t[e]);return window.btoa(i.join(""))}function I(e){return e.charAt(0).toUpperCase()+e.substring(1)}function M(e,t){return function(e,t){return!e.gender||e.gender===t.gender}(e,t)&&function(e,t){return!e.age||U(E(t.birthDate).years,e.age)}(e,t)}function U(e,t,i){var n,o;return(void 0===(null===(n=t.low)||void 0===n?void 0:n.value)||W(e,t.low.value,i))&&(void 0===(null===(o=t.high)||void 0===o?void 0:o.value)||_(e,t.high.value,i))}function L(e,t,i){return i?Math.abs(e-t)<Math.pow(10,-i):e===t}function N(e,t,i){return i?e<t&&Math.abs(e-t)>Math.pow(10,-i):e<t}function j(e,t,i){return i?e>t&&Math.abs(e-t)>Math.pow(10,-i):e>t}function _(e,t,i){return N(e,t,i)||L(e,t,i)}function W(e,t,i){return j(e,t,i)||L(e,t,i)}function B(){const e=new Uint32Array(28);return crypto.getRandomValues(e),O(e.buffer)}var Q,q,F,H,$,z,G,V;function X(e){const t=function(e){if("undefined"!=typeof window)return window.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}(e.replace(/-/g,"+").replace(/_/g,"/")),i=Array.from(t).reduce(((e,t)=>`${e}%${("00"+t.charCodeAt(0).toString(16)).slice(-2)}`),""),n=decodeURIComponent(i);return JSON.parse(n)}function Y(e){const[t,i,n]=e.split(".");return X(i)}Q=new WeakMap;class J{constructor(e){this[z]="ReadablePromise",q.set(this,void 0),F.set(this,"pending"),H.set(this,void 0),$.set(this,void 0),n(this,q,e.then((e=>(n(this,F,"success","f"),n(this,H,e,"f"),e)),(e=>{throw n(this,F,"error","f"),n(this,$,e,"f"),e})),"f")}isPending(){return"pending"===i(this,F,"f")}isOk(){return"success"===i(this,F,"f")}read(){switch(i(this,F,"f")){case"pending":throw i(this,q,"f");case"error":throw i(this,$,"f");default:return i(this,H,"f")}}then(e,t){return i(this,q,"f").then(e,t)}catch(e){return i(this,q,"f").catch(e)}finally(e){return i(this,q,"f").finally(e)}}q=new WeakMap,F=new WeakMap,H=new WeakMap,$=new WeakMap,z=Symbol.toStringTag;class K{constructor(){G.set(this,void 0),n(this,G,"undefined"!=typeof localStorage?localStorage:new Z,"f")}clear(){i(this,G,"f").clear()}getString(e){return i(this,G,"f").getItem(e)||void 0}setString(e,t){t?i(this,G,"f").setItem(e,t):i(this,G,"f").removeItem(e)}getObject(e){const t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?S(t):void 0)}}G=new WeakMap;class Z{constructor(){V.set(this,void 0),n(this,V,new Map,"f")}get length(){return i(this,V,"f").size}clear(){i(this,V,"f").clear()}getItem(e){var t;return null!==(t=i(this,V,"f").get(e))&&void 0!==t?t:null}setItem(e,t){t?i(this,V,"f").set(e,t):i(this,V,"f").delete(e)}removeItem(e){i(this,V,"f").delete(e)}key(e){return Array.from(i(this,V,"f").keys())[e]}}V=new WeakMap;var ee,te={types:{Element:{display:"Element",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]}}},BackboneElement:{display:"BackboneElement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]}}},Address:{display:"Address",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},line:{min:0,max:"*",type:[{code:"string"}]},city:{min:0,max:"1",type:[{code:"string"}]},district:{min:0,max:"1",type:[{code:"string"}]},state:{min:0,max:"1",type:[{code:"string"}]},postalCode:{min:0,max:"1",type:[{code:"string"}]},country:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Age:{display:"Age",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Annotation:{display:"Annotation",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"author[x]":{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{min:0,max:"1",type:[{code:"dateTime"}]},text:{min:1,max:"1",type:[{code:"markdown"}]}}},Attachment:{display:"Attachment",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},contentType:{min:0,max:"1",type:[{code:"code"}]},language:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]},url:{min:0,max:"1",type:[{code:"url"}]},size:{min:0,max:"1",type:[{code:"unsignedInt"}]},hash:{min:0,max:"1",type:[{code:"base64Binary"}]},title:{min:0,max:"1",type:[{code:"string"}]},creation:{min:0,max:"1",type:[{code:"dateTime"}]}}},CodeableConcept:{display:"CodeableConcept",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},coding:{min:0,max:"*",type:[{code:"Coding"}]},text:{min:0,max:"1",type:[{code:"string"}]}}},Coding:{display:"Coding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"uri"}]},version:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"1",type:[{code:"code"}]},display:{min:0,max:"1",type:[{code:"string"}]},userSelected:{min:0,max:"1",type:[{code:"boolean"}]}}},ContactDetail:{display:"ContactDetail",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"string"}]},telecom:{min:0,max:"*",type:[{code:"ContactPoint"}]}}},ContactPoint:{display:"ContactPoint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},system:{min:0,max:"1",type:[{code:"code"}]},value:{min:0,max:"1",type:[{code:"string"}]},use:{min:0,max:"1",type:[{code:"code"}]},rank:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Contributor:{display:"Contributor",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:1,max:"1",type:[{code:"string"}]},contact:{min:0,max:"*",type:[{code:"ContactDetail"}]}}},Count:{display:"Count",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},DataRequirement:{display:"DataRequirement",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{min:0,max:"1",type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{min:0,max:"*",type:[{code:"string"}]},codeFilter:{min:0,max:"*",type:[{code:"Element"}]},dateFilter:{min:0,max:"*",type:[{code:"Element"}]},limit:{min:0,max:"1",type:[{code:"positiveInt"}]},sort:{min:0,max:"*",type:[{code:"Element"}]}}},DataRequirementCodeFilter:{display:"DataRequirementCodeFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{min:0,max:"*",type:[{code:"Coding"}]}},parentType:"DataRequirement"},DataRequirementDateFilter:{display:"DataRequirementDateFilter",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:0,max:"1",type:[{code:"string"}]},searchParam:{min:0,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}},parentType:"DataRequirement"},DataRequirementSort:{display:"DataRequirementSort",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},direction:{min:1,max:"1",type:[{code:"code"}]}},parentType:"DataRequirement"},Distance:{display:"Distance",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Dosage:{display:"Dosage",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},sequence:{min:0,max:"1",type:[{code:"integer"}]},text:{min:0,max:"1",type:[{code:"string"}]},additionalInstruction:{min:0,max:"*",type:[{code:"CodeableConcept"}]},patientInstruction:{min:0,max:"1",type:[{code:"string"}]},timing:{min:0,max:"1",type:[{code:"Timing"}]},"asNeeded[x]":{min:0,max:"1",type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{min:0,max:"1",type:[{code:"CodeableConcept"}]},route:{min:0,max:"1",type:[{code:"CodeableConcept"}]},method:{min:0,max:"1",type:[{code:"CodeableConcept"}]},doseAndRate:{min:0,max:"*",type:[{code:"Element"}]},maxDosePerPeriod:{min:0,max:"1",type:[{code:"Ratio"}]},maxDosePerAdministration:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{display:"DosageDoseAndRate",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},"dose[x]":{min:0,max:"1",type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{min:0,max:"1",type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}},parentType:"Dosage"},Duration:{display:"Duration",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"1",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},ElementDefinition:{display:"ElementDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},representation:{min:0,max:"*",type:[{code:"code"}]},sliceName:{min:0,max:"1",type:[{code:"string"}]},sliceIsConstraining:{min:0,max:"1",type:[{code:"boolean"}]},label:{min:0,max:"1",type:[{code:"string"}]},code:{min:0,max:"*",type:[{code:"Coding"}]},slicing:{min:0,max:"1",type:[{code:"Element"}]},short:{min:0,max:"1",type:[{code:"string"}]},definition:{min:0,max:"1",type:[{code:"markdown"}]},comment:{min:0,max:"1",type:[{code:"markdown"}]},requirements:{min:0,max:"1",type:[{code:"markdown"}]},alias:{min:0,max:"*",type:[{code:"string"}]},min:{min:0,max:"1",type:[{code:"unsignedInt"}]},max:{min:0,max:"1",type:[{code:"string"}]},base:{min:0,max:"1",type:[{code:"Element"}]},contentReference:{min:0,max:"1",type:[{code:"uri"}]},type:{min:0,max:"*",type:[{code:"Element"}]},"defaultValue[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{min:0,max:"1",type:[{code:"markdown"}]},orderMeaning:{min:0,max:"1",type:[{code:"string"}]},"fixed[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{min:0,max:"*",type:[{code:"Element"}]},"minValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{min:0,max:"1",type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{min:0,max:"1",type:[{code:"integer"}]},condition:{min:0,max:"*",type:[{code:"id"}]},constraint:{min:0,max:"*",type:[{code:"Element"}]},mustSupport:{min:0,max:"1",type:[{code:"boolean"}]},isModifier:{min:0,max:"1",type:[{code:"boolean"}]},isModifierReason:{min:0,max:"1",type:[{code:"string"}]},isSummary:{min:0,max:"1",type:[{code:"boolean"}]},binding:{min:0,max:"1",type:[{code:"Element"}]},mapping:{min:0,max:"*",type:[{code:"Element"}]}}},ElementDefinitionSlicing:{display:"ElementDefinitionSlicing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},discriminator:{min:0,max:"*",type:[{code:"Element"}]},description:{min:0,max:"1",type:[{code:"string"}]},ordered:{min:0,max:"1",type:[{code:"boolean"}]},rules:{min:1,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionSlicingDiscriminator:{display:"ElementDefinitionSlicingDiscriminator",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},path:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinitionSlicing"},ElementDefinitionBase:{display:"ElementDefinitionBase",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},path:{min:1,max:"1",type:[{code:"string"}]},min:{min:1,max:"1",type:[{code:"unsignedInt"}]},max:{min:1,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},ElementDefinitionType:{display:"ElementDefinitionType",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{min:0,max:"*",type:[{code:"code"}]},versioning:{min:0,max:"1",type:[{code:"code"}]}},parentType:"ElementDefinition"},ElementDefinitionExample:{display:"ElementDefinitionExample",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},label:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:1,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}},parentType:"ElementDefinition"},ElementDefinitionConstraint:{display:"ElementDefinitionConstraint",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},key:{min:1,max:"1",type:[{code:"id"}]},requirements:{min:0,max:"1",type:[{code:"string"}]},severity:{min:1,max:"1",type:[{code:"code"}]},human:{min:1,max:"1",type:[{code:"string"}]},expression:{min:0,max:"1",type:[{code:"string"}]},xpath:{min:0,max:"1",type:[{code:"string"}]},source:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}},parentType:"ElementDefinition"},ElementDefinitionBinding:{display:"ElementDefinitionBinding",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},strength:{min:1,max:"1",type:[{code:"code"}]},description:{min:0,max:"1",type:[{code:"string"}]},valueSet:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}},parentType:"ElementDefinition"},ElementDefinitionMapping:{display:"ElementDefinitionMapping",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},identity:{min:1,max:"1",type:[{code:"id"}]},language:{min:0,max:"1",type:[{code:"code"}]},map:{min:1,max:"1",type:[{code:"string"}]},comment:{min:0,max:"1",type:[{code:"string"}]}},parentType:"ElementDefinition"},Expression:{display:"Expression",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},description:{min:0,max:"1",type:[{code:"string"}]},name:{min:0,max:"1",type:[{code:"id"}]},language:{min:1,max:"1",type:[{code:"code"}]},expression:{min:0,max:"1",type:[{code:"string"}]},reference:{min:0,max:"1",type:[{code:"uri"}]}}},Extension:{display:"Extension",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},url:{min:1,max:"1",type:[{code:"string"}]},"value[x]":{min:0,max:"1",type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},HumanName:{display:"HumanName",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},text:{min:0,max:"1",type:[{code:"string"}]},family:{min:0,max:"1",type:[{code:"string"}]},given:{min:0,max:"*",type:[{code:"string"}]},prefix:{min:0,max:"*",type:[{code:"string"}]},suffix:{min:0,max:"*",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]}}},Identifier:{display:"Identifier",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},use:{min:0,max:"1",type:[{code:"code"}]},type:{min:0,max:"1",type:[{code:"CodeableConcept"}]},system:{min:0,max:"1",type:[{code:"uri"}]},value:{min:0,max:"1",type:[{code:"string"}]},period:{min:0,max:"1",type:[{code:"Period"}]},assigner:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{display:"MarketingStatus",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},country:{min:1,max:"1",type:[{code:"CodeableConcept"}]},jurisdiction:{min:0,max:"1",type:[{code:"CodeableConcept"}]},status:{min:1,max:"1",type:[{code:"CodeableConcept"}]},dateRange:{min:1,max:"1",type:[{code:"Period"}]},restoreDate:{min:0,max:"1",type:[{code:"dateTime"}]}}},Meta:{display:"Meta",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},versionId:{min:0,max:"1",type:[{code:"id"}]},lastUpdated:{min:0,max:"1",type:[{code:"instant"}]},source:{min:0,max:"1",type:[{code:"uri"}]},profile:{min:0,max:"*",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{min:0,max:"*",type:[{code:"Coding"}]},tag:{min:0,max:"*",type:[{code:"Coding"}]},project:{min:0,max:"1",type:[{code:"uri"}]},author:{min:0,max:"1",type:[{code:"Reference"}]},account:{min:0,max:"1",type:[{code:"Reference"}]}}},Money:{display:"Money",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},currency:{min:0,max:"1",type:[{code:"code"}]}}},Narrative:{display:"Narrative",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},status:{min:1,max:"1",type:[{code:"code"}]},div:{min:1,max:"1",type:[{code:"xhtml"}]}}},ParameterDefinition:{display:"ParameterDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},name:{min:0,max:"1",type:[{code:"code"}]},use:{min:1,max:"1",type:[{code:"code"}]},min:{min:0,max:"1",type:[{code:"integer"}]},max:{min:0,max:"1",type:[{code:"string"}]},documentation:{min:0,max:"1",type:[{code:"string"}]},type:{min:1,max:"1",type:[{code:"code"}]},profile:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{display:"Period",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},start:{min:0,max:"1",type:[{code:"dateTime"}]},end:{min:0,max:"1",type:[{code:"dateTime"}]}}},Population:{display:"Population",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"age[x]":{min:0,max:"1",type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{min:0,max:"1",type:[{code:"CodeableConcept"}]},race:{min:0,max:"1",type:[{code:"CodeableConcept"}]},physiologicalCondition:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{display:"ProdCharacteristic",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},height:{min:0,max:"1",type:[{code:"Quantity"}]},width:{min:0,max:"1",type:[{code:"Quantity"}]},depth:{min:0,max:"1",type:[{code:"Quantity"}]},weight:{min:0,max:"1",type:[{code:"Quantity"}]},nominalVolume:{min:0,max:"1",type:[{code:"Quantity"}]},externalDiameter:{min:0,max:"1",type:[{code:"Quantity"}]},shape:{min:0,max:"1",type:[{code:"string"}]},color:{min:0,max:"*",type:[{code:"string"}]},imprint:{min:0,max:"*",type:[{code:"string"}]},image:{min:0,max:"*",type:[{code:"Attachment"}]},scoring:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{display:"ProductShelfLife",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},type:{min:1,max:"1",type:[{code:"CodeableConcept"}]},period:{min:1,max:"1",type:[{code:"Quantity"}]},specialPrecautionsForStorage:{min:0,max:"*",type:[{code:"CodeableConcept"}]}}},Quantity:{display:"Quantity",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},value:{min:0,max:"1",type:[{code:"decimal"}]},comparator:{min:0,max:"0",type:[{code:"code"}]},unit:{min:0,max:"1",type:[{code:"string"}]},system:{min:0,max:"1",type:[{code:"uri"}]},code:{min:0,max:"1",type:[{code:"code"}]}}},Range:{display:"Range",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},low:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{min:0,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{display:"Ratio",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},numerator:{min:0,max:"1",type:[{code:"Quantity"}]},denominator:{min:0,max:"1",type:[{code:"Quantity"}]}}},Reference:{display:"Reference",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},reference:{min:0,max:"1",type:[{code:"string"}]},type:{min:0,max:"1",type:[{code:"uri"}]},identifier:{min:0,max:"1",type:[{code:"Identifier"}]},display:{min:0,max:"1",type:[{code:"string"}]}}},RelatedArtifact:{display:"RelatedArtifact",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},label:{min:0,max:"1",type:[{code:"string"}]},display:{min:0,max:"1",type:[{code:"string"}]},citation:{min:0,max:"1",type:[{code:"markdown"}]},url:{min:0,max:"1",type:[{code:"url"}]},document:{min:0,max:"1",type:[{code:"Attachment"}]},resource:{min:0,max:"1",type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{display:"SampledData",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},origin:{min:1,max:"1",type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,max:"1",type:[{code:"decimal"}]},factor:{min:0,max:"1",type:[{code:"decimal"}]},lowerLimit:{min:0,max:"1",type:[{code:"decimal"}]},upperLimit:{min:0,max:"1",type:[{code:"decimal"}]},dimensions:{min:1,max:"1",type:[{code:"positiveInt"}]},data:{min:0,max:"1",type:[{code:"string"}]}}},Signature:{display:"Signature",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"*",type:[{code:"Coding"}]},when:{min:1,max:"1",type:[{code:"instant"}]},who:{min:1,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{min:0,max:"1",type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{min:0,max:"1",type:[{code:"code"}]},sigFormat:{min:0,max:"1",type:[{code:"code"}]},data:{min:0,max:"1",type:[{code:"base64Binary"}]}}},SubstanceAmount:{display:"SubstanceAmount",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},"amount[x]":{min:0,max:"1",type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{min:0,max:"1",type:[{code:"CodeableConcept"}]},amountText:{min:0,max:"1",type:[{code:"string"}]},referenceRange:{min:0,max:"1",type:[{code:"Element"}]}}},SubstanceAmountReferenceRange:{display:"SubstanceAmountReferenceRange",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},lowLimit:{min:0,max:"1",type:[{code:"Quantity"}]},highLimit:{min:0,max:"1",type:[{code:"Quantity"}]}},parentType:"SubstanceAmount"},Timing:{display:"Timing",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},modifierExtension:{min:0,max:"*",type:[{code:"Extension"}]},event:{min:0,max:"*",type:[{code:"dateTime"}]},repeat:{min:0,max:"1",type:[{code:"Element"}]},code:{min:0,max:"1",type:[{code:"CodeableConcept"}]}}},TimingRepeat:{display:"TimingRepeat",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},"bounds[x]":{min:0,max:"1",type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{min:0,max:"1",type:[{code:"positiveInt"}]},countMax:{min:0,max:"1",type:[{code:"positiveInt"}]},duration:{min:0,max:"1",type:[{code:"decimal"}]},durationMax:{min:0,max:"1",type:[{code:"decimal"}]},durationUnit:{min:0,max:"1",type:[{code:"code"}]},frequency:{min:0,max:"1",type:[{code:"positiveInt"}]},frequencyMax:{min:0,max:"1",type:[{code:"positiveInt"}]},period:{min:0,max:"1",type:[{code:"decimal"}]},periodMax:{min:0,max:"1",type:[{code:"decimal"}]},periodUnit:{min:0,max:"1",type:[{code:"code"}]},dayOfWeek:{min:0,max:"*",type:[{code:"code"}]},timeOfDay:{min:0,max:"*",type:[{code:"time"}]},when:{min:0,max:"*",type:[{code:"code"}]},offset:{min:0,max:"1",type:[{code:"unsignedInt"}]}},parentType:"Timing"},TriggerDefinition:{display:"TriggerDefinition",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},type:{min:1,max:"1",type:[{code:"code"}]},name:{min:0,max:"1",type:[{code:"string"}]},"timing[x]":{min:0,max:"1",type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{min:0,max:"*",type:[{code:"DataRequirement"}]},condition:{min:0,max:"1",type:[{code:"Expression"}]}}},UsageContext:{display:"UsageContext",properties:{id:{min:0,max:"1",type:[{code:"string"}]},extension:{min:0,max:"*",type:[{code:"Extension"}]},code:{min:1,max:"1",type:[{code:"Coding"}]},"value[x]":{min:1,max:"1",type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}}}};function ie(e){var t;if(!e.name)return;const i=null===(t=e.snapshot)||void 0===t?void 0:t.element;i&&(i.forEach((t=>function(e,t){var i,n;const o=t.path,r=null===(n=null===(i=t.type)||void 0===i?void 0:i[0])||void 0===n?void 0:n.code;if(void 0!==r&&"Element"!==r&&"BackboneElement"!==r)return;const a=o.split("."),s=oe(a);ae.types[s]=function(e,t,i){return{structureDefinition:t,elementDefinition:i,display:e,description:i.definition,properties:{}}}(s,e,t),ae.types[s].parentType=oe(a.slice(0,a.length-1))}(e,t))),i.forEach((e=>function(e){const t=e.path.split(".");if(1===t.length)return;const i=oe(t.slice(0,t.length-1)),n=ae.types[i];if(!n)return;const o=t[t.length-1];n.properties[o]=e}(e))))}function ne(e){if(e.base)for(const t of e.base){const i=ae.types[t];i&&(i.searchParams||(i.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"}}),i.searchParams[e.code]=e)}}function oe(e){return 1===e.length?e[0]:e.map(I).join("")}function re(e,t){var i;const n=ae.types[e];if(!n)return;const o=null!==(i=n.properties[t])&&void 0!==i?i:n.properties[t+"[x]"];if(o){if(o.contentReference){const e=o.contentReference.substring(1).split("."),t=e.pop();return re(oe(e),t)}return o}}e.PropertyType=void 0,(ee=e.PropertyType||(e.PropertyType={})).Address="Address",ee.Age="Age",ee.Annotation="Annotation",ee.Attachment="Attachment",ee.BackboneElement="BackboneElement",ee.CodeableConcept="CodeableConcept",ee.Coding="Coding",ee.ContactDetail="ContactDetail",ee.ContactPoint="ContactPoint",ee.Contributor="Contributor",ee.Count="Count",ee.DataRequirement="DataRequirement",ee.Distance="Distance",ee.Dosage="Dosage",ee.Duration="Duration",ee.Expression="Expression",ee.Extension="Extension",ee.HumanName="HumanName",ee.Identifier="Identifier",ee.MarketingStatus="MarketingStatus",ee.Meta="Meta",ee.Money="Money",ee.Narrative="Narrative",ee.ParameterDefinition="ParameterDefinition",ee.Period="Period",ee.Population="Population",ee.ProdCharacteristic="ProdCharacteristic",ee.ProductShelfLife="ProductShelfLife",ee.Quantity="Quantity",ee.Range="Range",ee.Ratio="Ratio",ee.Reference="Reference",ee.RelatedArtifact="RelatedArtifact",ee.SampledData="SampledData",ee.Signature="Signature",ee.SubstanceAmount="SubstanceAmount",ee.SystemString="http://hl7.org/fhirpath/System.String",ee.Timing="Timing",ee.TriggerDefinition="TriggerDefinition",ee.UsageContext="UsageContext",ee.base64Binary="base64Binary",ee.boolean="boolean",ee.canonical="canonical",ee.code="code",ee.date="date",ee.dateTime="dateTime",ee.decimal="decimal",ee.id="id",ee.instant="instant",ee.integer="integer",ee.markdown="markdown",ee.oid="oid",ee.positiveInt="positiveInt",ee.string="string",ee.time="time",ee.unsignedInt="unsignedInt",ee.uri="uri",ee.url="url",ee.uuid="uuid";const ae=te;var se,ce,de,le,ue,me,pe,he,fe,ye,ge,xe,ve,Te,Ee,we,Se,be,Pe,De,Ce,Ae,Re,Oe,ke,Ie,Me,Ue,Le,Ne,je,_e;const We="launch/patient openid fhirUser offline_access user/*.*";function Be(){return window.location.protocol+"//"+window.location.host+"/"}function Qe(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch(t){return e}}function qe(t){return[{type:e.PropertyType.boolean,value:t}]}function Fe(t){return null==t?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:e.PropertyType.integer,value:t}:"number"==typeof t?{type:e.PropertyType.decimal,value:t}:"boolean"==typeof t?{type:e.PropertyType.boolean,value:t}:"string"==typeof t?{type:e.PropertyType.string,value:t}:it(t)?{type:e.PropertyType.Quantity,value:t}:"object"==typeof t&&"resourceType"in t?{type:t.resourceType,value:t}:{type:e.PropertyType.BackboneElement,value:t}}function He(e){return 0!==e.length&&!!e[0].value}function $e(t,i){if(!(null==t?void 0:t.value))return;const n=re(t.type,i);if(n){const e=function(e,t,i){var n;const o=i.type;if(!o||0===o.length)return;let r,a="undefined";if(1===o.length)r=e.value[t],a=o[0].code;else for(const i of o){const n=t.replace("[x]","")+I(i.code);if(n in e.value){r=e.value[n],a=i.code;break}}if(P(r))return;"Element"!==a&&"BackboneElement"!==a||(a=oe(null===(n=i.path)||void 0===n?void 0:n.split(".")));return Array.isArray(r)?r.map((e=>ze(e,a))):ze(r,a)}(t,i,n);if(e)return e}return function(t,i){const n=t.value;if(!n||"object"!=typeof n)return;let o;if(i in n)o=n[i];else for(const t in e.PropertyType){const e=i+I(t);if(e in n){o=n[e];break}}if(P(o))return;return Array.isArray(o)?o.map(Fe):Fe(o)}(t,i)}function ze(e,t){return"Resource"===t&&"object"==typeof e&&"resourceType"in e&&(t=e.resourceType),{type:t,value:e}}function Ge(e){const t=[];for(const i of e){let e=!1;for(const n of t)if(He(Ye(i,n))){e=!0;break}e||t.push(i)}return t}function Ve(e){return qe(!He(e))}function Xe(e,t){return 0===e.length||0===t.length?[]:e.length!==t.length?qe(!1):qe(e.every(((e,i)=>He(Ye(e,t[i])))))}function Ye(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?qe(Math.abs(i-n)<1e-8):it(i)&&it(n)?qe(nt(i,n)):qe("object"==typeof i&&"object"==typeof n?ot(e,t):i===n)}function Je(e,t){return 0===e.length&&0===t.length?qe(!0):e.length!==t.length?qe(!1):(e.sort(Ze),t.sort(Ze),qe(e.every(((e,i)=>He(Ke(e,t[i]))))))}function Ke(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?qe(Math.abs(i-n)<.01):it(i)&&it(n)?qe(nt(i,n)):qe("object"==typeof i&&"object"==typeof n?ot(i,n):"string"==typeof i&&"string"==typeof n?i.toLowerCase()===n.toLowerCase():i===n)}function Ze(e,t){const i=e.value,n=t.value;return"number"==typeof i&&"number"==typeof n?i-n:"string"==typeof i&&"string"==typeof n?i.localeCompare(n):0}function et(e,t){const{value:i}=e;if(null==i)return!1;switch(t){case"Boolean":return"boolean"==typeof i;case"Decimal":case"Integer":return"number"==typeof i;case"Date":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?/);case"DateTime":return"string"==typeof i&&!!i.match(/^\d{4}(-\d{2}(-\d{2})?)?T/);case"Time":return"string"==typeof i&&!!i.match(/^T\d/);case"Period":return tt(i);case"Quantity":return it(i);default:return"object"==typeof i&&(null==i?void 0:i.resourceType)===t}}function tt(e){return!(!e||"object"!=typeof e||!("start"in e))}function it(e){return!(!e||"object"!=typeof e||!("value"in e)||"number"!=typeof e.value)}function nt(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function ot(e,t){const i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(const n of i){const i=e[n],o=t[n];if(rt(i)&&rt(o)){if(!ot(i,o))return!1}else if(i!==o)return!1}return!0}function rt(e){return null!==e&&"object"==typeof e}ce=new WeakMap,de=new WeakMap,le=new WeakMap,ue=new WeakMap,me=new WeakMap,pe=new WeakMap,he=new WeakMap,fe=new WeakMap,ye=new WeakMap,ge=new WeakMap,xe=new WeakMap,ve=new WeakMap,Te=new WeakMap,Ee=new WeakMap,we=new WeakMap,Se=new WeakMap,be=new WeakMap,se=new WeakSet,Pe=function(e){const t=this.getLogins().filter((t=>{var i,n;return(null===(i=t.profile)||void 0===i?void 0:i.reference)!==(null===(n=e.profile)||void 0===n?void 0:n.reference)}));t.push(e),i(this,le,"f").setObject("logins",t)},De=function(){return t(this,void 0,void 0,(function*(){return n(this,we,new Promise(((e,t)=>{this.get("auth/me").then((t=>{n(this,we,void 0,"f"),n(this,Se,t.profile,"f"),n(this,be,t.config,"f"),this.dispatchEvent({type:"change"}),e(i(this,Se,"f"))})).catch(t)})),"f"),i(this,we,"f")}))},Ce=function(e,t){if(i(this,me,"f")<=0||"no-cache"===(null==t?void 0:t.cache)||"reload"===(null==t?void 0:t.cache))return;const n=i(this,ue,"f").get(e);return!n||n.requestTime+i(this,me,"f")<Date.now()?void 0:n},Ae=function(e,t){i(this,me,"f")>0&&i(this,ue,"f").set(e,{requestTime:Date.now(),value:t})},Re=function(e,n,o={}){return t(this,void 0,void 0,(function*(){i(this,Ee,"f")&&(yield i(this,Ee,"f")),n.startsWith("http")||(n=i(this,pe,"f")+n),o.method=e,i(this,se,"m",Oe).call(this,o);const t=yield i(this,ce,"f").call(this,n,o);if(401===t.status)return i(this,se,"m",Me).call(this,e,n,o);if(204===t.status||304===t.status)return;const r=yield t.json();if(t.status>=400)throw r;return r}))},Oe=function(e){e.headers||(e.headers={});const t=e.headers;t["X-Medplum"]="extended",t["Content-Type"]||(t["Content-Type"]="application/fhir+json"),i(this,ve,"f")&&(t.Authorization="Bearer "+i(this,ve,"f")),e.cache||(e.cache="no-cache"),e.credentials||(e.credentials="include")},ke=function(e,t){e.headers||(e.headers={});e.headers["Content-Type"]=t},Ie=function(e,t){"string"==typeof t||"undefined"!=typeof Blob&&t instanceof Blob||"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Uint8Array&&t instanceof Uint8Array?e.body=t:t&&(e.body=JSON.stringify(t))},Me=function(e,n,o){return t(this,void 0,void 0,(function*(){return i(this,se,"m",Le).call(this).then((()=>i(this,se,"m",Re).call(this,e,n,o))).catch((e=>(this.clear(),i(this,xe,"f")&&i(this,xe,"f").call(this),Promise.reject(e))))}))},Ue=function(){return t(this,void 0,void 0,(function*(){yield this.startPkce();const e=new URL(i(this,fe,"f"));e.searchParams.set("response_type","code"),e.searchParams.set("state",sessionStorage.getItem("pkceState")),e.searchParams.set("client_id",i(this,he,"f")),e.searchParams.set("redirect_uri",Be()),e.searchParams.set("scope",We),e.searchParams.set("code_challenge_method","S256"),e.searchParams.set("code_challenge",sessionStorage.getItem("codeChallenge")),window.location.assign(e.toString())}))},Le=function(){return t(this,void 0,void 0,(function*(){if(i(this,Ee,"f"))return i(this,Ee,"f");if(!i(this,Te,"f"))throw this.clear(),new Error("Invalid refresh token");const e=new URLSearchParams;e.set("grant_type","refresh_token"),e.set("client_id",i(this,he,"f")),e.set("refresh_token",i(this,Te,"f")),n(this,Ee,i(this,se,"m",Ne).call(this,e),"f"),yield i(this,Ee,"f")}))},Ne=function(e){return t(this,void 0,void 0,(function*(){return i(this,ce,"f").call(this,i(this,ye,"f"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e,credentials:"include"}).then((e=>{if(!e.ok)throw new Error("Failed to fetch tokens");return e.json()})).then((e=>i(this,se,"m",je).call(this,e))).then((()=>this.getProfile()))}))},je=function(e){return t(this,void 0,void 0,(function*(){const t=e.access_token,n=Y(t);if(Date.now()>=1e3*n.exp)throw this.clear(),new Error("Token expired");if(i(this,he,"f")&&n.client_id!==i(this,he,"f"))throw this.clear(),new Error("Token was not issued for this audience");yield this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}))},_e=function(){try{window.addEventListener("storage",(e=>{null!==e.key&&"activeLogin"!==e.key||window.location.reload()}))}catch(e){}};const at=()=>[],st={empty:e=>qe(0===e.length),exists:(e,t)=>qe(t?e.filter((e=>He(t.eval([e])))).length>0:e.length>0),all:(e,t)=>qe(e.every((e=>He(t.eval([e]))))),allTrue:e=>{for(const t of e)if(!t.value)return qe(!1);return qe(!0)},anyTrue:e=>{for(const t of e)if(t.value)return qe(!0);return qe(!1)},allFalse:e=>{for(const t of e)if(t.value)return qe(!1);return qe(!0)},anyFalse:e=>{for(const t of e)if(!t.value)return qe(!0);return qe(!1)},subsetOf:at,supersetOf:at,count:t=>[{type:e.PropertyType.integer,value:t.length}],distinct:e=>{const t=[];for(const i of e)t.some((e=>e.value===i.value))||t.push(i);return t},isDistinct:e=>qe(e.length===st.distinct(e).length),where:(e,t)=>e.filter((e=>He(t.eval([e])))),select:(e,t)=>e.map((e=>t.eval([e]))).flat(),repeat:at,ofType:(e,t)=>e.filter((e=>e.type===t.name)),single:e=>{if(e.length>1)throw new Error("Expected input length one for single()");return 0===e.length?[]:e.slice(0,1)},first:e=>0===e.length?[]:e.slice(0,1),last:e=>0===e.length?[]:e.slice(e.length-1,e.length),tail:e=>0===e.length?[]:e.slice(1,e.length),skip:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for skip(num)");return n>=e.length?[]:n<=0?e:e.slice(n,e.length)},take:(e,t)=>{var i;const n=null===(i=t.eval(e)[0])||void 0===i?void 0:i.value;if("number"!=typeof n)throw new Error("Expected a number for take(num)");return n>=e.length?e:n<=0?[]:e.slice(0,n)},intersect:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)!n.some((e=>e.value===t.value))&&i.some((e=>e.value===t.value))&&n.push(t);return n},exclude:(e,t)=>{if(!t)return e;const i=t.eval(e),n=[];for(const t of e)i.some((e=>e.value===t.value))||n.push(t);return n},union:(e,t)=>{if(!t)return e;const i=t.eval(e);return Ge([...e,...i])},combine:(e,t)=>{if(!t)return e;const i=t.eval(e);return[...e,...i]},iif:(e,t,i,n)=>{const o=t.eval(e);if(o.length>1||1===o.length&&"boolean"!=typeof o[0].value)throw new Error("Expected criterion to evaluate to a Boolean");return He(o)?i.eval(e):n?n.eval(e):[]},toBoolean:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);if("boolean"==typeof i)return[{type:e.PropertyType.boolean,value:i}];if("number"==typeof i&&(0===i||1===i))return qe(!!i);if("string"==typeof i){const e=i.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(e))return qe(!0);if(["false","f","no","n","0","0.0"].includes(e))return qe(!1)}return[]},convertsToBoolean:e=>0===e.length?[]:qe(1===st.toBoolean(e).length),toInteger:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);return"number"==typeof i?[{type:e.PropertyType.integer,value:i}]:"string"==typeof i&&i.match(/^[+-]?\d+$/)?[{type:e.PropertyType.integer,value:parseInt(i,10)}]:"boolean"==typeof i?[{type:e.PropertyType.integer,value:i?1:0}]:[]},convertsToInteger:e=>0===e.length?[]:qe(1===st.toInteger(e).length),toDate:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.date,value:Qe(i)}]:[]},convertsToDate:e=>0===e.length?[]:qe(1===st.toDate(e).length),toDateTime:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);return"string"==typeof i&&i.match(/^\d{4}(-\d{2}(-\d{2})?)?/)?[{type:e.PropertyType.dateTime,value:Qe(i)}]:[]},convertsToDateTime:e=>0===e.length?[]:qe(1===st.toDateTime(e).length),toDecimal:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);return"number"==typeof i?[{type:e.PropertyType.decimal,value:i}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?$/)?[{type:e.PropertyType.decimal,value:parseFloat(i)}]:"boolean"==typeof i?[{type:e.PropertyType.decimal,value:i?1:0}]:[]},convertsToDecimal:e=>0===e.length?[]:qe(1===st.toDecimal(e).length),toQuantity:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);return it(i)?[{type:e.PropertyType.Quantity,value:i}]:"number"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i,unit:"1"}}]:"string"==typeof i&&i.match(/^-?\d{1,9}(\.\d{1,9})?/)?[{type:e.PropertyType.Quantity,value:{value:parseFloat(i),unit:"1"}}]:"boolean"==typeof i?[{type:e.PropertyType.Quantity,value:{value:i?1:0,unit:"1"}}]:[]},convertsToQuantity:e=>0===e.length?[]:qe(1===st.toQuantity(e).length),toString:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);return null==i?[]:it(i)?[{type:e.PropertyType.string,value:`${i.value} '${i.unit}'`}]:[{type:e.PropertyType.string,value:i.toString()}]},convertsToString:e=>0===e.length?[]:qe(1===st.toString(e).length),toTime:t=>{if(0===t.length)return[];const[{value:i}]=lt(t,1);if("string"==typeof i){const t=i.match(/^T?(\d{2}(:\d{2}(:\d{2})?)?)/);if(t)return[{type:e.PropertyType.time,value:Qe("T"+t[1])}]}return[]},convertsToTime:e=>0===e.length?[]:qe(1===st.toTime(e).length),indexOf:(e,t)=>ct(((e,t)=>e.indexOf(t)),e,t),substring:(e,t,i)=>ct(((e,t,i)=>{const n=t,o=i?n+i:e.length;return n<0||n>=e.length?void 0:e.substring(n,o)}),e,t,i),startsWith:(e,t)=>ct(((e,t)=>e.startsWith(t)),e,t),endsWith:(e,t)=>ct(((e,t)=>e.endsWith(t)),e,t),contains:(e,t)=>ct(((e,t)=>e.includes(t)),e,t),upper:e=>ct((e=>e.toUpperCase()),e),lower:e=>ct((e=>e.toLowerCase()),e),replace:(e,t,i)=>ct(((e,t,i)=>e.replaceAll(t,i)),e,t,i),matches:(e,t)=>ct(((e,t)=>!!e.match(t)),e,t),replaceMatches:(e,t,i)=>ct(((e,t,i)=>e.replaceAll(t,i)),e,t,i),length:e=>ct((e=>e.length),e),toChars:e=>ct((e=>e?e.split(""):void 0),e),abs:e=>dt(Math.abs,e),ceiling:e=>dt(Math.ceil,e),exp:e=>dt(Math.exp,e),floor:e=>dt(Math.floor,e),ln:e=>dt(Math.log,e),log:(e,t)=>dt(((e,t)=>Math.log(e)/Math.log(t)),e,t),power:(e,t)=>dt(Math.pow,e,t),round:e=>dt(Math.round,e),sqrt:e=>dt(Math.sqrt,e),truncate:e=>dt((e=>0|e),e),children:at,descendants:at,trace:(e,t)=>(console.log("trace",e,t),e),now:()=>[{type:e.PropertyType.dateTime,value:(new Date).toISOString()}],timeOfDay:()=>[{type:e.PropertyType.time,value:(new Date).toISOString().substring(11)}],today:()=>[{type:e.PropertyType.date,value:(new Date).toISOString().substring(0,10)}],between:(t,i,n,o)=>{var r;const a=st.toDateTime(i.eval(t));if(0===a.length)throw new Error("Invalid start date");const s=st.toDateTime(n.eval(t));if(0===s.length)throw new Error("Invalid end date");const c=null===(r=o.eval(t)[0])||void 0===r?void 0:r.value;if("years"!==c&&"months"!==c&&"days"!==c)throw new Error("Invalid units");const d=E(a[0].value,s[0].value);return[{type:e.PropertyType.Quantity,value:{value:d[c],unit:c}}]},is:(t,i)=>{let n="";return i instanceof Gt?n=i.name:i instanceof ti&&(n=i.left.name+"."+i.right.name),n?t.map((t=>({type:e.PropertyType.boolean,value:et(t,n)}))):[]},not:t=>st.toBoolean(t).map((t=>({type:e.PropertyType.boolean,value:!t.value}))),resolve:t=>t.map((t=>{const i=t.value;let n;if("string"==typeof i)n=i;else if("object"==typeof i){const e=i;if(e.resource)return Fe(e.resource);n=e.reference}if(!n)return{type:e.PropertyType.BackboneElement,value:null};const[o,r]=n.split("/");return{type:e.PropertyType.BackboneElement,value:{resourceType:o,id:r}}})).filter((e=>!!e.value)),as:e=>e,type:t=>t.map((({value:t})=>"boolean"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Boolean"}}:"number"==typeof t?{type:e.PropertyType.BackboneElement,value:{namespace:"System",name:"Integer"}}:t&&"object"==typeof t&&"resourceType"in t?{type:e.PropertyType.BackboneElement,value:{namespace:"FHIR",name:t.resourceType}}:{type:e.PropertyType.BackboneElement,value:null})),conformsTo:(t,i)=>{const n=i.eval(t)[0].value;if(!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=n.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map((t=>{var i;return{type:e.PropertyType.boolean,value:(null===(i=t.value)||void 0===i?void 0:i.resourceType)===o}}))}};function ct(e,t,...i){if(0===t.length)return[];const[{value:n}]=lt(t,1);if("string"!=typeof n)throw new Error("String function cannot be called with non-string");const o=e(n,...i.map((e=>{var i,n;return e&&(null===(n=null===(i=e.eval(t))||void 0===i?void 0:i[0])||void 0===n?void 0:n.value)})));return void 0===o?[]:Array.isArray(o)?o.map(Fe):[Fe(o)]}function dt(t,i,...n){if(0===i.length)return[];const[{value:o}]=lt(i,1),r=it(o),a=r?o.value:o;if("number"!=typeof a)throw new Error("Math function cannot be called with non-number");const s=t(a,...n.map((e=>{var t,n;return null===(n=null===(t=e.eval(i))||void 0===t?void 0:t[0])||void 0===n?void 0:n.value})));return[{type:r?e.PropertyType.Quantity:i[0].type,value:r?Object.assign(Object.assign({},o),{value:s}):s}]}function lt(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const t of e)if(null==t)throw new Error("Expected non-null argument");return e}var ut,mt,pt,ht,ft,yt,gt,xt,vt,Tt,Et,wt,St,bt,Pt,Dt,Ct,At,Rt,Ot,kt,It,Mt,Ut,Lt,Nt,jt,_t,Wt,Bt,Qt,qt,Ft,Ht;class $t{constructor(e,t){this.original=e,this.child=t}eval(e){try{return e.length>0?e.map((e=>this.child.eval([e]))).flat():this.child.eval([])}catch(e){throw new Error(`FhirPathError on "${this.original}": ${e}`)}}}class zt{constructor(e){this.value=e}eval(){return[this.value]}}class Gt{constructor(e){this.name=e,ut.add(this)}eval(e){return"$this"===this.name?e:e.map((e=>i(this,ut,"m",mt).call(this,e))).flat().filter((e=>void 0!==(null==e?void 0:e.value)))}}ut=new WeakSet,mt=function(e){const t=e.value;if(t&&"object"==typeof t)return"resourceType"in t&&t.resourceType===this.name?e:$e(e,this.name)};class Vt{eval(){return[]}}class Xt{constructor(e,t){this.child=e,this.impl=t}eval(e){return this.impl(this.child.eval(e))}}class Yt{constructor(e,t){this.left=e,this.right=t}eval(e){return st.ofType(this.left.eval(e),this.right)}}class Jt{constructor(e,t,i){this.left=e,this.right=t,this.impl=i}eval(t){const i=this.left.eval(t);if(1!==i.length)return[];const n=this.right.eval(t);if(1!==n.length)return[];const o=i[0].value,r=n[0].value,a=it(o)?o.value:o,s=it(r)?r.value:r,c=this.impl(a,s);return"boolean"==typeof c?qe(c):it(o)?[{type:e.PropertyType.Quantity,value:Object.assign(Object.assign({},o),{value:c})}]:[Fe(c)]}}class Kt{constructor(e,t){this.left=e,this.right=t}eval(t){const i=[...this.left.eval(t),...this.right.eval(t)];return i.length>0&&i.every((e=>"string"==typeof e.value))?[{type:e.PropertyType.string,value:i.map((e=>e.value)).join("")}]:i}}class Zt{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);return qe(t.some((e=>e.value===i[0].value)))}}class ei{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);return qe(this.right.eval(e).some((e=>e.value===t[0].value)))}}class ti{constructor(e,t){this.left=e,this.right=t}eval(e){return this.right.eval(this.left.eval(e))}}class ii{constructor(e,t){this.left=e,this.right=t}eval(e){return Ge([...this.left.eval(e),...this.right.eval(e)])}}class ni{constructor(e,t){this.left=e,this.right=t}eval(e){return Xe(this.left.eval(e),this.right.eval(e))}}class oi{constructor(e,t){this.left=e,this.right=t}eval(e){return Ve(Xe(this.left.eval(e),this.right.eval(e)))}}class ri{constructor(e,t){this.left=e,this.right=t}eval(e){return Je(this.left.eval(e),this.right.eval(e))}}class ai{constructor(e,t){this.left=e,this.right=t}eval(e){return Ve(Je(this.left.eval(e),this.right.eval(e)))}}class si{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(1!==t.length)return[];const i=this.right.name;return qe(et(t[0],i))}}class ci{constructor(e,t){this.left=e,this.right=t}eval(e){var t,i,n,o;const r=this.left.eval(e),a=this.right.eval(e);return!0===(null===(t=r[0])||void 0===t?void 0:t.value)&&!0===(null===(i=a[0])||void 0===i?void 0:i.value)?qe(!0):!1===(null===(n=r[0])||void 0===n?void 0:n.value)||!1===(null===(o=a[0])||void 0===o?void 0:o.value)?qe(!1):[]}}class di{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e);if(He(t))return t;const i=this.right.eval(e);return He(i)?i:[]}}class li{constructor(e,t){this.left=e,this.right=t}eval(e){const t=this.left.eval(e),i=this.right.eval(e);if(0===t.length&&0===i.length)return[];const n=0===t.length?null:t[0].value,o=0===i.length?null:i[0].value;return!0===n&&!0!==o||!0!==n&&!0===o?qe(!0):!0===n&&!0===o||!1===n&&!1===o?qe(!1):[]}}class ui{constructor(e,t,i){this.name=e,this.args=t,this.impl=i}eval(e){return this.impl(e,...this.args)}}class mi{constructor(e,t){this.left=e,this.expr=t}eval(e){const t=this.expr.eval(e);if(1!==t.length)return[];const i=t[0].value;if("number"!=typeof i)throw new Error("Invalid indexer expression: should return integer}");const n=this.left.eval(e);return i in n?[n[i]]:[]}}class pi{constructor(){pt.set(this,{}),ht.set(this,{})}registerInfix(e,t){return i(this,ht,"f")[e]=t,this}registerPrefix(e,t){return i(this,pt,"f")[e]=t,this}prefix(e,t,i){return this.registerPrefix(e,{parse(e,n){const o=e.consumeAndParse(t);return i(n,o)}})}infixLeft(e,t,i){return this.registerInfix(e,{parse(e,n,o){const r=e.consumeAndParse(t);return i(n,o,r)},precedence:t})}construct(e){return new hi(e,i(this,pt,"f"),i(this,ht,"f"))}}pt=new WeakMap,ht=new WeakMap;class hi{constructor(e,t,i){ft.set(this,void 0),yt.set(this,void 0),gt.set(this,void 0),n(this,ft,e,"f"),n(this,yt,t,"f"),n(this,gt,i,"f")}hasMore(){return i(this,ft,"f").length>0}match(e){const t=this.peek();return(null==t?void 0:t.id)===e&&(this.consume(),!0)}consumeAndParse(e=1/0){const t=this.consume(),n=i(this,yt,"f")[t.id];if(!n)throw Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);let o=n.parse(this,t);for(;e>this.getPrecedence();){const e=this.consume();o=i(this,gt,"f")[e.id].parse(this,o,e)}return o}getPrecedence(){const e=this.peek();if(!e)return 1/0;const t=i(this,gt,"f")[e.id];return t?t.precedence:1/0}consume(e){var t;if(!i(this,ft,"f").length)throw Error("Cant consume unknown more tokens.");if(e&&(null===(t=this.peek())||void 0===t?void 0:t.id)!==e){const t=this.peek();throw Error(`Expected ${e} but got "${t.value}" at line ${t.line} column ${t.column}.`)}return i(this,ft,"f").shift()}peek(){return i(this,ft,"f").length>0?i(this,ft,"f")[0]:void 0}removeComments(){n(this,ft,i(this,ft,"f").filter((e=>"Comment"!==e.id)),"f")}}ft=new WeakMap,yt=new WeakMap,gt=new WeakMap;const fi=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class yi{constructor(e,t,i){xt.add(this),vt.set(this,void 0),Tt.set(this,void 0),Et.set(this,void 0),wt.set(this,[]),St.set(this,{index:0,line:0,column:0}),bt.set(this,[]),n(this,vt,e,"f"),n(this,Tt,t,"f"),n(this,Et,i,"f")}tokenize(){for(;i(this,St,"f").index<i(this,vt,"f").length;){const e=i(this,xt,"m",Ct).call(this);e&&i(this,wt,"f").push(e)}return i(this,wt,"f")}}vt=new WeakMap,Tt=new WeakMap,Et=new WeakMap,wt=new WeakMap,St=new WeakMap,bt=new WeakMap,xt=new WeakSet,Pt=function(){return i(this,wt,"f").slice(-1)[0]},Dt=function(){i(this,xt,"m",Qt).call(this);const e=i(this,xt,"m",Ct).call(this);return i(this,xt,"m",qt).call(this),e},Ct=function(){i(this,xt,"m",At).call(this);const e=i(this,xt,"m",_t).call(this);if(!e)return;i(this,xt,"m",Qt).call(this);const t=i(this,xt,"m",Bt).call(this);return"/"===e&&"*"===t?i(this,xt,"m",Rt).call(this):"/"===e&&"/"===t?i(this,xt,"m",Ot).call(this):"'"===e||'"'===e?i(this,xt,"m",kt).call(this,e):"`"===e?i(this,xt,"m",It).call(this):"@"===e?i(this,xt,"m",Mt).call(this):e.match(/\d/)?i(this,xt,"m",Ut).call(this):e.match(/\w/)||"$"===e&&t.match(/\w/)?i(this,xt,"m",Lt).call(this):i(this,xt,"m",Nt).call(this)},At=function(){i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/\s/)))},Rt=function(){const e=i(this,St,"f").index;return i(this,xt,"m",jt).call(this,(()=>"*"!==i(this,xt,"m",_t).call(this)||"/"!==i(this,xt,"m",Bt).call(this))),i(this,xt,"m",Ft).call(this),i(this,xt,"m",Ft).call(this),i(this,xt,"m",Ht).call(this,"Comment",i(this,vt,"f").substring(e,i(this,St,"f").index))},Ot=function(){return i(this,xt,"m",Ht).call(this,"Comment",i(this,xt,"m",jt).call(this,(()=>"\n"!==i(this,xt,"m",_t).call(this))))},kt=function(e){i(this,xt,"m",Ft).call(this);const t=i(this,xt,"m",Ht).call(this,"String",i(this,xt,"m",jt).call(this,(()=>"\\"===i(this,xt,"m",Wt).call(this)||i(this,xt,"m",_t).call(this)!==e)));return i(this,xt,"m",Ft).call(this),t},It=function(){i(this,xt,"m",Ft).call(this);const e=i(this,xt,"m",Ht).call(this,"Symbol",i(this,xt,"m",jt).call(this,(()=>"`"!==i(this,xt,"m",_t).call(this))));return i(this,xt,"m",Ft).call(this),e},Mt=function(){i(this,xt,"m",Ft).call(this);const e=i(this,St,"f").index;return i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/[\d-]/))),"T"===i(this,xt,"m",_t).call(this)&&(i(this,xt,"m",Ft).call(this),i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/[\d:]/))),"."===i(this,xt,"m",_t).call(this)&&i(this,xt,"m",Bt).call(this).match(/\d/)&&(i(this,xt,"m",Ft).call(this),i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/\d/)))),"Z"===i(this,xt,"m",_t).call(this)?i(this,xt,"m",Ft).call(this):"+"!==i(this,xt,"m",_t).call(this)&&"-"!==i(this,xt,"m",_t).call(this)||(i(this,xt,"m",Ft).call(this),i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/[\d:]/))))),i(this,xt,"m",Ht).call(this,"DateTime",i(this,vt,"f").substring(e,i(this,St,"f").index))},Ut=function(){const e=i(this,St,"f").index;let t="Number";return i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/\d/))),"."===i(this,xt,"m",_t).call(this)&&i(this,xt,"m",Bt).call(this).match(/\d/)&&(i(this,xt,"m",Ft).call(this),i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/\d/))))," "===i(this,xt,"m",_t).call(this)&&function(e){if(e){if("String"===e.id)return!0;if("Symbol"===e.id&&fi.includes(e.value))return!0}return!1}(i(this,xt,"m",Dt).call(this))&&(t="Quantity",i(this,xt,"m",Ct).call(this)),i(this,xt,"m",Ht).call(this,t,i(this,vt,"f").substring(e,i(this,St,"f").index))},Lt=function(){var e;const t=i(this,xt,"m",jt).call(this,(()=>i(this,xt,"m",_t).call(this).match(/[$\w]/)));return"."!==(null===(e=i(this,xt,"m",Pt).call(this))||void 0===e?void 0:e.value)&&i(this,Tt,"f").includes(t)?i(this,xt,"m",Ht).call(this,t,t):i(this,xt,"m",Ht).call(this,"Symbol",t)},Nt=function(){const e=i(this,xt,"m",_t).call(this),t=e+i(this,xt,"m",Bt).call(this);return i(this,Et,"f").includes(t)?(i(this,xt,"m",Ft).call(this),i(this,xt,"m",Ft).call(this),i(this,xt,"m",Ht).call(this,t,t)):(i(this,xt,"m",Ft).call(this),i(this,xt,"m",Ht).call(this,e,e))},jt=function(e){const t=i(this,St,"f").index;for(;i(this,St,"f").index<i(this,vt,"f").length&&e();)i(this,xt,"m",Ft).call(this);return i(this,vt,"f").substring(t,i(this,St,"f").index)},_t=function(){return i(this,vt,"f")[i(this,St,"f").index]},Wt=function(){var e;return null!==(e=i(this,vt,"f")[i(this,St,"f").index-1])&&void 0!==e?e:""},Bt=function(){var e;return null!==(e=i(this,vt,"f")[i(this,St,"f").index+1])&&void 0!==e?e:""},Qt=function(){i(this,bt,"f").push(Object.assign({},i(this,St,"f")))},qt=function(){const e=i(this,bt,"f").pop();if(!e)throw new Error("No mark to reset to");i(this,St,"f").index=e.index,i(this,St,"f").line=e.line,i(this,St,"f").column=e.column},Ft=function(){i(this,St,"f").index++,"\n"===i(this,xt,"m",_t).call(this)?(i(this,St,"f").line++,i(this,St,"f").column=0):i(this,St,"f").column++},Ht=function(e,t){const n=i(this,bt,"f").pop();if(!n)throw new Error("No mark for token");return Object.assign({id:e,value:t},n)};const gi=["true","false","and","as","contains","div","in","is","mod","or","xor"],xi=["!=","!~","<=",">=","{}","->"];function vi(e){return new yi(e,gi,xi).tokenize()}const Ti={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)`");return t}},Ei={parse(e,t){const i=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new mi(t,i)},precedence:2},wi={parse(e,t){if(!(t instanceof Gt))throw new Error("Unexpected parentheses");if(!(t.name in st))throw new Error("Unrecognized function: "+t.name);const i=[];for(;!e.match(")");)i.push(e.consumeAndParse()),e.match(",");return new ui(t.name,i,st[t.name])},precedence:0};function Si(e){const t=e.split(" "),i=parseFloat(t[0]);let n=t[1];return n=n&&n.startsWith("'")&&n.endsWith("'")?n.substring(1,n.length-1):"{"+n+"}",{value:i,unit:n}}function bi(){return(new pi).registerPrefix("String",{parse:(t,i)=>new zt({type:e.PropertyType.string,value:i.value})}).registerPrefix("DateTime",{parse:(t,i)=>new zt({type:e.PropertyType.dateTime,value:Qe(i.value)})}).registerPrefix("Quantity",{parse:(t,i)=>new zt({type:e.PropertyType.Quantity,value:Si(i.value)})}).registerPrefix("Number",{parse:(t,i)=>new zt({type:e.PropertyType.decimal,value:parseFloat(i.value)})}).registerPrefix("true",{parse:()=>new zt({type:e.PropertyType.boolean,value:!0})}).registerPrefix("false",{parse:()=>new zt({type:e.PropertyType.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new Gt(t.value)}).registerPrefix("{}",{parse:()=>new Vt}).registerPrefix("(",Ti).registerInfix("[",Ei).registerInfix("(",wi).prefix("+",3,((e,t)=>new Xt(t,(e=>e)))).prefix("-",3,((e,t)=>new Jt(t,t,((e,t)=>-t)))).infixLeft(".",1,((e,t,i)=>new ti(e,i))).infixLeft("/",4,((e,t,i)=>new Jt(e,i,((e,t)=>e/t)))).infixLeft("*",4,((e,t,i)=>new Jt(e,i,((e,t)=>e*t)))).infixLeft("+",5,((e,t,i)=>new Jt(e,i,((e,t)=>e+t)))).infixLeft("-",5,((e,t,i)=>new Jt(e,i,((e,t)=>e-t)))).infixLeft("|",7,((e,t,i)=>new ii(e,i))).infixLeft("=",9,((e,t,i)=>new ni(e,i))).infixLeft("!=",9,((e,t,i)=>new oi(e,i))).infixLeft("~",9,((e,t,i)=>new ri(e,i))).infixLeft("!~",9,((e,t,i)=>new ai(e,i))).infixLeft("<",8,((e,t,i)=>new Jt(e,i,((e,t)=>e<t)))).infixLeft("<=",8,((e,t,i)=>new Jt(e,i,((e,t)=>e<=t)))).infixLeft(">",8,((e,t,i)=>new Jt(e,i,((e,t)=>e>t)))).infixLeft(">=",8,((e,t,i)=>new Jt(e,i,((e,t)=>e>=t)))).infixLeft("&",5,((e,t,i)=>new Kt(e,i))).infixLeft("and",6,((e,t,i)=>new ci(e,i))).infixLeft("as",6,((e,t,i)=>new Yt(e,i))).infixLeft("contains",6,((e,t,i)=>new Zt(e,i))).infixLeft("div",6,((e,t,i)=>new Jt(e,i,((e,t)=>e/t|0)))).infixLeft("in",6,((e,t,i)=>new ei(e,i))).infixLeft("is",6,((e,t,i)=>new si(e,i))).infixLeft("mod",6,((e,t,i)=>new Jt(e,i,((e,t)=>e%t)))).infixLeft("or",6,((e,t,i)=>new di(e,i))).infixLeft("xor",6,((e,t,i)=>new li(e,i)))}const Pi=bi();function Di(e){return new $t(e,Pi.construct(vi(e)).consumeAndParse())}function Ci(e,t){return Di(e).eval(t)}class Ai{constructor(e){this.segments=e}get(e){return"number"==typeof e?this.segments[e]:this.segments.find((t=>t.name===e))}getAll(e){return this.segments.filter((t=>t.name===e))}toString(){return this.segments.map((e=>e.toString())).join("\r")}buildAck(){var e,t,i,n,o,r;const a=new Date,s=this.get("MSH"),c=(null===(e=null==s?void 0:s.get(2))||void 0===e?void 0:e.toString())||"",d=(null===(t=null==s?void 0:s.get(3))||void 0===t?void 0:t.toString())||"",l=(null===(i=null==s?void 0:s.get(4))||void 0===i?void 0:i.toString())||"",u=(null===(n=null==s?void 0:s.get(5))||void 0===n?void 0:n.toString())||"",m=(null===(o=null==s?void 0:s.get(9))||void 0===o?void 0:o.toString())||"",p=(null===(r=null==s?void 0:s.get(12))||void 0===r?void 0:r.toString())||"2.5.1";return new Ai([new Ri(["MSH","^~\\&",l,u,c,d,a.toISOString(),"","ACK",a.getTime().toString(),"P",p]),new Ri(["MSA","AA",m,"OK"])])}static parse(e){if(!e.startsWith("MSH|^~\\&")){const e=new Error("Invalid HL7 message");throw e.type="entity.parse.failed",e}return new Ai(e.split(/[\r\n]+/).map((e=>Ri.parse(e))))}}class Ri{constructor(e){A(e)?this.fields=e.map((e=>Oi.parse(e))):this.fields=e,this.name=this.fields[0].components[0]}get(e){return this.fields[e]}toString(){return this.fields.map((e=>e.toString())).join("|")}static parse(e){return new Ri(e.split("|").map((e=>Oi.parse(e))))}}class Oi{constructor(e){this.components=e}get(e){return this.components[e]}toString(){return this.components.join("^")}static parse(e){return new Oi(e.split("^"))}}const ki="ok",Ii="created",Mi="gone",Ui="not-modified",Li="not-found",Ni="unauthorized",ji="forbidden",_i="too-many-requests",Wi={resourceType:"OperationOutcome",id:ki,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},Bi={resourceType:"OperationOutcome",id:Ii,issue:[{severity:"information",code:"informational",details:{text:"Created"}}]},Qi={resourceType:"OperationOutcome",id:Ui,issue:[{severity:"information",code:"informational",details:{text:"Not Modified"}}]},qi={resourceType:"OperationOutcome",id:Li,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},Fi={resourceType:"OperationOutcome",id:Ni,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Hi={resourceType:"OperationOutcome",id:ji,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]},$i={resourceType:"OperationOutcome",id:Mi,issue:[{severity:"error",code:"deleted",details:{text:"Gone"}}]},zi={resourceType:"OperationOutcome",id:_i,issue:[{severity:"error",code:"throttled",details:{text:"Too Many Requests"}}]};function Gi(e){return e.id===ki||e.id===Ii||e.id===Ui}class Vi extends Error{constructor(e){var t,i;super(null===(i=null===(t=null==e?void 0:e.issue)||void 0===t?void 0:t[0].details)||void 0===i?void 0:i.text),this.outcome=e}}var Xi;e.Operator=void 0,(Xi=e.Operator||(e.Operator={})).EQUALS="eq",Xi.NOT_EQUALS="ne",Xi.GREATER_THAN="gt",Xi.LESS_THAN="lt",Xi.GREATER_THAN_OR_EQUALS="ge",Xi.LESS_THAN_OR_EQUALS="le",Xi.STARTS_AFTER="sa",Xi.ENDS_BEFORE="eb",Xi.APPROXIMATELY="ap",Xi.CONTAINS="contains",Xi.EXACT="exact",Xi.TEXT="text",Xi.NOT="not",Xi.ABOVE="above",Xi.BELOW="below",Xi.IN="in",Xi.NOT_IN="not-in",Xi.OF_TYPE="of-type",Xi.MISSING="missing";const Yi=[e.Operator.CONTAINS,e.Operator.EXACT,e.Operator.TEXT,e.Operator.NOT,e.Operator.ABOVE,e.Operator.BELOW,e.Operator.IN,e.Operator.NOT_IN,e.Operator.OF_TYPE,e.Operator.MISSING],Ji=[e.Operator.NOT_EQUALS,e.Operator.GREATER_THAN,e.Operator.LESS_THAN,e.Operator.GREATER_THAN_OR_EQUALS,e.Operator.LESS_THAN_OR_EQUALS,e.Operator.STARTS_AFTER,e.Operator.ENDS_BEFORE,e.Operator.APPROXIMATELY];var Ki;function Zi(t,i){let n=e.SearchParameterType.TEXT;switch(t.type){case"date":n=i===e.PropertyType.dateTime||i===e.PropertyType.instant?e.SearchParameterType.DATETIME:e.SearchParameterType.DATE;break;case"number":n=e.SearchParameterType.NUMBER;break;case"quantity":n=e.SearchParameterType.QUANTITY;break;case"reference":n=e.SearchParameterType.REFERENCE;break;case"token":"boolean"===i&&(n=e.SearchParameterType.BOOLEAN)}return n}function en(e,t){const i=t.split(" | ");for(const t of i){if((n=t).includes(" as Period")||n.includes(" as SampledDate"))continue;const i=tn(t);if(i.startsWith(e+"."))return i}var n}function tn(e){let t=e.trim();t.startsWith("(")&&t.endsWith(")")&&(t=t.substring(1,t.length-1)),t.includes("[0]")&&(t=t.replaceAll("[0]",""));const i=[" != "," as ",".as(",".exists(",".where("];for(const e of i)t.includes(e)&&(t=t.substring(0,t.indexOf(e)));return t}e.SearchParameterType=void 0,(Ki=e.SearchParameterType||(e.SearchParameterType={})).BOOLEAN="BOOLEAN",Ki.NUMBER="NUMBER",Ki.QUANTITY="QUANTITY",Ki.TEXT="TEXT",Ki.REFERENCE="REFERENCE",Ki.DATE="DATE",Ki.DATETIME="DATETIME",Ki.PERIOD="PERIOD",e.AndAtom=ci,e.ArithemticOperatorAtom=Jt,e.AsAtom=Yt,e.COMPONENT_SEPARATOR="^",e.ConcatAtom=Kt,e.ContainsAtom=Zt,e.DEFAULT_SEARCH_COUNT=20,e.DotAtom=ti,e.EmptySetAtom=Vt,e.EqualsAtom=ni,e.EquivalentAtom=ri,e.FHIRPATH_KEYWORDS=gi,e.FHIRPATH_OPERATORS=xi,e.FIELD_SEPARATOR="|",e.FhirPathAtom=$t,e.FunctionAtom=ui,e.Hl7Field=Oi,e.Hl7Message=Ai,e.Hl7Segment=Ri,e.InAtom=ei,e.IndexerAtom=mi,e.IsAtom=si,e.LRUCache=c,e.LiteralAtom=zt,e.MedplumClient=class extends class{constructor(){Q.set(this,void 0),n(this,Q,{},"f")}addEventListener(e,t){i(this,Q,"f")[e]||(i(this,Q,"f")[e]=[]),i(this,Q,"f")[e].push(t)}removeEventListeneer(e,t){const n=i(this,Q,"f")[e];if(n)for(let e=0;e<n.length;e++)if(n[e]===t)return void n.splice(e,1)}dispatchEvent(e){const t=i(this,Q,"f")[e.type];return t&&t.forEach((t=>t.call(this,e))),!e.defaultPrevented}}{constructor(e){var t,o;if(super(),se.add(this),ce.set(this,void 0),de.set(this,void 0),le.set(this,void 0),ue.set(this,void 0),me.set(this,void 0),pe.set(this,void 0),he.set(this,void 0),fe.set(this,void 0),ye.set(this,void 0),ge.set(this,void 0),xe.set(this,void 0),ve.set(this,void 0),Te.set(this,void 0),Ee.set(this,void 0),we.set(this,void 0),Se.set(this,void 0),be.set(this,void 0),(null==e?void 0:e.baseUrl)&&!e.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");n(this,ce,(null==e?void 0:e.fetch)||window.fetch.bind(window),"f"),n(this,de,null==e?void 0:e.createPdf,"f"),n(this,le,new K,"f"),n(this,ue,new c(null!==(t=null==e?void 0:e.resourceCacheSize)&&void 0!==t?t:1e3),"f"),n(this,me,null!==(o=null==e?void 0:e.cacheTime)&&void 0!==o?o:6e4,"f"),n(this,pe,function(e){if(!e)return e;return e.endsWith("/")?e:e+"/"}(null==e?void 0:e.baseUrl)||"https://api.medplum.com/","f"),n(this,he,(null==e?void 0:e.clientId)||"","f"),n(this,fe,(null==e?void 0:e.authorizeUrl)||i(this,pe,"f")+"oauth2/authorize","f"),n(this,ye,(null==e?void 0:e.tokenUrl)||i(this,pe,"f")+"oauth2/token","f"),n(this,ge,(null==e?void 0:e.logoutUrl)||i(this,pe,"f")+"oauth2/logout","f"),n(this,xe,null==e?void 0:e.onUnauthenticated,"f");const r=this.getActiveLogin();r&&(n(this,ve,r.accessToken,"f"),n(this,Te,r.refreshToken,"f"),i(this,se,"m",De).call(this).catch(console.log)),i(this,se,"m",_e).call(this)}getBaseUrl(){return i(this,pe,"f")}clear(){i(this,le,"f").clear(),i(this,ue,"f").clear(),n(this,ve,void 0,"f"),n(this,Te,void 0,"f"),n(this,Se,void 0,"f"),n(this,be,void 0,"f"),this.dispatchEvent({type:"change"})}invalidateUrl(e){e=e.toString(),i(this,ue,"f").delete(e)}invalidateSearches(e){const t="fhir/R4/"+e;for(const e of i(this,ue,"f").keys())(e.endsWith(t)||e.includes(t+"?"))&&i(this,ue,"f").delete(e)}get(e,t={}){e=e.toString();const n=i(this,se,"m",Ce).call(this,e,t);if(n)return n.value;const o=new J(i(this,se,"m",Re).call(this,"GET",e,t));return i(this,se,"m",Ae).call(this,e,o),o}post(e,t,n,o={}){return e=e.toString(),t&&i(this,se,"m",Ie).call(this,o,t),n&&i(this,se,"m",ke).call(this,o,n),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"POST",e,o)}put(e,t,n,o={}){return e=e.toString(),t&&i(this,se,"m",Ie).call(this,o,t),n&&i(this,se,"m",ke).call(this,o,n),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"PUT",e,o)}patch(e,t,n={}){return e=e.toString(),i(this,se,"m",Ie).call(this,n,t),i(this,se,"m",ke).call(this,n,"application/json-patch+json"),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"PATCH",e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),i(this,se,"m",Re).call(this,"DELETE",e,t)}startNewUser(e){return t(this,void 0,void 0,(function*(){return yield this.startPkce(),this.post("auth/newuser",Object.assign(Object.assign({},e),{codeChallengeMethod:"S256",codeChallenge:sessionStorage.getItem("codeChallenge")}))}))}startNewProject(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newproject",e)}))}startNewPatient(e){return t(this,void 0,void 0,(function*(){return this.post("auth/newpatient",e)}))}startLogin(e){var n,o;return t(this,void 0,void 0,(function*(){const{codeChallenge:t,codeChallengeMethod:r}=this.getCodeChallenge(e);return this.post("auth/login",Object.assign(Object.assign({},e),{clientId:null!==(n=e.clientId)&&void 0!==n?n:i(this,he,"f"),scope:null!==(o=e.scope)&&void 0!==o?o:We,codeChallengeMethod:r,codeChallenge:t}))}))}startGoogleLogin(e){var n,o;return t(this,void 0,void 0,(function*(){const{codeChallenge:t,codeChallengeMethod:r}=this.getCodeChallenge(e);return this.post("auth/google",Object.assign(Object.assign({},e),{clientId:null!==(n=e.clientId)&&void 0!==n?n:i(this,he,"f"),scope:null!==(o=e.scope)&&void 0!==o?o:We,codeChallengeMethod:r,codeChallenge:t}))}))}getCodeChallenge(e){if(e.codeChallenge)return{codeChallenge:e.codeChallenge,codeChallengeMethod:e.codeChallengeMethod};const t=sessionStorage.getItem("codeChallenge");return t?{codeChallenge:t,codeChallengeMethod:"S256"}:{}}signOut(){this.clear()}signInWithRedirect(){return t(this,void 0,void 0,(function*(){const e=new URLSearchParams(window.location.search).get("code");return e?this.processCode(e):void(yield i(this,se,"m",Ue).call(this))}))}signOutWithRedirect(){window.location.assign(i(this,ge,"f"))}fhirUrl(...e){return new URL(i(this,pe,"f")+"fhir/R4/"+e.join("/"))}fhirSearchUrl(e,t){const i=this.fhirUrl(e);return t&&(i.search=t.toString()),i}search(e,t,i={}){return this.get(this.fhirSearchUrl(e,t),i)}searchOne(e,t,n={}){const o=this.fhirSearchUrl(e,t);o.searchParams.set("_count","1"),o.searchParams.sort();const r=o.toString()+"-searchOne",a=i(this,se,"m",Ce).call(this,r,n);if(a)return a.value;const s=new J(this.search(e,o.searchParams,n).then((e=>{var t,i;return null===(i=null===(t=e.entry)||void 0===t?void 0:t[0])||void 0===i?void 0:i.resource})));return i(this,se,"m",Ae).call(this,r,s),s}searchResources(e,t,n={}){const o=this.fhirSearchUrl(e,t).toString()+"-searchResources",r=i(this,se,"m",Ce).call(this,o,n);if(r)return r.value;const a=new J(this.search(e,t,n).then((e=>{var t,i;return null!==(i=null===(t=e.entry)||void 0===t?void 0:t.map((e=>e.resource)))&&void 0!==i?i:[]})));return i(this,se,"m",Ae).call(this,o,a),a}searchValueSet(e,t,i={}){const n=this.fhirUrl("ValueSet","$expand");return n.searchParams.set("url",e),n.searchParams.set("filter",t),this.get(n.toString(),i)}getCached(e,t){var n;const o=null===(n=i(this,ue,"f").get(this.fhirUrl(e,t).toString()))||void 0===n?void 0:n.value;return o&&o.isOk()?o.read():void 0}getCachedReference(e){const t=e.reference;if(!t)return;const[i,n]=t.split("/");return i&&n?this.getCached(i,n):void 0}readResource(e,t,i={}){return this.get(this.fhirUrl(e,t),i)}readReference(e,t={}){const i=null==e?void 0:e.reference;if(!i)return new J(Promise.reject(new Error("Missing reference")));const[n,o]=i.split("/");return n&&o?this.readResource(n,o,t):new J(Promise.reject(new Error("Invalid reference")))}getSchema(){return ae}requestSchema(e){return t(this,void 0,void 0,(function*(){if(e in ae.types)return ae;const t=`{\n StructureDefinitionList(name: "${e}") {\n name,\n description,\n snapshot {\n element {\n id,\n path,\n min,\n max,\n type {\n code,\n targetProfile\n },\n binding {\n valueSet\n },\n definition\n }\n }\n }\n SearchParameterList(base: "${e}", _count: 100) {\n base,\n code,\n type,\n expression,\n target\n }\n }`.replace(/\s+/g," "),i=yield this.graphql(t);for(const e of i.data.StructureDefinitionList)ie(e);for(const e of i.data.SearchParameterList)ne(e);return ae}))}readHistory(e,t,i={}){return this.get(this.fhirUrl(e,t,"_history"),i)}readVersion(e,t,i,n={}){return this.get(this.fhirUrl(e,t,"_history",i),n)}readPatientEverything(e,t={}){return this.get(this.fhirUrl("Patient",e,"$everything"),t)}createResource(e){if(!e.resourceType)throw new Error("Missing resourceType");return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e)}createResourceIfNoneExist(e,i){var n;return t(this,void 0,void 0,(function*(){return null!==(n=yield this.searchOne(e.resourceType,i))&&void 0!==n?n:this.createResource(e)}))}createBinary(e,t,i){const n=this.fhirUrl("Binary");return t&&n.searchParams.set("_filename",t),this.post(n,e,i)}createPdf(e,n,o,r){return t(this,void 0,void 0,(function*(){if(!i(this,de,"f"))throw new Error("PDF creation not enabled");const t=yield i(this,de,"f").call(this,e,o,r);return this.createBinary(t,n,"application/pdf")}))}createComment(e,t){const i=this.getProfile();let n,o;return"Encounter"===e.resourceType&&(n=y(e),o=e.subject),"ServiceRequest"===e.resourceType&&(n=e.encounter,o=e.subject),"Patient"===e.resourceType&&(o=y(e)),this.createResource({resourceType:"Communication",basedOn:[y(e)],encounter:n,subject:o,sender:i?y(i):void 0,sent:(new Date).toISOString(),payload:[{contentString:t}]})}updateResource(e){return t(this,void 0,void 0,(function*(){if(!e.resourceType)throw new Error("Missing resourceType");if(!e.id)throw new Error("Missing id");this.invalidateSearches(e.resourceType);const t=yield this.put(this.fhirUrl(e.resourceType,e.id),e);return null!=t?t:e}))}patchResource(e,t,i){return this.invalidateSearches(e),this.patch(this.fhirUrl(e,t),i)}deleteResource(e,t){return this.invalidateSearches(e),this.delete(this.fhirUrl(e,t))}executeBatch(e){return this.post("fhir/R4",e)}sendEmail(e){return this.post("email/v1/send",e,"application/json")}graphql(e,t,i,n){return this.post(this.fhirUrl("$graphql"),{query:e,operationName:t,variables:i},"application/json",n)}readResourceGraph(e,t,i){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${i}`)}getActiveLogin(){return i(this,le,"f").getObject("activeLogin")}setActiveLogin(e){return t(this,void 0,void 0,(function*(){n(this,ve,e.accessToken,"f"),n(this,Te,e.refreshToken,"f"),n(this,Se,void 0,"f"),n(this,be,void 0,"f"),i(this,le,"f").setObject("activeLogin",e),i(this,se,"m",Pe).call(this,e),i(this,ue,"f").clear(),n(this,Ee,void 0,"f"),yield i(this,se,"m",De).call(this)}))}getAccessToken(){return i(this,ve,"f")}setAccessToken(e){n(this,ve,e,"f"),n(this,Te,void 0,"f"),n(this,Se,void 0,"f"),n(this,be,void 0,"f")}getLogins(){var e;return null!==(e=i(this,le,"f").getObject("logins"))&&void 0!==e?e:[]}isLoading(){return!!i(this,we,"f")}getProfile(){return i(this,Se,"f")}getProfileAsync(){return t(this,void 0,void 0,(function*(){return i(this,we,"f")&&(yield i(this,we,"f")),this.getProfile()}))}getUserConfiguration(){return i(this,be,"f")}download(e,n={}){return t(this,void 0,void 0,(function*(){i(this,Ee,"f")&&(yield i(this,Ee,"f")),i(this,se,"m",Oe).call(this,n);return(yield i(this,ce,"f").call(this,e.toString(),n)).blob()}))}startPkce(){return t(this,void 0,void 0,(function*(){const e=B();sessionStorage.setItem("pkceState",e);const i=B();sessionStorage.setItem("codeVerifier",i);const n=k(yield function(e){return t(this,void 0,void 0,(function*(){return crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e))}))}(i)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");sessionStorage.setItem("codeChallenge",n)}))}processCode(e){const t=new URLSearchParams;t.set("grant_type","authorization_code"),t.set("client_id",i(this,he,"f")),t.set("code",e),t.set("redirect_uri",Be());const n=sessionStorage.getItem("codeVerifier");return n&&t.set("code_verifier",n),i(this,se,"m",Ne).call(this,t)}startClientLogin(e,n){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;return t.set("grant_type","client_credentials"),t.set("client_id",e),t.set("client_secret",n),i(this,se,"m",Ne).call(this,t)}))}},e.NotEqualsAtom=oi,e.NotEquivalentAtom=ai,e.OperationOutcomeError=Vi,e.OrAtom=di,e.ReadablePromise=J,e.SEGMENT_SEPARATOR="\r",e.SymbolAtom=Gt,e.UnaryOperatorAtom=Xt,e.UnionAtom=ii,e.XorAtom=li,e.allOk=Wi,e.arrayBufferToBase64=k,e.arrayBufferToHex=O,e.assertOk=function(e,t){if(!Gi(e)||void 0===t)throw new Vi(e)},e.badRequest=function(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}},e.booleanToTypedValue=qe,e.buildTypeName=oe,e.calculateAge=E,e.calculateAgeString=function(e,t){const{years:i,months:n,days:o}=E(e,t);return i>=2?i.toString().padStart(3,"0")+"Y":n>=1?n.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"},e.capitalize=I,e.createReference=y,e.createSchema=function(){return{types:{}}},e.created=Bi,e.deepClone=function(e){return JSON.parse(JSON.stringify(e))},e.deepEquals=D,e.evalFhirPath=function(e,t){const i=Array.isArray(t)?t:[t];for(let e=0;e<i.length;e++){const t=i[e];"object"==typeof t&&"type"in t&&"value"in t||(i[e]=Fe(i[e]))}return Ci(e,i).map((e=>e.value))},e.evalFhirPathTyped=Ci,e.fhirPathArrayEquals=Xe,e.fhirPathArrayEquivalent=Je,e.fhirPathEquals=Ye,e.fhirPathEquivalent=Ke,e.fhirPathIs=et,e.fhirPathNot=Ve,e.findObservationInterval=function(e,t,i,n){var o;return null===(o=e.qualifiedInterval)||void 0===o?void 0:o.find((o=>{var r;return M(o,t)&&function(e,t,i){return!!e.range&&U(t,e.range,i)}(o,i,null===(r=e.quantitativeDetails)||void 0===r?void 0:r.decimalPrecision)&&(void 0===n||o.category===n)}))},e.findObservationReferenceRange=function(e,t,i){var n;return null===(n=e.qualifiedInterval)||void 0===n?void 0:n.find((e=>M(e,t)&&i.includes(e.condition)))},e.forbidden=Hi,e.formatAddress=function(e,t){const i=[];return e.line&&i.push(...e.line),e.city&&i.push(e.city),e.state&&i.push(e.state),e.postalCode&&i.push(e.postalCode),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&i.push("["+e.use+"]"),i.join(", ").trim()},e.formatDate=function(e,t){if(!e)return"";const i=new Date(e);return l(i)?i.toLocaleDateString(void 0,t):""},e.formatDateTime=m,e.formatFamilyName=function(e){return e.family||""},e.formatGivenName=function(e){const t=[];return e.given&&t.push(...e.given),t.join(" ").trim()},e.formatHumanName=d,e.formatPeriod=function(e){return e&&(e.start||e.end)?m(e.start)+" - "+m(e.end):""},e.formatSearchQuery=function(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach((e=>t.push(function(e){const t=Yi.includes(e.operator)?":"+e.operator:"",i=Ji.includes(e.operator)?e.operator:"";return`${e.code}${t}=${i}${encodeURIComponent(e.value)}`}(e)))),e.sortRules&&e.sortRules.length>0&&t.push(function(e){if(!e||0===e.length)return"";return"_sort="+e.map((e=>e.descending?"-"+e.code:e.code)).join(",")}(e.sortRules)),void 0!==e.offset&&t.push("_offset="+e.offset),void 0!==e.count&&t.push("_count="+e.count),void 0!==e.total&&t.push("_total="+e.total),0===t.length?"":(t.sort(),"?"+t.join("&"))},e.formatTime=u,e.formatTiming=function(e){var t;if(!e)return"";const i=[];if(null===(t=e.repeat)||void 0===t?void 0:t.periodUnit){const t=e.repeat.frequency||1,n=e.repeat.period||1,o=e.repeat.periodUnit;1===t&&1===n?i.push(p[o]):(1===t?i.push("once"):i.push(t+" times"),1===n?i.push("per "+h[o]):i.push("per "+n+" "+f[o])),e.repeat.dayOfWeek&&i.push("on "+e.repeat.dayOfWeek.map(I).join(", ")),e.repeat.timeOfDay&&i.push("at "+e.repeat.timeOfDay.map((e=>u(e))).join(", "))}return e.event&&i.push(e.event.map((e=>m(e))).join(", ")),I(i.join(" ").trim())},e.getCodeBySystem=function(e,t){var i,n;return null===(n=null===(i=null==e?void 0:e.coding)||void 0===i?void 0:i.find((e=>e.system===t)))||void 0===n?void 0:n.code},e.getDateProperty=function(e){return e?new Date(e):void 0},e.getDisplayString=v,e.getElementDefinition=re,e.getExpressionForResourceType=en,e.getExtensionValue=function(e,...t){var i;let n=e;for(let e=0;e<t.length&&n;e++)n=null===(i=null==n?void 0:n.extension)||void 0===i?void 0:i.find((i=>i.url===t[e]));return null==n?void 0:n.valueString},e.getIdentifier=function(e,t){const i=e.identifier;if(!i)return;const n=Array.isArray(i)?i:[i];for(const e of n)if(e.system===t)return e.value},e.getImageSrc=function(e){if(x(e)){const t=e.photo;if(t)for(const e of t){const t=T(e);if(t)return t}}if("Bot"===e.resourceType&&e.photo){const t=T(e.photo);if(t)return t}},e.getPropertyDisplayName=function(e){const t=e.replaceAll("[x]","").split(".").pop();return"id"===t?"ID":t.split(/(?=[A-Z])/).map(I).join(" ").replace("_"," ").replace(/\s+/g," ")},e.getQuestionnaireAnswers=function(e){const t={};return w(e.item,t),t},e.getReferenceString=g,e.getSearchParameterDetails=function(t,i){var n,o;let r=null===(o=null===(n=ae.types[t])||void 0===n?void 0:n.searchParamsDetails)||void 0===o?void 0:o[i.code];return r||(r=function(t,i){var n,o,r,a,s,c,d;if("_lastUpdated"===i.code)return{columnName:"lastUpdated",type:e.SearchParameterType.DATETIME};const l=i.code,u=function(e){return e.split("-").reduce(((e,t,i)=>e+(i?I(t):t)),"")}(l),m=null===(n=en(t,i.expression))||void 0===n?void 0:n.split(".");if(!m)return{columnName:u,type:e.SearchParameterType.TEXT};const p=Zi(i);let h,f,y=t,g=!1;for(let e=1;e<m.length;e++){const n=m[e];if(h=null!==(a=null===(r=null===(o=ae.types[y])||void 0===o?void 0:o.properties)||void 0===r?void 0:r[n])&&void 0!==a?a:null===(c=null===(s=ae.types[y])||void 0===s?void 0:s.properties)||void 0===c?void 0:c[n+"[x]"],!h)throw new Error(`Element definition not found for ${t} ${i.code}`);if("*"===h.max&&(g=!0),f=null===(d=h.type)||void 0===d?void 0:d[0].code,!f)return{columnName:u,type:p,array:g};e<m.length-1&&("Element"===f||"BackboneElement"===f?y+=I(n):y=f)}const x=Zi(i,f),v={columnName:u,type:x,elementDefinition:h,array:g};return function(e,t,i){const n=ae.types[e];n.searchParamsDetails||(n.searchParamsDetails={});n.searchParamsDetails[t]=i}(t,l,v),v}(t,i)),r},e.getStatus=function(e){return e.id===ki?200:e.id===Ii?201:e.id===Ui?304:e.id===Ni?401:e.id===ji?403:e.id===Li?404:e.id===Mi?410:e.id===_i?429:400},e.getTypedPropertyValue=$e,e.globalSchema=ae,e.gone=$i,e.indexSearchParameter=ne,e.indexStructureDefinition=ie,e.indexStructureDefinitionBundle=function(e){for(const t of e.entry){const e=t.resource;"StructureDefinition"===e.resourceType&&ie(e)}},e.initFhirPathParserBuilder=bi,e.isEmpty=P,e.isGone=function(e){return e.id===Mi},e.isLowerCase=function(e){return e===e.toLowerCase()&&e!==e.toUpperCase()},e.isNotFound=function(e){return e.id===Li},e.isObject=C,e.isOk=Gi,e.isPeriod=tt,e.isProfileResource=x,e.isQuantity=it,e.isQuantityEquivalent=nt,e.isStringArray=A,e.isUUID=function(e){return!!e.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i)},e.isValidDate=l,e.matchesRange=U,e.normalizeErrorString=function(e){var t,i,n,o;if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message;if("object"==typeof e&&"resourceType"in e){return null!==(o=null===(n=null===(i=null===(t=e.issue)||void 0===t?void 0:t[0])||void 0===i?void 0:i.details)||void 0===n?void 0:n.text)&&void 0!==o?o:"Unknown error"}return JSON.stringify(e)},e.notFound=qi,e.notModified=Qi,e.parseFhirPath=Di,e.parseJWTPayload=Y,e.parseSearchDefinition=function(t){const i=new URL(t,"https://example.com/"),n=i.pathname.replace(/(^\/)|(\/$)/g,"").split("/").pop();let o,r,a,s,c,d;return new URLSearchParams(i.search).forEach(((t,i)=>{"_fields"===i?a=t.split(","):"_offset"===i?s=parseInt(t):"_count"===i?c=parseInt(t):"_total"===i?d=t:"_sort"===i?(r=r||[],r.push(function(e){return e.startsWith("-")?{code:e.substring(1),descending:!0}:{code:e}}(t))):(o=o||[],o.push(function(t,i){let n=t,o=e.Operator.EQUALS;for(const e of Yi){const t=n.indexOf(":"+e);-1!==t&&(o=e,n=n.substring(0,t))}for(const e of Ji)i.match(new RegExp("^"+e+"\\d"))&&(o=e,i=i.substring(e.length));return{code:n,operator:o,value:i}}(i,t)))})),{resourceType:n,filters:o,fields:a,offset:s,count:c,total:d,sortRules:r}},e.preciseEquals=L,e.preciseGreaterThan=j,e.preciseGreaterThanOrEquals=W,e.preciseLessThan=N,e.preciseLessThanOrEquals=_,e.removeDuplicates=Ge,e.resolveId=function(e){var t;return null===(t=null==e?void 0:e.reference)||void 0===t?void 0:t.split("/")[1]},e.setCodeBySystem=function(e,t,i){var n,o;e.coding||(e.coding=[]);const r=null===(n=e.coding)||void 0===n?void 0:n.find((e=>e.system===t));r?r.code=i:null===(o=e.coding)||void 0===o||o.push({system:t,code:i})},e.stringify=S,e.toJsBoolean=He,e.toTypedValue=Fe,e.tokenize=vi,e.tooManyRequests=zi,e.unauthorized=Fi,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=index.min.js.map