@medplum/ccda 5.1.35 → 5.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +2 -2
- package/package.json +5 -5
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var po=Object.defineProperty;var ho=(t,e,r)=>e in t?po(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var D=(t,e,r)=>ho(t,typeof e!="symbol"?e+"":e,r);var fo=Object.defineProperty,mo=(t,e,r)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e,r)=>mo(t,typeof e!="symbol"?e+"":e,r),wt=class{constructor(t=10){O(this,"max"),O(this,"cache"),this.max=t,this.cache=new Map}clear(){this.cache.clear()}get(t){let e=this.cache.get(t);return e&&(this.cache.delete(t),this.cache.set(t,e)),e}set(t,e){this.cache.has(t)?this.cache.delete(t):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(t,e)}delete(t){this.cache.delete(t)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}},_o=class{constructor(t,e){O(this,"operator"),O(this,"child"),this.operator=t,this.child=e}toString(){return`${this.operator}(${this.child.toString()})`}},v=class{constructor(t,e,r){O(this,"operator"),O(this,"left"),O(this,"right"),this.operator=t,this.left=e,this.right=r}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}},Eo=class{constructor(){O(this,"prefixParselets",{}),O(this,"infixParselets",{})}registerInfix(t,e){return this.infixParselets[t]=e,this}registerPrefix(t,e){return this.prefixParselets[t]=e,this}prefix(t,e,r){return this.registerPrefix(t,{parse(i,n){let o=i.consumeAndParse(e);return r(n,o)}})}infixLeft(t,e,r){return this.registerInfix(t,{parse(i,n,o){let s=i.consumeAndParse(e);return r(n,o,s)},precedence:e})}construct(t){return new Io(t,this.prefixParselets,this.infixParselets)}},Io=class{constructor(t,e,r){O(this,"tokens"),O(this,"prefixParselets"),O(this,"infixParselets"),this.tokens=t,this.prefixParselets=e,this.infixParselets=r}hasMore(){return this.tokens.length>0}match(t){return this.peek()?.id!==t?!1:(this.consume(),!0)}consumeAndParse(t=1/0){let e=this.consume(),r=this.prefixParselets[e.id];if(!r)throw new Error(`Parse error at "${e.value}" (line ${e.line}, column ${e.column}). No matching prefix parselet.`);let i=r.parse(this,e);for(;t>this.getPrecedence();){let n=this.consume();i=this.getInfixParselet(n).parse(this,i,n)}return i}getPrecedence(){let t=this.peek();if(!t)return 1/0;let e=this.getInfixParselet(t);return e?e.precedence:1/0}consume(t,e){if(!this.tokens.length)throw new Error("Cant consume unknown more tokens.");if(t&&this.peek()?.id!==t){let r=this.peek();throw new Error(`Expected ${t} but got "${r.id}" (${r.value}) at line ${r.line} column ${r.column}.`)}if(e&&this.peek()?.value!==e){let r=this.peek();throw new Error(`Expected "${e}" but got "${r.value}" at line ${r.line} column ${r.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(t=>t.id!=="Comment")}getInfixParselet(t){return this.infixParselets[t.id==="Symbol"?t.value:t.id]}};var fe="http://unitsofmeasure.org",je="http://loinc.org",qe="http://snomed.info/sct",vr="http://www.nlm.nih.gov/research/umls/rxnorm",Dr="http://www.ama-assn.org/go/cpt";var xr="http://hl7.org/fhir/sid/ndc",S="http://hl7.org",R="http://terminology.hl7.org",xa=`${R}/CodeSystem/v2-0203`;var To="unauthorized";var He={resourceType:"OperationOutcome",id:To,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Pa={...He,issue:[...He.issue,{severity:"error",code:"expired",details:{text:"Token expired"}}]},ba={...He,issue:[...He.issue,{severity:"error",code:"invalid",details:{text:"Token not issued for this audience"}}]};function So(t,e){let r=e.max&&e.max===Number.MAX_SAFE_INTEGER?Number.POSITIVE_INFINITY:e.max;return{path:t,description:"",type:e.type??[],min:e.min??0,max:r??1,isArray:!!r&&r>1,constraints:[]}}function Oo(t){let e=Object.create(null);for(let[r,i]of Object.entries(t))e[r]={name:r,type:r,path:r,elements:Object.fromEntries(Object.entries(i.elements).map(([n,o])=>[n,So(n,o)])),constraints:[],innerTypes:[]};return e}var yo={Element:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},BackboneElement:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},Address:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"code"}]},text:{type:[{code:"string"}]},line:{max:9007199254740991,type:[{code:"string"}]},city:{type:[{code:"string"}]},district:{type:[{code:"string"}]},state:{type:[{code:"string"}]},postalCode:{type:[{code:"string"}]},country:{type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},Age:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},Annotation:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"author[x]":{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:{type:[{code:"dateTime"}]},text:{min:1,type:[{code:"markdown"}]}}},Attachment:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},contentType:{type:[{code:"code"}]},language:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]},url:{type:[{code:"url"}]},size:{type:[{code:"unsignedInt"}]},hash:{type:[{code:"base64Binary"}]},title:{type:[{code:"string"}]},creation:{type:[{code:"dateTime"}]}}},CodeableConcept:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},Coding:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},code:{type:[{code:"code"}]},display:{type:[{code:"string"}]},userSelected:{type:[{code:"boolean"}]}}},ContactDetail:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},ContactPoint:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"code"}]},value:{type:[{code:"string"}]},use:{type:[{code:"code"}]},rank:{type:[{code:"positiveInt"}]},period:{type:[{code:"Period"}]}}},Contributor:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{min:1,type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]}}},Count:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},DataRequirement:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{max:9007199254740991,type:[{code:"string"}]},codeFilter:{max:9007199254740991,type:[{code:"DataRequirementCodeFilter"}]},dateFilter:{max:9007199254740991,type:[{code:"DataRequirementDateFilter"}]},limit:{type:[{code:"positiveInt"}]},sort:{max:9007199254740991,type:[{code:"DataRequirementSort"}]}}},DataRequirementCodeFilter:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{max:9007199254740991,type:[{code:"Coding"}]}}},DataRequirementDateFilter:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},"value[x]":{type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}}},DataRequirementSort:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},direction:{min:1,type:[{code:"code"}]}}},Distance:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},Dosage:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},sequence:{type:[{code:"integer"}]},text:{type:[{code:"string"}]},additionalInstruction:{max:9007199254740991,type:[{code:"CodeableConcept"}]},patientInstruction:{type:[{code:"string"}]},timing:{type:[{code:"Timing"}]},"asNeeded[x]":{type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{type:[{code:"CodeableConcept"}]},route:{type:[{code:"CodeableConcept"}]},method:{type:[{code:"CodeableConcept"}]},doseAndRate:{max:9007199254740991,type:[{code:"DosageDoseAndRate"}]},maxDosePerPeriod:{type:[{code:"Ratio"}]},maxDosePerAdministration:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{type:[{code:"CodeableConcept"}]},"dose[x]":{type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Duration:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},ElementDefinition:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},representation:{max:9007199254740991,type:[{code:"code"}]},sliceName:{type:[{code:"string"}]},sliceIsConstraining:{type:[{code:"boolean"}]},label:{type:[{code:"string"}]},code:{max:9007199254740991,type:[{code:"Coding"}]},slicing:{type:[{code:"ElementDefinitionSlicing"}]},short:{type:[{code:"string"}]},definition:{type:[{code:"markdown"}]},comment:{type:[{code:"markdown"}]},requirements:{type:[{code:"markdown"}]},alias:{max:9007199254740991,type:[{code:"string"}]},min:{type:[{code:"unsignedInt"}]},max:{type:[{code:"string"}]},base:{type:[{code:"ElementDefinitionBase"}]},contentReference:{type:[{code:"uri"}]},type:{max:9007199254740991,type:[{code:"ElementDefinitionType"}]},"defaultValue[x]":{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:{type:[{code:"markdown"}]},orderMeaning:{type:[{code:"string"}]},"fixed[x]":{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]":{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:{max:9007199254740991,type:[{code:"ElementDefinitionExample"}]},"minValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{type:[{code:"integer"}]},condition:{max:9007199254740991,type:[{code:"id"}]},constraint:{max:9007199254740991,type:[{code:"ElementDefinitionConstraint"}]},mustSupport:{type:[{code:"boolean"}]},isModifier:{type:[{code:"boolean"}]},isModifierReason:{type:[{code:"string"}]},isSummary:{type:[{code:"boolean"}]},binding:{type:[{code:"ElementDefinitionBinding"}]},mapping:{max:9007199254740991,type:[{code:"ElementDefinitionMapping"}]}}},ElementDefinitionSlicingDiscriminator:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},path:{min:1,type:[{code:"string"}]}}},ElementDefinitionSlicing:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},discriminator:{max:9007199254740991,type:[{code:"ElementDefinitionSlicingDiscriminator"}]},description:{type:[{code:"string"}]},ordered:{type:[{code:"boolean"}]},rules:{min:1,type:[{code:"code"}]}}},ElementDefinitionBase:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},min:{min:1,type:[{code:"unsignedInt"}]},max:{min:1,type:[{code:"string"}]}}},ElementDefinitionType:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{max:9007199254740991,type:[{code:"code"}]},versioning:{type:[{code:"code"}]}}},ElementDefinitionExample:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},label:{min:1,type:[{code:"string"}]},"value[x]":{min: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"}]}}},ElementDefinitionConstraint:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},key:{min:1,type:[{code:"id"}]},requirements:{type:[{code:"string"}]},severity:{min:1,type:[{code:"code"}]},human:{min:1,type:[{code:"string"}]},expression:{type:[{code:"string"}]},xpath:{type:[{code:"string"}]},source:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},ElementDefinitionBinding:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},strength:{min:1,type:[{code:"code"}]},description:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}}},ElementDefinitionMapping:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},identity:{min:1,type:[{code:"id"}]},language:{type:[{code:"code"}]},map:{min:1,type:[{code:"string"}]},comment:{type:[{code:"string"}]}}},Expression:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},description:{type:[{code:"string"}]},name:{type:[{code:"id"}]},language:{min:1,type:[{code:"code"}]},expression:{type:[{code:"string"}]},reference:{type:[{code:"uri"}]}}},Extension:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},url:{min:1,type:[{code:"uri"}]},"value[x]":{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:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},text:{type:[{code:"string"}]},family:{type:[{code:"string"}]},given:{max:9007199254740991,type:[{code:"string"}]},prefix:{max:9007199254740991,type:[{code:"string"}]},suffix:{max:9007199254740991,type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},Identifier:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"CodeableConcept"}]},system:{type:[{code:"uri"}]},value:{type:[{code:"string"}]},period:{type:[{code:"Period"}]},assigner:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},country:{min:1,type:[{code:"CodeableConcept"}]},jurisdiction:{type:[{code:"CodeableConcept"}]},status:{min:1,type:[{code:"CodeableConcept"}]},dateRange:{min:1,type:[{code:"Period"}]},restoreDate:{type:[{code:"dateTime"}]}}},Meta:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},versionId:{type:[{code:"id"}]},lastUpdated:{type:[{code:"instant"}]},source:{type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{max:9007199254740991,type:[{code:"Coding"}]},tag:{max:9007199254740991,type:[{code:"Coding"}]},project:{type:[{code:"uri"}]},author:{type:[{code:"Reference"}]},onBehalfOf:{type:[{code:"Reference"}]},account:{type:[{code:"Reference"}]},accounts:{max:9007199254740991,type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]},deleted:{type:[{code:"boolean"}]}}},Money:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},Narrative:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},ParameterDefinition:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"code"}]},use:{min:1,type:[{code:"code"}]},min:{type:[{code:"integer"}]},max:{type:[{code:"string"}]},documentation:{type:[{code:"string"}]},type:{min:1,type:[{code:"code"}]},profile:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},Population:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"age[x]":{type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{type:[{code:"CodeableConcept"}]},race:{type:[{code:"CodeableConcept"}]},physiologicalCondition:{type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},height:{type:[{code:"Quantity"}]},width:{type:[{code:"Quantity"}]},depth:{type:[{code:"Quantity"}]},weight:{type:[{code:"Quantity"}]},nominalVolume:{type:[{code:"Quantity"}]},externalDiameter:{type:[{code:"Quantity"}]},shape:{type:[{code:"string"}]},color:{max:9007199254740991,type:[{code:"string"}]},imprint:{max:9007199254740991,type:[{code:"string"}]},image:{max:9007199254740991,type:[{code:"Attachment"}]},scoring:{type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},identifier:{type:[{code:"Identifier"}]},type:{min:1,type:[{code:"CodeableConcept"}]},period:{min:1,type:[{code:"Quantity"}]},specialPrecautionsForStorage:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},Quantity:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},Range:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},low:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},Reference:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},reference:{type:[{code:"string"}]},type:{type:[{code:"uri"}]},identifier:{type:[{code:"Identifier"}]},display:{type:[{code:"string"}]}}},RelatedArtifact:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},label:{type:[{code:"string"}]},display:{type:[{code:"string"}]},citation:{type:[{code:"markdown"}]},url:{type:[{code:"url"}]},document:{type:[{code:"Attachment"}]},resource:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},origin:{min:1,type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,type:[{code:"decimal"}]},factor:{type:[{code:"decimal"}]},lowerLimit:{type:[{code:"decimal"}]},upperLimit:{type:[{code:"decimal"}]},dimensions:{min:1,type:[{code:"positiveInt"}]},data:{type:[{code:"string"}]}}},Signature:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,max:9007199254740991,type:[{code:"Coding"}]},when:{min:1,type:[{code:"instant"}]},who:{min: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:{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:{type:[{code:"code"}]},sigFormat:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]}}},SubstanceAmount:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"amount[x]":{type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{type:[{code:"CodeableConcept"}]},amountText:{type:[{code:"string"}]},referenceRange:{type:[{code:"SubstanceAmountReferenceRange"}]}}},SubstanceAmountReferenceRange:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},lowLimit:{type:[{code:"Quantity"}]},highLimit:{type:[{code:"Quantity"}]}}},Timing:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},event:{max:9007199254740991,type:[{code:"dateTime"}]},repeat:{type:[{code:"TimingRepeat"}]},code:{type:[{code:"CodeableConcept"}]}}},TimingRepeat:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"bounds[x]":{type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{type:[{code:"positiveInt"}]},countMax:{type:[{code:"positiveInt"}]},duration:{type:[{code:"decimal"}]},durationMax:{type:[{code:"decimal"}]},durationUnit:{type:[{code:"code"}]},frequency:{type:[{code:"positiveInt"}]},frequencyMax:{type:[{code:"positiveInt"}]},period:{type:[{code:"decimal"}]},periodMax:{type:[{code:"decimal"}]},periodUnit:{type:[{code:"code"}]},dayOfWeek:{max:9007199254740991,type:[{code:"code"}]},timeOfDay:{max:9007199254740991,type:[{code:"time"}]},when:{max:9007199254740991,type:[{code:"code"}]},offset:{type:[{code:"unsignedInt"}]}}},TriggerDefinition:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{type:[{code:"string"}]},"timing[x]":{type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{max:9007199254740991,type:[{code:"DataRequirement"}]},condition:{type:[{code:"Expression"}]}}},UsageContext:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"Coding"}]},"value[x]":{min: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"]}]}}},MoneyQuantity:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},SimpleQuantity:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{max:0,type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},IdentityProvider:{elements:{issuer:{type:[{code:"string"}]},jwksUrl:{type:[{code:"string"}]},authorizeUrl:{type:[{code:"string"}]},tokenUrl:{type:[{code:"string"}]},tokenAuthMethod:{type:[{code:"code"}]},userInfoUrl:{type:[{code:"string"}]},userInfoMode:{type:[{code:"code"}]},userInfoApiKey:{type:[{code:"string"}]},clientId:{type:[{code:"string"}]},clientSecret:{type:[{code:"string"}]},usePkce:{type:[{code:"boolean"}]},useSubject:{type:[{code:"boolean"}]},identitySource:{type:[{code:"code"}]},identityMappingMode:{type:[{code:"code"}]}}}};var Co=Oo(yo);var yr=Object.create(null);function go(t){let e;return e=yr[t],e||(e=yr[t]=Object.create(null)),e}function No(t,e){if(e){let r=go(e)[t];if(r)return r}return Co[t]}function Ro(t,e,r){let i=t.path;return Ao(vo(t,e,r),i,e)}function Ao(t,e,r){let i=e?e+".":"";return t===void 0?{type:"undefined",value:void 0,path:`${i}${r}`}:Array.isArray(t)?t.map((n,o)=>({...n,path:`${i}${r}[${o}]`})):{...t,path:`${i}${r}`}}var La=new wt(1e3);var Pr={canonical:/^\S*$/,code:/^[^\s]+( [^\s]+)*$/,date:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/,dateTime:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/,id:/^[A-Za-z0-9\-.]{1,64}$/,instant:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/,markdown:/^[\r\n\t\u0020-\uFFFF]+$/,oid:/^urn:oid:[0-2](\.(0|[1-9]\d*))+$/,string:/^[\r\n\t\u0020-\uFFFF]+$/,time:/^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/,uri:/^\S*$/,url:/^\S*$/,uuid:/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,xhtml:/.*/};function c(t){return[{type:u.boolean,value:t}]}function Q(t){return t==null?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:u.integer,value:t}:typeof t=="number"?{type:u.decimal,value:t}:typeof t=="boolean"?{type:u.boolean,value:t}:typeof t=="string"?{type:u.string,value:t}:V(t)?{type:u.Quantity,value:t}:me(t)?{type:t.resourceType,value:t}:Vr(t)?{type:u.CodeableConcept,value:t}:wr(t)?{type:u.Coding,value:t}:{type:u.BackboneElement,value:t}}function W(t){return t.length===0?!1:!!t[0].value}function b(t,e){if(t.length!==0){if(t.length===1&&(!e||t[0].type===e))return t[0];{let r=e?` of type ${e}`:"";throw new Error(`Expected singleton${r}, but found ${JSON.stringify(t)}`)}}}function vo(t,e,r){if(!t.value)return;let i=zo(t.type,e,r?.profileUrl);return i?Do(t,e,i):Vt(t,e)}function Do(t,e,r){let i=t.value,n=r.type;if(!n||n.length===0)return;let o,s="undefined",a,l=r.path.lastIndexOf("."),E=r.path.substring(l+1),A=E,j=!1;E.endsWith("[x]")&&(A=E.substring(0,E.length-3),j=!0);for(let N of n){let Lt=A;if(j&&(Lt+=oe(N.code)),o=i[Lt],a=i["_"+Lt],o!==void 0||a!==void 0){s=N.code;break}}if(a)if(Array.isArray(o)){o=o.slice();for(let N=0;N<Math.max(o.length,a.length);N++)o[N]=Ut(o[N],a[N])}else if(!o&&Array.isArray(a)){o=a.slice();for(let N=0;N<a.length;N++)o[N]=Ut(void 0,a[N])}else o=Ut(o,a);if(!he(o))return(s==="Element"||s==="BackboneElement")&&(s=r.type[0].code),Array.isArray(o)?o.map(N=>Cr(N,s)):Cr(o,s)}function Cr(t,e){return e==="Resource"&&me(t)&&(e=t.resourceType),{type:e,value:t}}function Vt(t,e){let r=t.value;if(!r||typeof r!="object")return;let i;if(e in r){let n=r[e];Array.isArray(n)?i=n.map(Q):i=Q(n)}else{let n=e.endsWith("[x]")?e.substring(0,e.length-3):e;for(let o of Object.values(u)){let s=n+oe(o);if(s in r){let a=r[s];Array.isArray(a)?i=a.map(l=>({type:o,value:l})):i={type:o,value:a};break}}}if(Array.isArray(i)){if(i.length===0||he(i[0]))return}else if(he(i))return;return i}function br(t){let e=[];for(let r of t){let i=!1;for(let n of e)if(W(We(r,n))){i=!0;break}i||e.push(r)}return e}function xo(t){return c(!W(t))}function Po(t,e){return t.length===0||e.length===0?[]:t.length!==e.length?c(!1):c(t.every((r,i)=>W(We(r,e[i]))))}function bo(t,e){return t.length===0||e.length===0?[]:t.length!==e.length?c(!0):c(t.some((r,i)=>!W(We(r,e[i]))))}function We(t,e){let r=t.value?.valueOf(),i=e.value?.valueOf();return typeof r=="number"&&typeof i=="number"?c(Math.abs(r-i)<1e-8):V(r)&&V(i)?c(Ur(r,i)):c(typeof r=="object"&&typeof i=="object"?kt(t,e):r===i)}function Lr(t,e){return t.length===0&&e.length===0?c(!0):t.length!==e.length?c(!1):(t.sort(gr),e.sort(gr),c(t.every((r,i)=>W(Lo(r,e[i])))))}function Lo(t,e){let{type:r,value:i}=t,{type:n,value:o}=e,s=i?.valueOf(),a=o?.valueOf();return typeof s=="number"&&typeof a=="number"?c(Math.abs(s-a)<.01):V(s)&&V(a)?c(Ur(s,a)):c(r==="Coding"&&n==="Coding"?typeof s!="object"||typeof a!="object"?!1:s.code===a.code&&s.system===a.system:typeof s=="object"&&typeof a=="object"?kt({...s,id:void 0},{...a,id:void 0}):typeof s=="string"&&typeof a=="string"?s.toLowerCase()===a.toLowerCase():s===a)}function gr(t,e){let r=t.value?.valueOf(),i=e.value?.valueOf();return typeof r=="number"&&typeof i=="number"?r-i:typeof r=="string"&&typeof i=="string"?r.localeCompare(i):0}function Ye(t,e){let{value:r}=t;if(r==null)return!1;let i=e;switch(i.startsWith("System.")&&(i=i.substring(7)),i.startsWith("FHIR.")&&(i=i.substring(5)),i){case"Boolean":return typeof r=="boolean";case"Decimal":case"Integer":return typeof r=="number";case"Date":return Uo(r);case"DateTime":return Mt(r);case"Time":return typeof r=="string"&&!!/^T\d/.exec(r);case"Period":return Mo(r);case"Quantity":return V(r);default:return t.type===i||typeof r=="object"&&r?.resourceType===i}}function Uo(t){return typeof t=="string"&&!!Pr.date.exec(t)}function Mt(t){return typeof t=="string"&&!!Pr.dateTime.exec(t)}function Mo(t){return!!(t&&typeof t=="object"&&("start"in t&&Mt(t.start)||"end"in t&&Mt(t.end)))}function V(t){return!!(t&&typeof t=="object"&&"value"in t&&typeof t.value=="number")}function Ur(t,e){return Math.abs(t.value-e.value)<.01&&(t.unit===e.unit||t.code===e.code||t.unit===e.code||t.code===e.unit)}function kt(t,e){let r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(let n of r){let o=t[n],s=e[n];if(Nr(o)&&Nr(s)){if(!kt(o,s))return!1}else if(o!==s)return!1}return!0}function Nr(t){return t!==null&&typeof t=="object"}function Ut(t,e){if(e){if(typeof e!="object")throw new Error("Primitive extension must be an object");return wo(t??{},e)}return t}function wo(t,e){return delete e.__proto__,delete e.constructor,Object.assign(t,e)}function Vo(t,e){return me(t,e)&&"id"in t&&typeof t.id=="string"}function I(t){let e=Mr(t)??"undefined/undefined",r=Bo(t);return r===e?{reference:e}:{reference:e,display:r}}function Mr(t){if(Fr(t))return t.reference;if(Vo(t))return`${t.resourceType}/${t.id}`}function ko(t){if(t)return Fr(t)?t.reference.split("/")[1]:t.id}function Fo(t){return t.resourceType==="Patient"||t.resourceType==="Practitioner"||t.resourceType==="RelatedPerson"}function Bo(t){if(Fo(t)){let e=Yo(t);if(e)return e}if(t.resourceType==="Appointment"&&t.serviceType?.[0])return le(t.serviceType[0]);if(t.resourceType==="Device"){let e=Go(t);if(e)return e}if(t.resourceType==="DocumentReference"){if(t.description)return t.description;if(t.type)return le(t.type)}if(t.resourceType==="MedicationRequest"&&t.medicationCodeableConcept||t.resourceType==="MedicationStatement"&&t.medicationCodeableConcept)return le(t.medicationCodeableConcept);if(t.resourceType==="Slot"&&(t.start||t.end))return`${Rr(t.start)} - ${Rr(t.end)}`;if(t.resourceType==="Subscription"&&t.criteria)return t.criteria;if(t.resourceType==="User"&&t.email)return t.email;if("name"in t&&t.name&&typeof t.name=="string")return t.name;if("code"in t&&t.code){let e=t.code;if(Array.isArray(e)&&(e=e[0]),Vr(e))return le(e);if(Ho(e))return e.text}return Mr(t)??""}function Yo(t){let e=t.name;if(e&&e.length>0)return qo(e[0])}function Go(t){let e=t.deviceName;if(e&&e.length>0)return e[0].name}function $o(t,e){let r=new Date(t);r.setUTCHours(0,0,0,0);let i=e?new Date(e):new Date;i.setUTCHours(0,0,0,0);let n=r.getUTCFullYear(),o=r.getUTCMonth(),s=r.getUTCDate(),a=i.getUTCFullYear(),l=i.getUTCMonth(),E=i.getUTCDate(),A=a-n;(l<o||l===o&&E<s)&&A--;let j=a*12+l-(n*12+o);E<s&&j--;let N=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return{years:A,months:j,days:N}}function Qe(t,...e){let r=t;for(let i=0;i<e.length&&r;i++)r=r?.extension?.find(n=>n.url===e[i]);return r}function he(t){if(t==null)return!0;let e=typeof t;return e==="string"||e==="object"?!Ft(t):!1}function Ft(t){if(t==null)return!1;let e=typeof t;return e==="string"&&t!==""||e==="object"&&("length"in t&&t.length>0||Object.keys(t).length>0)}function Bt(t){return/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(t)}function Yt(t){return t!==null&&typeof t=="object"}function wr(t){return Yt(t)&&"code"in t&&typeof t.code=="string"}function Vr(t){return Yt(t)&&"coding"in t&&Array.isArray(t.coding)&&t.coding.every(wr)}function Ho(t){return Yt(t)&&"text"in t&&typeof t.text=="string"}var jo=[];for(let t=0;t<256;t++)jo.push(t.toString(16).padStart(2,"0"));function oe(t){return t?t.charAt(0).toUpperCase()+t.substring(1):""}function kr(t,e){return t?(t.push(e),t):[e]}var m=Object.freeze([]);function qo(t,e){if(!t)return"";let r=[];if(t.prefix&&e?.prefix!==!1&&r.push(...t.prefix),t.given&&r.push(...t.given),t.family&&r.push(t.family),t.suffix&&e?.suffix!==!1&&r.push(...t.suffix),t.use&&(e?.all||e?.use)&&r.push("["+t.use+"]"),r.length===0){let i=pe(t.text);if(i)return i}return r.join(" ").trim()}function Wo(t){return t instanceof Date&&!Number.isNaN(t.getTime())}function Rr(t,e,r){if(!t)return"";let i=new Date(t);return Wo(i)?i.toLocaleString(e,r):""}function le(t){return t?pe(t.text)||(t.coding?t.coding.map(r=>Qo(r)).join(", "):""):""}function Qo(t,e){let r=pe(t?.display);if(r){let i=e?pe(t?.code):void 0;return`${r}${i?" ("+i+")":""}`}return pe(t?.code)??""}function pe(t){return typeof t=="string"?t:void 0}var u={Address:"Address",Age:"Age",Annotation:"Annotation",Attachment:"Attachment",BackboneElement:"BackboneElement",CodeableConcept:"CodeableConcept",Coding:"Coding",ContactDetail:"ContactDetail",ContactPoint:"ContactPoint",Contributor:"Contributor",Count:"Count",DataRequirement:"DataRequirement",Distance:"Distance",Dosage:"Dosage",Duration:"Duration",Element:"Element",ElementDefinition:"ElementDefinition",Expression:"Expression",Extension:"Extension",HumanName:"HumanName",Identifier:"Identifier",MarketingStatus:"MarketingStatus",Meta:"Meta",Money:"Money",MoneyQuantity:"MoneyQuantity",Narrative:"Narrative",ParameterDefinition:"ParameterDefinition",Period:"Period",Population:"Population",ProdCharacteristic:"ProdCharacteristic",ProductShelfLife:"ProductShelfLife",Quantity:"Quantity",Range:"Range",Ratio:"Ratio",Reference:"Reference",RelatedArtifact:"RelatedArtifact",SampledData:"SampledData",Signature:"Signature",SimpleQuantity:"SimpleQuantity",SubstanceAmount:"SubstanceAmount",SystemString:"http://hl7.org/fhirpath/System.String",Timing:"Timing",TriggerDefinition:"TriggerDefinition",UsageContext:"UsageContext",base64Binary:"base64Binary",boolean:"boolean",canonical:"canonical",code:"code",date:"date",dateTime:"dateTime",decimal:"decimal",id:"id",instant:"instant",integer:"integer",markdown:"markdown",oid:"oid",positiveInt:"positiveInt",string:"string",time:"time",unsignedInt:"unsignedInt",uri:"uri",url:"url",uuid:"uuid",xhtml:"xhtml"};function zo(t,e,r){let i=No(t,r);if(i)return Zo(i.elements,e)}function Zo(t,e){let r=t[e]??t[e+"[x]"];if(r)return r;for(let i=0;i<e.length;i++){let n=e[i];if(n>="A"&&n<="Z"){let o=e.slice(0,i)+"[x]",s=t[o];if(s)return s}}}function me(t,e){return!(!t||typeof t!="object"||!("resourceType"in t)||e&&t.resourceType!==e)}function Fr(t,e){return t&&typeof t=="object"&&"reference"in t&&typeof t.reference=="string"?e?t.reference.match(new RegExp(`^${e}(/|\\?)`))!==null:!0:!1}function Ge(t){if(t.startsWith("T"))return t+"T00:00:00.000Z".substring(t.length);if(t.length<=10)return t;try{return new Date(t).toISOString()}catch{return t}}var q=()=>[];function $e(t){return t instanceof ne?t.name:t instanceof Br&&t.left instanceof ne&&t.right instanceof ne?t.left.name+"."+t.right.name:""}var P={empty:(t,e)=>c(e.every(r=>he(r.value))),hasValue:(t,e)=>c(e.length!==0),exists:(t,e,r)=>c(r?e.some(i=>W(r.eval(t,[i]))):e.length>0&&e.every(i=>!he(i.value))),all:(t,e,r)=>c(e.every(i=>W(r.eval(t,[i])))),allTrue:(t,e)=>{for(let r of e)if(!r.value)return c(!1);return c(!0)},anyTrue:(t,e)=>{for(let r of e)if(r.value)return c(!0);return c(!1)},allFalse:(t,e)=>{for(let r of e)if(r.value)return c(!1);return c(!0)},anyFalse:(t,e)=>{for(let r of e)if(!r.value)return c(!0);return c(!1)},subsetOf:(t,e,r)=>{if(e.length===0)return c(!0);let i=r.eval(t,X(t));return i.length===0?c(!1):c(e.every(n=>i.some(o=>o.value===n.value)))},supersetOf:(t,e,r)=>{let i=r.eval(t,X(t));return i.length===0?c(!0):e.length===0?c(!1):c(i.every(n=>e.some(o=>o.value===n.value)))},count:(t,e)=>[{type:u.integer,value:e.length}],distinct:(t,e)=>{let r=[];for(let i of e)r.some(n=>n.value===i.value)||r.push(i);return r},isDistinct:(t,e)=>c(e.length===P.distinct(t,e).length),where:(t,e,r)=>e.filter(i=>W(r.eval(t,[i]))),select:(t,e,r)=>e.flatMap(i=>r.eval({parent:t,variables:{$this:i}},[i])),repeat:q,ofType:(t,e,r)=>{let i=$e(r);return i?e.filter(n=>Ye(n,i)):[]},single:(t,e)=>{if(e.length>1)throw new Error("Expected input length one for single()");return e.length===0?[]:e.slice(0,1)},first:(t,e)=>e.length===0?[]:e.slice(0,1),last:(t,e)=>e.length===0?[]:e.slice(-1,e.length),tail:(t,e)=>e.length===0?[]:e.slice(1,e.length),skip:(t,e,r)=>{let i=r.eval(t,e)[0]?.value;if(typeof i!="number")throw new TypeError("Expected a number for skip(num)");return i>=e.length?[]:i<=0?e:e.slice(i,e.length)},take:(t,e,r)=>{let i=r.eval(t,e)[0]?.value;if(typeof i!="number")throw new TypeError("Expected a number for take(num)");return i<=0?[]:e.slice(0,i)},intersect:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t)),n=[];for(let o of e)!n.some(s=>s.value===o.value)&&i.some(s=>s.value===o.value)&&n.push(o);return n},exclude:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t)),n=[];for(let o of e)i.some(s=>s.value===o.value)||n.push(o);return n},union:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t));return br([...e,...i])},combine:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t));return[...e,...i]},htmlChecks:(t,e,r)=>[Q(!0)],iif:(t,e,r,i,n)=>{let o=r.eval(t,e);if(o.length>1||o.length===1&&typeof o[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return W(o)?i.eval(t,e):n?n.eval(t,e):[]},toBoolean:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);if(typeof r=="boolean")return[{type:u.boolean,value:r}];if(typeof r=="number"&&(r===0||r===1))return c(!!r);if(typeof r=="string"){let i=r.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(i))return c(!0);if(["false","f","no","n","0","0.0"].includes(i))return c(!1)}return[]},convertsToBoolean:(t,e)=>e.length===0?[]:c(P.toBoolean(t,e).length===1),toInteger:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="number"?[{type:u.integer,value:r}]:typeof r=="string"&&/^[+-]?\d+$/.exec(r)?[{type:u.integer,value:Number.parseInt(r,10)}]:typeof r=="boolean"?[{type:u.integer,value:r?1:0}]:[]},convertsToInteger:(t,e)=>e.length===0?[]:c(P.toInteger(t,e).length===1),toDate:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(r)?[{type:u.date,value:Ge(r)}]:[]},convertsToDate:(t,e)=>e.length===0?[]:c(P.toDate(t,e).length===1),toDateTime:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(r)?[{type:u.dateTime,value:Ge(r)}]:[]},convertsToDateTime:(t,e)=>e.length===0?[]:c(P.toDateTime(t,e).length===1),toDecimal:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="number"?[{type:u.decimal,value:r}]:typeof r=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(r)?[{type:u.decimal,value:Number.parseFloat(r)}]:typeof r=="boolean"?[{type:u.decimal,value:r?1:0}]:[]},convertsToDecimal:(t,e)=>e.length===0?[]:c(P.toDecimal(t,e).length===1),toQuantity:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return V(r)?[{type:u.Quantity,value:r}]:typeof r=="number"?[{type:u.Quantity,value:{value:r,unit:"1"}}]:typeof r=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(r)?[{type:u.Quantity,value:{value:Number.parseFloat(r),unit:"1"}}]:typeof r=="boolean"?[{type:u.Quantity,value:{value:r?1:0,unit:"1"}}]:[]},convertsToQuantity:(t,e)=>e.length===0?[]:c(P.toQuantity(t,e).length===1),toString:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return r==null?[]:V(r)?[{type:u.string,value:`${r.value} '${r.unit}'`}]:[{type:u.string,value:r.toString()}]},convertsToString:(t,e)=>e.length===0?[]:c(P.toString(t,e).length===1),toTime:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);if(typeof r=="string"){let i=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(r);if(i)return[{type:u.time,value:Ge("T"+i[1])}]}return[]},convertsToTime:(t,e)=>e.length===0?[]:c(P.toTime(t,e).length===1),indexOf:(t,e,r)=>w((i,n)=>i.indexOf(n),t,e,r),substring:(t,e,r,i)=>w((n,o,s)=>{let a=o,l=s?a+s:n.length;return a<0||a>=n.length?void 0:n.substring(a,l)},t,e,r,i),startsWith:(t,e,r)=>w((i,n)=>i.startsWith(n),t,e,r),endsWith:(t,e,r)=>w((i,n)=>i.endsWith(n),t,e,r),contains:(t,e,r)=>w((i,n)=>i.includes(n),t,e,r),upper:(t,e)=>w(r=>r.toUpperCase(),t,e),lower:(t,e)=>w(r=>r.toLowerCase(),t,e),replace:(t,e,r,i)=>w((n,o,s)=>n.replaceAll(o,s),t,e,r,i),matches:(t,e,r)=>w((i,n)=>!!new RegExp(n).exec(i),t,e,r),replaceMatches:(t,e,r,i)=>w((n,o,s)=>n.replaceAll(new RegExp(o,"g"),s.replaceAll(/\$\{(\w+)\}/g,"$<$1>")),t,e,r,i),length:(t,e)=>w(r=>r.length,t,e),toChars:(t,e)=>w(r=>r?r.split(""):void 0,t,e),encode:q,decode:q,escape:q,unescape:q,trim:q,split:q,join:(t,e,r)=>{let i=r?.eval(t,X(t))[0]?.value??"";if(typeof i!="string")throw new TypeError("Separator must be a string.");return[{type:u.string,value:e.map(n=>n.value?.toString()??"").join(i)}]},abs:(t,e)=>Y(Math.abs,t,e),ceiling:(t,e)=>Y(Math.ceil,t,e),exp:(t,e)=>Y(Math.exp,t,e),floor:(t,e)=>Y(Math.floor,t,e),ln:(t,e)=>Y(Math.log,t,e),log:(t,e,r)=>Y((i,n)=>Math.log(i)/Math.log(n),t,e,r),power:(t,e,r)=>Y(Math.pow,t,e,r),round:(t,e,...r)=>Y((i,n=0)=>{if(typeof n!="number"||n<0)throw new Error("Invalid precision provided to round()");let o=Math.pow(10,n);return Math.round(i*o)/o},t,e,...r),sqrt:(t,e)=>Y(Math.sqrt,t,e),truncate:(t,e)=>Y(r=>Math.trunc(r),t,e),children:q,descendants:q,trace:(t,e,r)=>e,now:()=>[{type:u.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:u.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:u.date,value:new Date().toISOString().substring(0,10)}],between:(t,e,r,i,n)=>{let o=P.toDateTime(t,r.eval(t,e));if(o.length===0)throw new Error("Invalid start date");let s=P.toDateTime(t,i.eval(t,e));if(s.length===0)throw new Error("Invalid end date");let a=n.eval(t,e)[0]?.value;if(a!=="years"&&a!=="months"&&a!=="days")throw new Error("Invalid units");let l=$o(o[0].value,s[0].value);return[{type:u.Quantity,value:{value:l[a],unit:a}}]},is:(t,e,r)=>{let i=$e(r);return i?e.map(n=>({type:u.boolean,value:Ye(n,i)})):[]},not:(t,e)=>P.toBoolean(t,e).map(r=>({type:u.boolean,value:!r.value})),resolve:(t,e)=>e.map(r=>{let i=r.value,n;if(typeof i=="string")n=i;else if(typeof i=="object"){let o=i;if(o.resource)return Q(o.resource);o.reference?n=o.reference:o.type&&o.identifier&&(n=`${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`)}if(n?.includes("?")){let[o]=n.split("?");return{type:o,value:{resourceType:o}}}if(n?.includes("/")){let[o,s]=n.split("/");return{type:o,value:{resourceType:o,id:s}}}return{type:u.BackboneElement,value:void 0}}).filter(r=>!!r.value),as:(t,e,r)=>{let i=$e(r);if(!i)throw new Error(`Expected a valid type identifier as the right operand of 'as', but found ${r.toString()}`);let n=b(e);return n&&Ye(n,i)?[n]:[]},type:(t,e)=>e.map(({value:r})=>typeof r=="boolean"?{type:u.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof r=="number"?{type:u.BackboneElement,value:{namespace:"System",name:"Integer"}}:me(r)?{type:u.BackboneElement,value:{namespace:"FHIR",name:r.resourceType}}:{type:u.BackboneElement,value:null}),conformsTo:(t,e,r)=>{let i=r.eval(t,e)[0].value;if(!i.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");let n=i.replace("http://hl7.org/fhir/StructureDefinition/","");return e.map(o=>({type:u.boolean,value:o.value?.resourceType===n}))},getResourceKey:(t,e)=>{let r=e[0]?.value;return r?.id?[{type:u.id,value:r.id}]:[]},getReferenceKey:(t,e,r)=>{let i=e[0]?.value;if(!i?.reference)return[];let n="";return r instanceof ne&&(n=r.name),n&&!i.reference.startsWith(n+"/")?[]:[{type:u.id,value:ko(i)}]},extension:(t,e,r)=>{let i=r.eval(t,e)[0].value,n=e?.[0]?.value;if(n){let o=Qe(n,i);if(o)return[{type:u.Extension,value:o}]}return[]}};function w(t,e,r,...i){if(r.length===0)return[];let[{value:n}]=G(r,1);if(typeof n!="string")throw new TypeError("String function cannot be called with non-string");let o=i.map(a=>a?.eval(e,r)[0]?.value),s=t(n,...o);return s===void 0?[]:Array.isArray(s)?s.map(Q):[Q(s)]}function Y(t,e,r,...i){if(r.length===0)return[];let[{value:n}]=G(r,1),o=V(n),s=o?n.value:n;if(typeof s!="number")throw new TypeError("Math function cannot be called with non-number");let a=t(s,...i.map(A=>A.eval(e,r)[0]?.value)),l=o?u.Quantity:r[0].type,E=o?{...n,value:a}:a;return[{type:l,value:E}]}function G(t,e){if(t.length!==e)throw new Error(`Expected ${e} arguments`);for(let r of t)if(r==null)throw new Error("Expected non-null argument");return t}function X(t){let e=t;for(;e.parent?.variables.$this;)e=e.parent;return[e.variables.$this]}var ie=class{constructor(t){O(this,"value"),this.value=t}eval(){return[this.value]}toString(){let t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}},ne=class{constructor(t){O(this,"name"),this.name=t}eval(t,e){if(this.name==="$this")return e;let r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return e.flatMap(i=>this.evalValue(i)).filter(i=>i?.value!==void 0)}getVariable(t){let e=t.variables[this.name];if(e!==void 0)return e;if(t.parent)return this.getVariable(t.parent)}evalValue(t){let e=t.value;if(!(!e||typeof e!="object"))return me(e,this.name)?("path"in t||(t.path=e.resourceType),t):Ro(t,this.name)}toString(){return this.name}},Jo=class{eval(){return[]}toString(){return"{}"}},Xo=class extends _o{constructor(t,e,r){super(t,e),O(this,"impl"),this.impl=r}eval(t,e){return this.impl(this.child.eval(t,e))}toString(){return this.operator+this.child.toString()}},Ko=class extends v{constructor(t,e){super("as",t,e)}eval(t,e){return P.as(t,this.left.eval(t,e),this.right)}},F=class extends v{constructor(t,e,r,i){super(t,e,r),O(this,"impl"),this.impl=i}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);if(r.length<1||i.length<1)return[];let n=b(r)?.value,o=b(i)?.value,s=V(n)?n.value:n,a=V(o)?o.value:o,l=this.impl(s,a);return typeof l=="boolean"?c(l):V(n)?[{type:u.Quantity,value:{...n,value:l}}]:[Q(l)]}},Ar=Object.freeze({type:"string",value:""}),es=class extends v{constructor(t,e){super("&",t,e)}eval(t,e){let r=b(this.left.eval(t,e))??Ar,i=b(this.right.eval(t,e))??Ar;if(typeof r.value!="string")throw new Error(`Expected string operand for &, but got ${r.type}`);if(typeof i.value!="string")throw new Error(`Expected string operand for &, but got ${i.type}`);return[{type:u.string,value:r.value+i.value}]}},ts=class extends v{constructor(t,e){super("contains",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return c(r.some(n=>n.value===i[0].value))}},rs=class extends v{constructor(t,e){super("in",t,e)}eval(t,e){let r=b(this.left.eval(t,e)),i=this.right.eval(t,e);return r?c(i.some(n=>We(r,n)[0].value)):[]}},Br=class extends v{constructor(t,e){super(".",t,e)}eval(t,e){return this.right.eval(t,this.left.eval(t,e))}toString(){return`${this.left.toString()}.${this.right.toString()}`}},is=class extends v{constructor(t,e){super("|",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return br([...r,...i])}},ns=class extends v{constructor(t,e){super("=",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return Po(r,i)}},os=class extends v{constructor(t,e){super("!=",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return bo(r,i)}},ss=class extends v{constructor(t,e){super("~",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return Lr(r,i)}},as=class extends v{constructor(t,e){super("!~",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return xo(Lr(r,i))}},cs=class extends v{constructor(t,e){super("is",t,e)}eval(t,e){let r=this.left.eval(t,e);if(r.length!==1)return[];let i=$e(this.right);return i?c(Ye(r[0],i)):[]}},ds=class extends v{constructor(t,e){super("and",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return r?.value===!0&&i?.value===!0?c(!0):r?.value===!1||i?.value===!1?c(!1):[]}},us=class extends v{constructor(t,e){super("or",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return r?.value===!1&&i?.value===!1?c(!1):r?.value||i?.value?c(!0):[]}},ls=class extends v{constructor(t,e){super("xor",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return!r||!i?[]:c(r.value!==i.value)}},ps=class extends v{constructor(t,e){super("implies",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return i?.value===!0||r?.value===!1?c(!0):!r||!i?[]:c(!1)}},hs=class{constructor(t,e){O(this,"name"),O(this,"args"),this.name=t,this.args=e}eval(t,e){let r=P[this.name];if(!r)throw new Error("Unrecognized function: "+this.name);return r(t,e,...this.args)}toString(){return`${this.name}(${this.args.map(t=>t.toString()).join(", ")})`}},fs=class{constructor(t,e){O(this,"left"),O(this,"expr"),this.left=t,this.expr=e}eval(t,e){let r=this.expr.eval(t,e);if(r.length!==1)return[];let i=r[0].value;if(typeof i!="number")throw new Error("Invalid indexer expression: should return integer}");let n=this.left.eval(t,e);return i in n?[n[i]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}};var Yr=["!=","!~","<=",">=","{}","->"];var _={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,IntegerDivide:4,Modulo:4,Add:5,Subtract:5,Ampersand:5,Is:6,As:6,Union:7,GreaterThan:8,GreaterThanOrEquals:8,LessThan:8,LessThanOrEquals:8,Equals:9,Equivalent:9,NotEquals:9,NotEquivalent:9,In:10,Contains:10,And:11,Xor:12,Or:12,Implies:13,Arrow:100,Semicolon:200},ms={parse(t){let e=t.consumeAndParse();if(!t.match(")"))throw new Error("Parse error: expected `)` got `"+t.peek()?.value+"`");return e}},_s={parse(t,e){let r=t.consumeAndParse();if(!t.match("]"))throw new Error("Parse error: expected `]`");return new fs(e,r)},precedence:_.Indexer},Es={parse(t,e){if(!(e instanceof ne))throw new Error("Unexpected parentheses");let r=[];for(;!t.match(")");)r.push(t.consumeAndParse()),t.match(",");return new hs(e.name,r)},precedence:_.FunctionCall};function Is(t){let e=t.split(" "),r=Number.parseFloat(e[0]),i=e[1];return i?.startsWith("'")&&i.endsWith("'")?i=i.substring(1,i.length-1):i="{"+i+"}",{value:r,unit:i}}function Gt(){return new Eo().registerPrefix("String",{parse:(t,e)=>new ie({type:u.string,value:e.value})}).registerPrefix("DateTime",{parse:(t,e)=>new ie({type:u.dateTime,value:Ge(e.value)})}).registerPrefix("Quantity",{parse:(t,e)=>new ie({type:u.Quantity,value:Is(e.value)})}).registerPrefix("Number",{parse:(t,e)=>new ie({type:e.value.includes(".")?u.decimal:u.integer,value:Number.parseFloat(e.value)})}).registerPrefix("true",{parse:()=>new ie({type:u.boolean,value:!0})}).registerPrefix("false",{parse:()=>new ie({type:u.boolean,value:!1})}).registerPrefix("Symbol",{parse:(t,e)=>new ne(e.value)}).registerPrefix("{}",{parse:()=>new Jo}).registerPrefix("(",ms).registerInfix("[",_s).registerInfix("(",Es).prefix("+",_.UnaryAdd,(t,e)=>new Xo("+",e,r=>r)).prefix("-",_.UnarySubtract,(t,e)=>new F("-",e,e,(r,i)=>-i)).infixLeft(".",_.Dot,(t,e,r)=>new Br(t,r)).infixLeft("/",_.Divide,(t,e,r)=>new F("/",t,r,(i,n)=>i/n)).infixLeft("*",_.Multiply,(t,e,r)=>new F("*",t,r,(i,n)=>i*n)).infixLeft("+",_.Add,(t,e,r)=>new F("+",t,r,(i,n)=>i+n)).infixLeft("-",_.Subtract,(t,e,r)=>new F("-",t,r,(i,n)=>i-n)).infixLeft("|",_.Union,(t,e,r)=>new is(t,r)).infixLeft("=",_.Equals,(t,e,r)=>new ns(t,r)).infixLeft("!=",_.NotEquals,(t,e,r)=>new os(t,r)).infixLeft("~",_.Equivalent,(t,e,r)=>new ss(t,r)).infixLeft("!~",_.NotEquivalent,(t,e,r)=>new as(t,r)).infixLeft("<",_.LessThan,(t,e,r)=>new F("<",t,r,(i,n)=>i<n)).infixLeft("<=",_.LessThanOrEquals,(t,e,r)=>new F("<=",t,r,(i,n)=>i<=n)).infixLeft(">",_.GreaterThan,(t,e,r)=>new F(">",t,r,(i,n)=>i>n)).infixLeft(">=",_.GreaterThanOrEquals,(t,e,r)=>new F(">=",t,r,(i,n)=>i>=n)).infixLeft("&",_.Ampersand,(t,e,r)=>new es(t,r)).infixLeft("and",_.And,(t,e,r)=>new ds(t,r)).infixLeft("as",_.As,(t,e,r)=>new Ko(t,r)).infixLeft("contains",_.Contains,(t,e,r)=>new ts(t,r)).infixLeft("div",_.Divide,(t,e,r)=>new F("div",t,r,(i,n)=>Math.trunc(i/n))).infixLeft("in",_.In,(t,e,r)=>new rs(t,r)).infixLeft("is",_.Is,(t,e,r)=>new cs(t,r)).infixLeft("mod",_.Modulo,(t,e,r)=>new F("mod",t,r,(i,n)=>i%n)).infixLeft("or",_.Or,(t,e,r)=>new us(t,r)).infixLeft("xor",_.Xor,(t,e,r)=>new ls(t,r)).infixLeft("implies",_.Implies,(t,e,r)=>new ps(t,r))}var Ua=Gt();var h={EQUALS:"eq",NOT_EQUALS:"ne",GREATER_THAN:"gt",LESS_THAN:"lt",GREATER_THAN_OR_EQUALS:"ge",LESS_THAN_OR_EQUALS:"le",STARTS_AFTER:"sa",ENDS_BEFORE:"eb",APPROXIMATELY:"ap",CONTAINS:"contains",STARTS_WITH:"sw",EXACT:"exact",TEXT:"text",NOT:"not",ABOVE:"above",BELOW:"below",IN:"in",NOT_IN:"not-in",OF_TYPE:"of-type",MISSING:"missing",PRESENT:"present",IDENTIFIER:"identifier",ITERATE:"iterate"},Ma={contains:h.CONTAINS,exact:h.EXACT,above:h.ABOVE,below:h.BELOW,text:h.TEXT,not:h.NOT,in:h.IN,"not-in":h.NOT_IN,"of-type":h.OF_TYPE,missing:h.MISSING,identifier:h.IDENTIFIER,iterate:h.ITERATE},wa={eq:h.EQUALS,ne:h.NOT_EQUALS,lt:h.LESS_THAN,le:h.LESS_THAN_OR_EQUALS,gt:h.GREATER_THAN,ge:h.GREATER_THAN_OR_EQUALS,sa:h.STARTS_AFTER,eb:h.ENDS_BEFORE,ap:h.APPROXIMATELY,sw:h.STARTS_WITH};var Va=[h.MISSING,h.PRESENT];var ka=new wt(1e3);var Be={READ:"read",VREAD:"vread",UPDATE:"update",DELETE:"delete",HISTORY:"history",CREATE:"create",SEARCH:"search"},Fa=[Be.READ,Be.VREAD,Be.HISTORY,Be.SEARCH];function ze(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g,t=>{let e=Math.trunc(Math.random()*16);return(t==="x"?e:e&3|8).toString(16)})}var Ts={CSS:"text/css",DICOM:"application/dicom",DICOM_JSON:"application/dicom+json",EVENT_STREAM:"text/event-stream",FAVICON:"image/vnd.microsoft.icon",FHIR_JSON:"application/fhir+json",FORM_URL_ENCODED:"application/x-www-form-urlencoded",HL7_V2:"x-application/hl7-v2+er7",HTML:"text/html",JAVASCRIPT:"text/javascript",JOSE:"application/jose",JSON:"application/json",JSON_PATCH:"application/json-patch+json",JWT:"application/jwt",MULTIPART_FORM_DATA:"multipart/form-data",PNG:"image/png",SCIM_JSON:"application/scim+json",SVG:"image/svg+xml",TEXT:"text/plain",TYPESCRIPT:"text/typescript",PING:"x-application/ping",XML:"text/xml",CDA_XML:"application/cda+xml",OCTET_STREAM:"application/octet-stream"};var Ba={Event:typeof globalThis.Event<"u"?globalThis.Event:void 0,ErrorEvent:void 0,CloseEvent:void 0};var Ya={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1};var Ss;Ss=Symbol.toStringTag;var Ga=[WebSocket.CLOSING,WebSocket.CLOSED];var $a=new wt(1e3);var Ha=Ts.FHIR_JSON+", */*; q=0.1";var ja=[...Yr,"->","<<",">>","=="];var qa=Gt().registerInfix("->",{precedence:_.Arrow}).registerInfix(";",{precedence:_.Semicolon});var Wa=Object.freeze({implicitArrayCreation:!0});var Qa=" ".repeat(2);var za=[...Yr,"eq","ne","co"];var Za={eq:h.EXACT,ne:h.NOT_EQUALS,co:h.CONTAINS,sw:h.STARTS_WITH,ew:void 0,gt:h.GREATER_THAN,lt:h.LESS_THAN,ge:h.GREATER_THAN_OR_EQUALS,le:h.LESS_THAN_OR_EQUALS,ap:h.APPROXIMATELY,sa:h.STARTS_AFTER,eb:h.ENDS_BEFORE,pr:h.PRESENT,po:void 0,ss:void 0,sb:void 0,in:h.IN,ni:h.NOT_IN,re:h.EQUALS,identifier:h.IDENTIFIER};var Ja=Gt();var Xa=`${S}/fhir/StructureDefinition/patient-preferredPharmacy`;var Ka={wk:1440*7,d:1440,h:60,min:1};function $t(t){if(!t)return;let e=t.substring(0,4),r="01",i="01";return t.length>=8&&(r=t.substring(4,6),i=t.substring(6,8)),`${e}-${r}-${i}`}function C(t){if(!t)return;let e=/^[+-]\d{4}$/,r=t.substring(0,4),i="01",n="01",o="00",s="00",a="00",l="Z";t.length>=8&&(i=t.substring(4,6),n=t.substring(6,8)),t.length>=12&&(o=t.substring(8,10),s=t.substring(10,12));let E=t.charAt(12);t.length>=14&&E!=="+"&&E!=="-"&&(a=t.substring(12,14));let A=E==="+"||E==="-"?12:14;return t.length>A&&(l=t.substring(A),l==="+0000"||l==="-0000"?l="Z":e.test(l)&&(l=`${l.substring(0,3)}:${l.substring(3)}`)),`${r}-${i}-${n}T${o}:${s}:${a}${l}`}function k(t){if(t)return t.substring(0,10).replaceAll("-","")}function T(t){if(!t)return;let[e,r]=t.split("T"),i=e.replaceAll("-",""),n=(r??"").replaceAll(/\.\d+/g,"").replaceAll(":","").replaceAll("Z","+0000");return`${i}${n}`}function Gr(t,e){if(t?.start||t?.end){let r={};return t.start&&(r.low={"@_value":T(t.start)??""}),t.end&&(r.high={"@_value":T(t.end)??""}),r}return e?{"@_value":T(e)??""}:{}}var K="1.3.6.1.4.1.19376.1.5.3.1.3.1";var $r="2.16.840.1.113883.1.3";var Hr="2.16.840.1.113883.2.20.5.1",jr="2.16.840.1.113883.3.26.1.1";var qr="2.16.840.1.113883.3.221.5",Wr="2.16.840.1.113883.4.1",Qr="2.16.840.1.113883.4.3",zr="2.16.840.1.113883.4.6",Zr="2.16.840.1.113883.4.9",Ze="2.16.840.1.113883.5.1",Je="2.16.840.1.113883.5.4",Xe="2.16.840.1.113883.5.6",Ht="2.16.840.1.113883.5.25",Jr="2.16.840.1.113883.5.111",y="2.16.840.1.113883.6.1",Xr="2.16.840.1.113883.6.12",Kr="2.16.840.1.113883.6.24",ei="2.16.840.1.113883.6.69",ti="2.16.840.1.113883.6.88",L="2.16.840.1.113883.6.96",ri="2.16.840.1.113883.6.101",ii="2.16.840.1.113883.6.209",Ke="2.16.840.1.113883.6.238",ni="2.16.840.1.113883.6.254",oi="2.16.840.1.113883.6.345";var et="2.16.840.1.113883.10.20.15.3.8";var _e="2.16.840.1.113883.10.20.22.1.1";var jt="2.16.840.1.113883.10.20.22.1.2";var qt="2.16.840.1.113883.10.20.22.1.14";var tt="2.16.840.1.113883.10.20.22.2.1.1";var Ee="2.16.840.1.113883.10.20.22.2.2",Ie="2.16.840.1.113883.10.20.22.2.2.1";var Wt="2.16.840.1.113883.10.20.22.2.3.1";var si="2.16.840.1.113883.10.20.22.2.4.1";var ai="2.16.840.1.113883.10.20.22.2.5",Te="2.16.840.1.113883.10.20.22.2.5.1",ci="2.16.840.1.113883.10.20.22.2.5.1 .2",di="2.16.840.1.113883.10.20.22.2.5.2",ui="2.16.840.1.113883.10.20.22.2.6",Se="2.16.840.1.113883.10.20.22.2.6.1",li="2.16.840.1.113883.10.20.22.2.6.1.2",pi="2.16.840.1.113883.10.20.22.2.6.2";var se="2.16.840.1.113883.10.20.22.2.7.1";var rt="2.16.840.1.113883.10.20.22.2.8";var Z="2.16.840.1.113883.10.20.22.2.10";var Qt="2.16.840.1.113883.10.20.22.2.14";var zt="2.16.840.1.113883.10.20.22.2.17";var Oe="2.16.840.1.113883.10.20.22.2.18";var hi="2.16.840.1.113883.10.20.22.2.22.1";var fi="2.16.840.1.113883.10.20.22.2.23";var mi="2.16.840.1.113883.10.20.22.2.56";var it="2.16.840.1.113883.10.20.22.2.58";var ye="2.16.840.1.113883.10.20.22.2.60";var nt="2.16.840.1.113883.10.20.22.2.65";var ot="2.16.840.1.113883.10.20.22.2.500",Ce="2.16.840.1.113883.10.20.22.4.1",_i="2.16.840.1.113883.10.20.22.4.1.2",ge="2.16.840.1.113883.10.20.22.4.2",Ei="2.16.840.1.113883.10.20.22.4.2.2",Zt="2.16.840.1.113883.10.20.22.4.3";var $="2.16.840.1.113883.10.20.22.4.4",Ii="2.16.840.1.113883.10.20.22.4.4.2";var Jt="2.16.840.1.113883.10.20.22.4.7";var Xt="2.16.840.1.113883.10.20.22.4.8";var Kt="2.16.840.1.113883.10.20.22.4.9";var ae="2.16.840.1.113883.10.20.22.4.12";var Ne="2.16.840.1.113883.10.20.22.4.13";var ce="2.16.840.1.113883.10.20.22.4.14";var er="2.16.840.1.113883.10.20.22.4.16";var Ti="2.16.840.1.113883.10.20.22.4.20";var tr="2.16.840.1.113883.10.20.22.4.23";var Re="2.16.840.1.113883.10.20.22.4.26",Si="2.16.840.1.113883.10.20.22.4.26.2",Ae="2.16.840.1.113883.10.20.22.4.27",Oi="2.16.840.1.113883.10.20.22.4.27.2";var rr="2.16.840.1.113883.10.20.22.4.30";var st="2.16.840.1.113883.10.20.22.4.32";var yi="2.16.840.1.113883.10.20.22.4.37",Ci="2.16.840.1.113883.10.20.22.4.38",gi="2.16.840.1.113883.10.20.22.4.38.1";var at="2.16.840.1.113883.10.20.22.4.41";var ct="2.16.840.1.113883.10.20.22.4.44";var ve="2.16.840.1.113883.10.20.22.4.49";var ir="2.16.840.1.113883.10.20.22.4.52";var nr="2.16.840.1.113883.10.20.22.4.54",or="2.16.840.1.113883.10.20.22.4.60";var sr="2.16.840.1.113883.10.20.22.4.61";var De="2.16.840.1.113883.10.20.22.4.66";var xe="2.16.840.1.113883.10.20.22.4.67";var dt="2.16.840.1.113883.10.20.22.4.69",Ni="2.16.840.1.113883.10.20.22.4.70";var Ri="2.16.840.1.113883.10.20.22.4.74";var Ai="2.16.840.1.113883.10.20.22.4.75";var Pe="2.16.840.1.113883.10.20.22.4.78",vi="2.16.840.1.113883.10.20.22.4.78.2";var be="2.16.840.1.113883.10.20.22.4.85";var ut="2.16.840.1.113883.10.20.22.4.86",Di="2.16.840.1.113883.10.20.22.4.87";var xi="2.16.840.1.113883.10.20.22.4.89",Pi="2.16.840.1.113883.10.20.22.4.90";var bi="2.16.840.1.113883.10.20.22.4.114";var Li="2.16.840.1.113883.10.20.22.4.119";var de="2.16.840.1.113883.10.20.22.4.121";var Ui="2.16.840.1.113883.10.20.22.4.128";var Mi="2.16.840.1.113883.10.20.22.4.130";var ar="2.16.840.1.113883.10.20.22.4.132",wi="2.16.840.1.113883.10.20.22.4.133";var Vi="2.16.840.1.113883.10.20.22.4.140";var lt="2.16.840.1.113883.10.20.22.4.147",Le="2.16.840.1.113883.10.20.22.4.200",ki="2.16.840.1.113883.10.20.22.4.201",Fi="2.16.840.1.113883.10.20.22.4.202";var Bi="2.16.840.1.113883.10.20.22.4.244";var Yi="2.16.840.1.113883.10.20.22.4.250";var Gi="2.16.840.1.113883.10.20.22.4.406",$i="2.16.840.1.113883.10.20.22.4.407";var Hi="2.16.840.1.113883.10.20.22.4.416";var cr="2.16.840.1.113883.10.20.22.4.500",ji="2.16.840.1.113883.10.20.22.4.501";var pt="2.16.840.1.113883.10.20.22.4.503",ht="2.16.840.1.113883.10.20.22.4.504",dr="2.16.840.1.113883.10.20.22.4.505",ft="2.16.840.1.113883.10.20.22.4.506",mt="2.16.840.1.113883.10.20.22.4.507",qi="2.16.840.1.113883.10.20.22.4.508";var Wi="2.16.840.1.113883.10.20.22.4.512";var Qi="2.16.840.1.113883.10.20.22.5.8";var ur="2.16.840.1.113883.12.292",lr="2.16.840.1.113883.3.3719";function _t(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>_t(e)).filter(e=>e!==void 0);if(typeof t=="object"){let e=Object.keys(t).filter(i=>i!=="@_nullFlavor");if(e.length===0)return;let r={};for(let i of e){let n=_t(t[i]);n!==void 0&&(r[i]=n)}return Object.keys(r).length===0?void 0:r}return t}var g=class{constructor(e,r){D(this,"details");D(this,"entries");D(this,"ccdaToFhirMap");D(this,"fhirToCcdaMap");this.details=e,this.entries=r,this.ccdaToFhirMap={},this.fhirToCcdaMap={};for(let i of r)this.ccdaToFhirMap[i.ccdaValue]||(this.ccdaToFhirMap[i.ccdaValue]=i),this.fhirToCcdaMap[i.fhirValue]||(this.fhirToCcdaMap[i.fhirValue]=i)}getEntryByFhir(e){return this.fhirToCcdaMap[e]}getEntryByCcda(e){return this.ccdaToFhirMap[e]}mapCcdaToFhir(e){return this.ccdaToFhirMap[e]?.fhirValue}mapCcdaToFhirWithDefault(e,r){return e?this.mapCcdaToFhir(e)??r:r}mapFhirToCcdaWithDefault(e,r){return e?this.mapFhirToCcda(e)??r:r}mapCcdaToFhirCodeableConcept(e){let r=this.ccdaToFhirMap[e];if(r)return{coding:[{system:this.details.fhirSystemUrl,code:r.fhirValue,display:r.displayName}],text:r.displayName}}mapFhirToCcda(e){if(e)return this.fhirToCcdaMap[e]?.ccdaValue}mapFhirToCcdaCode(e){if(!e)return;let r=this.fhirToCcdaMap[e];if(r)return{"@_code":r.ccdaValue,"@_displayName":r.displayName,"@_codeSystem":this.details.ccdaSystemOid,"@_codeSystemName":this.details.ccdaSystemOid?Nt.getEntryByCcda(this.details.ccdaSystemOid)?.displayName:void 0}}},te="http:",Os=`${S}/fhir/administrative-gender`,pr=`${R}/CodeSystem/condition-clinical`,Zi=`${R}/CodeSystem/condition-verification`,Lc=`${R}/CodeSystem/v3-LanguageAbilityMode`,Uc=`${R}/CodeSystem/v3-LanguageAbilityProficiency`,Mc=`${R}/CodeSystem/v3-Race`,Ji=`${R}/CodeSystem/condition-category`,hr=`${R}/CodeSystem/condition-ver-status`,Et=`${R}/CodeSystem/allergyintolerance-clinical`,fr=`${R}/CodeSystem/allergyintolerance-verification`,mr=`${R}/CodeSystem/v3-ActCode`,Xi=`${R}/CodeSystem/v3-ParticipationType`,Ki=`${R}/CodeSystem/diagnosis-role`,ys=`${R}/CodeSystem/v3-Confidentiality`,Cs=`${R}/CodeSystem/observation-category`,gs=`${R}/CodeSystem/v3-RoleCode`,Ns=`${S}/fhir/ValueSet/address-use`,Rs=`${S}/fhir/ValueSet/name-use`,As=`${S}/fhir/ValueSet/administrative-gender`,vs=`${S}/fhir/ValueSet/contactentity-use`,wc=`${S}/fhir/ValueSet/medicationrequest-status`,Vc=`${S}/fhir/StructureDefinition/language-mode`,kc=`${S}/fhir/StructureDefinition/language-proficiency`,Fc=`${S}/fhir/us/core/StructureDefinition/us-core-patient`,Ue=`${S}/fhir/us/core/StructureDefinition/us-core-race`,It=`${S}/fhir/us/core/StructureDefinition/us-core-ethnicity`,en=`${S}/fhir/us/core/StructureDefinition/us-core-condition`,tn=`${S}/fhir/us/core/StructureDefinition/us-core-medicationrequest`,Bc=`${S}/cda/template`,Ds=`${te}//ncithesaurus-stage.nci.nih.gov`,xs=`${S}/fhir/sid/us-ssn`,Ps=`${S}/fhir/sid/us-dln`,bs=`${S}/fhir/sid/us-npi`,Ls=`${te}//fdasis.nlm.nih.gov`,Us=`${te}//nucc.org/provider-taxonomy`,Ms=`${te}//va.gov/terminology/medrt`,ws=`${te}//hl7.org/fhir/ndfrt`,Vs=`${te}//nucc.org/cvx`,ks=`${S}/fhir/sid/cvx`,Fs=`${S}/fhir/sid/icf`,rn=`${te}//www.w3.org/2001/XMLSchema-instance`,Tt="https://medplum.com/fhir/StructureDefinition/ccda-narrative-reference",nn="48765-2",on="11369-6",sn="10160-0",St="11450-4",an="30954-2",cn="29762-2",dn="8716-3",un="47519-4",Ot="18776-5",yt="51848-0",ln="46264-8",Me="61146-7",we="75310-3",pn="46240-8",Ve="42349-1",hn="57133-1",fn="10190-7",mn="85847-2",_n="48768-6",Ct="11488-4",Yc="34109-9",Gc="60591-5",gt="34133-9",En="76662-6",In="75323-6",Tn="58144-7",Sn="72166-2",On="11367-0",yn="46098-0",Cn="76689-9",gn="8689-2",Nn="75321-0",Rn="47420-5",An="89571-4",vn="47420-5",Dn="11341-5",xn="86188-0",_r="82810-3",Pn="95370-3",Nt=new g({},[{ccdaValue:Hr,fhirValue:"https://fhir.infoway-inforoute.ca/CodeSystem/pCLOCD",displayName:"pan-Canadian LOINC Observation Code Database (pCLOCD)"},{ccdaValue:jr,fhirValue:Ds,displayName:"NCI Thesaurus"},{ccdaValue:Wr,fhirValue:xs,displayName:"SSN"},{ccdaValue:Qr,fhirValue:Ps,displayName:"DLN"},{ccdaValue:zr,fhirValue:bs,displayName:"NPI"},{ccdaValue:Zr,fhirValue:Ls,displayName:"Unique Ingredient Identifier (UNII)"},{ccdaValue:y,fhirValue:je,displayName:"LOINC"},{ccdaValue:Xr,fhirValue:Dr,displayName:"Current Procedural Terminology (CPT)"},{ccdaValue:Kr,fhirValue:"urn:iso:std:iso:11073:10101",displayName:"Medical Device Communications (MDC)"},{ccdaValue:ei,fhirValue:xr,displayName:"National Drug Code (NDC)"},{ccdaValue:ti,fhirValue:vr,displayName:"RxNorm"},{ccdaValue:L,fhirValue:qe,displayName:"SNOMED CT"},{ccdaValue:ri,fhirValue:Us,displayName:"NUCC Health Care Provider Taxonomy"},{ccdaValue:oi,fhirValue:Ms,displayName:"Medication Reference Terminology (MED-RT)"},{ccdaValue:ii,fhirValue:ws,displayName:"National Drug File Reference Terminology (NDF-RT)"},{ccdaValue:ur,fhirValue:Vs,displayName:"CVX"},{ccdaValue:Ht,fhirValue:"Confidentiality",displayName:"Confidentiality"},{ccdaValue:Ze,fhirValue:Os,displayName:"Administrative Sex"},{ccdaValue:Jr,fhirValue:gs,displayName:"Role Code"},{ccdaValue:qr,fhirValue:"",displayName:"Insurance Type Code"},{ccdaValue:ur,fhirValue:ks,displayName:"Vaccine Administered Code Set (CVX)"},{ccdaValue:ni,fhirValue:Fs,displayName:"International Classification of Functioning, Disability and Health (ICF)"}]);function ee(t){if(t)return Nt.mapCcdaToFhir(t)??`urn:oid:${t}`}function Er(t){if(!t)return;let e=[],r=ee(t["@_codeSystem"]),i=t["@_code"],n=t["@_displayName"];(r||i||n)&&e.push({...r&&{system:r},...i&&{code:i},...n&&{display:n}});for(let s of t.translation??m){let a=ee(s["@_codeSystem"]),l=s["@_code"],E=s["@_displayName"];(a||l||E)&&e.push({...a&&{system:a},...l&&{code:l},...E&&{display:E}})}let o=t["@_displayName"];return e.length===0?o?{text:o}:void 0:{coding:e,...o&&{text:o}}}function bn(t){if(t)return t.startsWith("urn:oid:")?t.replace("urn:oid:",""):Nt.mapFhirToCcda(t)}function p(t){if(!t?.coding?.[0])return;let e=zi(t.coding[0]);if(t.coding.length>1){e.translation=[];for(let r=1;r<t.coding.length;r++)e.translation.push(zi(t.coding[r]))}return e}function zi(t){let e=t?.system?Nt.getEntryByFhir(t.system):void 0,r=e?.ccdaValue,i=e?.displayName,n=t.system?.startsWith("urn:oid:")?t.system.replace("urn:oid:",""):void 0;return{"@_code":t.code,"@_displayName":t.display,"@_codeSystem":r??n,"@_codeSystemName":i}}function U(t){let e=p(t);if(e)return{"@_xsi:type":"CD",...e}}var Ln=new g({ccdaSystemOid:Ht,fhirSystemUrl:ys},[{ccdaValue:"U",fhirValue:"U",displayName:"unrestricted"},{ccdaValue:"L",fhirValue:"L",displayName:"low"},{ccdaValue:"M",fhirValue:"M",displayName:"moderate"},{ccdaValue:"N",fhirValue:"N",displayName:"normal"},{ccdaValue:"R",fhirValue:"R",displayName:"restricted"},{ccdaValue:"V",fhirValue:"V",displayName:"very restricted"}]),Rt=new g({fhirSystemUrl:Rs},[{ccdaValue:"C",fhirValue:"usual",displayName:"Common/Called by"},{ccdaValue:"L",fhirValue:"official",displayName:"Legal"},{ccdaValue:"TEMP",fhirValue:"temp",displayName:"Temporary"},{ccdaValue:"P",fhirValue:"nickname",displayName:"Nickname"},{ccdaValue:"ANON",fhirValue:"anonymous",displayName:"Anonymous"},{ccdaValue:"L",fhirValue:"maiden",displayName:"Maiden"},{ccdaValue:"L",fhirValue:"old",displayName:"Old"}]),Un=new g({fhirSystemUrl:As},[{ccdaValue:"F",fhirValue:"female",displayName:"Female"},{ccdaValue:"M",fhirValue:"male",displayName:"Male"},{ccdaValue:"UN",fhirValue:"unknown",displayName:"Unknown"},{ccdaValue:"UN",fhirValue:"other",displayName:"Other"}]),At=new g({fhirSystemUrl:Ns},[{ccdaValue:"HP",fhirValue:"home",displayName:"Home"},{ccdaValue:"WP",fhirValue:"work",displayName:"Work"}]),vt=new g({fhirSystemUrl:vs},[{ccdaValue:"WP",fhirValue:"work",displayName:"Work"},{ccdaValue:"HP",fhirValue:"home",displayName:"Home"},{ccdaValue:"MC",fhirValue:"mobile",displayName:"Mobile"}]),Dt=new g({fhirSystemUrl:fr},[{ccdaValue:"unconfirmed",fhirValue:"unconfirmed",displayName:"Unconfirmed"},{ccdaValue:"provisional",fhirValue:"provisional",displayName:"Provisional"},{ccdaValue:"differential",fhirValue:"differential",displayName:"Differential"},{ccdaValue:"confirmed",fhirValue:"confirmed",displayName:"Confirmed"},{ccdaValue:"refuted",fhirValue:"refuted",displayName:"Refuted"},{ccdaValue:"entered-in-error",fhirValue:"entered-in-error",displayName:"Entered in Error"},{ccdaValue:"unknown",fhirValue:"unknown",displayName:"Unknown"}]),Mn=new g({ccdaSystemOid:L,fhirSystemUrl:Et},[{ccdaValue:"414285001",fhirValue:"food",displayName:"Allergy to food (finding)"},{ccdaValue:"419511003",fhirValue:"medication",displayName:"Propensity to adverse reactions to drug (finding)"},{ccdaValue:"426232007",fhirValue:"environment",displayName:"Environmental allergy (finding)"},{ccdaValue:"418038007",fhirValue:"biologic",displayName:"Propensity to adverse reactions to substance (finding)"}]),xt=new g({ccdaSystemOid:L,fhirSystemUrl:Et},[{ccdaValue:"255604002",fhirValue:"mild",displayName:"Mild"},{ccdaValue:"6736007",fhirValue:"moderate",displayName:"Moderate"},{ccdaValue:"24484000",fhirValue:"severe",displayName:"Severe"}]),ke=new g({fhirSystemUrl:hr},[{ccdaValue:"active",fhirValue:"active",displayName:"Active"},{ccdaValue:"inactive",fhirValue:"inactive",displayName:"Inactive"},{ccdaValue:"resolved",fhirValue:"inactive",displayName:"Resolved"},{ccdaValue:"remission",fhirValue:"inactive",displayName:"In Remission"},{ccdaValue:"relapse",fhirValue:"active",displayName:"Relapse"},{ccdaValue:"resolved relapse",fhirValue:"inactive",displayName:"Resolved Relapse"},{ccdaValue:"aborted",fhirValue:"aborted",displayName:"Aborted"}]),Pt=new g({},[{ccdaValue:"completed",fhirValue:"completed",displayName:"Completed"},{ccdaValue:"nullified",fhirValue:"entered-in-error",displayName:"Nullified"},{ccdaValue:"aborted",fhirValue:"not-done",displayName:"Aborted"},{ccdaValue:"cancelled",fhirValue:"not-done",displayName:"Cancelled"},{ccdaValue:"obsolete",fhirValue:"not-done",displayName:"Obsolete"}]),wn=new g({},[{ccdaValue:"active",fhirValue:"in-progress",displayName:"In Progress"},{ccdaValue:"completed",fhirValue:"finished",displayName:"Finished"},{ccdaValue:"aborted",fhirValue:"cancelled",displayName:"Cancelled"},{ccdaValue:"cancelled",fhirValue:"cancelled",displayName:"Cancelled"},{ccdaValue:"unknown",fhirValue:"unknown",displayName:"Unknown"}]),Vn=new g({},[{ccdaValue:"completed",fhirValue:"completed",displayName:"Completed"},{ccdaValue:"active",fhirValue:"active",displayName:"Active"},{ccdaValue:"aborted",fhirValue:"stopped",displayName:"Stopped"},{ccdaValue:"cancelled",fhirValue:"not-done",displayName:"Not Done"},{ccdaValue:"new",fhirValue:"not-done",displayName:"Draft"},{ccdaValue:"unknown",fhirValue:"unknown",displayName:"Unknown"}]),bt=new g({},[{ccdaValue:"active",fhirValue:"active",displayName:"Active"},{ccdaValue:"completed",fhirValue:"completed",displayName:"Completed"},{ccdaValue:"aborted",fhirValue:"stopped",displayName:"Stopped"},{ccdaValue:"cancelled",fhirValue:"cancelled",displayName:"Cancelled"},{ccdaValue:"aborted",fhirValue:"entered-in-error",displayName:"Entered in Error"},{ccdaValue:"active",fhirValue:"draft",displayName:"Draft"},{ccdaValue:"cancelled",fhirValue:"unknown",displayName:"Unknown"},{ccdaValue:"nullified",fhirValue:"cancelled",displayName:"Nullified"},{ccdaValue:"obsolete",fhirValue:"cancelled",displayName:"Obsolete"}]),kn=new g({fhirSystemUrl:Cs},[{ccdaValue:Ci,fhirValue:"social-history",displayName:"Social History"},{ccdaValue:gi,fhirValue:"social-history",displayName:"Social History V2"},{ccdaValue:Pe,fhirValue:"social-history",displayName:"Smoking Status"},{ccdaValue:vi,fhirValue:"social-history",displayName:"Current Smoking Status"},{ccdaValue:be,fhirValue:"social-history",displayName:"Tobacco Use"},{ccdaValue:pt,fhirValue:"social-history",displayName:"Basic Occupation"},{ccdaValue:ht,fhirValue:"social-history",displayName:"Basic Industry"},{ccdaValue:ji,fhirValue:"social-history",displayName:"Sexual Orientation"},{ccdaValue:mt,fhirValue:"social-history",displayName:"Sex Observation"},{ccdaValue:Le,fhirValue:"social-history",displayName:"Gender Identity"},{ccdaValue:ki,fhirValue:"social-history",displayName:"Gender Identity V2"},{ccdaValue:et,fhirValue:"social-history",displayName:"Pregnancy Status"},{ccdaValue:ft,fhirValue:"social-history",displayName:"Tribal Affiliation"},{ccdaValue:Ae,fhirValue:"vital-signs",displayName:"Vital Signs Observation"},{ccdaValue:Oi,fhirValue:"vital-signs",displayName:"Vital Signs Observation V2"},{ccdaValue:Re,fhirValue:"vital-signs",displayName:"Vital Signs Organizer"},{ccdaValue:Si,fhirValue:"vital-signs",displayName:"Vital Signs Organizer V2"},{ccdaValue:Wi,fhirValue:"vital-signs",displayName:"Average Blood Pressure Organizer"},{ccdaValue:ge,fhirValue:"laboratory",displayName:"Result Observation"},{ccdaValue:Ei,fhirValue:"laboratory",displayName:"Result Observation V2"},{ccdaValue:Gi,fhirValue:"laboratory",displayName:"Laboratory Battery (ID)"},{ccdaValue:$i,fhirValue:"laboratory",displayName:"Laboratory Observation (ID)"},{ccdaValue:Hi,fhirValue:"laboratory",displayName:"Laboratory Result Organizer (ID)"},{ccdaValue:Ce,fhirValue:"laboratory",displayName:"Result Organizer"},{ccdaValue:_i,fhirValue:"laboratory",displayName:"Result Organizer V2"},{ccdaValue:dt,fhirValue:"survey",displayName:"Assessment Scale Observation"},{ccdaValue:ut,fhirValue:"survey",displayName:"Assessment Scale Supporting Observation"},{ccdaValue:Ri,fhirValue:"survey",displayName:"Cognitive Status Result Observation"},{ccdaValue:Ai,fhirValue:"survey",displayName:"Cognitive Status Result Organizer"},{ccdaValue:xe,fhirValue:"survey",displayName:"Functional Status Result Observation"},{ccdaValue:De,fhirValue:"survey",displayName:"Functional Status Result Organizer"},{ccdaValue:Ne,fhirValue:"exam",displayName:"Procedure Activity Observation"},{ccdaValue:$,fhirValue:"exam",displayName:"Problem Observation"},{ccdaValue:Ii,fhirValue:"exam",displayName:"Problem Observation V2"},{ccdaValue:Ni,fhirValue:"exam",displayName:"Pressure Ulcer Observation"},{ccdaValue:bi,fhirValue:"exam",displayName:"Wound Observation"},{ccdaValue:wi,fhirValue:"exam",displayName:"Wound Measurements Observation"},{ccdaValue:se,fhirValue:"exam",displayName:"Procedure Section"},{ccdaValue:qi,fhirValue:"therapy",displayName:"Medication Adherence"},{ccdaValue:Mi,fhirValue:"therapy",displayName:"Nutrition Recommendations"},{ccdaValue:Bi,fhirValue:"therapy",displayName:"Diet Statement (Nutrition)"},{ccdaValue:Yi,fhirValue:"therapy",displayName:"Monitoring, Evaluation and Outcome (Nutrition)"}]),Fn=new g({fhirSystemUrl:mr},[{ccdaValue:"71",fhirValue:"HMO",displayName:"Health Maintenance Organization"},{ccdaValue:"72",fhirValue:"PPO",displayName:"Preferred Provider Organization"},{ccdaValue:"73",fhirValue:"POS",displayName:"Point of Service"},{ccdaValue:"79",fhirValue:"MCPOL",displayName:"Managed Care Policy"},{ccdaValue:"81",fhirValue:"pay",displayName:"Self Pay"},{ccdaValue:"9999",fhirValue:"",displayName:"Unknown"}]);import{XMLBuilder as Bn,XMLParser as Yn}from"fast-xml-parser";var Bs=["ClinicalDocument.participant","ClinicalDocument.recordTarget",".id",".templateId",".name",".addr",".telecom",".streetAddressLine",".author",".effectiveTime","name.given","name.suffix","name.prefix","patient.raceCode","patient.sdtc:raceCode","patient.ethnicGroupCode","patient.languageCommunication","component.structuredBody.component","component.structuredBody.component.section","component.section","component.observation","component.act","code.translation","value.translation","routeCode.translation","methodCode.translation","targetSiteCode.translation","approachSiteCode.translation","administrationUnitCode.translation","section.entry","entry.act","entry.organizer","entry.substanceAdministration","entry.observation","entry.encounter","entry.procedure","encounter.performer","encounter.participant","encounter.entryRelationship","entryRelationship.observation","entryRelationship.substanceAdministration","entryRelationship.act","organizer.component","substanceAdministration.consumable.manufacturedProduct","substanceAdministration.entryRelationship","substanceAdministration.performer","act.entryRelationship","act.performer","observation.participant","observation.entryRelationship","observation.referenceRange","consumable.manufacturedProduct","manufacturedProduct.manufacturedMaterial","manufacturedProduct.manufacturerOrganization","manufacturedProduct.manufacturedLabeledDrug","manufacturedMaterial.code","manufacturedMaterial.lotNumberText"];function Wc(t){return new Yn({ignoreAttributes:!1,attributeNamePrefix:"@_",parseAttributeValue:!1,parseTagValue:!1,jPath:!0,isArray:(i,n,o,s)=>Bs.some(a=>n.endsWith(a))}).parse(t).ClinicalDocument}function Qc(t){return new Bn({ignoreAttributes:!1,attributeNamePrefix:"@_",format:!0,suppressBooleanAttributes:!1,suppressEmptyNode:!0}).build({"?xml":{"@_version":"1.0","@_encoding":"UTF-8"},"?xml-stylesheet":{"@_type":"text/xsl","@_href":"CDA.xsl"},ClinicalDocument:{"@_xmlns":"urn:hl7-org:v3","@_xmlns:xsi":rn,"@_xmlns:voc":"urn:hl7-org:v3/voc","@_xmlns:sdtc":"urn:hl7-org:sdtc",...t}})}function Gn(t){return new Yn({ignoreAttributes:!1,attributeNamePrefix:"@_",parseAttributeValue:!1,parseTagValue:!1}).parse(t)}function $n(t){return t?typeof t=="string"?t:new Bn({ignoreAttributes:!1,attributeNamePrefix:"@_",format:!1,suppressBooleanAttributes:!1,suppressEmptyNode:!0}).build(t).split(`
|
|
1
|
+
var po=Object.defineProperty;var ho=(t,e,r)=>e in t?po(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var D=(t,e,r)=>ho(t,typeof e!="symbol"?e+"":e,r);var fo=Object.defineProperty,mo=(t,e,r)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e,r)=>mo(t,typeof e!="symbol"?e+"":e,r),wt=class{constructor(t=10){O(this,"max"),O(this,"cache"),this.max=t,this.cache=new Map}clear(){this.cache.clear()}get(t){let e=this.cache.get(t);return e&&(this.cache.delete(t),this.cache.set(t,e)),e}set(t,e){this.cache.has(t)?this.cache.delete(t):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(t,e)}delete(t){this.cache.delete(t)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}},_o=class{constructor(t,e){O(this,"operator"),O(this,"child"),this.operator=t,this.child=e}toString(){return`${this.operator}(${this.child.toString()})`}},v=class{constructor(t,e,r){O(this,"operator"),O(this,"left"),O(this,"right"),this.operator=t,this.left=e,this.right=r}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}},Eo=class{constructor(){O(this,"prefixParselets",{}),O(this,"infixParselets",{})}registerInfix(t,e){return this.infixParselets[t]=e,this}registerPrefix(t,e){return this.prefixParselets[t]=e,this}prefix(t,e,r){return this.registerPrefix(t,{parse(i,n){let o=i.consumeAndParse(e);return r(n,o)}})}infixLeft(t,e,r){return this.registerInfix(t,{parse(i,n,o){let s=i.consumeAndParse(e);return r(n,o,s)},precedence:e})}construct(t){return new Io(t,this.prefixParselets,this.infixParselets)}},Io=class{constructor(t,e,r){O(this,"tokens"),O(this,"prefixParselets"),O(this,"infixParselets"),this.tokens=t,this.prefixParselets=e,this.infixParselets=r}hasMore(){return this.tokens.length>0}match(t){return this.peek()?.id!==t?!1:(this.consume(),!0)}consumeAndParse(t=1/0){let e=this.consume(),r=this.prefixParselets[e.id];if(!r)throw new Error(`Parse error at "${e.value}" (line ${e.line}, column ${e.column}). No matching prefix parselet.`);let i=r.parse(this,e);for(;t>this.getPrecedence();){let n=this.consume();i=this.getInfixParselet(n).parse(this,i,n)}return i}getPrecedence(){let t=this.peek();if(!t)return 1/0;let e=this.getInfixParselet(t);return e?e.precedence:1/0}consume(t,e){if(!this.tokens.length)throw new Error("Cant consume unknown more tokens.");if(t&&this.peek()?.id!==t){let r=this.peek();throw new Error(`Expected ${t} but got "${r.id}" (${r.value}) at line ${r.line} column ${r.column}.`)}if(e&&this.peek()?.value!==e){let r=this.peek();throw new Error(`Expected "${e}" but got "${r.value}" at line ${r.line} column ${r.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(t=>t.id!=="Comment")}getInfixParselet(t){return this.infixParselets[t.id==="Symbol"?t.value:t.id]}};var fe="http://unitsofmeasure.org",je="http://loinc.org",qe="http://snomed.info/sct",vr="http://www.nlm.nih.gov/research/umls/rxnorm",Dr="http://www.ama-assn.org/go/cpt";var xr="http://hl7.org/fhir/sid/ndc",S="http://hl7.org",R="http://terminology.hl7.org",xa=`${R}/CodeSystem/v2-0203`;var To="unauthorized";var He={resourceType:"OperationOutcome",id:To,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Pa={...He,issue:[...He.issue,{severity:"error",code:"expired",details:{text:"Token expired"}}]},ba={...He,issue:[...He.issue,{severity:"error",code:"invalid",details:{text:"Token not issued for this audience"}}]};function So(t,e){let r=e.max&&e.max===Number.MAX_SAFE_INTEGER?Number.POSITIVE_INFINITY:e.max;return{path:t,description:"",type:e.type??[],min:e.min??0,max:r??1,isArray:!!r&&r>1,constraints:[]}}function Oo(t){let e=Object.create(null);for(let[r,i]of Object.entries(t))e[r]={name:r,type:r,path:r,elements:Object.fromEntries(Object.entries(i.elements).map(([n,o])=>[n,So(n,o)])),constraints:[],innerTypes:[]};return e}var yo={Element:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},BackboneElement:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},Address:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"code"}]},text:{type:[{code:"string"}]},line:{max:9007199254740991,type:[{code:"string"}]},city:{type:[{code:"string"}]},district:{type:[{code:"string"}]},state:{type:[{code:"string"}]},postalCode:{type:[{code:"string"}]},country:{type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},Age:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},Annotation:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"author[x]":{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:{type:[{code:"dateTime"}]},text:{min:1,type:[{code:"markdown"}]}}},Attachment:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},contentType:{type:[{code:"code"}]},language:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]},url:{type:[{code:"url"}]},size:{type:[{code:"unsignedInt"}]},hash:{type:[{code:"base64Binary"}]},title:{type:[{code:"string"}]},creation:{type:[{code:"dateTime"}]}}},CodeableConcept:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},Coding:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},code:{type:[{code:"code"}]},display:{type:[{code:"string"}]},userSelected:{type:[{code:"boolean"}]}}},ContactDetail:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},ContactPoint:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"code"}]},value:{type:[{code:"string"}]},use:{type:[{code:"code"}]},rank:{type:[{code:"positiveInt"}]},period:{type:[{code:"Period"}]}}},Contributor:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{min:1,type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]}}},Count:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},DataRequirement:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{max:9007199254740991,type:[{code:"string"}]},codeFilter:{max:9007199254740991,type:[{code:"DataRequirementCodeFilter"}]},dateFilter:{max:9007199254740991,type:[{code:"DataRequirementDateFilter"}]},limit:{type:[{code:"positiveInt"}]},sort:{max:9007199254740991,type:[{code:"DataRequirementSort"}]}}},DataRequirementCodeFilter:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{max:9007199254740991,type:[{code:"Coding"}]}}},DataRequirementDateFilter:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},"value[x]":{type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}}},DataRequirementSort:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},direction:{min:1,type:[{code:"code"}]}}},Distance:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},Dosage:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},sequence:{type:[{code:"integer"}]},text:{type:[{code:"string"}]},additionalInstruction:{max:9007199254740991,type:[{code:"CodeableConcept"}]},patientInstruction:{type:[{code:"string"}]},timing:{type:[{code:"Timing"}]},"asNeeded[x]":{type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{type:[{code:"CodeableConcept"}]},route:{type:[{code:"CodeableConcept"}]},method:{type:[{code:"CodeableConcept"}]},doseAndRate:{max:9007199254740991,type:[{code:"DosageDoseAndRate"}]},maxDosePerPeriod:{type:[{code:"Ratio"}]},maxDosePerAdministration:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},DosageDoseAndRate:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{type:[{code:"CodeableConcept"}]},"dose[x]":{type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Duration:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},ElementDefinition:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},representation:{max:9007199254740991,type:[{code:"code"}]},sliceName:{type:[{code:"string"}]},sliceIsConstraining:{type:[{code:"boolean"}]},label:{type:[{code:"string"}]},code:{max:9007199254740991,type:[{code:"Coding"}]},slicing:{type:[{code:"ElementDefinitionSlicing"}]},short:{type:[{code:"string"}]},definition:{type:[{code:"markdown"}]},comment:{type:[{code:"markdown"}]},requirements:{type:[{code:"markdown"}]},alias:{max:9007199254740991,type:[{code:"string"}]},min:{type:[{code:"unsignedInt"}]},max:{type:[{code:"string"}]},base:{type:[{code:"ElementDefinitionBase"}]},contentReference:{type:[{code:"uri"}]},type:{max:9007199254740991,type:[{code:"ElementDefinitionType"}]},"defaultValue[x]":{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:{type:[{code:"markdown"}]},orderMeaning:{type:[{code:"string"}]},"fixed[x]":{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]":{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:{max:9007199254740991,type:[{code:"ElementDefinitionExample"}]},"minValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{type:[{code:"integer"}]},condition:{max:9007199254740991,type:[{code:"id"}]},constraint:{max:9007199254740991,type:[{code:"ElementDefinitionConstraint"}]},mustSupport:{type:[{code:"boolean"}]},isModifier:{type:[{code:"boolean"}]},isModifierReason:{type:[{code:"string"}]},isSummary:{type:[{code:"boolean"}]},binding:{type:[{code:"ElementDefinitionBinding"}]},mapping:{max:9007199254740991,type:[{code:"ElementDefinitionMapping"}]}}},ElementDefinitionSlicingDiscriminator:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},path:{min:1,type:[{code:"string"}]}}},ElementDefinitionSlicing:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},discriminator:{max:9007199254740991,type:[{code:"ElementDefinitionSlicingDiscriminator"}]},description:{type:[{code:"string"}]},ordered:{type:[{code:"boolean"}]},rules:{min:1,type:[{code:"code"}]}}},ElementDefinitionBase:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},min:{min:1,type:[{code:"unsignedInt"}]},max:{min:1,type:[{code:"string"}]}}},ElementDefinitionType:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{max:9007199254740991,type:[{code:"code"}]},versioning:{type:[{code:"code"}]}}},ElementDefinitionExample:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},label:{min:1,type:[{code:"string"}]},"value[x]":{min: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"}]}}},ElementDefinitionConstraint:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},key:{min:1,type:[{code:"id"}]},requirements:{type:[{code:"string"}]},severity:{min:1,type:[{code:"code"}]},human:{min:1,type:[{code:"string"}]},expression:{type:[{code:"string"}]},xpath:{type:[{code:"string"}]},source:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},ElementDefinitionBinding:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},strength:{min:1,type:[{code:"code"}]},description:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}}},ElementDefinitionMapping:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},identity:{min:1,type:[{code:"id"}]},language:{type:[{code:"code"}]},map:{min:1,type:[{code:"string"}]},comment:{type:[{code:"string"}]}}},Expression:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},description:{type:[{code:"string"}]},name:{type:[{code:"id"}]},language:{min:1,type:[{code:"code"}]},expression:{type:[{code:"string"}]},reference:{type:[{code:"uri"}]}}},Extension:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},url:{min:1,type:[{code:"uri"}]},"value[x]":{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:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},text:{type:[{code:"string"}]},family:{type:[{code:"string"}]},given:{max:9007199254740991,type:[{code:"string"}]},prefix:{max:9007199254740991,type:[{code:"string"}]},suffix:{max:9007199254740991,type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},Identifier:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"CodeableConcept"}]},system:{type:[{code:"uri"}]},value:{type:[{code:"string"}]},period:{type:[{code:"Period"}]},assigner:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},MarketingStatus:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},country:{min:1,type:[{code:"CodeableConcept"}]},jurisdiction:{type:[{code:"CodeableConcept"}]},status:{min:1,type:[{code:"CodeableConcept"}]},dateRange:{min:1,type:[{code:"Period"}]},restoreDate:{type:[{code:"dateTime"}]}}},Meta:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},versionId:{type:[{code:"id"}]},lastUpdated:{type:[{code:"instant"}]},source:{type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{max:9007199254740991,type:[{code:"Coding"}]},tag:{max:9007199254740991,type:[{code:"Coding"}]},project:{type:[{code:"uri"}]},author:{type:[{code:"Reference"}]},onBehalfOf:{type:[{code:"Reference"}]},account:{type:[{code:"Reference"}]},accounts:{max:9007199254740991,type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]},deleted:{type:[{code:"boolean"}]}}},Money:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},Narrative:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},ParameterDefinition:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"code"}]},use:{min:1,type:[{code:"code"}]},min:{type:[{code:"integer"}]},max:{type:[{code:"string"}]},documentation:{type:[{code:"string"}]},type:{min:1,type:[{code:"code"}]},profile:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},Period:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},Population:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"age[x]":{type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{type:[{code:"CodeableConcept"}]},race:{type:[{code:"CodeableConcept"}]},physiologicalCondition:{type:[{code:"CodeableConcept"}]}}},ProdCharacteristic:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},height:{type:[{code:"Quantity"}]},width:{type:[{code:"Quantity"}]},depth:{type:[{code:"Quantity"}]},weight:{type:[{code:"Quantity"}]},nominalVolume:{type:[{code:"Quantity"}]},externalDiameter:{type:[{code:"Quantity"}]},shape:{type:[{code:"string"}]},color:{max:9007199254740991,type:[{code:"string"}]},imprint:{max:9007199254740991,type:[{code:"string"}]},image:{max:9007199254740991,type:[{code:"Attachment"}]},scoring:{type:[{code:"CodeableConcept"}]}}},ProductShelfLife:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},identifier:{type:[{code:"Identifier"}]},type:{min:1,type:[{code:"CodeableConcept"}]},period:{min:1,type:[{code:"Quantity"}]},specialPrecautionsForStorage:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},Quantity:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},Range:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},low:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},Ratio:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},Reference:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},reference:{type:[{code:"string"}]},type:{type:[{code:"uri"}]},identifier:{type:[{code:"Identifier"}]},display:{type:[{code:"string"}]}}},RelatedArtifact:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},label:{type:[{code:"string"}]},display:{type:[{code:"string"}]},citation:{type:[{code:"markdown"}]},url:{type:[{code:"url"}]},document:{type:[{code:"Attachment"}]},resource:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},SampledData:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},origin:{min:1,type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,type:[{code:"decimal"}]},factor:{type:[{code:"decimal"}]},lowerLimit:{type:[{code:"decimal"}]},upperLimit:{type:[{code:"decimal"}]},dimensions:{min:1,type:[{code:"positiveInt"}]},data:{type:[{code:"string"}]}}},Signature:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,max:9007199254740991,type:[{code:"Coding"}]},when:{min:1,type:[{code:"instant"}]},who:{min: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:{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:{type:[{code:"code"}]},sigFormat:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]}}},SubstanceAmount:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"amount[x]":{type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{type:[{code:"CodeableConcept"}]},amountText:{type:[{code:"string"}]},referenceRange:{type:[{code:"SubstanceAmountReferenceRange"}]}}},SubstanceAmountReferenceRange:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},lowLimit:{type:[{code:"Quantity"}]},highLimit:{type:[{code:"Quantity"}]}}},Timing:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},event:{max:9007199254740991,type:[{code:"dateTime"}]},repeat:{type:[{code:"TimingRepeat"}]},code:{type:[{code:"CodeableConcept"}]}}},TimingRepeat:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"bounds[x]":{type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{type:[{code:"positiveInt"}]},countMax:{type:[{code:"positiveInt"}]},duration:{type:[{code:"decimal"}]},durationMax:{type:[{code:"decimal"}]},durationUnit:{type:[{code:"code"}]},frequency:{type:[{code:"positiveInt"}]},frequencyMax:{type:[{code:"positiveInt"}]},period:{type:[{code:"decimal"}]},periodMax:{type:[{code:"decimal"}]},periodUnit:{type:[{code:"code"}]},dayOfWeek:{max:9007199254740991,type:[{code:"code"}]},timeOfDay:{max:9007199254740991,type:[{code:"time"}]},when:{max:9007199254740991,type:[{code:"code"}]},offset:{type:[{code:"unsignedInt"}]}}},TriggerDefinition:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{type:[{code:"string"}]},"timing[x]":{type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{max:9007199254740991,type:[{code:"DataRequirement"}]},condition:{type:[{code:"Expression"}]}}},UsageContext:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"Coding"}]},"value[x]":{min: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"]}]}}},MoneyQuantity:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},SimpleQuantity:{elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{max:0,type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},IdentityProvider:{elements:{issuer:{type:[{code:"string"}]},audience:{type:[{code:"string"}]},jwksUrl:{type:[{code:"string"}]},authorizeUrl:{type:[{code:"string"}]},tokenUrl:{type:[{code:"string"}]},tokenAuthMethod:{type:[{code:"code"}]},userInfoUrl:{type:[{code:"string"}]},userInfoMode:{type:[{code:"code"}]},userInfoApiKey:{type:[{code:"string"}]},clientId:{type:[{code:"string"}]},clientSecret:{type:[{code:"string"}]},usePkce:{type:[{code:"boolean"}]},useSubject:{type:[{code:"boolean"}]},identitySource:{type:[{code:"code"}]},identityMappingMode:{type:[{code:"code"}]}}}};var Co=Oo(yo);var yr=Object.create(null);function go(t){let e;return e=yr[t],e||(e=yr[t]=Object.create(null)),e}function No(t,e){if(e){let r=go(e)[t];if(r)return r}return Co[t]}function Ro(t,e,r){let i=t.path;return Ao(vo(t,e,r),i,e)}function Ao(t,e,r){let i=e?e+".":"";return t===void 0?{type:"undefined",value:void 0,path:`${i}${r}`}:Array.isArray(t)?t.map((n,o)=>({...n,path:`${i}${r}[${o}]`})):{...t,path:`${i}${r}`}}var La=new wt(1e3);var Pr={canonical:/^\S*$/,code:/^[^\s]+( [^\s]+)*$/,date:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/,dateTime:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/,id:/^[A-Za-z0-9\-.]{1,64}$/,instant:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/,markdown:/^[\r\n\t\u0020-\uFFFF]+$/,oid:/^urn:oid:[0-2](\.(0|[1-9]\d*))+$/,string:/^[\r\n\t\u0020-\uFFFF]+$/,time:/^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/,uri:/^\S*$/,url:/^\S*$/,uuid:/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,xhtml:/.*/};function c(t){return[{type:u.boolean,value:t}]}function Q(t){return t==null?{type:"undefined",value:void 0}:Number.isSafeInteger(t)?{type:u.integer,value:t}:typeof t=="number"?{type:u.decimal,value:t}:typeof t=="boolean"?{type:u.boolean,value:t}:typeof t=="string"?{type:u.string,value:t}:V(t)?{type:u.Quantity,value:t}:me(t)?{type:t.resourceType,value:t}:Vr(t)?{type:u.CodeableConcept,value:t}:wr(t)?{type:u.Coding,value:t}:{type:u.BackboneElement,value:t}}function W(t){return t.length===0?!1:!!t[0].value}function b(t,e){if(t.length!==0){if(t.length===1&&(!e||t[0].type===e))return t[0];{let r=e?` of type ${e}`:"";throw new Error(`Expected singleton${r}, but found ${JSON.stringify(t)}`)}}}function vo(t,e,r){if(!t.value)return;let i=zo(t.type,e,r?.profileUrl);return i?Do(t,e,i):Vt(t,e)}function Do(t,e,r){let i=t.value,n=r.type;if(!n||n.length===0)return;let o,s="undefined",a,l=r.path.lastIndexOf("."),E=r.path.substring(l+1),A=E,j=!1;E.endsWith("[x]")&&(A=E.substring(0,E.length-3),j=!0);for(let N of n){let Lt=A;if(j&&(Lt+=oe(N.code)),o=i[Lt],a=i["_"+Lt],o!==void 0||a!==void 0){s=N.code;break}}if(a)if(Array.isArray(o)){o=o.slice();for(let N=0;N<Math.max(o.length,a.length);N++)o[N]=Ut(o[N],a[N])}else if(!o&&Array.isArray(a)){o=a.slice();for(let N=0;N<a.length;N++)o[N]=Ut(void 0,a[N])}else o=Ut(o,a);if(!he(o))return(s==="Element"||s==="BackboneElement")&&(s=r.type[0].code),Array.isArray(o)?o.map(N=>Cr(N,s)):Cr(o,s)}function Cr(t,e){return e==="Resource"&&me(t)&&(e=t.resourceType),{type:e,value:t}}function Vt(t,e){let r=t.value;if(!r||typeof r!="object")return;let i;if(e in r){let n=r[e];Array.isArray(n)?i=n.map(Q):i=Q(n)}else{let n=e.endsWith("[x]")?e.substring(0,e.length-3):e;for(let o of Object.values(u)){let s=n+oe(o);if(s in r){let a=r[s];Array.isArray(a)?i=a.map(l=>({type:o,value:l})):i={type:o,value:a};break}}}if(Array.isArray(i)){if(i.length===0||he(i[0]))return}else if(he(i))return;return i}function br(t){let e=[];for(let r of t){let i=!1;for(let n of e)if(W(We(r,n))){i=!0;break}i||e.push(r)}return e}function xo(t){return c(!W(t))}function Po(t,e){return t.length===0||e.length===0?[]:t.length!==e.length?c(!1):c(t.every((r,i)=>W(We(r,e[i]))))}function bo(t,e){return t.length===0||e.length===0?[]:t.length!==e.length?c(!0):c(t.some((r,i)=>!W(We(r,e[i]))))}function We(t,e){let r=t.value?.valueOf(),i=e.value?.valueOf();return typeof r=="number"&&typeof i=="number"?c(Math.abs(r-i)<1e-8):V(r)&&V(i)?c(Ur(r,i)):c(typeof r=="object"&&typeof i=="object"?kt(t,e):r===i)}function Lr(t,e){return t.length===0&&e.length===0?c(!0):t.length!==e.length?c(!1):(t.sort(gr),e.sort(gr),c(t.every((r,i)=>W(Lo(r,e[i])))))}function Lo(t,e){let{type:r,value:i}=t,{type:n,value:o}=e,s=i?.valueOf(),a=o?.valueOf();return typeof s=="number"&&typeof a=="number"?c(Math.abs(s-a)<.01):V(s)&&V(a)?c(Ur(s,a)):c(r==="Coding"&&n==="Coding"?typeof s!="object"||typeof a!="object"?!1:s.code===a.code&&s.system===a.system:typeof s=="object"&&typeof a=="object"?kt({...s,id:void 0},{...a,id:void 0}):typeof s=="string"&&typeof a=="string"?s.toLowerCase()===a.toLowerCase():s===a)}function gr(t,e){let r=t.value?.valueOf(),i=e.value?.valueOf();return typeof r=="number"&&typeof i=="number"?r-i:typeof r=="string"&&typeof i=="string"?r.localeCompare(i):0}function Ye(t,e){let{value:r}=t;if(r==null)return!1;let i=e;switch(i.startsWith("System.")&&(i=i.substring(7)),i.startsWith("FHIR.")&&(i=i.substring(5)),i){case"Boolean":return typeof r=="boolean";case"Decimal":case"Integer":return typeof r=="number";case"Date":return Uo(r);case"DateTime":return Mt(r);case"Time":return typeof r=="string"&&!!/^T\d/.exec(r);case"Period":return Mo(r);case"Quantity":return V(r);default:return t.type===i||typeof r=="object"&&r?.resourceType===i}}function Uo(t){return typeof t=="string"&&!!Pr.date.exec(t)}function Mt(t){return typeof t=="string"&&!!Pr.dateTime.exec(t)}function Mo(t){return!!(t&&typeof t=="object"&&("start"in t&&Mt(t.start)||"end"in t&&Mt(t.end)))}function V(t){return!!(t&&typeof t=="object"&&"value"in t&&typeof t.value=="number")}function Ur(t,e){return Math.abs(t.value-e.value)<.01&&(t.unit===e.unit||t.code===e.code||t.unit===e.code||t.code===e.unit)}function kt(t,e){let r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(let n of r){let o=t[n],s=e[n];if(Nr(o)&&Nr(s)){if(!kt(o,s))return!1}else if(o!==s)return!1}return!0}function Nr(t){return t!==null&&typeof t=="object"}function Ut(t,e){if(e){if(typeof e!="object")throw new Error("Primitive extension must be an object");return wo(t??{},e)}return t}function wo(t,e){return delete e.__proto__,delete e.constructor,Object.assign(t,e)}function Vo(t,e){return me(t,e)&&"id"in t&&typeof t.id=="string"}function I(t){let e=Mr(t)??"undefined/undefined",r=Bo(t);return r===e?{reference:e}:{reference:e,display:r}}function Mr(t){if(Fr(t))return t.reference;if(Vo(t))return`${t.resourceType}/${t.id}`}function ko(t){if(t)return Fr(t)?t.reference.split("/")[1]:t.id}function Fo(t){return t.resourceType==="Patient"||t.resourceType==="Practitioner"||t.resourceType==="RelatedPerson"}function Bo(t){if(Fo(t)){let e=Yo(t);if(e)return e}if(t.resourceType==="Appointment"&&t.serviceType?.[0])return le(t.serviceType[0]);if(t.resourceType==="Device"){let e=Go(t);if(e)return e}if(t.resourceType==="DocumentReference"){if(t.description)return t.description;if(t.type)return le(t.type)}if(t.resourceType==="MedicationRequest"&&t.medicationCodeableConcept||t.resourceType==="MedicationStatement"&&t.medicationCodeableConcept)return le(t.medicationCodeableConcept);if(t.resourceType==="Slot"&&(t.start||t.end))return`${Rr(t.start)} - ${Rr(t.end)}`;if(t.resourceType==="Subscription"&&t.criteria)return t.criteria;if(t.resourceType==="User"&&t.email)return t.email;if("name"in t&&t.name&&typeof t.name=="string")return t.name;if("code"in t&&t.code){let e=t.code;if(Array.isArray(e)&&(e=e[0]),Vr(e))return le(e);if(Ho(e))return e.text}return Mr(t)??""}function Yo(t){let e=t.name;if(e&&e.length>0)return qo(e[0])}function Go(t){let e=t.deviceName;if(e&&e.length>0)return e[0].name}function $o(t,e){let r=new Date(t);r.setUTCHours(0,0,0,0);let i=e?new Date(e):new Date;i.setUTCHours(0,0,0,0);let n=r.getUTCFullYear(),o=r.getUTCMonth(),s=r.getUTCDate(),a=i.getUTCFullYear(),l=i.getUTCMonth(),E=i.getUTCDate(),A=a-n;(l<o||l===o&&E<s)&&A--;let j=a*12+l-(n*12+o);E<s&&j--;let N=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return{years:A,months:j,days:N}}function Qe(t,...e){let r=t;for(let i=0;i<e.length&&r;i++)r=r?.extension?.find(n=>n.url===e[i]);return r}function he(t){if(t==null)return!0;let e=typeof t;return e==="string"||e==="object"?!Ft(t):!1}function Ft(t){if(t==null)return!1;let e=typeof t;return e==="string"&&t!==""||e==="object"&&("length"in t&&t.length>0||Object.keys(t).length>0)}function Bt(t){return/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(t)}function Yt(t){return t!==null&&typeof t=="object"}function wr(t){return Yt(t)&&"code"in t&&typeof t.code=="string"}function Vr(t){return Yt(t)&&"coding"in t&&Array.isArray(t.coding)&&t.coding.every(wr)}function Ho(t){return Yt(t)&&"text"in t&&typeof t.text=="string"}var jo=[];for(let t=0;t<256;t++)jo.push(t.toString(16).padStart(2,"0"));function oe(t){return t?t.charAt(0).toUpperCase()+t.substring(1):""}function kr(t,e){return t?(t.push(e),t):[e]}var m=Object.freeze([]);function qo(t,e){if(!t)return"";let r=[];if(t.prefix&&e?.prefix!==!1&&r.push(...t.prefix),t.given&&r.push(...t.given),t.family&&r.push(t.family),t.suffix&&e?.suffix!==!1&&r.push(...t.suffix),t.use&&(e?.all||e?.use)&&r.push("["+t.use+"]"),r.length===0){let i=pe(t.text);if(i)return i}return r.join(" ").trim()}function Wo(t){return t instanceof Date&&!Number.isNaN(t.getTime())}function Rr(t,e,r){if(!t)return"";let i=new Date(t);return Wo(i)?i.toLocaleString(e,r):""}function le(t){return t?pe(t.text)||(t.coding?t.coding.map(r=>Qo(r)).join(", "):""):""}function Qo(t,e){let r=pe(t?.display);if(r){let i=e?pe(t?.code):void 0;return`${r}${i?" ("+i+")":""}`}return pe(t?.code)??""}function pe(t){return typeof t=="string"?t:void 0}var u={Address:"Address",Age:"Age",Annotation:"Annotation",Attachment:"Attachment",BackboneElement:"BackboneElement",CodeableConcept:"CodeableConcept",Coding:"Coding",ContactDetail:"ContactDetail",ContactPoint:"ContactPoint",Contributor:"Contributor",Count:"Count",DataRequirement:"DataRequirement",Distance:"Distance",Dosage:"Dosage",Duration:"Duration",Element:"Element",ElementDefinition:"ElementDefinition",Expression:"Expression",Extension:"Extension",HumanName:"HumanName",Identifier:"Identifier",MarketingStatus:"MarketingStatus",Meta:"Meta",Money:"Money",MoneyQuantity:"MoneyQuantity",Narrative:"Narrative",ParameterDefinition:"ParameterDefinition",Period:"Period",Population:"Population",ProdCharacteristic:"ProdCharacteristic",ProductShelfLife:"ProductShelfLife",Quantity:"Quantity",Range:"Range",Ratio:"Ratio",Reference:"Reference",RelatedArtifact:"RelatedArtifact",SampledData:"SampledData",Signature:"Signature",SimpleQuantity:"SimpleQuantity",SubstanceAmount:"SubstanceAmount",SystemString:"http://hl7.org/fhirpath/System.String",Timing:"Timing",TriggerDefinition:"TriggerDefinition",UsageContext:"UsageContext",base64Binary:"base64Binary",boolean:"boolean",canonical:"canonical",code:"code",date:"date",dateTime:"dateTime",decimal:"decimal",id:"id",instant:"instant",integer:"integer",markdown:"markdown",oid:"oid",positiveInt:"positiveInt",string:"string",time:"time",unsignedInt:"unsignedInt",uri:"uri",url:"url",uuid:"uuid",xhtml:"xhtml"};function zo(t,e,r){let i=No(t,r);if(i)return Zo(i.elements,e)}function Zo(t,e){let r=t[e]??t[e+"[x]"];if(r)return r;for(let i=0;i<e.length;i++){let n=e[i];if(n>="A"&&n<="Z"){let o=e.slice(0,i)+"[x]",s=t[o];if(s)return s}}}function me(t,e){return!(!t||typeof t!="object"||!("resourceType"in t)||e&&t.resourceType!==e)}function Fr(t,e){return t&&typeof t=="object"&&"reference"in t&&typeof t.reference=="string"?e?t.reference.match(new RegExp(`^${e}(/|\\?)`))!==null:!0:!1}function Ge(t){if(t.startsWith("T"))return t+"T00:00:00.000Z".substring(t.length);if(t.length<=10)return t;try{return new Date(t).toISOString()}catch{return t}}var q=()=>[];function $e(t){return t instanceof ne?t.name:t instanceof Br&&t.left instanceof ne&&t.right instanceof ne?t.left.name+"."+t.right.name:""}var P={empty:(t,e)=>c(e.every(r=>he(r.value))),hasValue:(t,e)=>c(e.length!==0),exists:(t,e,r)=>c(r?e.some(i=>W(r.eval(t,[i]))):e.length>0&&e.every(i=>!he(i.value))),all:(t,e,r)=>c(e.every(i=>W(r.eval(t,[i])))),allTrue:(t,e)=>{for(let r of e)if(!r.value)return c(!1);return c(!0)},anyTrue:(t,e)=>{for(let r of e)if(r.value)return c(!0);return c(!1)},allFalse:(t,e)=>{for(let r of e)if(r.value)return c(!1);return c(!0)},anyFalse:(t,e)=>{for(let r of e)if(!r.value)return c(!0);return c(!1)},subsetOf:(t,e,r)=>{if(e.length===0)return c(!0);let i=r.eval(t,X(t));return i.length===0?c(!1):c(e.every(n=>i.some(o=>o.value===n.value)))},supersetOf:(t,e,r)=>{let i=r.eval(t,X(t));return i.length===0?c(!0):e.length===0?c(!1):c(i.every(n=>e.some(o=>o.value===n.value)))},count:(t,e)=>[{type:u.integer,value:e.length}],distinct:(t,e)=>{let r=[];for(let i of e)r.some(n=>n.value===i.value)||r.push(i);return r},isDistinct:(t,e)=>c(e.length===P.distinct(t,e).length),where:(t,e,r)=>e.filter(i=>W(r.eval(t,[i]))),select:(t,e,r)=>e.flatMap(i=>r.eval({parent:t,variables:{$this:i}},[i])),repeat:q,ofType:(t,e,r)=>{let i=$e(r);return i?e.filter(n=>Ye(n,i)):[]},single:(t,e)=>{if(e.length>1)throw new Error("Expected input length one for single()");return e.length===0?[]:e.slice(0,1)},first:(t,e)=>e.length===0?[]:e.slice(0,1),last:(t,e)=>e.length===0?[]:e.slice(-1,e.length),tail:(t,e)=>e.length===0?[]:e.slice(1,e.length),skip:(t,e,r)=>{let i=r.eval(t,e)[0]?.value;if(typeof i!="number")throw new TypeError("Expected a number for skip(num)");return i>=e.length?[]:i<=0?e:e.slice(i,e.length)},take:(t,e,r)=>{let i=r.eval(t,e)[0]?.value;if(typeof i!="number")throw new TypeError("Expected a number for take(num)");return i<=0?[]:e.slice(0,i)},intersect:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t)),n=[];for(let o of e)!n.some(s=>s.value===o.value)&&i.some(s=>s.value===o.value)&&n.push(o);return n},exclude:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t)),n=[];for(let o of e)i.some(s=>s.value===o.value)||n.push(o);return n},union:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t));return br([...e,...i])},combine:(t,e,r)=>{if(!r)return e;let i=r.eval(t,X(t));return[...e,...i]},htmlChecks:(t,e,r)=>[Q(!0)],iif:(t,e,r,i,n)=>{let o=r.eval(t,e);if(o.length>1||o.length===1&&typeof o[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return W(o)?i.eval(t,e):n?n.eval(t,e):[]},toBoolean:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);if(typeof r=="boolean")return[{type:u.boolean,value:r}];if(typeof r=="number"&&(r===0||r===1))return c(!!r);if(typeof r=="string"){let i=r.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(i))return c(!0);if(["false","f","no","n","0","0.0"].includes(i))return c(!1)}return[]},convertsToBoolean:(t,e)=>e.length===0?[]:c(P.toBoolean(t,e).length===1),toInteger:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="number"?[{type:u.integer,value:r}]:typeof r=="string"&&/^[+-]?\d+$/.exec(r)?[{type:u.integer,value:Number.parseInt(r,10)}]:typeof r=="boolean"?[{type:u.integer,value:r?1:0}]:[]},convertsToInteger:(t,e)=>e.length===0?[]:c(P.toInteger(t,e).length===1),toDate:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(r)?[{type:u.date,value:Ge(r)}]:[]},convertsToDate:(t,e)=>e.length===0?[]:c(P.toDate(t,e).length===1),toDateTime:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(r)?[{type:u.dateTime,value:Ge(r)}]:[]},convertsToDateTime:(t,e)=>e.length===0?[]:c(P.toDateTime(t,e).length===1),toDecimal:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return typeof r=="number"?[{type:u.decimal,value:r}]:typeof r=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(r)?[{type:u.decimal,value:Number.parseFloat(r)}]:typeof r=="boolean"?[{type:u.decimal,value:r?1:0}]:[]},convertsToDecimal:(t,e)=>e.length===0?[]:c(P.toDecimal(t,e).length===1),toQuantity:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return V(r)?[{type:u.Quantity,value:r}]:typeof r=="number"?[{type:u.Quantity,value:{value:r,unit:"1"}}]:typeof r=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(r)?[{type:u.Quantity,value:{value:Number.parseFloat(r),unit:"1"}}]:typeof r=="boolean"?[{type:u.Quantity,value:{value:r?1:0,unit:"1"}}]:[]},convertsToQuantity:(t,e)=>e.length===0?[]:c(P.toQuantity(t,e).length===1),toString:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);return r==null?[]:V(r)?[{type:u.string,value:`${r.value} '${r.unit}'`}]:[{type:u.string,value:r.toString()}]},convertsToString:(t,e)=>e.length===0?[]:c(P.toString(t,e).length===1),toTime:(t,e)=>{if(e.length===0)return[];let[{value:r}]=G(e,1);if(typeof r=="string"){let i=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(r);if(i)return[{type:u.time,value:Ge("T"+i[1])}]}return[]},convertsToTime:(t,e)=>e.length===0?[]:c(P.toTime(t,e).length===1),indexOf:(t,e,r)=>w((i,n)=>i.indexOf(n),t,e,r),substring:(t,e,r,i)=>w((n,o,s)=>{let a=o,l=s?a+s:n.length;return a<0||a>=n.length?void 0:n.substring(a,l)},t,e,r,i),startsWith:(t,e,r)=>w((i,n)=>i.startsWith(n),t,e,r),endsWith:(t,e,r)=>w((i,n)=>i.endsWith(n),t,e,r),contains:(t,e,r)=>w((i,n)=>i.includes(n),t,e,r),upper:(t,e)=>w(r=>r.toUpperCase(),t,e),lower:(t,e)=>w(r=>r.toLowerCase(),t,e),replace:(t,e,r,i)=>w((n,o,s)=>n.replaceAll(o,s),t,e,r,i),matches:(t,e,r)=>w((i,n)=>!!new RegExp(n).exec(i),t,e,r),replaceMatches:(t,e,r,i)=>w((n,o,s)=>n.replaceAll(new RegExp(o,"g"),s.replaceAll(/\$\{(\w+)\}/g,"$<$1>")),t,e,r,i),length:(t,e)=>w(r=>r.length,t,e),toChars:(t,e)=>w(r=>r?r.split(""):void 0,t,e),encode:q,decode:q,escape:q,unescape:q,trim:q,split:q,join:(t,e,r)=>{let i=r?.eval(t,X(t))[0]?.value??"";if(typeof i!="string")throw new TypeError("Separator must be a string.");return[{type:u.string,value:e.map(n=>n.value?.toString()??"").join(i)}]},abs:(t,e)=>Y(Math.abs,t,e),ceiling:(t,e)=>Y(Math.ceil,t,e),exp:(t,e)=>Y(Math.exp,t,e),floor:(t,e)=>Y(Math.floor,t,e),ln:(t,e)=>Y(Math.log,t,e),log:(t,e,r)=>Y((i,n)=>Math.log(i)/Math.log(n),t,e,r),power:(t,e,r)=>Y(Math.pow,t,e,r),round:(t,e,...r)=>Y((i,n=0)=>{if(typeof n!="number"||n<0)throw new Error("Invalid precision provided to round()");let o=Math.pow(10,n);return Math.round(i*o)/o},t,e,...r),sqrt:(t,e)=>Y(Math.sqrt,t,e),truncate:(t,e)=>Y(r=>Math.trunc(r),t,e),children:q,descendants:q,trace:(t,e,r)=>e,now:()=>[{type:u.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:u.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:u.date,value:new Date().toISOString().substring(0,10)}],between:(t,e,r,i,n)=>{let o=P.toDateTime(t,r.eval(t,e));if(o.length===0)throw new Error("Invalid start date");let s=P.toDateTime(t,i.eval(t,e));if(s.length===0)throw new Error("Invalid end date");let a=n.eval(t,e)[0]?.value;if(a!=="years"&&a!=="months"&&a!=="days")throw new Error("Invalid units");let l=$o(o[0].value,s[0].value);return[{type:u.Quantity,value:{value:l[a],unit:a}}]},is:(t,e,r)=>{let i=$e(r);return i?e.map(n=>({type:u.boolean,value:Ye(n,i)})):[]},not:(t,e)=>P.toBoolean(t,e).map(r=>({type:u.boolean,value:!r.value})),resolve:(t,e)=>e.map(r=>{let i=r.value,n;if(typeof i=="string")n=i;else if(typeof i=="object"){let o=i;if(o.resource)return Q(o.resource);o.reference?n=o.reference:o.type&&o.identifier&&(n=`${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`)}if(n?.includes("?")){let[o]=n.split("?");return{type:o,value:{resourceType:o}}}if(n?.includes("/")){let[o,s]=n.split("/");return{type:o,value:{resourceType:o,id:s}}}return{type:u.BackboneElement,value:void 0}}).filter(r=>!!r.value),as:(t,e,r)=>{let i=$e(r);if(!i)throw new Error(`Expected a valid type identifier as the right operand of 'as', but found ${r.toString()}`);let n=b(e);return n&&Ye(n,i)?[n]:[]},type:(t,e)=>e.map(({value:r})=>typeof r=="boolean"?{type:u.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof r=="number"?{type:u.BackboneElement,value:{namespace:"System",name:"Integer"}}:me(r)?{type:u.BackboneElement,value:{namespace:"FHIR",name:r.resourceType}}:{type:u.BackboneElement,value:null}),conformsTo:(t,e,r)=>{let i=r.eval(t,e)[0].value;if(!i.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");let n=i.replace("http://hl7.org/fhir/StructureDefinition/","");return e.map(o=>({type:u.boolean,value:o.value?.resourceType===n}))},getResourceKey:(t,e)=>{let r=e[0]?.value;return r?.id?[{type:u.id,value:r.id}]:[]},getReferenceKey:(t,e,r)=>{let i=e[0]?.value;if(!i?.reference)return[];let n="";return r instanceof ne&&(n=r.name),n&&!i.reference.startsWith(n+"/")?[]:[{type:u.id,value:ko(i)}]},extension:(t,e,r)=>{let i=r.eval(t,e)[0].value,n=e?.[0]?.value;if(n){let o=Qe(n,i);if(o)return[{type:u.Extension,value:o}]}return[]}};function w(t,e,r,...i){if(r.length===0)return[];let[{value:n}]=G(r,1);if(typeof n!="string")throw new TypeError("String function cannot be called with non-string");let o=i.map(a=>a?.eval(e,r)[0]?.value),s=t(n,...o);return s===void 0?[]:Array.isArray(s)?s.map(Q):[Q(s)]}function Y(t,e,r,...i){if(r.length===0)return[];let[{value:n}]=G(r,1),o=V(n),s=o?n.value:n;if(typeof s!="number")throw new TypeError("Math function cannot be called with non-number");let a=t(s,...i.map(A=>A.eval(e,r)[0]?.value)),l=o?u.Quantity:r[0].type,E=o?{...n,value:a}:a;return[{type:l,value:E}]}function G(t,e){if(t.length!==e)throw new Error(`Expected ${e} arguments`);for(let r of t)if(r==null)throw new Error("Expected non-null argument");return t}function X(t){let e=t;for(;e.parent?.variables.$this;)e=e.parent;return[e.variables.$this]}var ie=class{constructor(t){O(this,"value"),this.value=t}eval(){return[this.value]}toString(){let t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}},ne=class{constructor(t){O(this,"name"),this.name=t}eval(t,e){if(this.name==="$this")return e;let r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return e.flatMap(i=>this.evalValue(i)).filter(i=>i?.value!==void 0)}getVariable(t){let e=t.variables[this.name];if(e!==void 0)return e;if(t.parent)return this.getVariable(t.parent)}evalValue(t){let e=t.value;if(!(!e||typeof e!="object"))return me(e,this.name)?("path"in t||(t.path=e.resourceType),t):Ro(t,this.name)}toString(){return this.name}},Jo=class{eval(){return[]}toString(){return"{}"}},Xo=class extends _o{constructor(t,e,r){super(t,e),O(this,"impl"),this.impl=r}eval(t,e){return this.impl(this.child.eval(t,e))}toString(){return this.operator+this.child.toString()}},Ko=class extends v{constructor(t,e){super("as",t,e)}eval(t,e){return P.as(t,this.left.eval(t,e),this.right)}},F=class extends v{constructor(t,e,r,i){super(t,e,r),O(this,"impl"),this.impl=i}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);if(r.length<1||i.length<1)return[];let n=b(r)?.value,o=b(i)?.value,s=V(n)?n.value:n,a=V(o)?o.value:o,l=this.impl(s,a);return typeof l=="boolean"?c(l):V(n)?[{type:u.Quantity,value:{...n,value:l}}]:[Q(l)]}},Ar=Object.freeze({type:"string",value:""}),es=class extends v{constructor(t,e){super("&",t,e)}eval(t,e){let r=b(this.left.eval(t,e))??Ar,i=b(this.right.eval(t,e))??Ar;if(typeof r.value!="string")throw new Error(`Expected string operand for &, but got ${r.type}`);if(typeof i.value!="string")throw new Error(`Expected string operand for &, but got ${i.type}`);return[{type:u.string,value:r.value+i.value}]}},ts=class extends v{constructor(t,e){super("contains",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return c(r.some(n=>n.value===i[0].value))}},rs=class extends v{constructor(t,e){super("in",t,e)}eval(t,e){let r=b(this.left.eval(t,e)),i=this.right.eval(t,e);return r?c(i.some(n=>We(r,n)[0].value)):[]}},Br=class extends v{constructor(t,e){super(".",t,e)}eval(t,e){return this.right.eval(t,this.left.eval(t,e))}toString(){return`${this.left.toString()}.${this.right.toString()}`}},is=class extends v{constructor(t,e){super("|",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return br([...r,...i])}},ns=class extends v{constructor(t,e){super("=",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return Po(r,i)}},os=class extends v{constructor(t,e){super("!=",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return bo(r,i)}},ss=class extends v{constructor(t,e){super("~",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return Lr(r,i)}},as=class extends v{constructor(t,e){super("!~",t,e)}eval(t,e){let r=this.left.eval(t,e),i=this.right.eval(t,e);return xo(Lr(r,i))}},cs=class extends v{constructor(t,e){super("is",t,e)}eval(t,e){let r=this.left.eval(t,e);if(r.length!==1)return[];let i=$e(this.right);return i?c(Ye(r[0],i)):[]}},ds=class extends v{constructor(t,e){super("and",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return r?.value===!0&&i?.value===!0?c(!0):r?.value===!1||i?.value===!1?c(!1):[]}},us=class extends v{constructor(t,e){super("or",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return r?.value===!1&&i?.value===!1?c(!1):r?.value||i?.value?c(!0):[]}},ls=class extends v{constructor(t,e){super("xor",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return!r||!i?[]:c(r.value!==i.value)}},ps=class extends v{constructor(t,e){super("implies",t,e)}eval(t,e){let r=b(this.left.eval(t,e),"boolean"),i=b(this.right.eval(t,e),"boolean");return i?.value===!0||r?.value===!1?c(!0):!r||!i?[]:c(!1)}},hs=class{constructor(t,e){O(this,"name"),O(this,"args"),this.name=t,this.args=e}eval(t,e){let r=P[this.name];if(!r)throw new Error("Unrecognized function: "+this.name);return r(t,e,...this.args)}toString(){return`${this.name}(${this.args.map(t=>t.toString()).join(", ")})`}},fs=class{constructor(t,e){O(this,"left"),O(this,"expr"),this.left=t,this.expr=e}eval(t,e){let r=this.expr.eval(t,e);if(r.length!==1)return[];let i=r[0].value;if(typeof i!="number")throw new Error("Invalid indexer expression: should return integer}");let n=this.left.eval(t,e);return i in n?[n[i]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}};var Yr=["!=","!~","<=",">=","{}","->"];var _={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,IntegerDivide:4,Modulo:4,Add:5,Subtract:5,Ampersand:5,Is:6,As:6,Union:7,GreaterThan:8,GreaterThanOrEquals:8,LessThan:8,LessThanOrEquals:8,Equals:9,Equivalent:9,NotEquals:9,NotEquivalent:9,In:10,Contains:10,And:11,Xor:12,Or:12,Implies:13,Arrow:100,Semicolon:200},ms={parse(t){let e=t.consumeAndParse();if(!t.match(")"))throw new Error("Parse error: expected `)` got `"+t.peek()?.value+"`");return e}},_s={parse(t,e){let r=t.consumeAndParse();if(!t.match("]"))throw new Error("Parse error: expected `]`");return new fs(e,r)},precedence:_.Indexer},Es={parse(t,e){if(!(e instanceof ne))throw new Error("Unexpected parentheses");let r=[];for(;!t.match(")");)r.push(t.consumeAndParse()),t.match(",");return new hs(e.name,r)},precedence:_.FunctionCall};function Is(t){let e=t.split(" "),r=Number.parseFloat(e[0]),i=e[1];return i?.startsWith("'")&&i.endsWith("'")?i=i.substring(1,i.length-1):i="{"+i+"}",{value:r,unit:i}}function Gt(){return new Eo().registerPrefix("String",{parse:(t,e)=>new ie({type:u.string,value:e.value})}).registerPrefix("DateTime",{parse:(t,e)=>new ie({type:u.dateTime,value:Ge(e.value)})}).registerPrefix("Quantity",{parse:(t,e)=>new ie({type:u.Quantity,value:Is(e.value)})}).registerPrefix("Number",{parse:(t,e)=>new ie({type:e.value.includes(".")?u.decimal:u.integer,value:Number.parseFloat(e.value)})}).registerPrefix("true",{parse:()=>new ie({type:u.boolean,value:!0})}).registerPrefix("false",{parse:()=>new ie({type:u.boolean,value:!1})}).registerPrefix("Symbol",{parse:(t,e)=>new ne(e.value)}).registerPrefix("{}",{parse:()=>new Jo}).registerPrefix("(",ms).registerInfix("[",_s).registerInfix("(",Es).prefix("+",_.UnaryAdd,(t,e)=>new Xo("+",e,r=>r)).prefix("-",_.UnarySubtract,(t,e)=>new F("-",e,e,(r,i)=>-i)).infixLeft(".",_.Dot,(t,e,r)=>new Br(t,r)).infixLeft("/",_.Divide,(t,e,r)=>new F("/",t,r,(i,n)=>i/n)).infixLeft("*",_.Multiply,(t,e,r)=>new F("*",t,r,(i,n)=>i*n)).infixLeft("+",_.Add,(t,e,r)=>new F("+",t,r,(i,n)=>i+n)).infixLeft("-",_.Subtract,(t,e,r)=>new F("-",t,r,(i,n)=>i-n)).infixLeft("|",_.Union,(t,e,r)=>new is(t,r)).infixLeft("=",_.Equals,(t,e,r)=>new ns(t,r)).infixLeft("!=",_.NotEquals,(t,e,r)=>new os(t,r)).infixLeft("~",_.Equivalent,(t,e,r)=>new ss(t,r)).infixLeft("!~",_.NotEquivalent,(t,e,r)=>new as(t,r)).infixLeft("<",_.LessThan,(t,e,r)=>new F("<",t,r,(i,n)=>i<n)).infixLeft("<=",_.LessThanOrEquals,(t,e,r)=>new F("<=",t,r,(i,n)=>i<=n)).infixLeft(">",_.GreaterThan,(t,e,r)=>new F(">",t,r,(i,n)=>i>n)).infixLeft(">=",_.GreaterThanOrEquals,(t,e,r)=>new F(">=",t,r,(i,n)=>i>=n)).infixLeft("&",_.Ampersand,(t,e,r)=>new es(t,r)).infixLeft("and",_.And,(t,e,r)=>new ds(t,r)).infixLeft("as",_.As,(t,e,r)=>new Ko(t,r)).infixLeft("contains",_.Contains,(t,e,r)=>new ts(t,r)).infixLeft("div",_.Divide,(t,e,r)=>new F("div",t,r,(i,n)=>Math.trunc(i/n))).infixLeft("in",_.In,(t,e,r)=>new rs(t,r)).infixLeft("is",_.Is,(t,e,r)=>new cs(t,r)).infixLeft("mod",_.Modulo,(t,e,r)=>new F("mod",t,r,(i,n)=>i%n)).infixLeft("or",_.Or,(t,e,r)=>new us(t,r)).infixLeft("xor",_.Xor,(t,e,r)=>new ls(t,r)).infixLeft("implies",_.Implies,(t,e,r)=>new ps(t,r))}var Ua=Gt();var h={EQUALS:"eq",NOT_EQUALS:"ne",GREATER_THAN:"gt",LESS_THAN:"lt",GREATER_THAN_OR_EQUALS:"ge",LESS_THAN_OR_EQUALS:"le",STARTS_AFTER:"sa",ENDS_BEFORE:"eb",APPROXIMATELY:"ap",CONTAINS:"contains",STARTS_WITH:"sw",EXACT:"exact",TEXT:"text",NOT:"not",ABOVE:"above",BELOW:"below",IN:"in",NOT_IN:"not-in",OF_TYPE:"of-type",MISSING:"missing",PRESENT:"present",IDENTIFIER:"identifier",ITERATE:"iterate"},Ma={contains:h.CONTAINS,exact:h.EXACT,above:h.ABOVE,below:h.BELOW,text:h.TEXT,not:h.NOT,in:h.IN,"not-in":h.NOT_IN,"of-type":h.OF_TYPE,missing:h.MISSING,identifier:h.IDENTIFIER,iterate:h.ITERATE},wa={eq:h.EQUALS,ne:h.NOT_EQUALS,lt:h.LESS_THAN,le:h.LESS_THAN_OR_EQUALS,gt:h.GREATER_THAN,ge:h.GREATER_THAN_OR_EQUALS,sa:h.STARTS_AFTER,eb:h.ENDS_BEFORE,ap:h.APPROXIMATELY,sw:h.STARTS_WITH};var Va=[h.MISSING,h.PRESENT];var ka=new wt(1e3);var Be={READ:"read",VREAD:"vread",UPDATE:"update",DELETE:"delete",HISTORY:"history",CREATE:"create",SEARCH:"search"},Fa=[Be.READ,Be.VREAD,Be.HISTORY,Be.SEARCH];function ze(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/g,t=>{let e=Math.trunc(Math.random()*16);return(t==="x"?e:e&3|8).toString(16)})}var Ts={CSS:"text/css",DICOM:"application/dicom",DICOM_JSON:"application/dicom+json",EVENT_STREAM:"text/event-stream",FAVICON:"image/vnd.microsoft.icon",FHIR_JSON:"application/fhir+json",FORM_URL_ENCODED:"application/x-www-form-urlencoded",HL7_V2:"x-application/hl7-v2+er7",HTML:"text/html",JAVASCRIPT:"text/javascript",JOSE:"application/jose",JSON:"application/json",JSON_PATCH:"application/json-patch+json",JWT:"application/jwt",LINKSET_JSON:"application/linkset+json",MULTIPART_FORM_DATA:"multipart/form-data",PNG:"image/png",SCIM_JSON:"application/scim+json",SVG:"image/svg+xml",TEXT:"text/plain",TYPESCRIPT:"text/typescript",PING:"x-application/ping",XML:"text/xml",CDA_XML:"application/cda+xml",OCTET_STREAM:"application/octet-stream"};var Ba={Event:typeof globalThis.Event<"u"?globalThis.Event:void 0,ErrorEvent:void 0,CloseEvent:void 0};var Ya={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1};var Ss;Ss=Symbol.toStringTag;var Ga=[WebSocket.CLOSING,WebSocket.CLOSED];var $a=new wt(1e3);var Ha=Ts.FHIR_JSON+", */*; q=0.1";var ja=[...Yr,"->","<<",">>","=="];var qa=Gt().registerInfix("->",{precedence:_.Arrow}).registerInfix(";",{precedence:_.Semicolon});var Wa=Object.freeze({implicitArrayCreation:!0});var Qa=" ".repeat(2);var za=[...Yr,"eq","ne","co"];var Za={eq:h.EXACT,ne:h.NOT_EQUALS,co:h.CONTAINS,sw:h.STARTS_WITH,ew:void 0,gt:h.GREATER_THAN,lt:h.LESS_THAN,ge:h.GREATER_THAN_OR_EQUALS,le:h.LESS_THAN_OR_EQUALS,ap:h.APPROXIMATELY,sa:h.STARTS_AFTER,eb:h.ENDS_BEFORE,pr:h.PRESENT,po:void 0,ss:void 0,sb:void 0,in:h.IN,ni:h.NOT_IN,re:h.EQUALS,identifier:h.IDENTIFIER};var Ja=Gt();var Xa=`${S}/fhir/StructureDefinition/patient-preferredPharmacy`;var Ka={wk:1440*7,d:1440,h:60,min:1};function $t(t){if(!t)return;let e=t.substring(0,4),r="01",i="01";return t.length>=8&&(r=t.substring(4,6),i=t.substring(6,8)),`${e}-${r}-${i}`}function C(t){if(!t)return;let e=/^[+-]\d{4}$/,r=t.substring(0,4),i="01",n="01",o="00",s="00",a="00",l="Z";t.length>=8&&(i=t.substring(4,6),n=t.substring(6,8)),t.length>=12&&(o=t.substring(8,10),s=t.substring(10,12));let E=t.charAt(12);t.length>=14&&E!=="+"&&E!=="-"&&(a=t.substring(12,14));let A=E==="+"||E==="-"?12:14;return t.length>A&&(l=t.substring(A),l==="+0000"||l==="-0000"?l="Z":e.test(l)&&(l=`${l.substring(0,3)}:${l.substring(3)}`)),`${r}-${i}-${n}T${o}:${s}:${a}${l}`}function k(t){if(t)return t.substring(0,10).replaceAll("-","")}function T(t){if(!t)return;let[e,r]=t.split("T"),i=e.replaceAll("-",""),n=(r??"").replaceAll(/\.\d+/g,"").replaceAll(":","").replaceAll("Z","+0000");return`${i}${n}`}function Gr(t,e){if(t?.start||t?.end){let r={};return t.start&&(r.low={"@_value":T(t.start)??""}),t.end&&(r.high={"@_value":T(t.end)??""}),r}return e?{"@_value":T(e)??""}:{}}var K="1.3.6.1.4.1.19376.1.5.3.1.3.1";var $r="2.16.840.1.113883.1.3";var Hr="2.16.840.1.113883.2.20.5.1",jr="2.16.840.1.113883.3.26.1.1";var qr="2.16.840.1.113883.3.221.5",Wr="2.16.840.1.113883.4.1",Qr="2.16.840.1.113883.4.3",zr="2.16.840.1.113883.4.6",Zr="2.16.840.1.113883.4.9",Ze="2.16.840.1.113883.5.1",Je="2.16.840.1.113883.5.4",Xe="2.16.840.1.113883.5.6",Ht="2.16.840.1.113883.5.25",Jr="2.16.840.1.113883.5.111",y="2.16.840.1.113883.6.1",Xr="2.16.840.1.113883.6.12",Kr="2.16.840.1.113883.6.24",ei="2.16.840.1.113883.6.69",ti="2.16.840.1.113883.6.88",L="2.16.840.1.113883.6.96",ri="2.16.840.1.113883.6.101",ii="2.16.840.1.113883.6.209",Ke="2.16.840.1.113883.6.238",ni="2.16.840.1.113883.6.254",oi="2.16.840.1.113883.6.345";var et="2.16.840.1.113883.10.20.15.3.8";var _e="2.16.840.1.113883.10.20.22.1.1";var jt="2.16.840.1.113883.10.20.22.1.2";var qt="2.16.840.1.113883.10.20.22.1.14";var tt="2.16.840.1.113883.10.20.22.2.1.1";var Ee="2.16.840.1.113883.10.20.22.2.2",Ie="2.16.840.1.113883.10.20.22.2.2.1";var Wt="2.16.840.1.113883.10.20.22.2.3.1";var si="2.16.840.1.113883.10.20.22.2.4.1";var ai="2.16.840.1.113883.10.20.22.2.5",Te="2.16.840.1.113883.10.20.22.2.5.1",ci="2.16.840.1.113883.10.20.22.2.5.1 .2",di="2.16.840.1.113883.10.20.22.2.5.2",ui="2.16.840.1.113883.10.20.22.2.6",Se="2.16.840.1.113883.10.20.22.2.6.1",li="2.16.840.1.113883.10.20.22.2.6.1.2",pi="2.16.840.1.113883.10.20.22.2.6.2";var se="2.16.840.1.113883.10.20.22.2.7.1";var rt="2.16.840.1.113883.10.20.22.2.8";var Z="2.16.840.1.113883.10.20.22.2.10";var Qt="2.16.840.1.113883.10.20.22.2.14";var zt="2.16.840.1.113883.10.20.22.2.17";var Oe="2.16.840.1.113883.10.20.22.2.18";var hi="2.16.840.1.113883.10.20.22.2.22.1";var fi="2.16.840.1.113883.10.20.22.2.23";var mi="2.16.840.1.113883.10.20.22.2.56";var it="2.16.840.1.113883.10.20.22.2.58";var ye="2.16.840.1.113883.10.20.22.2.60";var nt="2.16.840.1.113883.10.20.22.2.65";var ot="2.16.840.1.113883.10.20.22.2.500",Ce="2.16.840.1.113883.10.20.22.4.1",_i="2.16.840.1.113883.10.20.22.4.1.2",ge="2.16.840.1.113883.10.20.22.4.2",Ei="2.16.840.1.113883.10.20.22.4.2.2",Zt="2.16.840.1.113883.10.20.22.4.3";var $="2.16.840.1.113883.10.20.22.4.4",Ii="2.16.840.1.113883.10.20.22.4.4.2";var Jt="2.16.840.1.113883.10.20.22.4.7";var Xt="2.16.840.1.113883.10.20.22.4.8";var Kt="2.16.840.1.113883.10.20.22.4.9";var ae="2.16.840.1.113883.10.20.22.4.12";var Ne="2.16.840.1.113883.10.20.22.4.13";var ce="2.16.840.1.113883.10.20.22.4.14";var er="2.16.840.1.113883.10.20.22.4.16";var Ti="2.16.840.1.113883.10.20.22.4.20";var tr="2.16.840.1.113883.10.20.22.4.23";var Re="2.16.840.1.113883.10.20.22.4.26",Si="2.16.840.1.113883.10.20.22.4.26.2",Ae="2.16.840.1.113883.10.20.22.4.27",Oi="2.16.840.1.113883.10.20.22.4.27.2";var rr="2.16.840.1.113883.10.20.22.4.30";var st="2.16.840.1.113883.10.20.22.4.32";var yi="2.16.840.1.113883.10.20.22.4.37",Ci="2.16.840.1.113883.10.20.22.4.38",gi="2.16.840.1.113883.10.20.22.4.38.1";var at="2.16.840.1.113883.10.20.22.4.41";var ct="2.16.840.1.113883.10.20.22.4.44";var ve="2.16.840.1.113883.10.20.22.4.49";var ir="2.16.840.1.113883.10.20.22.4.52";var nr="2.16.840.1.113883.10.20.22.4.54",or="2.16.840.1.113883.10.20.22.4.60";var sr="2.16.840.1.113883.10.20.22.4.61";var De="2.16.840.1.113883.10.20.22.4.66";var xe="2.16.840.1.113883.10.20.22.4.67";var dt="2.16.840.1.113883.10.20.22.4.69",Ni="2.16.840.1.113883.10.20.22.4.70";var Ri="2.16.840.1.113883.10.20.22.4.74";var Ai="2.16.840.1.113883.10.20.22.4.75";var Pe="2.16.840.1.113883.10.20.22.4.78",vi="2.16.840.1.113883.10.20.22.4.78.2";var be="2.16.840.1.113883.10.20.22.4.85";var ut="2.16.840.1.113883.10.20.22.4.86",Di="2.16.840.1.113883.10.20.22.4.87";var xi="2.16.840.1.113883.10.20.22.4.89",Pi="2.16.840.1.113883.10.20.22.4.90";var bi="2.16.840.1.113883.10.20.22.4.114";var Li="2.16.840.1.113883.10.20.22.4.119";var de="2.16.840.1.113883.10.20.22.4.121";var Ui="2.16.840.1.113883.10.20.22.4.128";var Mi="2.16.840.1.113883.10.20.22.4.130";var ar="2.16.840.1.113883.10.20.22.4.132",wi="2.16.840.1.113883.10.20.22.4.133";var Vi="2.16.840.1.113883.10.20.22.4.140";var lt="2.16.840.1.113883.10.20.22.4.147",Le="2.16.840.1.113883.10.20.22.4.200",ki="2.16.840.1.113883.10.20.22.4.201",Fi="2.16.840.1.113883.10.20.22.4.202";var Bi="2.16.840.1.113883.10.20.22.4.244";var Yi="2.16.840.1.113883.10.20.22.4.250";var Gi="2.16.840.1.113883.10.20.22.4.406",$i="2.16.840.1.113883.10.20.22.4.407";var Hi="2.16.840.1.113883.10.20.22.4.416";var cr="2.16.840.1.113883.10.20.22.4.500",ji="2.16.840.1.113883.10.20.22.4.501";var pt="2.16.840.1.113883.10.20.22.4.503",ht="2.16.840.1.113883.10.20.22.4.504",dr="2.16.840.1.113883.10.20.22.4.505",ft="2.16.840.1.113883.10.20.22.4.506",mt="2.16.840.1.113883.10.20.22.4.507",qi="2.16.840.1.113883.10.20.22.4.508";var Wi="2.16.840.1.113883.10.20.22.4.512";var Qi="2.16.840.1.113883.10.20.22.5.8";var ur="2.16.840.1.113883.12.292",lr="2.16.840.1.113883.3.3719";function _t(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>_t(e)).filter(e=>e!==void 0);if(typeof t=="object"){let e=Object.keys(t).filter(i=>i!=="@_nullFlavor");if(e.length===0)return;let r={};for(let i of e){let n=_t(t[i]);n!==void 0&&(r[i]=n)}return Object.keys(r).length===0?void 0:r}return t}var g=class{constructor(e,r){D(this,"details");D(this,"entries");D(this,"ccdaToFhirMap");D(this,"fhirToCcdaMap");this.details=e,this.entries=r,this.ccdaToFhirMap={},this.fhirToCcdaMap={};for(let i of r)this.ccdaToFhirMap[i.ccdaValue]||(this.ccdaToFhirMap[i.ccdaValue]=i),this.fhirToCcdaMap[i.fhirValue]||(this.fhirToCcdaMap[i.fhirValue]=i)}getEntryByFhir(e){return this.fhirToCcdaMap[e]}getEntryByCcda(e){return this.ccdaToFhirMap[e]}mapCcdaToFhir(e){return this.ccdaToFhirMap[e]?.fhirValue}mapCcdaToFhirWithDefault(e,r){return e?this.mapCcdaToFhir(e)??r:r}mapFhirToCcdaWithDefault(e,r){return e?this.mapFhirToCcda(e)??r:r}mapCcdaToFhirCodeableConcept(e){let r=this.ccdaToFhirMap[e];if(r)return{coding:[{system:this.details.fhirSystemUrl,code:r.fhirValue,display:r.displayName}],text:r.displayName}}mapFhirToCcda(e){if(e)return this.fhirToCcdaMap[e]?.ccdaValue}mapFhirToCcdaCode(e){if(!e)return;let r=this.fhirToCcdaMap[e];if(r)return{"@_code":r.ccdaValue,"@_displayName":r.displayName,"@_codeSystem":this.details.ccdaSystemOid,"@_codeSystemName":this.details.ccdaSystemOid?Nt.getEntryByCcda(this.details.ccdaSystemOid)?.displayName:void 0}}},te="http:",Os=`${S}/fhir/administrative-gender`,pr=`${R}/CodeSystem/condition-clinical`,Zi=`${R}/CodeSystem/condition-verification`,Lc=`${R}/CodeSystem/v3-LanguageAbilityMode`,Uc=`${R}/CodeSystem/v3-LanguageAbilityProficiency`,Mc=`${R}/CodeSystem/v3-Race`,Ji=`${R}/CodeSystem/condition-category`,hr=`${R}/CodeSystem/condition-ver-status`,Et=`${R}/CodeSystem/allergyintolerance-clinical`,fr=`${R}/CodeSystem/allergyintolerance-verification`,mr=`${R}/CodeSystem/v3-ActCode`,Xi=`${R}/CodeSystem/v3-ParticipationType`,Ki=`${R}/CodeSystem/diagnosis-role`,ys=`${R}/CodeSystem/v3-Confidentiality`,Cs=`${R}/CodeSystem/observation-category`,gs=`${R}/CodeSystem/v3-RoleCode`,Ns=`${S}/fhir/ValueSet/address-use`,Rs=`${S}/fhir/ValueSet/name-use`,As=`${S}/fhir/ValueSet/administrative-gender`,vs=`${S}/fhir/ValueSet/contactentity-use`,wc=`${S}/fhir/ValueSet/medicationrequest-status`,Vc=`${S}/fhir/StructureDefinition/language-mode`,kc=`${S}/fhir/StructureDefinition/language-proficiency`,Fc=`${S}/fhir/us/core/StructureDefinition/us-core-patient`,Ue=`${S}/fhir/us/core/StructureDefinition/us-core-race`,It=`${S}/fhir/us/core/StructureDefinition/us-core-ethnicity`,en=`${S}/fhir/us/core/StructureDefinition/us-core-condition`,tn=`${S}/fhir/us/core/StructureDefinition/us-core-medicationrequest`,Bc=`${S}/cda/template`,Ds=`${te}//ncithesaurus-stage.nci.nih.gov`,xs=`${S}/fhir/sid/us-ssn`,Ps=`${S}/fhir/sid/us-dln`,bs=`${S}/fhir/sid/us-npi`,Ls=`${te}//fdasis.nlm.nih.gov`,Us=`${te}//nucc.org/provider-taxonomy`,Ms=`${te}//va.gov/terminology/medrt`,ws=`${te}//hl7.org/fhir/ndfrt`,Vs=`${te}//nucc.org/cvx`,ks=`${S}/fhir/sid/cvx`,Fs=`${S}/fhir/sid/icf`,rn=`${te}//www.w3.org/2001/XMLSchema-instance`,Tt="https://medplum.com/fhir/StructureDefinition/ccda-narrative-reference",nn="48765-2",on="11369-6",sn="10160-0",St="11450-4",an="30954-2",cn="29762-2",dn="8716-3",un="47519-4",Ot="18776-5",yt="51848-0",ln="46264-8",Me="61146-7",we="75310-3",pn="46240-8",Ve="42349-1",hn="57133-1",fn="10190-7",mn="85847-2",_n="48768-6",Ct="11488-4",Yc="34109-9",Gc="60591-5",gt="34133-9",En="76662-6",In="75323-6",Tn="58144-7",Sn="72166-2",On="11367-0",yn="46098-0",Cn="76689-9",gn="8689-2",Nn="75321-0",Rn="47420-5",An="89571-4",vn="47420-5",Dn="11341-5",xn="86188-0",_r="82810-3",Pn="95370-3",Nt=new g({},[{ccdaValue:Hr,fhirValue:"https://fhir.infoway-inforoute.ca/CodeSystem/pCLOCD",displayName:"pan-Canadian LOINC Observation Code Database (pCLOCD)"},{ccdaValue:jr,fhirValue:Ds,displayName:"NCI Thesaurus"},{ccdaValue:Wr,fhirValue:xs,displayName:"SSN"},{ccdaValue:Qr,fhirValue:Ps,displayName:"DLN"},{ccdaValue:zr,fhirValue:bs,displayName:"NPI"},{ccdaValue:Zr,fhirValue:Ls,displayName:"Unique Ingredient Identifier (UNII)"},{ccdaValue:y,fhirValue:je,displayName:"LOINC"},{ccdaValue:Xr,fhirValue:Dr,displayName:"Current Procedural Terminology (CPT)"},{ccdaValue:Kr,fhirValue:"urn:iso:std:iso:11073:10101",displayName:"Medical Device Communications (MDC)"},{ccdaValue:ei,fhirValue:xr,displayName:"National Drug Code (NDC)"},{ccdaValue:ti,fhirValue:vr,displayName:"RxNorm"},{ccdaValue:L,fhirValue:qe,displayName:"SNOMED CT"},{ccdaValue:ri,fhirValue:Us,displayName:"NUCC Health Care Provider Taxonomy"},{ccdaValue:oi,fhirValue:Ms,displayName:"Medication Reference Terminology (MED-RT)"},{ccdaValue:ii,fhirValue:ws,displayName:"National Drug File Reference Terminology (NDF-RT)"},{ccdaValue:ur,fhirValue:Vs,displayName:"CVX"},{ccdaValue:Ht,fhirValue:"Confidentiality",displayName:"Confidentiality"},{ccdaValue:Ze,fhirValue:Os,displayName:"Administrative Sex"},{ccdaValue:Jr,fhirValue:gs,displayName:"Role Code"},{ccdaValue:qr,fhirValue:"",displayName:"Insurance Type Code"},{ccdaValue:ur,fhirValue:ks,displayName:"Vaccine Administered Code Set (CVX)"},{ccdaValue:ni,fhirValue:Fs,displayName:"International Classification of Functioning, Disability and Health (ICF)"}]);function ee(t){if(t)return Nt.mapCcdaToFhir(t)??`urn:oid:${t}`}function Er(t){if(!t)return;let e=[],r=ee(t["@_codeSystem"]),i=t["@_code"],n=t["@_displayName"];(r||i||n)&&e.push({...r&&{system:r},...i&&{code:i},...n&&{display:n}});for(let s of t.translation??m){let a=ee(s["@_codeSystem"]),l=s["@_code"],E=s["@_displayName"];(a||l||E)&&e.push({...a&&{system:a},...l&&{code:l},...E&&{display:E}})}let o=t["@_displayName"];return e.length===0?o?{text:o}:void 0:{coding:e,...o&&{text:o}}}function bn(t){if(t)return t.startsWith("urn:oid:")?t.replace("urn:oid:",""):Nt.mapFhirToCcda(t)}function p(t){if(!t?.coding?.[0])return;let e=zi(t.coding[0]);if(t.coding.length>1){e.translation=[];for(let r=1;r<t.coding.length;r++)e.translation.push(zi(t.coding[r]))}return e}function zi(t){let e=t?.system?Nt.getEntryByFhir(t.system):void 0,r=e?.ccdaValue,i=e?.displayName,n=t.system?.startsWith("urn:oid:")?t.system.replace("urn:oid:",""):void 0;return{"@_code":t.code,"@_displayName":t.display,"@_codeSystem":r??n,"@_codeSystemName":i}}function U(t){let e=p(t);if(e)return{"@_xsi:type":"CD",...e}}var Ln=new g({ccdaSystemOid:Ht,fhirSystemUrl:ys},[{ccdaValue:"U",fhirValue:"U",displayName:"unrestricted"},{ccdaValue:"L",fhirValue:"L",displayName:"low"},{ccdaValue:"M",fhirValue:"M",displayName:"moderate"},{ccdaValue:"N",fhirValue:"N",displayName:"normal"},{ccdaValue:"R",fhirValue:"R",displayName:"restricted"},{ccdaValue:"V",fhirValue:"V",displayName:"very restricted"}]),Rt=new g({fhirSystemUrl:Rs},[{ccdaValue:"C",fhirValue:"usual",displayName:"Common/Called by"},{ccdaValue:"L",fhirValue:"official",displayName:"Legal"},{ccdaValue:"TEMP",fhirValue:"temp",displayName:"Temporary"},{ccdaValue:"P",fhirValue:"nickname",displayName:"Nickname"},{ccdaValue:"ANON",fhirValue:"anonymous",displayName:"Anonymous"},{ccdaValue:"L",fhirValue:"maiden",displayName:"Maiden"},{ccdaValue:"L",fhirValue:"old",displayName:"Old"}]),Un=new g({fhirSystemUrl:As},[{ccdaValue:"F",fhirValue:"female",displayName:"Female"},{ccdaValue:"M",fhirValue:"male",displayName:"Male"},{ccdaValue:"UN",fhirValue:"unknown",displayName:"Unknown"},{ccdaValue:"UN",fhirValue:"other",displayName:"Other"}]),At=new g({fhirSystemUrl:Ns},[{ccdaValue:"HP",fhirValue:"home",displayName:"Home"},{ccdaValue:"WP",fhirValue:"work",displayName:"Work"}]),vt=new g({fhirSystemUrl:vs},[{ccdaValue:"WP",fhirValue:"work",displayName:"Work"},{ccdaValue:"HP",fhirValue:"home",displayName:"Home"},{ccdaValue:"MC",fhirValue:"mobile",displayName:"Mobile"}]),Dt=new g({fhirSystemUrl:fr},[{ccdaValue:"unconfirmed",fhirValue:"unconfirmed",displayName:"Unconfirmed"},{ccdaValue:"provisional",fhirValue:"provisional",displayName:"Provisional"},{ccdaValue:"differential",fhirValue:"differential",displayName:"Differential"},{ccdaValue:"confirmed",fhirValue:"confirmed",displayName:"Confirmed"},{ccdaValue:"refuted",fhirValue:"refuted",displayName:"Refuted"},{ccdaValue:"entered-in-error",fhirValue:"entered-in-error",displayName:"Entered in Error"},{ccdaValue:"unknown",fhirValue:"unknown",displayName:"Unknown"}]),Mn=new g({ccdaSystemOid:L,fhirSystemUrl:Et},[{ccdaValue:"414285001",fhirValue:"food",displayName:"Allergy to food (finding)"},{ccdaValue:"419511003",fhirValue:"medication",displayName:"Propensity to adverse reactions to drug (finding)"},{ccdaValue:"426232007",fhirValue:"environment",displayName:"Environmental allergy (finding)"},{ccdaValue:"418038007",fhirValue:"biologic",displayName:"Propensity to adverse reactions to substance (finding)"}]),xt=new g({ccdaSystemOid:L,fhirSystemUrl:Et},[{ccdaValue:"255604002",fhirValue:"mild",displayName:"Mild"},{ccdaValue:"6736007",fhirValue:"moderate",displayName:"Moderate"},{ccdaValue:"24484000",fhirValue:"severe",displayName:"Severe"}]),ke=new g({fhirSystemUrl:hr},[{ccdaValue:"active",fhirValue:"active",displayName:"Active"},{ccdaValue:"inactive",fhirValue:"inactive",displayName:"Inactive"},{ccdaValue:"resolved",fhirValue:"inactive",displayName:"Resolved"},{ccdaValue:"remission",fhirValue:"inactive",displayName:"In Remission"},{ccdaValue:"relapse",fhirValue:"active",displayName:"Relapse"},{ccdaValue:"resolved relapse",fhirValue:"inactive",displayName:"Resolved Relapse"},{ccdaValue:"aborted",fhirValue:"aborted",displayName:"Aborted"}]),Pt=new g({},[{ccdaValue:"completed",fhirValue:"completed",displayName:"Completed"},{ccdaValue:"nullified",fhirValue:"entered-in-error",displayName:"Nullified"},{ccdaValue:"aborted",fhirValue:"not-done",displayName:"Aborted"},{ccdaValue:"cancelled",fhirValue:"not-done",displayName:"Cancelled"},{ccdaValue:"obsolete",fhirValue:"not-done",displayName:"Obsolete"}]),wn=new g({},[{ccdaValue:"active",fhirValue:"in-progress",displayName:"In Progress"},{ccdaValue:"completed",fhirValue:"finished",displayName:"Finished"},{ccdaValue:"aborted",fhirValue:"cancelled",displayName:"Cancelled"},{ccdaValue:"cancelled",fhirValue:"cancelled",displayName:"Cancelled"},{ccdaValue:"unknown",fhirValue:"unknown",displayName:"Unknown"}]),Vn=new g({},[{ccdaValue:"completed",fhirValue:"completed",displayName:"Completed"},{ccdaValue:"active",fhirValue:"active",displayName:"Active"},{ccdaValue:"aborted",fhirValue:"stopped",displayName:"Stopped"},{ccdaValue:"cancelled",fhirValue:"not-done",displayName:"Not Done"},{ccdaValue:"new",fhirValue:"not-done",displayName:"Draft"},{ccdaValue:"unknown",fhirValue:"unknown",displayName:"Unknown"}]),bt=new g({},[{ccdaValue:"active",fhirValue:"active",displayName:"Active"},{ccdaValue:"completed",fhirValue:"completed",displayName:"Completed"},{ccdaValue:"aborted",fhirValue:"stopped",displayName:"Stopped"},{ccdaValue:"cancelled",fhirValue:"cancelled",displayName:"Cancelled"},{ccdaValue:"aborted",fhirValue:"entered-in-error",displayName:"Entered in Error"},{ccdaValue:"active",fhirValue:"draft",displayName:"Draft"},{ccdaValue:"cancelled",fhirValue:"unknown",displayName:"Unknown"},{ccdaValue:"nullified",fhirValue:"cancelled",displayName:"Nullified"},{ccdaValue:"obsolete",fhirValue:"cancelled",displayName:"Obsolete"}]),kn=new g({fhirSystemUrl:Cs},[{ccdaValue:Ci,fhirValue:"social-history",displayName:"Social History"},{ccdaValue:gi,fhirValue:"social-history",displayName:"Social History V2"},{ccdaValue:Pe,fhirValue:"social-history",displayName:"Smoking Status"},{ccdaValue:vi,fhirValue:"social-history",displayName:"Current Smoking Status"},{ccdaValue:be,fhirValue:"social-history",displayName:"Tobacco Use"},{ccdaValue:pt,fhirValue:"social-history",displayName:"Basic Occupation"},{ccdaValue:ht,fhirValue:"social-history",displayName:"Basic Industry"},{ccdaValue:ji,fhirValue:"social-history",displayName:"Sexual Orientation"},{ccdaValue:mt,fhirValue:"social-history",displayName:"Sex Observation"},{ccdaValue:Le,fhirValue:"social-history",displayName:"Gender Identity"},{ccdaValue:ki,fhirValue:"social-history",displayName:"Gender Identity V2"},{ccdaValue:et,fhirValue:"social-history",displayName:"Pregnancy Status"},{ccdaValue:ft,fhirValue:"social-history",displayName:"Tribal Affiliation"},{ccdaValue:Ae,fhirValue:"vital-signs",displayName:"Vital Signs Observation"},{ccdaValue:Oi,fhirValue:"vital-signs",displayName:"Vital Signs Observation V2"},{ccdaValue:Re,fhirValue:"vital-signs",displayName:"Vital Signs Organizer"},{ccdaValue:Si,fhirValue:"vital-signs",displayName:"Vital Signs Organizer V2"},{ccdaValue:Wi,fhirValue:"vital-signs",displayName:"Average Blood Pressure Organizer"},{ccdaValue:ge,fhirValue:"laboratory",displayName:"Result Observation"},{ccdaValue:Ei,fhirValue:"laboratory",displayName:"Result Observation V2"},{ccdaValue:Gi,fhirValue:"laboratory",displayName:"Laboratory Battery (ID)"},{ccdaValue:$i,fhirValue:"laboratory",displayName:"Laboratory Observation (ID)"},{ccdaValue:Hi,fhirValue:"laboratory",displayName:"Laboratory Result Organizer (ID)"},{ccdaValue:Ce,fhirValue:"laboratory",displayName:"Result Organizer"},{ccdaValue:_i,fhirValue:"laboratory",displayName:"Result Organizer V2"},{ccdaValue:dt,fhirValue:"survey",displayName:"Assessment Scale Observation"},{ccdaValue:ut,fhirValue:"survey",displayName:"Assessment Scale Supporting Observation"},{ccdaValue:Ri,fhirValue:"survey",displayName:"Cognitive Status Result Observation"},{ccdaValue:Ai,fhirValue:"survey",displayName:"Cognitive Status Result Organizer"},{ccdaValue:xe,fhirValue:"survey",displayName:"Functional Status Result Observation"},{ccdaValue:De,fhirValue:"survey",displayName:"Functional Status Result Organizer"},{ccdaValue:Ne,fhirValue:"exam",displayName:"Procedure Activity Observation"},{ccdaValue:$,fhirValue:"exam",displayName:"Problem Observation"},{ccdaValue:Ii,fhirValue:"exam",displayName:"Problem Observation V2"},{ccdaValue:Ni,fhirValue:"exam",displayName:"Pressure Ulcer Observation"},{ccdaValue:bi,fhirValue:"exam",displayName:"Wound Observation"},{ccdaValue:wi,fhirValue:"exam",displayName:"Wound Measurements Observation"},{ccdaValue:se,fhirValue:"exam",displayName:"Procedure Section"},{ccdaValue:qi,fhirValue:"therapy",displayName:"Medication Adherence"},{ccdaValue:Mi,fhirValue:"therapy",displayName:"Nutrition Recommendations"},{ccdaValue:Bi,fhirValue:"therapy",displayName:"Diet Statement (Nutrition)"},{ccdaValue:Yi,fhirValue:"therapy",displayName:"Monitoring, Evaluation and Outcome (Nutrition)"}]),Fn=new g({fhirSystemUrl:mr},[{ccdaValue:"71",fhirValue:"HMO",displayName:"Health Maintenance Organization"},{ccdaValue:"72",fhirValue:"PPO",displayName:"Preferred Provider Organization"},{ccdaValue:"73",fhirValue:"POS",displayName:"Point of Service"},{ccdaValue:"79",fhirValue:"MCPOL",displayName:"Managed Care Policy"},{ccdaValue:"81",fhirValue:"pay",displayName:"Self Pay"},{ccdaValue:"9999",fhirValue:"",displayName:"Unknown"}]);import{XMLBuilder as Bn,XMLParser as Yn}from"fast-xml-parser";var Bs=["ClinicalDocument.participant","ClinicalDocument.recordTarget",".id",".templateId",".name",".addr",".telecom",".streetAddressLine",".author",".effectiveTime","name.given","name.suffix","name.prefix","patient.raceCode","patient.sdtc:raceCode","patient.ethnicGroupCode","patient.languageCommunication","component.structuredBody.component","component.structuredBody.component.section","component.section","component.observation","component.act","code.translation","value.translation","routeCode.translation","methodCode.translation","targetSiteCode.translation","approachSiteCode.translation","administrationUnitCode.translation","section.entry","entry.act","entry.organizer","entry.substanceAdministration","entry.observation","entry.encounter","entry.procedure","encounter.performer","encounter.participant","encounter.entryRelationship","entryRelationship.observation","entryRelationship.substanceAdministration","entryRelationship.act","organizer.component","substanceAdministration.consumable.manufacturedProduct","substanceAdministration.entryRelationship","substanceAdministration.performer","act.entryRelationship","act.performer","observation.participant","observation.entryRelationship","observation.referenceRange","consumable.manufacturedProduct","manufacturedProduct.manufacturedMaterial","manufacturedProduct.manufacturerOrganization","manufacturedProduct.manufacturedLabeledDrug","manufacturedMaterial.code","manufacturedMaterial.lotNumberText"];function Wc(t){return new Yn({ignoreAttributes:!1,attributeNamePrefix:"@_",parseAttributeValue:!1,parseTagValue:!1,jPath:!0,isArray:(i,n,o,s)=>Bs.some(a=>n.endsWith(a))}).parse(t).ClinicalDocument}function Qc(t){return new Bn({ignoreAttributes:!1,attributeNamePrefix:"@_",format:!0,suppressBooleanAttributes:!1,suppressEmptyNode:!0}).build({"?xml":{"@_version":"1.0","@_encoding":"UTF-8"},"?xml-stylesheet":{"@_type":"text/xsl","@_href":"CDA.xsl"},ClinicalDocument:{"@_xmlns":"urn:hl7-org:v3","@_xmlns:xsi":rn,"@_xmlns:voc":"urn:hl7-org:v3/voc","@_xmlns:sdtc":"urn:hl7-org:sdtc",...t}})}function Gn(t){return new Yn({ignoreAttributes:!1,attributeNamePrefix:"@_",parseAttributeValue:!1,parseTagValue:!1}).parse(t)}function $n(t){return t?typeof t=="string"?t:new Bn({ignoreAttributes:!1,attributeNamePrefix:"@_",format:!1,suppressBooleanAttributes:!1,suppressEmptyNode:!0}).build(t).split(`
|
|
2
2
|
`).map(i=>i.trim()).join(""):""}function rd(t,e){return new Ir(_t(t),e).convert()}var Ir=class{constructor(e,r){D(this,"ccda");D(this,"options");D(this,"resources",[]);D(this,"patient");this.ccda=e,this.options=r}convert(){return this.processHeader(),{resourceType:"Bundle",type:"document",entry:[{resource:this.createComposition()},...this.patient?[{resource:this.patient}]:[],...this.resources.map(r=>({resource:r}))]}}processHeader(){let e=this.ccda.recordTarget?.[0]?.patientRole;e&&(this.patient=this.createPatient(e),this.createRelatedPersons())}createPatient(e){let r=e.patient,i=[];return r.raceCode&&r.raceCode.length>0&&i.push({url:Ue,extension:r.raceCode.map(n=>({url:"ombCategory",valueCoding:this.mapCodeToCoding(n)}))}),r.ethnicGroupCode&&r.ethnicGroupCode.length>0&&i.push({url:It,extension:r.ethnicGroupCode.map(n=>({url:"ombCategory",valueCoding:this.mapCodeToCoding(n)}))}),{resourceType:"Patient",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),name:this.mapCcdaNameArrayFhirHumanNameArray(r.name),gender:this.mapGenderCode(r.administrativeGenderCode?.["@_code"]),birthDate:$t(r.birthTime?.["@_value"]),address:this.mapAddresses(e.addr),telecom:this.mapTelecom(e.telecom),extension:i.length>0?i:void 0}}createRelatedPersons(){let e=this.ccda.participant;for(let r of e??m){let i=this.mapParticipantToRelatedPerson(r);i&&this.resources.push(i)}}mapParticipantToRelatedPerson(e){let r=this.patient;if(!r)return;let i=e.associatedEntity;if(!i)return;let n=Er(i.code);return{resourceType:"RelatedPerson",id:this.mapId(i.id),patient:I(r),relationship:n?[n]:void 0,identifier:this.mapIdentifiers(i.id),name:this.mapCcdaNameArrayFhirHumanNameArray(i.associatedPerson?.name),address:this.mapAddresses(i.addr),telecom:this.mapTelecom(i.telecom)}}mapId(e){let r=e?.find(i=>!i["@_extension"]&&i["@_root"]&&Bt(i["@_root"]));return r?r["@_root"]:ze()}mapIdentifiers(e){let r;for(let i of e??m)!i["@_extension"]&&i["@_root"]&&Bt(i["@_root"])||(r=kr(r,{system:ee(i["@_root"]),value:i["@_extension"]}));return r}mapCcdaNameArrayFhirHumanNameArray(e){return e?.map(r=>this.mapCcdaNameToFhirHumanName(r)).filter(Boolean)}mapCcdaNameToFhirHumanName(e){if(!e)return;let r={},i=e["@_use"]?Rt.mapCcdaToFhir(e["@_use"]):void 0;return i&&(r.use=i),e.prefix&&(r.prefix=e.prefix.map(B)?.filter(Boolean)),e.family&&(r.family=B(e.family)),e.given&&(r.given=e.given.map(B)?.filter(Boolean)),e.suffix&&(r.suffix=e.suffix.map(B)?.filter(Boolean)),r}mapAddresses(e){if(!(!e||e.length===0))return e?.map(r=>({use:r["@_use"]?At.mapCcdaToFhir(r["@_use"]):void 0,line:r.streetAddressLine?.map(B).filter(Boolean),city:B(r.city),state:B(r.state),postalCode:B(r.postalCode),country:B(r.country)}))}mapTelecom(e){if(!(!e||e.length===0))return e?.map(r=>({use:r["@_use"]?vt.mapCcdaToFhir(r["@_use"]):void 0,system:this.getTelecomSystem(r["@_value"]),value:this.getTelecomValue(r["@_value"])}))}createComposition(){let e=this.ccda.component?.structuredBody?.component||[],r=[];for(let i of e)for(let n of i.section){let o=this.processSection(n);r.push({title:n.title,code:this.mapCode(n.code),text:{status:"generated",div:`<div xmlns="http://www.w3.org/1999/xhtml">${$n(n.text)}</div>`},entry:o.map(I)}),this.resources.push(...o)}return{resourceType:"Composition",id:this.mapId(this.ccda.id),language:this.ccda.languageCode?.["@_code"],status:"final",type:this.ccda.code?this.mapCode(this.ccda.code):{coding:[{system:je,code:gt}]},confidentiality:this.ccda.confidentialityCode?.["@_code"],author:this.ccda.author?.[0]?[this.mapAuthorToReference(this.ccda.author?.[0])]:[{display:"Medplum"}],custodian:this.mapCustodianToReference(this.ccda.custodian),event:this.mapDocumentationOfToEvent(this.ccda.documentationOf),date:C(this.ccda.effectiveTime?.[0]?.["@_value"])??new Date().toISOString(),title:this.ccda.title??"Medical Summary",section:r}}processSection(e){let r=[];for(let i of e.entry??m)this.processEntry(e,i,r);return r}processEntry(e,r,i){for(let n of r.act??m){let o=this.processAct(e,n);o&&i.push(o)}for(let n of r.substanceAdministration??m){let o=this.processSubstanceAdministration(e,n);o&&i.push(o)}for(let n of r.organizer??m)i.push(this.processOrganizer(e,n));for(let n of r.observation??m){let o=this.processObservation(e,n);o&&i.push(o)}for(let n of r.encounter??m)i.push(this.processEncounter(e,n));for(let n of r.procedure??m)i.push(this.processProcedure(e,n))}processAct(e,r){let i=e.templateId[0]["@_root"];switch(i){case Se:case ui:case li:case pi:return this.processAllergyIntoleranceAct(r);case Te:case ai:case ci:case di:return this.processConditionAct(r);case Z:return this.processCarePlanAct(r);case it:return this.processConditionAct(r);case se:return this.processProcedureAct(r);case K:return;case nt:return;case Oe:return;default:if(this.options?.ignoreUnsupportedSections)return;throw new Error("Unhandled act templateId: "+i)}}processAllergyIntoleranceAct(e){let r=e.entryRelationship?.find(s=>s["@_typeCode"]==="SUBJ")?.observation?.[0];if(!r)return;let i={resourceType:"AllergyIntolerance",id:this.mapId(e.id),clinicalStatus:this.createClinicalStatus(e),verificationStatus:this.createVerificationStatus(),type:"allergy",category:["food"],patient:I(this.patient),recorder:this.mapAuthorToReference(e.author?.[0]),recordedDate:this.mapEffectiveTimeToDateTime(e.effectiveTime?.[0]),onsetDateTime:this.mapEffectiveTimeToDateTime(r.effectiveTime?.[0])};r.value?.["@_code"]==="414285001"&&(i.category=["food"]),i.extension=this.mapTextReference(r.text);let n=r.participant?.[0]?.participantRole?.playingEntity?.code;n&&(i.code=this.mapCode(n),i.code&&n.originalText?.reference?.["@_value"]&&(i.code.extension=this.mapTextReference(n.originalText)));let o=r.entryRelationship?.find(s=>s["@_typeCode"]==="MFST")?.observation;return o&&(i.reaction=o.map(s=>this.processReaction(s))),i.asserter=this.mapAuthorToReference(r.author?.[0]),i}processConditionAct(e){let r=e.entryRelationship?.find(n=>n["@_typeCode"]==="SUBJ")?.observation?.[0];if(!r)return;let i={resourceType:"Condition",id:this.mapId(e.id),identifier:this.concatArrays(this.mapIdentifiers(e.id),this.mapIdentifiers(r.id)),meta:{profile:[en]},clinicalStatus:{coding:[{system:pr,code:ke.mapCcdaToFhirWithDefault(e.statusCode?.["@_code"],"active")}]},verificationStatus:{coding:[{system:Zi,code:"confirmed"}]},category:[{coding:[{system:Ji,code:"problem-list-item",display:"Problem List Item"}]}],code:this.mapCode(r.value),subject:I(this.patient),onsetDateTime:C(r.effectiveTime?.[0]?.low?.["@_value"]),abatementDateTime:C(r.effectiveTime?.[0]?.high?.["@_value"]),recordedDate:this.mapEffectiveTimeToDateTime(e.effectiveTime?.[0]),recorder:this.mapAuthorToReference(r.author?.[0]),asserter:this.mapAuthorToReference(r.author?.[0])};return i.extension=this.mapTextReference(r.text),i}processCarePlanAct(e){return{resourceType:"CarePlan",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),status:"completed",intent:"plan",title:"CARE PLAN",category:e.code?[this.mapCode(e.code)]:void 0,subject:I(this.patient),description:B(e.text)}}processProcedureAct(e){return{resourceType:"Procedure",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),status:"completed",code:this.mapCode(e.code),subject:I(this.patient),performedDateTime:C(e.effectiveTime?.[0]?.["@_value"]),recorder:this.mapAuthorToReference(e.author?.[0]),asserter:this.mapAuthorToReference(e.author?.[0]),extension:this.mapTextReference(e.text)}}processSubstanceAdministration(e,r){let i=e.templateId[0]["@_root"];switch(i){case tt:case Z:return this.processMedicationSubstanceAdministration(r);case Ee:case Ie:return this.processImmunizationSubstanceAdministration(r);default:if(this.options?.ignoreUnsupportedSections)return;throw new Error("Unhandled substance administration templateId: "+i)}}processMedicationSubstanceAdministration(e){let r=this.mapId(e.id),i=e.consumable?.manufacturedProduct?.[0]?.manufacturedMaterial?.[0]?.code?.[0],n=e.routeCode,o=e.doseQuantity,s=e.consumable?.manufacturedProduct?.[0]?.manufacturerOrganization?.[0],a=e.entryRelationship?.find(A=>A.substanceAdministration?.[0]?.templateId?.[0]?.["@_root"]===lt)?.substanceAdministration?.[0],l,E;return s?l={resourceType:"Medication",id:"med-"+r,code:this.mapCode(i),extension:this.mapTextReference(i?.originalText),manufacturer:s?{identifier:{value:s.id?.[0]?.["@_root"]},display:s.name?.[0]}:void 0}:E={...this.mapCode(i),extension:this.mapTextReference(i?.originalText)},{resourceType:"MedicationRequest",id:r,contained:l?[l]:void 0,meta:{profile:[tn]},extension:this.mapTextReference(e.text),status:bt.mapCcdaToFhirWithDefault(e.statusCode?.["@_code"],"active"),intent:"order",medicationReference:l?{reference:"#med-"+r}:void 0,medicationCodeableConcept:E,subject:I(this.patient),authoredOn:C(e.author?.[0]?.time?.["@_value"]),dispenseRequest:e.effectiveTime?.[0]?{validityPeriod:{start:C(e.effectiveTime?.[0]?.low?.["@_value"]),end:C(e.effectiveTime?.[0]?.high?.["@_value"])}}:void 0,dosageInstruction:[{text:typeof e.text=="string"?e.text:void 0,extension:this.mapTextReference(a?.text),route:n?this.mapCode(n):void 0,timing:{repeat:e.effectiveTime?.[1]?.period?{period:Number(e.effectiveTime?.[1]?.period["@_value"]),periodUnit:e.effectiveTime?.[1]?.period["@_unit"]}:void 0},doseAndRate:o?[{doseQuantity:{system:fe,value:Number(o["@_value"]),code:"[IU]",unit:"[IU]"}}]:void 0}]}}processImmunizationSubstanceAdministration(e){let r=e.consumable;if(!r)return;let i={resourceType:"Immunization",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),status:Pt.mapCcdaToFhirWithDefault(e.statusCode?.["@_code"],"completed"),vaccineCode:this.mapCode(r.manufacturedProduct?.[0]?.manufacturedMaterial?.[0]?.code?.[0]),patient:I(this.patient),occurrenceDateTime:C(e.effectiveTime?.[0]?.["@_value"]),lotNumber:r.manufacturedProduct?.[0]?.manufacturedMaterial?.[0]?.lotNumberText?.[0]};return e.performer&&(i.performer=this.mapCcdaPerformerArrayToImmunizationPerformerArray(e.performer)),i.extension=this.mapTextReference(e.text),e.consumable?.manufacturedProduct?.[0]?.manufacturerOrganization?.[0]&&(i.manufacturer={display:e.consumable?.manufacturedProduct?.[0]?.manufacturerOrganization?.[0]?.name?.[0]}),i}processReaction(e){let r=this.mapCode(e.value)??{extension:[{url:"http://hl7.org/fhir/StructureDefinition/data-absent-reason",valueCode:"unknown"}]},i={id:this.mapId(e.id),manifestation:[r],onset:C(e.effectiveTime?.[0]?.low?.["@_value"])};if(this.processSeverity(e,i),e.text?.reference?.["@_value"]){let n=this.mapTextReference(e.text);n&&(i.manifestation[0].extension=[...i.manifestation[0].extension??[],...n])}return i}processSeverity(e,r){let i=e.entryRelationship?.find(o=>o["@_typeCode"]==="SUBJ")?.observation?.[0];if(!i)return;let n=i.value?.["@_code"];n&&(r.severity=xt.mapCcdaToFhir(n)),r.extension=this.mapTextReference(i.text)}mapEffectiveTimeToDateTime(e){if(e?.["@_value"])return C(e["@_value"]);if(e?.low?.["@_value"])return C(e.low["@_value"])}mapEffectiveTimeToPeriod(e){if(!e?.["@_value"]&&(e?.low||e?.high))return{start:C(e?.low?.["@_value"]),end:C(e?.high?.["@_value"])}}mapGenderCode(e){return e?{F:"female",M:"male",UN:"unknown"}[e]:void 0}getTelecomSystem(e){if(e)return e.startsWith("tel:")?"phone":e.startsWith("mailto:")?"email":"other"}getTelecomValue(e){if(e)return e.replace(/^(tel:|mailto:)/,"")}mapCode(e){if(!e)return;let r=[],i=ee(e["@_codeSystem"]),n=e["@_code"],o=e["@_displayName"];(i||n||o)&&r.push({...i&&{system:i},...n&&{code:n},...o&&{display:o}});let s=[];Array.isArray(e.translation)?s=e.translation:e.translation&&(s=[e.translation]);for(let l of s){let E=ee(l["@_codeSystem"]),A=l["@_code"],j=l["@_displayName"];(E||A||j)&&r.push({...E&&{system:E},...A&&{code:A},...j&&{display:j}})}let a=e["@_displayName"]||e.originalText?.reference?.["@_value"]||B(e.originalText);return r.length===0?a?{text:a}:void 0:{coding:r,...a&&{text:a}}}mapCodeToCoding(e){if(e)return{system:ee(e["@_codeSystem"]),code:e["@_code"],display:e["@_displayName"]}}mapQualification(e){let r=this.mapCode(e);if(r)return[{code:r}]}createClinicalStatus(e){return{coding:[{system:Et,code:Dt.mapCcdaToFhirWithDefault(e.statusCode?.["@_code"],"active")}]}}createVerificationStatus(){return{coding:[{system:fr,code:"confirmed"}]}}mapAuthorToReference(e){if(!e)return;let r={resourceType:"Practitioner",id:this.mapId(e.assignedAuthor?.id),identifier:this.mapIdentifiers(e.assignedAuthor?.id),name:this.mapCcdaNameArrayFhirHumanNameArray(e.assignedAuthor?.assignedPerson?.name),address:this.mapAddresses(e.assignedAuthor?.addr),telecom:this.mapTelecom(e.assignedAuthor?.telecom),qualification:this.mapQualification(e.assignedAuthor?.code)};return this.resources.push(r),I(r)}mapAssignedEntityToReference(e){if(!e)return;let r=e.assignedPerson,i=e.representedOrganization,n={resourceType:"Practitioner",id:this.mapId(e?.id),identifier:this.mapIdentifiers(e?.id),name:this.mapCcdaNameArrayFhirHumanNameArray(r?.name),address:this.mapAddresses(e?.addr),telecom:this.mapTelecom(e?.telecom)};this.resources.push(n);let o={resourceType:"Organization",id:this.mapId(e?.id),identifier:this.mapIdentifiers(i?.id),name:i?.name?.[0],address:this.mapAddresses(i?.addr)};this.resources.push(o);let s={resourceType:"PractitionerRole",id:this.mapId(e?.id),practitioner:I(n),organization:I(o)};return this.resources.push(s),I(s)}mapCustodianToReference(e){if(!e)return;let r={resourceType:"Organization",id:this.mapId(e.assignedCustodian.representedCustodianOrganization.id),identifier:this.mapIdentifiers(e.assignedCustodian.representedCustodianOrganization.id),name:e.assignedCustodian.representedCustodianOrganization.name?.[0],address:this.mapAddresses(e.assignedCustodian.representedCustodianOrganization.addr),telecom:this.mapTelecom(e.assignedCustodian.representedCustodianOrganization.telecom)};return this.resources.push(r),I(r)}mapDocumentationOfToEvent(e){if(!e)return;let r=e.serviceEvent;if(r)return[{code:r.code?[this.mapCode(r.code)]:void 0,period:this.mapEffectiveTimeToPeriod(r.effectiveTime?.[0])}]}concatArrays(e,r){return e?r?[...e,...r]:e:r}mapCcdaPerformerArrayToImmunizationPerformerArray(e){let r=[];for(let i of e){let n=i.assignedEntity,o=this.mapAssignedEntityToReference(n);o&&r.push({actor:o})}return r}processOrganizer(e,r){return e.templateId[0]["@_root"]===ot?this.processCareTeamOrganizer(r):this.processVitalsOrganizer(r)}processCareTeamOrganizer(e){let r=[];for(let n of e.component??m){let o=this.processCareTeamMember(n);o&&r.push(o)}return{resourceType:"CareTeam",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),participant:r.length>0?r:void 0}}processCareTeamMember(e){let r=e.act?.[0];if(!r)return;let i=r.performer?.[0];if(i)return{role:i.functionCode?[this.mapCode(i.functionCode)]:void 0,member:this.mapAssignedEntityToReference(i.assignedEntity),period:this.mapEffectiveTimeToPeriod(r.effectiveTime?.[0])}}processVitalsOrganizer(e){let r={resourceType:"Observation",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),status:"final",category:this.mapObservationTemplateIdToObservationCategory(e.templateId),code:this.mapCode(e.code),subject:I(this.patient)};e.effectiveTime?.[0]?.["@_value"]&&(r.effectiveDateTime=C(e.effectiveTime?.[0]?.["@_value"]));let i=[];for(let n of e.component??m)i.push(...this.processVitalsComponent(n));return i.length>0&&(r.hasMember=i),r}processVitalsComponent(e){let r=[];for(let i of e.observation??m){let n=this.processVitalsObservation(i);n&&(r.push(I(n)),this.resources.push(n))}return r}processObservation(e,r){let i=r.templateId[0]["@_root"];if(i===ye||i===de)return this.processGoalObservation(r);switch(e.templateId[0]["@_root"]){case Z:case ye:return this.processGoalObservation(r);default:return this.processVitalsObservation(r)}}processGoalObservation(e){let r=[];e.code&&r.push(this.mapCode(e.code));let i=[],n,o=e.value;if(o){let a=o["@_xsi:type"];a==="CD"?n=Er(o):a==="ST"&&(n={text:o["#text"]??""})}for(let a of e.entryRelationship??m)i.push({measure:this.mapCode(a.act?.[0]?.code),detailCodeableConcept:this.mapCode(a.act?.[0]?.code),dueDate:C(a.act?.[0]?.effectiveTime?.[0]?.low?.["@_value"])});return{resourceType:"Goal",id:this.mapId(e.id),extension:this.mapTextReference(e.text),identifier:this.mapIdentifiers(e.id),lifecycleStatus:this.mapGoalLifecycleStatus(e),category:r,description:n??{text:"Unknown goal"},subject:I(this.patient),startDate:$t(e.effectiveTime?.[0]?.["@_value"]),target:i}}mapGoalLifecycleStatus(e){return{active:"active",completed:"completed",cancelled:"cancelled",aborted:"cancelled"}[e.statusCode["@_code"]??"active"]}processVitalsObservation(e){let r=this.mapCode(e.code);if(!r)return;let i={resourceType:"Observation",id:this.mapId(e.id),identifier:this.mapIdentifiers(e.id),status:"final",category:this.mapObservationTemplateIdToObservationCategory(e.templateId),code:r,subject:I(this.patient),referenceRange:this.mapReferenceRangeArray(e.referenceRange),performer:e.author?.map(o=>this.mapAuthorToReference(o)).filter(Boolean)};if(e.value?.["@_xsi:type"])switch(e.value["@_xsi:type"]){case"PQ":case"CO":i.valueQuantity={value:e.value["@_value"]?Number.parseFloat(e.value["@_value"]):void 0,unit:e.value["@_unit"],system:fe,code:e.value["@_unit"]};break;case"CD":case"CE":i.valueCodeableConcept=this.mapCode(e.value);break;case"ST":i.valueString=e.value["#text"]??"";break;case"INT":i.valueInteger=e.value["@_value"]?Number.parseInt(e.value["@_value"],10):void 0;break;default:console.warn(`Unhandled observation value type: ${e.value["@_xsi:type"]}`)}e.effectiveTime?.[0]?.["@_value"]&&(i.effectiveDateTime=C(e.effectiveTime?.[0]?.["@_value"])),i.extension=this.mapTextReference(e.text);let n=e.entryRelationship;for(let o of n??m){let s=o.observation;for(let a of s??m){let l=this.processVitalsObservation(a);l&&(this.resources.push(l),i.hasMember||(i.hasMember=[]),i.hasMember.push(I(l)))}}return i}mapObservationTemplateIdToObservationCategory(e){if(!e)return;let r=new Set,i=[];for(let n of e){let o=kn.mapCcdaToFhirCodeableConcept(n["@_root"]);o?.coding?.[0]?.code&&!r.has(o.coding[0].code)&&(r.add(o.coding[0].code),i.push(o))}return Array.from(i.values())}mapReferenceRangeArray(e){if(!(!e||e.length===0))return e.map(r=>this.mapReferenceRange(r)).filter(Boolean)}mapReferenceRange(e){if(!e)return;let r=e.observationRange;if(!r)return;let i={};i.extension=this.mapTextReference(r.text);let n=r.value;if(n?.low&&(i.low={value:n.low["@_value"]?Number.parseFloat(n.low["@_value"]):void 0,unit:n.low["@_unit"],system:fe,code:n.low["@_unit"]}),n?.high&&(i.high={value:n.high["@_value"]?Number.parseFloat(n.high["@_value"]):void 0,unit:n.high["@_unit"],system:fe,code:n.high["@_unit"]}),!(!i.extension&&!i.low&&!i.high))return i}processEncounter(e,r){let i={resourceType:"Encounter",id:this.mapId(r.id),identifier:this.mapIdentifiers(r.id),status:wn.mapCcdaToFhirWithDefault(r.statusCode?.["@_code"],"unknown"),class:{system:mr,code:r.code?.["@_code"]??"AMB",display:r.code?.["@_displayName"]??"Ambulatory"},type:r.code?[this.mapCode(r.code)]:void 0,subject:I(this.patient),period:this.mapEffectiveTimeToPeriod(r.effectiveTime?.[0])};if(r.performer&&(i.participant=r.performer.map(n=>({type:[{coding:[{system:Xi,code:n["@_typeCode"]??"PPRF",display:"Primary Performer"}]}],individual:this.mapAssignedEntityToReference(n.assignedEntity)}))),r.entryRelationship){let n=r.entryRelationship.filter(o=>o["@_typeCode"]==="RSON").map(o=>{let s=o.observation?.[0];if(!s)return;let a={resourceType:"Condition",id:this.mapId(s.id),identifier:this.mapIdentifiers(s.id),clinicalStatus:{coding:[{system:pr,code:"active"}]},verificationStatus:{coding:[{system:hr,code:"confirmed"}]},code:this.mapCode(s.value),subject:I(this.patient),onsetDateTime:C(s.effectiveTime?.[0]?.low?.["@_value"])};return this.resources.push(a),{condition:I(a),use:{coding:[{system:Ki,code:"AD",display:"Admission diagnosis"}]}}}).filter(Boolean);n.length>0&&(i.diagnosis=n)}return i.extension=this.mapTextReference(r.text),i}processProcedure(e,r){return{resourceType:"Procedure",id:this.mapId(r.id),identifier:this.mapIdentifiers(r.id),status:Vn.mapCcdaToFhirWithDefault(r.statusCode?.["@_code"],"completed"),code:this.mapCode(r.code),subject:I(this.patient),performedPeriod:this.mapEffectiveTimeToPeriod(r.effectiveTime?.[0]),bodySite:r.targetSiteCode?[this.mapCode(r.targetSiteCode)]:void 0,extension:this.mapTextReference(r.text)}}mapTextReference(e){if(!(!e||typeof e!="object")&&e?.reference?.["@_value"])return[{url:Tt,valueString:e.reference?.["@_value"]}]}};function B(t){if(t){if(typeof t=="string")return t;if(typeof t=="object"&&"#text"in t)return t["#text"]}}var Hn=[{"@_root":_e,"@_extension":"2015-08-01"},{"@_root":_e},{"@_root":jt,"@_extension":"2015-08-01"},{"@_root":jt}],jn=[{"@_root":_e,"@_extension":"2015-08-01"},{"@_root":_e},{"@_root":qt,"@_extension":"2015-08-01"},{"@_root":qt}],Ys=[{"@_root":Se,"@_extension":"2015-08-01"},{"@_root":Se}],Gs=[{"@_root":tt,"@_extension":"2014-06-09"}],$s=[{"@_root":Te,"@_extension":"2015-08-01"},{"@_root":Te}],Hs=[{"@_root":Ee},{"@_root":Ee,"@_extension":"2015-08-01"},{"@_root":Ie},{"@_root":Ie,"@_extension":"2015-08-01"}],js=[{"@_root":si,"@_extension":"2015-08-01"}],qs=[{"@_root":zt},{"@_root":zt,"@_extension":"2015-08-01"}],Ws=[{"@_root":se,"@_extension":"2014-06-09"}],ad=[{"@_root":Z,"@_extension":"2014-06-09"}],cd=[{"@_root":Wt,"@_extension":"2015-08-01"}],Qs=[{"@_root":Wt,"@_extension":"2015-08-01"}],zs=[{"@_root":fi,"@_extension":"2015-08-01"}],Zs=[{"@_root":rt}],Js=[{"@_root":Z},{"@_root":Z,"@_extension":"2014-06-09"}],Xs=[{"@_root":hi,"@_extension":"2015-08-01"}],Ks=[{"@_root":ye}],ea=[{"@_root":it,"@_extension":"2015-08-01"}],ta=[{"@_root":K,"@_extension":"2014-06-09"}],ra=[{"@_root":mi,"@_extension":"2015-08-01"}],ia=[{"@_root":nt,"@_extension":"2016-11-01"}],na=[{"@_root":ot,"@_extension":"2022-06-01"}],oa=[{"@_root":Oe,"@_extension":"2015-08-01"},{"@_root":Oe}],sa=[{"@_root":Qt,"@_extension":"2014-06-09"},{"@_root":Qt}],qn=Object.fromEntries([[nn,Ys],[sn,Gs],[St,$s],[on,Hs],[dn,js],[cn,qs],[un,Ws],[an,Qs],[yt,Zs],[Ot,Js],[pn,Xs],[Me,Ks],[we,ea],[Ve,ta],[fn,ra],[Ct,ia],[mn,na],[_n,oa],[ln,zs],[Rn,sa]]);function Wn(t){return{name:H(t.name),administrativeGenderCode:aa(t.gender),birthTime:ca(t.birthDate),raceCode:la(t),"sdtc:raceCode":pa(t),ethnicGroupCode:ha(t.extension),languageCommunication:fa(t.communication)}}function H(t){return t?.map(e=>({"@_use":e.use?Rt.mapFhirToCcdaWithDefault(e.use,"L"):void 0,prefix:e.prefix,family:e.family,given:e.given,suffix:e.suffix}))}function aa(t){if(t)return{"@_code":Un.mapFhirToCcda(t),"@_displayName":t?oe(t):"Unknown","@_codeSystem":Ze,"@_codeSystemName":"AdministrativeGender"}}function ca(t){if(t)return{"@_value":t.replaceAll("-","")}}function M(t){return!t||t.length===0?[{"@_nullFlavor":"UNK"}]:t?.map(e=>({"@_use":e.use?vt.mapFhirToCcda(e.use):void 0,"@_value":`${da(e.system)}${e.value}`}))}function da(t){return t==="email"?"mailto:":t==="phone"?"tel:":t==="fax"?"fax:":""}function x(t){return!t||t.length===0?[{"@_nullFlavor":"UNK"}]:t.map(e=>ua(e)).filter(Boolean)}function ua(t){return t?{"@_use":t.use?At.mapFhirToCcda(t.use):void 0,streetAddressLine:t.line||[],city:t.city,state:t.state,postalCode:t.postalCode,country:t.country}:void 0}function la(t){let e=Qe(t,Ue,"ombCategory")?.valueCoding;return e?[{"@_code":e.code,"@_displayName":e.display,"@_codeSystem":Ke,"@_codeSystemName":"CDC Race and Ethnicity"}]:[{"@_nullFlavor":"UNK"}]}function pa(t){let e=Qe(t,Ue,"detailed")?.valueCoding;if(e)return[{"@_code":e.code,"@_displayName":e.display,"@_codeSystem":Ke,"@_codeSystemName":"CDC Race and Ethnicity"}]}function ha(t){let r=t?.find(i=>i.url===It)?.extension?.find(i=>i.url==="ombCategory")?.valueCoding;return r?[{"@_code":r.code,"@_displayName":r.display,"@_codeSystem":Ke,"@_codeSystemName":"CDC Race and Ethnicity"}]:[{"@_nullFlavor":"UNK"}]}function fa(t){if(t?.length)return[{languageCode:{"@_code":t[0].language?.coding?.[0]?.code}}]}function d(t,e){let r=[];t&&r.push({"@_root":t});for(let i of e??m){let n=bn(i.system);n&&r.push({"@_root":n,"@_extension":i.value})}return r}function J(t,e){if(e)return[{low:{"@_value":T(e.start)},high:{"@_value":T(e.end)}}];if(t)return[{"@_value":T(t)}]}function ue(t,e){if(e)return[{"@_xsi:type":"IVL_TS",low:e.start?{"@_value":k(e.start)}:void 0,high:e.end?{"@_value":k(e.end)}:void 0}];if(t)return[{"@_value":k(t)}]}function z(t,e,r=!1){if(!t&&!e)return;let i={};return t?i.low={"@_value":T(t)}:r&&(i.low={"@_nullFlavor":"NI"}),e?i.high={"@_value":T(e)}:r&&(i.high={"@_nullFlavor":"NI"}),[i]}function Fe(t){let e=t?.find(r=>r.url===Tt)?.valueString;return e?{"@_value":e}:void 0}function f(t){let e=Fe(t);return e?{reference:e}:void 0}function Qn(t){if(!t)return;let e=Gn(t.div)?.div;return e?.["@_xmlns"]&&delete e["@_xmlns"],e}function zn(t,e){let r=e.reaction?.[0];return{act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":rr},{"@_root":rr,"@_extension":"2015-08-01"}],id:d(e.id,e.identifier),code:{"@_code":"CONC","@_codeSystem":Xe},statusCode:{"@_code":Dt.mapFhirToCcdaWithDefault(e.clinicalStatus?.coding?.[0]?.code,"active")},effectiveTime:z(e.recordedDate,void 0),author:t.mapAuthor(e.recorder,e.recordedDate),text:f(e.extension),entryRelationship:[{"@_typeCode":"SUBJ",observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:[{"@_root":Jt},{"@_root":Jt,"@_extension":"2014-06-09"}],id:d(e.id,e.identifier),code:{"@_code":"ASSERTION","@_codeSystem":Je},text:f(e.extension),statusCode:{"@_code":"completed"},effectiveTime:z(e.onsetPeriod?.start??e.onsetDateTime,e.onsetPeriod?.end,!0),value:ma(e.category),author:t.mapAuthor(e.asserter,e.recordedDate),participant:[{"@_typeCode":"CSM",participantRole:{"@_classCode":"MANU",playingEntity:{"@_classCode":"MMAT",code:e.code?.coding?.[0]?.code==="716186003"?{"@_nullFlavor":"NA"}:{...p(e.code),originalText:e.code?.extension?{reference:Fe(e.code?.extension)}:void 0}}}}],entryRelationship:r?[{"@_typeCode":"MFST","@_inversionInd":"true",observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:[{"@_root":Kt},{"@_root":Kt,"@_extension":"2014-06-09"}],id:d(r.id,void 0),code:{"@_code":"ASSERTION","@_codeSystem":Je},statusCode:{"@_code":"completed"},effectiveTime:ue(e.onsetDateTime,e.onsetPeriod),value:U(r.manifestation?.[0]),text:f(r.manifestation?.[0]?.extension),entryRelationship:[{"@_typeCode":"SUBJ","@_inversionInd":"true",observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:[{"@_root":Xt},{"@_root":Xt,"@_extension":"2014-06-09"}],code:{"@_code":"SEV","@_codeSystem":Je,"@_codeSystemName":"ActCode"},statusCode:{"@_code":"completed"},value:{"@_xsi:type":"CD","@_code":xt.mapFhirToCcdaWithDefault(r.severity,"M"),"@_displayName":r.severity?oe(r.severity):void 0,"@_codeSystem":L,"@_codeSystemName":"SNOMED CT"},text:f(r.extension)}]}]}]}]:[]}]}]}]}}function ma(t){return{"@_xsi:type":"CD",...Mn.mapFhirToCcdaCode(t?.[0])??{"@_code":"419199007","@_displayName":"Allergy to substance (disorder)","@_codeSystem":L,"@_codeSystemName":"SNOMED CT"}}}function Zn(t,e){if(e.status==="completed")return{act:[{"@_classCode":"ACT","@_moodCode":"INT",templateId:[{"@_root":Ti}],id:d(e.id,e.identifier),code:U(e.category?.[0]),text:e.description?{"#text":e.description}:f(e.extension),statusCode:{"@_code":e.status}}]}}function Jn(t,e){return{organizer:[{"@_classCode":"CLUSTER","@_moodCode":"EVN",templateId:[{"@_root":cr,"@_extension":"2022-07-01"},{"@_root":cr,"@_extension":"2022-06-01"}],id:d(e.id,e.identifier),component:e.participant?.map(r=>({"@_typeCode":"PRF",role:r.role}))}]}}function Xn(t,e){return{act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":Fi,"@_extension":"2016-11-01"}],id:d(e.id,e.identifier),code:p(e.code)??{"@_code":Ct,"@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Note"},text:e.summary?{"#text":e.summary}:f(e.extension),statusCode:{"@_code":"completed"},effectiveTime:[{"@_value":k(e.date)}],author:t.mapAuthor(e.assessor,e.date)}]}}function Kn(t,e,r){let i=e.code?.coding?.[0]?.code;if(i===St)return _a(t,r);if(i===we)return Ea(t,r)}function _a(t,e){return{act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":Zt},{"@_root":Zt,"@_extension":"2015-08-01"}],id:d(e.id,void 0),code:{"@_code":"CONC","@_codeSystem":Xe},statusCode:{"@_code":ke.mapFhirToCcdaWithDefault(e.clinicalStatus?.coding?.[0]?.code,"active")},effectiveTime:z(e.recordedDate,void 0),entryRelationship:[{"@_typeCode":"SUBJ",observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:[{"@_root":$},{"@_root":$,"@_extension":"2015-08-01"}],id:e.identifier?d(void 0,e.identifier):[{"@_root":ze()}],text:f(e.extension),code:{"@_code":"55607006","@_codeSystem":L,"@_codeSystemName":"SNOMED CT","@_displayName":"Problem",translation:[{"@_code":In,"@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Condition"}]},statusCode:{"@_code":"completed"},effectiveTime:[{low:e.onsetDateTime?{"@_value":k(e.onsetDateTime)}:void 0,high:e.abatementDateTime?{"@_value":T(e.abatementDateTime)}:void 0}],value:U(e.code),author:t.mapAuthor(e.asserter,e.recordedDate)}]}]}]}}function Ea(t,e){let r=[];for(let i of e.evidence??m)for(let n of i.detail??m){let o=t.findResourceByReference(n);o?.resourceType==="Observation"&&r.push({"@_typeCode":"REFR",observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:[{"@_root":$},{"@_root":$,"@_extension":"2015-08-01"}],id:d(o.id,o.identifier),text:f(o.extension),code:{"@_code":"404684003","@_codeSystem":L,"@_codeSystemName":"SNOMED CT","@_displayName":"Clinical finding (finding)",translation:[{"@_code":Nn,"@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Clinical finding"}]},statusCode:{"@_code":"completed"},effectiveTime:z(o.effectivePeriod?.start,o.effectivePeriod?.end,!0),value:U(o.valueCodeableConcept),author:t.mapAuthor(o.performer?.[0],o.effectiveDateTime)}]})}return{act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":ar,"@_extension":"2015-08-01"},{"@_root":ar,"@_extension":"2022-06-01"}],id:d(e.id,void 0),code:{"@_code":we,"@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Health Concern"},statusCode:{"@_code":ke.mapFhirToCcdaWithDefault(e.clinicalStatus?.coding?.[0]?.code,"active")},effectiveTime:z(e.recordedDate,void 0),entryRelationship:r}]}}function eo(t,e){let r=t.findResourceByReference(e.device);if(!r)return;let i=[],n=d(r.id,r.identifier);return n&&i.push(...n),r.udiCarrier?.[0]?.deviceIdentifier&&i.push({"@_root":lr,"@_extension":r.udiCarrier[0].carrierHRF,"@_assigningAuthorityName":"FDA"}),{procedure:[{"@_classCode":"PROC","@_moodCode":"EVN",templateId:[{"@_root":ce,"@_extension":"2014-06-09"},{"@_root":ce}],id:d(e.id,e.identifier),code:{"@_code":"360030002","@_codeSystem":L,"@_codeSystemName":"SNOMED CT","@_displayName":"Application of medical device"},statusCode:{"@_code":"completed"},participant:[{"@_typeCode":"DEV",participantRole:{"@_classCode":"MANU",templateId:[{"@_root":yi}],id:i,playingDevice:{"@_classCode":"DEV",code:p(r.type)},scopingEntity:{id:[{"@_root":lr}]}}}]}]}}function to(t,e){let r=Vt(Q(e),"value");return(e.component||e.hasMember)&&!Ft(r)?{organizer:[Ia(t,e)]}:{observation:[re(t,e)]}}function Ia(t,e){let r=[];for(let n of e.component??m)r.push({observation:[re(t,e,n)]});for(let n of e.hasMember??m){let o=t.findResourceByReference(n);if(o?.resourceType==="Observation")if(o.component)for(let s of o.component)r.push({observation:[re(t,o,s)]});else r.push({observation:[re(t,o)]})}return{"@_classCode":"CLUSTER","@_moodCode":"EVN",templateId:Ta(e),id:d(e.id,e.identifier),code:p(e.code),statusCode:{"@_code":"completed"},effectiveTime:[{"@_value":T(e.effectiveDateTime)}],component:r}}function re(t,e,r){let i=p(r?.code??e.code);i?.["@_code"]===_r&&(i={"@_code":"ASSERTION","@_codeSystem":"2.16.840.1.113883.5.4"});let n=[];for(let s of e.hasMember??m){let a=t.findResourceByReference(s);a?.resourceType==="Observation"&&n.push({"@_typeCode":"COMP",observation:[re(t,a)]})}return{"@_classCode":"OBS","@_moodCode":"EVN",templateId:Tr(e,r),id:d(e.id,e.identifier),code:i,statusCode:{"@_code":"completed"},effectiveTime:[Gr(e.effectivePeriod,e.effectiveDateTime)],value:Sr(r??e),referenceRange:Sa(r?.referenceRange??e.referenceRange),text:f(r?.extension??e.extension),author:t.mapAuthor(e.performer?.[0],e.effectiveDateTime),entryRelationship:n}}function Ta(t){return t.code?.coding?.[0]?.code==="d5"?[{"@_root":De,"@_extension":"2014-06-09"},{"@_root":De}]:[{"@_root":Re},{"@_root":Re,"@_extension":"2015-08-01"}]}function Tr(t,e){let r=t.code?.coding?.[0]?.code,i=t.category?.[0]?.coding?.[0]?.code;return r===Sn?[{"@_root":Pe},{"@_root":Pe,"@_extension":"2014-06-09"}]:r===On?[{"@_root":be},{"@_root":be,"@_extension":"2014-06-09"}]:r===yn?[{"@_root":mt,"@_extension":"2023-06-28"}]:r===Cn?[{"@_root":Le},{"@_root":Le,"@_extension":"2016-06-01"}]:r===An?[{"@_root":dr},{"@_root":dr,"@_extension":"2023-05-01"}]:r===Dn?[{"@_root":pt,"@_extension":"2023-05-01"}]:r===xn?[{"@_root":ht,"@_extension":"2023-05-01"}]:r===_r?[{"@_root":et}]:r===Pn?[{"@_root":ft,"@_extension":"2023-05-01"}]:r==="d5"?e?.code?.coding?.[0]?.code===vn?[{"@_root":Ui}]:[{"@_root":xe,"@_extension":"2014-06-09"},{"@_root":xe}]:i==="exam"?[{"@_root":Ne},{"@_root":Ne,"@_extension":"2014-06-09"}]:i==="laboratory"?[{"@_root":ge},{"@_root":ge,"@_extension":"2015-08-01"}]:i==="survey"?t.hasMember?[{"@_root":dt,"@_extension":"2022-06-01"}]:[{"@_root":ut}]:[{"@_root":Ae},{"@_root":Ae,"@_extension":"2014-06-09"}]}function Sr(t){if(t.valueQuantity)return{"@_xsi:type":"PQ","@_unit":t.valueQuantity.unit,"@_value":t.valueQuantity.value?.toString()};if(t.valueCodeableConcept)return U(t.valueCodeableConcept);if(t.valueString!==void 0)return{"@_xsi:type":"ST","#text":t.valueString};if(t.valueInteger!==void 0)return{"@_xsi:type":"INT","@_value":t.valueInteger.toString()}}function Sa(t){if(!(!t||t.length===0))return t.map(e=>Oa(e)).filter(Boolean)}function Oa(t){if(!t)return;let e=Fe(t.extension);return e?{observationRange:{text:{reference:e},value:{"@_xsi:type":"ED",reference:e}}}:t.low||t.high?{observationRange:{value:{"@_xsi:type":"IVL_PQ",low:t.low?{"@_value":t.low.value?.toString(),"@_unit":t.low.unit}:void 0,high:t.high?{"@_value":t.high.value?.toString(),"@_unit":t.high.unit}:void 0}}}:{observationRange:{text:f(t.extension)}}}function ro(t,e){let r=[];for(let i of e.result??m){let n=t.findResourceByReference(i);n?.resourceType==="Observation"&&r.push({observation:[re(t,n)]})}return{organizer:[{"@_classCode":"CLUSTER","@_moodCode":"EVN",templateId:[{"@_root":Ce},{"@_root":Ce,"@_extension":"2015-08-01"}],id:d(e.id,e.identifier),code:p(e.code),statusCode:{"@_code":"completed"},component:r}]}}function io(t,e){return{encounter:[{"@_classCode":"ENC","@_moodCode":"EVN",templateId:[{"@_root":ve},{"@_root":ve,"@_extension":"2015-08-01"}],id:d(e.id,e.identifier),code:p(e.type?.[0]),text:f(e.extension),effectiveTime:J(void 0,e.period),participant:e.participant?.map(r=>({"@_typeCode":"LOC",participantRole:{"@_classCode":"SDLOC",templateId:[{"@_root":st}],code:p(r.type?.[0])}})),entryRelationship:e.diagnosis?.map(r=>ya(t,r)).filter(Boolean)}]}}function ya(t,e){let r=t.findResourceByReference(e.condition);if(r?.resourceType==="Condition")return{"@_typeCode":"REFR",act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":ve,"@_extension":"2015-08-01"},{"@_root":ve}],code:{"@_code":"29308-4","@_displayName":"Diagnosis","@_codeSystem":y,"@_codeSystemName":"LOINC"},entryRelationship:[{"@_typeCode":"SUBJ",observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:[{"@_root":$,"@_extension":"2015-08-01"},{"@_root":$}],id:d(r.id,r.identifier),code:{"@_code":"282291009","@_displayName":"Diagnosis interpretation","@_codeSystem":L,"@_codeSystemName":"SNOMED CT",translation:[{"@_code":"29308-4","@_displayName":"Diagnosis","@_codeSystem":y,"@_codeSystemName":"LOINC"}]},statusCode:{"@_code":"completed"},effectiveTime:z(r.onsetDateTime,r.abatementDateTime),value:U(r.code)}]}]}]}}function no(t,e){let r=t.code?.coding?.[0]?.code,i;if(e.category?.[0])i=p(e.category[0]);else if(r===Me)i={"@_code":Tn,"@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Resident's overall goal established during assessment process"};else if(e.description)i=p(e.description);else return;let n;if(r===Ot)n=[{"@_root":ct}];else if(i?.["@_code"]===gn)n=[{"@_root":de},{"@_root":de,"@_extension":"2022-06-01"}];else if(r===Me)n=[{"@_root":de}];else return;let o;return e.description.coding?.[0]?.code?o=U(e.description):e.description.text&&(o={"@_xsi:type":"ST","#text":e.description.text}),{observation:[{"@_classCode":"OBS","@_moodCode":"GOL",templateId:n,id:d(e.id,e.identifier),code:i,statusCode:{"@_code":Ca(e.lifecycleStatus)},effectiveTime:[{"@_value":T(e.startDate)}],value:o,text:f(e.extension),entryRelationship:e.target?.map(s=>({"@_typeCode":"RSON","@_inversionInd":"true",act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":ae},{"@_root":ae,"@_extension":"2014-06-09"}],code:p(s.measure),statusCode:{"@_code":"completed"},effectiveTime:[{"@_value":T(e.startDate)}]}]}))}]}}function Ca(t){switch(t){case"completed":return"completed";case"cancelled":return"cancelled";default:return"active"}}function oo(t,e){let r=e?.manufacturer,i={substanceAdministration:[{"@_classCode":"SBADM","@_moodCode":"EVN","@_negationInd":"false",templateId:[{"@_root":ir},{"@_root":ir,"@_extension":"2015-08-01"}],id:d(e.id,e.identifier),text:f(e.extension),statusCode:{"@_code":Pt.mapFhirToCcdaWithDefault(e.status,"completed")},effectiveTime:[{"@_value":k(e.occurrenceDateTime)}],consumable:{manufacturedProduct:[{"@_classCode":"MANU",templateId:[{"@_root":nr},{"@_root":nr,"@_extension":"2014-06-09"}],manufacturedMaterial:[{code:[p(e.vaccineCode)],lotNumberText:e.lotNumber?[e.lotNumber]:void 0}],manufacturerOrganization:r?[{id:d(r.id,r.identifier?[r.identifier]:void 0),name:[r.display]}]:void 0}]}}]};return e.performer&&(i.substanceAdministration[0].performer=e.performer.map(n=>ga(t,n)).filter(Boolean)),i}function ga(t,e){if(!e)return;let r=t.findResourceByReference(e.actor);if(!r)return;let i,n;return r.resourceType==="PractitionerRole"?(i=t.findResourceByReference(r.practitioner),n=t.findResourceByReference(r.organization)):r.resourceType==="Practitioner"?i=r:r.resourceType==="Organization"&&(n=r),{assignedEntity:{id:d(r.id,r.identifier),addr:x(i?.address),telecom:M(r.telecom),assignedPerson:i?{id:d(i.id,i.identifier),name:H(i.name)}:void 0,representedOrganization:n?{id:d(n.id,n.identifier),name:n.name?[n.name]:void 0,addr:x(n.address),telecom:M(n.telecom)}:void 0}}}function so(t,e){let r=[];for(let i of e.coverage??m){let n=t.findResourceByReference(i.coverage);if(n?.resourceType!=="Coverage")continue;let o=n.class?.find(l=>l.type?.coding?.[0]?.code==="plan"),s=t.findResourceByReference(n.payor?.[0]),a=t.findResourceByReference(n.policyHolder);r.push({"@_typeCode":"COMP",sequenceNumber:{"@_xsi:type":"INT","@_value":r.length.toString()},act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":sr,"@_extension":"2015-08-01"},{"@_root":sr}],id:d(n.id,n.identifier),code:{"@_code":Fn.mapFhirToCcdaWithDefault(n.type?.coding?.[0]?.code,"9999"),"@_displayName":n.type?.coding?.[0]?.display||"Unknown","@_codeSystemName":"Source of Payment Typology (PHDSC)","@_codeSystem":"2.16.840.1.113883.3.221.5"},statusCode:{"@_code":"completed"},text:f(n.extension),performer:[{"@_typeCode":"PRF",templateId:[{"@_root":Di}],assignedEntity:{id:[{"@_root":"2.16.840.1.113883.6.300","@_extension":"999999"}],code:{"@_code":"PAYOR","@_codeSystem":"2.16.840.1.113883.5.110","@_codeSystemName":"HL7 RoleCode","@_displayName":"invoice payor"},addr:x(s?.address),telecom:M(s?.telecom),representedOrganization:{name:s?.name?[s.name]:void 0,telecom:M(s?.telecom),addr:x(s?.address)}}}],participant:[{"@_typeCode":"COV",templateId:[{"@_root":xi}],participantRole:{"@_classCode":"PAT",id:[{"@_root":"2.16.840.1.113883.6.300","@_extension":a?.identifier?.[0]?.value||"88800933502"}],code:{"@_code":"FAMDEP","@_codeSystem":"2.16.840.1.113883.5.111","@_displayName":a?"self":"dependent"},addr:x(a?.address),playingEntity:{"@_classCode":"PSN",name:H(a?.name),"sdtc:birthTime":a?.birthDate?{"@_value":k(a.birthDate)}:void 0}}},a?{"@_typeCode":"HLD",templateId:[{"@_root":Pi}],participantRole:{id:[{"@_root":"2.16.840.1.113883.6.300","@_extension":a.identifier?.[0]?.value||"888009335"}],addr:x(a.address),playingEntity:{name:H(a.name)}}}:void 0].filter(Boolean),entryRelationship:[{"@_typeCode":"REFR",act:[{"@_classCode":"ACT","@_moodCode":"DEF",id:d(n.id,n.identifier),code:{"@_code":"PAYOR","@_codeSystem":"2.16.840.1.113883.5.110","@_codeSystemName":"HL7 RoleCode","@_displayName":"invoice payor"},text:o?.value?{"#text":o.value}:void 0}]}]}]})}return{act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":or,"@_extension":"2015-08-01"},{"@_root":or}],id:d(e.id,e.identifier),code:{"@_code":"48768-6","@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Payment Sources"},statusCode:{"@_code":"completed"},entryRelationship:r}]}}function ao(t,e){let r=e.contained?.find(s=>s.resourceType==="Medication"),i=r?.code||e.medicationCodeableConcept,n=r?.manufacturer,o=[];if(e.dispenseRequest?.validityPeriod){let s=ue(void 0,e.dispenseRequest.validityPeriod);s&&o.push(...s)}return e.dosageInstruction?.[0]?.timing?.repeat?.period&&o.push({"@_xsi:type":"PIVL_TS","@_institutionSpecified":"true","@_operator":"A",period:{"@_value":e.dosageInstruction[0].timing.repeat.period.toString(),"@_unit":e.dosageInstruction[0].timing.repeat.periodUnit}}),{substanceAdministration:[{"@_classCode":"SBADM","@_moodCode":"EVN",templateId:[{"@_root":er,"@_extension":"2014-06-09"},{"@_root":er}],id:[{"@_root":e.id||crypto.randomUUID()}],text:f(e.extension),statusCode:{"@_code":bt.mapFhirToCcdaWithDefault(e.status,"active")},effectiveTime:o,routeCode:Na(e.dosageInstruction?.[0]?.route),doseQuantity:Ra(e.dosageInstruction?.[0]?.doseAndRate?.[0]),consumable:{"@_typeCode":"CSM",manufacturedProduct:[{"@_classCode":"MANU",templateId:[{"@_root":tr,"@_extension":"2014-06-09"},{"@_root":tr}],manufacturedMaterial:[{code:[{...p(i),originalText:f(r?.extension)}]}],manufacturerOrganization:n?[{id:d(n.id,n.identifier?[n.identifier]:void 0),name:[n.display]}]:void 0}]},author:t.mapAuthor(e.requester,e.authoredOn),entryRelationship:e.dosageInstruction?.filter(s=>!!s.extension)?.map(s=>({"@_typeCode":"COMP",substanceAdministration:[{"@_classCode":"SBADM","@_moodCode":"EVN",templateId:[{"@_root":lt}],code:{"@_code":En,"@_codeSystem":y,"@_codeSystemName":"LOINC","@_displayName":"Medication Instructions"},text:f(s.extension),consumable:{manufacturedProduct:[{manufacturedLabeledDrug:[{"@_nullFlavor":"NA"}]}]}}]}))}]}}function Na(t){if(t)return p(t)}function Ra(t){if(t?.doseQuantity)return{"@_value":t.doseQuantity.value?.toString(),"@_unit":t.doseQuantity.unit}}function co(t,e){if(e.resourceType==="Procedure"){let r=["183948003","409063005","311331002","61310001","183945009","309814009","278373008","410606002","183933003","24642003","225338006","128939004"],i=e.code?.coding?.[0]?.code;return i&&r.includes(i)?{act:[{"@_classCode":"ACT","@_moodCode":"EVN",templateId:[{"@_root":ae},{"@_root":ae,"@_extension":"2014-06-09"}],id:d(e.id,e.identifier),code:p(e.code),statusCode:{"@_code":"completed"},effectiveTime:J(e.performedDateTime,e.performedPeriod),text:f(e.extension)}]}:{procedure:[{"@_classCode":"PROC","@_moodCode":"EVN",templateId:[{"@_root":ce},{"@_root":ce,"@_extension":"2014-06-09"}],id:d(e.id,e.identifier),code:p(e.code),statusCode:{"@_code":"completed"},effectiveTime:J(e.performedDateTime,e.performedPeriod),text:f(e.extension),targetSiteCode:p(e.bodySite?.[0]),participant:[Aa(t,e.location)].filter(Boolean)}]}}if(e.resourceType==="Observation")return{observation:[{"@_classCode":"OBS","@_moodCode":"EVN",templateId:Tr(e),id:d(e.id,e.identifier),code:p(e.code),value:Sr(e),statusCode:{"@_code":"completed"},effectiveTime:J(e.effectiveDateTime,e.effectivePeriod),text:f(e.extension)}]};throw new Error(`Unknown history of procedures resource type: ${e.resourceType}`)}function Aa(t,e){if(!e)return;let r=t.findResourceByReference(e);if(r)return{"@_typeCode":"LOC",participantRole:{"@_classCode":"SDLOC",templateId:[{"@_root":st}],id:d(r.id,r.identifier),code:p(r.type?.[0]),addr:r.address?x([r.address]):void 0,telecom:M(r.telecom),playingEntity:{"@_classCode":"PLC",name:r.name?[r.name]:void 0}}}}function uo(t,e){return e.code?.coding?.[0]?.system===qe?{procedure:[{"@_classCode":"PROC","@_moodCode":"RQO",templateId:[{"@_root":at},{"@_root":at,"@_extension":"2014-06-09"},{"@_root":at,"@_extension":"2022-06-01"}],id:d(e.id,e.identifier),code:p(e.code),statusCode:{"@_code":"active"},effectiveTime:[{"@_value":T(e.authoredOn)}],text:f(e.extension)}]}:{observation:[{"@_classCode":"OBS","@_moodCode":"RQO",templateId:[{"@_root":ct}],id:d(e.id,e.identifier),code:p(e.code),statusCode:{"@_code":va(e.status)},effectiveTime:[{"@_value":T(e.occurrenceDateTime)}],text:f(e.extension)}]}}function va(t){switch(t){case"completed":return"completed";case"entered-in-error":return"cancelled";default:return"active"}}function lo(t){if(!t||t.length===0)return;let e=t[0];if(!(!e||!e.code&&!e.period))return{serviceEvent:{"@_classCode":"PCPR",code:p(e.code?.[0]),effectiveTime:ue(void 0,e.period)}}}function al(t,e){return new Or(t,e).convert()}var Or=class{constructor(e,r){D(this,"bundle");D(this,"options");D(this,"composition");D(this,"patient");this.bundle=e,this.options=r;let i=this.findResource("Composition");if(!i)throw new Error("Composition not found");let n=this.findResource("Patient");if(!n)throw new Error("Patient not found");this.composition=i,this.patient=n}convert(){let e=this.createSections(),r=this.composition.section?.find(o=>o.code?.coding?.[0]?.code===Ve)?.entry?.find(o=>o.reference?.startsWith("ServiceRequest/")),i,n;return this.options?.type==="referral"?(i=jn,n={"@_code":hn,"@_displayName":"Referral Note","@_codeSystem":y,"@_codeSystemName":"LOINC"}):(i=Hn,n={"@_code":gt,"@_displayName":"Summarization of Episode Note","@_codeSystem":y,"@_codeSystemName":"LOINC"}),{realmCode:{"@_code":"US"},typeId:{"@_root":$r,"@_extension":"POCD_HD000040"},templateId:i,id:d(this.composition.id,void 0),code:n,title:this.composition.title,effectiveTime:J(this.composition.date,void 0),confidentialityCode:this.composition.confidentiality?Ln.mapFhirToCcdaCode(this.composition.confidentiality):void 0,languageCode:{"@_code":this.composition.language??"en-US"},recordTarget:this.createRecordTarget(),author:this.mapAuthor(this.composition.author?.[0],this.composition.date,!0),custodian:this.mapCustodian(this.composition.custodian),informationRecipient:this.mapRecipient(r),participant:this.createParticipants(),documentationOf:lo(this.composition.event),component:e.length>0?{structuredBody:{component:e.map(o=>({section:[o]}))}}:void 0}}findResource(e){return this.bundle.entry?.find(r=>r.resource?.resourceType===e)?.resource}findResourceByReference(e){if(!e?.reference)return;let[r,i]=e.reference.split("/");if(!(!r||!i))return this.bundle.entry?.find(n=>n.resource?.resourceType===r&&n.resource?.id===i)?.resource}findResourcesByReferences(e){return e?e.map(r=>this.findResourceByReference(r)).filter(r=>!!r):[]}createRecordTarget(){if(!this.patient)throw new Error("Patient not found");return[{patientRole:{id:d(this.patient.id,this.patient.identifier),addr:x(this.patient.address),telecom:M(this.patient.telecom),patient:Wn(this.patient)}}]}createSections(){let e=[];for(let r of this.composition.section??m)e.push(this.createSection(r));return e}createSection(e){let r=e.code?.coding?.[0]?.code;if(!r)throw new Error(`Missing section code: ${JSON.stringify(e.code)}`);let i=qn[r];if(!i)throw new Error(`Unknown section code: ${r}`);let n=this.findResourcesByReferences(e.entry);return r===yt&&n.length===1&&n[0].resourceType==="ClinicalImpression"?this.createClinicalImpressionSection(e,n[0]):r===Ve&&n.length===1&&n[0].resourceType==="ServiceRequest"?this.createReasonForReferralSection(e,n[0]):{templateId:i,code:p(e.code),title:e.title,text:Qn(e.text),entry:n.map(o=>this.createEntry(e,o)).filter(Boolean),"@_nullFlavor":n.length===0?"NI":void 0}}createEntry(e,r){switch(r.resourceType){case"Account":return so(this,r);case"AllergyIntolerance":return zn(this,r);case"CarePlan":return Zn(this,r);case"CareTeam":return Jn(this,r);case"ClinicalImpression":return Xn(this,r);case"Condition":return Kn(this,e,r);case"DeviceUseStatement":return eo(this,r);case"DiagnosticReport":return ro(this,r);case"Encounter":return io(this,r);case"Goal":return no(e,r);case"Immunization":return oo(this,r);case"MedicationRequest":return ao(this,r);case"Procedure":return co(this,r);case"Observation":return to(this,r);case"ServiceRequest":return uo(this,r);default:return}}mapAuthor(e,r,i){if(!e)return;let n=this.findResourceByReference(e);if(!n)return;let o;if(n.resourceType==="Organization"?o=n:n.resourceType==="PractitionerRole"&&(o=this.findResourceByReference(n.organization),n=this.findResourceByReference(n.practitioner)),!n)return;let s;"address"in n&&(s=n.address);let a;"telecom"in n&&(a=n.telecom);let l;"qualification"in n&&(l=n.qualification?.[0]?.code);let E;return["Patient","Practitioner","RelatedPerson"].includes(n.resourceType)&&(E=n.name),[{templateId:[{"@_root":Li}],time:r?{"@_value":T(r)}:void 0,assignedAuthor:{id:d(n.id,n.identifier),addr:x(s),telecom:M(a),code:p(l),assignedPerson:E?{name:H(E)}:void 0,assignedAuthoringDevice:!E&&i?{manufacturerModelName:"Medplum",softwareName:"Medplum"}:void 0,representedOrganization:o?.name?{name:[o.name]}:void 0}}]}mapCustodian(e){if(!e)return;let r=this.findResourceByReference(e);if(r)return{assignedCustodian:{representedCustodianOrganization:{id:d(r.id,r.identifier),name:r.name?[r.name]:void 0,telecom:M(r.telecom),addr:x(r.address)}}}}mapRecipient(e){if(!e)return;let r=this.findResourceByReference(e);if(!r)return;let i=r.performer;if(!i||i.length===0)return;let n=this.findResourceByReference(i[0]);if(n?.resourceType==="Practitioner")return{intendedRecipient:{informationRecipient:{name:H(n.name)}}}}createParticipants(){let e=this.bundle.entry?.filter(r=>r.resource?.resourceType==="RelatedPerson").map(r=>r.resource);if(!(!e||e.length===0))return e.map(r=>({"@_typeCode":"IND",templateId:[{"@_root":Qi,"@_extension":"2023-05-01"}],associatedEntity:{"@_classCode":"PRS",id:d(r.id,r.identifier),code:p(r.relationship?.[0]),addr:x(r.address),telecom:M(r.telecom),associatedPerson:{name:H(r.name)}}}))}createClinicalImpressionSection(e,r){return{templateId:[{"@_root":rt}],code:p(e.code),title:e.title,text:r.summary,author:this.mapAuthor(r.assessor,r.date)}}createReasonForReferralSection(e,r){return{templateId:[{"@_root":K,"@_extension":"2014-06-09"},{"@_root":K}],code:p(e.code),title:e.title,text:r.note?.[0]?.text,entry:[{act:[{"@_classCode":"PCPR","@_moodCode":"INT",templateId:[{"@_root":Vi}],id:d(r.id,r.identifier),code:p(r.code),statusCode:{"@_code":"active"},effectiveTime:[{"@_value":T(r.occurrenceDateTime)}],priorityCode:{"@_code":"A","@_codeSystem":"2.16.840.1.113883.5.7","@_codeSystemName":"ActPriority","@_displayName":"ASAP"},author:this.mapAuthor(r.requester,r.occurrenceDateTime)}]}]}}};export{mr as ACT_CODE_SYSTEM,At as ADDRESS_USE_MAPPER,Ns as ADDRESS_USE_VALUE_SET,Os as ADMINISTRATIVE_GENDER_CODE_SYSTEM,As as ADMINISTRATIVE_GENDER_VALUE_SET,Ys as ALLERGIES_SECTION_TEMPLATE_IDS,Mn as ALLERGY_CATEGORY_MAPPER,Et as ALLERGY_CLINICAL_CODE_SYSTEM,xt as ALLERGY_SEVERITY_MAPPER,Dt as ALLERGY_STATUS_MAPPER,fr as ALLERGY_VERIFICATION_CODE_SYSTEM,Zs as ASSESSMENTS_SECTION_TEMPLATE_IDS,na as CARE_TEAM_SECTION_TEMPLATE_IDS,Tt as CCDA_NARRATIVE_REFERENCE_URL,Bc as CCDA_TEMPLATE_CODE_SYSTEM,Hn as CCDA_TEMPLATE_IDS,pr as CLINICAL_CONDITION_CODE_SYSTEM,ad as CLINICAL_NOTES_SECTION_TEMPLATE_IDS,Ji as CONDITION_CATEGORY_CODE_SYSTEM,Zi as CONDITION_VERIFICATION_CODE_SYSTEM,hr as CONDITION_VER_STATUS_CODE_SYSTEM,ys as CONFIDENTIALITY_CODE_SYSTEM,Ln as CONFIDENTIALITY_MAPPER,vs as CONTACT_ENTITY_USE_VALUE_SET,Vs as CVX_URL,zs as DEVICES_SECTION_TEMPLATE_IDS,Ki as DIAGNOSIS_ROLE_CODE_SYSTEM,Xs as ENCOUNTERS_SECTION_TEMPLATE_IDS,wn as ENCOUNTER_STATUS_MAPPER,g as EnumMapper,ks as FHIR_CVX_URL,Fs as FHIR_ICF_URL,sa as FUNCTIONAL_STATUS_TEMPLATE_IDS,Or as FhirToCcdaConverter,Un as GENDER_MAPPER,Ks as GOALS_SECTION_TEMPLATE_IDS,ea as HEALTH_CONCERNS_SECTION_TEMPLATE_IDS,te as HTTP,Rt as HUMAN_NAME_USE_MAPPER,Hs as IMMUNIZATIONS_SECTION_TEMPLATE_IDS,Pt as IMMUNIZATION_STATUS_MAPPER,Fn as INSURANCE_COVERAGE_TYPE_MAPPER,oa as INSURANCE_SECTION_TEMPLATE_IDS,cd as LAB_TESTS_SECTION_TEMPLATE_IDS,Lc as LANGUAGE_MODE_CODE_SYSTEM,Vc as LANGUAGE_MODE_URL,Uc as LANGUAGE_PROFICIENCY_CODE_SYSTEM,kc as LANGUAGE_PROFICIENCY_URL,yn as LOINC_ADMINISTRATIVE_SEX,nn as LOINC_ALLERGIES_SECTION,yt as LOINC_ASSESSMENTS_SECTION,Cn as LOINC_BIRTH_SEX,mn as LOINC_CARE_TEAM_SECTION,Nn as LOINC_CLINICAL_FINDING,In as LOINC_CONDITION,ln as LOINC_DEVICES_SECTION,An as LOINC_DISABILITY_STATUS,pn as LOINC_ENCOUNTERS_SECTION,vn as LOINC_FUNCTIONAL_STATUS_ASSESSMENT_NOTE,Rn as LOINC_FUNCTIONAL_STATUS_SECTION,Me as LOINC_GOALS_SECTION,we as LOINC_HEALTH_CONCERNS_SECTION,Dn as LOINC_HISTORY_OF_OCCUPATION,xn as LOINC_HISTORY_OF_OCCUPATION_INDUSTRY,gn as LOINC_HISTORY_OF_SOCIAL_FUNCTION,On as LOINC_HISTORY_OF_TOBACCO_USE,on as LOINC_IMMUNIZATIONS_SECTION,_n as LOINC_INSURANCE_SECTION,sn as LOINC_MEDICATIONS_SECTION,En as LOINC_MEDICATION_INSTRUCTIONS,fn as LOINC_MENTAL_STATUS_SECTION,Ct as LOINC_NOTES_SECTION,Yc as LOINC_NOTE_DOCUMENT,Tn as LOINC_OVERALL_GOAL,Gc as LOINC_PATIENT_SUMMARY_DOCUMENT,Ot as LOINC_PLAN_OF_TREATMENT_SECTION,_r as LOINC_PREGNANCY_STATUS,St as LOINC_PROBLEMS_SECTION,un as LOINC_PROCEDURES_SECTION,Ve as LOINC_REASON_FOR_REFERRAL_SECTION,hn as LOINC_REFERRAL_NOTE,an as LOINC_RESULTS_SECTION,cn as LOINC_SOCIAL_HISTORY_SECTION,gt as LOINC_SUMMARY_OF_EPISODE_NOTE,Sn as LOINC_TOBACCO_SMOKING_STATUS,qn as LOINC_TO_TEMPLATE_IDS,Pn as LOINC_TRIBAL_AFFILIATION,dn as LOINC_VITAL_SIGNS_SECTION,Gs as MEDICATIONS_SECTION_TEMPLATE_IDS,wc as MEDICATION_REQUEST_STATUS_VALUE_SET,bt as MEDICATION_STATUS_MAPPER,ra as MENTAL_STATUS_SECTION_TEMPLATE_IDS,Rs as NAME_USE_VALUE_SET,Ds as NCI_THESAURUS_URL,ws as NDFRT_URL,Us as NUCC_TAXONOMY_URL,Cs as OBSERVATION_CATEGORY_CODE_SYSTEM,kn as OBSERVATION_CATEGORY_MAPPER,Xi as PARTICIPATION_CODE_SYSTEM,ia as PATIENT_NOTES_SECTION_TEMPLATE_IDS,Js as PLAN_OF_TREATMENT_SECTION_TEMPLATE_IDS,$s as PROBLEMS_SECTION_TEMPLATE_IDS,ke as PROBLEM_STATUS_MAPPER,Ws as PROCEDURES_SECTION_TEMPLATE_IDS,Vn as PROCEDURE_STATUS_MAPPER,Mc as RACE_CODE_SYSTEM,ta as REASON_FOR_REFERRAL_SECTION_TEMPLATE_IDS,jn as REFERRAL_TEMPLATE_IDS,Qs as RESULTS_SECTION_TEMPLATE_IDS,gs as ROLE_CODE_CODE_SYSTEM,qs as SOCIAL_HISTORY_SECTION_TEMPLATE_IDS,Nt as SYSTEM_MAPPER,vt as TELECOM_USE_MAPPER,Ls as UNII_URL,en as US_CORE_CONDITION_URL,It as US_CORE_ETHNICITY_URL,tn as US_CORE_MEDICATION_REQUEST_URL,Fc as US_CORE_PATIENT_URL,Ue as US_CORE_RACE_URL,Ps as US_DRIVER_LICENSE_URL,bs as US_NPI_URL,xs as US_SSN_URL,Ms as VA_MEDRT_URL,js as VITAL_SIGNS_SECTION_TEMPLATE_IDS,rn as XSI_URL,rd as convertCcdaToFhir,Qc as convertCcdaToXml,al as convertFhirToCcda,$n as convertToCompactXml,Wc as convertXmlToCcda,Er as mapCcdaCodeToCodeableConcept,ee as mapCcdaSystemToFhir,$t as mapCcdaToFhirDate,C as mapCcdaToFhirDateTime,p as mapCodeableConceptToCcdaCode,U as mapCodeableConceptToCcdaValue,zi as mapCodingToCcdaCode,Gr as mapFhirPeriodOrDateTimeToCcda,bn as mapFhirSystemToCcda,k as mapFhirToCcdaDate,T as mapFhirToCcdaDateTime,Gn as parseXml};
|
|
3
3
|
/*!
|
|
4
4
|
* Reconnecting WebSocket
|