@medplum/mock 0.9.5 → 0.9.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.min.js","sources":["../../../src/mocks/accesspolicy.ts","../../../src/mocks/alice.ts","../../../src/mocks/bot.ts","../../../src/mocks/questionnaire.ts","../../../src/mocks/simpsons.ts","../../../src/mocks/subscription.ts","../../../src/mocks/types.ts","../../../src/mocks/valueset.ts","../../../../node_modules/tslib/tslib.es6.js","../../../fhirpath/dist/esm/index.js","../../../src/repo.ts","../../../src/client.ts"],"sourcesContent":["import { AccessPolicy, UserConfiguration, ValueSet } from '@medplum/fhirtypes';\n\nexport const ExampleAccessPolicy: AccessPolicy = {\n resourceType: 'AccessPolicy',\n id: '123',\n name: 'Example Access Policy',\n};\n\nexport const ExampleStatusValueSet: ValueSet = {\n resourceType: 'ValueSet',\n id: 'example-statuses',\n compose: {\n include: [\n {\n concept: [\n { code: 'ORDERED' },\n { code: 'SENT_TO_CUSTOMER' },\n { code: 'SENT_BACK_TO_LAB' },\n { code: 'LAB_PROCESSED' },\n { code: 'LAB_COMPLETE' },\n ],\n },\n ],\n },\n};\n\nexport const ExampleUserConfiguration: UserConfiguration = {\n resourceType: 'UserConfiguration',\n id: '123',\n name: 'Example User Configuration',\n option: [\n {\n id: 'statusValueSet',\n valueString: 'ValueSet/example-statuses',\n },\n ],\n};\n","import { createReference } from '@medplum/core';\nimport { Organization, Practitioner, Schedule, Slot } from '@medplum/fhirtypes';\n\nexport const TestOrganization: Organization = {\n resourceType: 'Organization',\n id: '123',\n meta: {\n versionId: '1',\n },\n name: 'Test Organization',\n};\n\nexport const DifferentOrganization: Organization = {\n resourceType: 'Organization',\n id: '456',\n meta: {\n versionId: '1',\n },\n name: 'Different',\n};\n\nexport const DrAliceSmith: Practitioner = {\n resourceType: 'Practitioner',\n id: '123',\n meta: {\n versionId: '2',\n lastUpdated: '2021-01-02T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n name: [\n {\n given: ['Alice'],\n family: 'Smith',\n },\n ],\n photo: [\n {\n contentType: 'image/png',\n url: 'https://docs.medplum.com/img/cdc-femaledoc.png',\n },\n ],\n};\n\nexport const DrAliceSmithPreviousVersion: Practitioner = {\n resourceType: 'Practitioner',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2021-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n name: [{ given: ['Medplum'], family: 'Admin' }],\n};\n\nexport const DrAliceSmithSchedule: Schedule = {\n resourceType: 'Schedule',\n id: '123',\n actor: [\n {\n reference: 'Practitioner/123',\n display: 'Dr. Alice Smith',\n },\n ],\n};\n\nexport const DrAliceSmithSlots: Slot[] = (() => {\n const schedule = createReference(DrAliceSmithSchedule);\n const result: Slot[] = [];\n const slotDate = new Date();\n for (let day = 0; day < 60; day++) {\n for (const hour of [9, 10, 11, 13, 14, 15]) {\n slotDate.setHours(hour, 0, 0, 0);\n result.push({\n resourceType: 'Slot',\n id: `slot-${day}-${hour}`,\n start: slotDate.toISOString(),\n schedule,\n });\n }\n slotDate.setDate(slotDate.getDate() + 1);\n }\n return result;\n})();\n","import { Bot, ClientApplication } from '@medplum/fhirtypes';\n\nexport const ExampleBot: Bot = {\n resourceType: 'Bot',\n id: '123',\n name: 'Test Bot',\n code: 'console.log(\"hello world\");',\n};\n\nexport const ExampleClient: ClientApplication = {\n resourceType: 'ClientApplication',\n id: '123',\n name: 'Test Client',\n};\n","import { Questionnaire, QuestionnaireResponse } from '@medplum/fhirtypes';\n\nexport const ExampleQuestionnaire: Questionnaire = {\n resourceType: 'Questionnaire',\n id: '123',\n name: 'Vitals',\n title: 'Vitals',\n subjectType: ['Patient'],\n item: [\n {\n linkId: '1',\n text: 'First question',\n type: 'string',\n },\n ],\n};\n\nexport const ExampleQuestionnaireResponse: QuestionnaireResponse = {\n resourceType: 'QuestionnaireResponse',\n id: '123',\n questionnaire: 'Questionnaire/123',\n subject: {\n reference: 'Patient/123',\n },\n source: {\n reference: 'Practitioner/123',\n },\n};\n","import { createReference } from '@medplum/core';\nimport {\n Communication,\n DiagnosticReport,\n Encounter,\n Media,\n Observation,\n Patient,\n ServiceRequest,\n Specimen,\n} from '@medplum/fhirtypes';\n\nexport const HomerSimpson: Patient = {\n resourceType: 'Patient',\n id: '123',\n meta: {\n versionId: '2',\n lastUpdated: '2020-01-02T00:00:00.000Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n identifier: [\n { system: 'abc', value: '123' },\n { system: 'def', value: '456' },\n ],\n active: true,\n birthDate: '1956-05-12',\n name: [\n {\n given: ['Homer'],\n family: 'Simpson',\n },\n ],\n photo: [\n {\n contentType: 'image/png',\n url: 'https://docs.medplum.com/img/homer-simpson.png',\n },\n ],\n telecom: [\n {\n system: 'phone',\n use: 'home',\n value: '555-7334',\n },\n {\n system: 'email',\n use: 'home',\n value: 'chunkylover53@aol.com',\n },\n ],\n address: [\n {\n use: 'home',\n line: ['742 Evergreen Terrace'],\n city: 'Springfield',\n state: 'IL',\n postalCode: '12345',\n },\n ],\n};\n\nexport const HomerSimpsonPreviousVersion: Patient = {\n resourceType: 'Patient',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-01T00:00:00.000Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n name: [\n {\n given: ['Homer'],\n family: 'Simpson',\n },\n ],\n photo: [\n {\n contentType: 'image/png',\n url: 'https://docs.medplum.com/img/homer-simpson.png',\n },\n ],\n};\n\nexport const HomerEncounter: Encounter = {\n resourceType: 'Encounter',\n id: '123',\n meta: {\n versionId: '456',\n lastUpdated: '2020-01-01T00:00:00.000Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n};\n\nexport const HomerCommunication: Communication = {\n resourceType: 'Communication',\n id: '123',\n meta: {\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n payload: [\n {\n contentString: 'Hello world',\n },\n ],\n};\n\nexport const HomerMedia: Media = {\n resourceType: 'Media',\n id: '123',\n meta: {\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n content: {\n contentType: 'text/plain',\n url: 'https://example.com/test.txt',\n },\n};\n\nexport const HomerDiagnosticReport: DiagnosticReport = {\n resourceType: 'DiagnosticReport',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-02T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n subject: {\n reference: 'Patient/123',\n display: 'Homer Simpson',\n },\n resultsInterpreter: [\n {\n reference: 'Practitioner/123',\n display: 'Dr. Alice Smith',\n },\n ],\n result: [\n { reference: 'Observation/1' },\n { reference: 'Observation/2' },\n { reference: 'Observation/3' },\n { reference: 'Observation/4' },\n { reference: 'Observation/5' },\n { reference: 'Observation/6' },\n ],\n};\n\nexport const HomerObservation1: Observation = {\n resourceType: 'Observation',\n id: '1',\n code: {\n text: 'Test 1',\n },\n valueString: 'test',\n};\n\nexport const HomerObservation2: Observation = {\n resourceType: 'Observation',\n id: '2',\n code: {\n text: 'Test 2',\n },\n valueQuantity: {\n value: 20,\n unit: 'x',\n },\n referenceRange: [\n {\n low: {\n value: 10,\n },\n },\n ],\n};\n\nexport const HomerObservation3: Observation = {\n resourceType: 'Observation',\n id: '3',\n code: {\n text: 'Test 3',\n },\n valueQuantity: {\n value: 30,\n unit: 'x',\n },\n referenceRange: [\n {\n high: {\n value: 50,\n },\n },\n ],\n};\n\nexport const HomerObservation4: Observation = {\n resourceType: 'Observation',\n id: '4',\n code: {\n text: 'Test 4',\n },\n valueQuantity: {\n value: 50,\n unit: 'x',\n comparator: '>',\n },\n referenceRange: [\n {\n low: {\n value: 10,\n unit: 'x',\n },\n high: {\n value: 50,\n unit: 'x',\n },\n },\n ],\n interpretation: [\n {\n text: 'HIGH',\n },\n ],\n};\n\nexport const HomerObservation5: Observation = {\n resourceType: 'Observation',\n id: '5',\n code: {\n text: 'Test 5',\n },\n valueQuantity: {\n value: 100,\n unit: 'x',\n },\n referenceRange: [{}],\n interpretation: [{}],\n};\n\nexport const HomerObservation6: Observation = {\n resourceType: 'Observation',\n id: '6',\n code: {\n text: 'Test 6',\n },\n component: [\n {\n valueQuantity: {\n value: 110,\n unit: 'mmHg',\n system: 'http://unitsofmeasure.org',\n },\n },\n {\n valueQuantity: {\n value: 75,\n unit: 'mmHg',\n system: 'http://unitsofmeasure.org',\n },\n },\n ],\n};\n\nexport const HomerSimpsonSpecimen: Specimen = {\n resourceType: 'Specimen',\n subject: createReference(HomerSimpson),\n collection: {\n collectedDateTime: '2020-01-01T12:00:00Z',\n },\n};\n\nexport const HomerServiceRequest: ServiceRequest = {\n resourceType: 'ServiceRequest',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n identifier: [\n {\n system: 'https://example.com',\n value: '9001',\n },\n ],\n code: {\n coding: [\n {\n system: 'http://snomed.info/sct',\n code: 'SERVICE_REQUEST_CODE',\n },\n ],\n },\n subject: {\n reference: 'Patient/123',\n display: 'Homer Simpson',\n },\n status: 'active',\n orderDetail: [\n {\n text: 'ORDERED',\n },\n ],\n specimen: [createReference(HomerSimpsonSpecimen)],\n authoredOn: '2020-01-01T12:00:00Z',\n};\n\nexport const BartSimpson: Patient = {\n resourceType: 'Patient',\n id: '555',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n birthDate: '1979-12-17',\n name: [\n {\n given: ['Bart'],\n family: 'Simpson',\n },\n ],\n photo: [\n {\n contentType: 'image/jpeg',\n url: 'https://example.com/picture.jpg',\n },\n ],\n telecom: [\n {\n system: 'phone',\n use: 'home',\n value: '555-1239',\n },\n {\n system: 'email',\n use: 'home',\n value: 'bart@thesimpsons.com',\n },\n ],\n};\n","import { AuditEvent, Subscription } from '@medplum/fhirtypes';\n\nexport const ExampleSubscription: Subscription = {\n resourceType: 'Subscription',\n id: '123',\n meta: {\n versionId: '456',\n },\n};\n\nexport const ExampleAuditEvent: AuditEvent = {\n resourceType: 'AuditEvent',\n id: '123',\n meta: {\n lastUpdated: new Date().toISOString(),\n versionId: '456',\n author: {\n reference: 'Practitioner/123',\n },\n },\n};\n","import { SearchParameter } from '@medplum/fhirtypes';\nimport StructureDefinitionList from './structuredefinitions.json';\n\nexport const PatientSearchParameters: SearchParameter[] = [\n {\n resourceType: 'SearchParameter',\n id: 'Patient-name',\n base: ['Patient'],\n code: 'name',\n name: 'name',\n type: 'string',\n expression: 'Patient.name',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Patient-birthdate',\n base: ['Patient'],\n code: 'birthdate',\n name: 'birthdate',\n type: 'date',\n expression: 'Patient.birthDate',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Patient-organization',\n base: ['Patient'],\n code: 'organization',\n name: 'organization',\n type: 'reference',\n expression: 'Patient.managingOrganization',\n target: ['Organization'],\n },\n {\n resourceType: 'SearchParameter',\n id: 'Patient-active',\n base: ['Patient'],\n code: 'active',\n name: 'active',\n type: 'token',\n expression: 'Patient.active',\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-telecom',\n base: ['Patient', 'Practitioner'],\n code: 'telecom',\n name: 'telecom',\n type: 'token',\n expression: 'Patient.telecom | Practitioner.telecom',\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-email',\n base: ['Patient', 'Practitioner'],\n code: 'email',\n name: 'email',\n type: 'token',\n expression: \"Patient.telecom.where(system='email') | Practitioner.telecom.where(system='email')\",\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-phone',\n base: ['Patient', 'Practitioner'],\n code: 'phone',\n name: 'phone',\n type: 'token',\n expression: \"Patient.telecom.where(system='phone') | Practitioner.telecom.where(system='phone')\",\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-address-city',\n base: ['Patient', 'Practitioner'],\n code: 'address-city',\n name: 'address-city',\n type: 'token',\n expression: 'Patient.address.city | Practitioner.address.city',\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-address-state',\n base: ['Patient', 'Practitioner'],\n code: 'address-state',\n name: 'address-state',\n type: 'token',\n expression: 'Patient.address.state | Practitioner.address.state',\n },\n {\n resourceType: 'SearchParameter',\n id: 'ServiceRequest-subject',\n code: 'subject',\n base: ['ServiceRequest'],\n type: 'reference',\n expression: 'ServiceRequest.subject',\n target: ['Group', 'Device', 'Patient', 'Location'],\n },\n {\n resourceType: 'SearchParameter',\n id: 'ServiceRequest-authored',\n code: 'authored',\n base: ['ServiceRequest'],\n type: 'date',\n expression: 'ServiceRequest.authoredOn',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Observation-value-quantity',\n code: 'value-quantity',\n base: ['Observation'],\n type: 'quantity',\n expression: '(Observation.value as Quantity) | (Observation.value as SampledData)',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Encounter-length',\n code: 'length',\n base: ['Encounter'],\n type: 'quantity',\n expression: 'Encounter.length',\n },\n];\n\nexport const GraphQLSchemaResponse = {\n data: {\n StructureDefinitionList,\n SearchParameterList: [...PatientSearchParameters],\n },\n};\n","import { ValueSet } from '@medplum/fhirtypes';\n\nexport const exampleValueSet: ValueSet = {\n resourceType: 'ValueSet',\n expansion: {\n contains: [\n {\n system: 'x',\n code: 'test-code',\n display: 'Test Display',\n },\n ],\n },\n};\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n\r\nfunction __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nfunction __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\n\n/**\n * Ensures that the value is wrapped in an array.\n * @param input The input as a an array or a value.\n * @returns The input as an array.\n */\nfunction ensureArray(input) {\n if (input === null || input === undefined) {\n return [];\n }\n return Array.isArray(input) ? input : [input];\n}\n/**\n * Applies a function to single value or an array of values.\n * @param context The context which will be passed to the function.\n * @param fn The function to apply.\n * @returns The result of the function.\n */\nfunction applyMaybeArray(context, fn) {\n if (context === undefined) {\n return undefined;\n }\n if (Array.isArray(context)) {\n return context\n .map((e) => fn(e))\n .filter((e) => !!e)\n .flat();\n }\n else {\n return fn(context);\n }\n}\n/**\n * Determines if the input is an empty array.\n * @param obj Any value or array of values.\n * @returns True if the input is an empty array.\n */\nfunction isEmptyArray(obj) {\n return Array.isArray(obj) && obj.length === 0;\n}\nfunction isFalsy(obj) {\n return !obj || isEmptyArray(obj);\n}\n/**\n * Converts unknown object into a JavaScript boolean.\n * Note that this is different than the FHIRPath \"toBoolean\",\n * which has particular semantics around arrays, empty arrays, and type conversions.\n * @param obj Any value or array of values.\n * @returns The converted boolean value according to FHIRPath rules.\n */\nfunction toJsBoolean(obj) {\n if (Array.isArray(obj)) {\n return obj.length === 0 ? false : !!obj[0];\n }\n return !!obj;\n}\n/**\n * Removes duplicates in array using FHIRPath equality rules.\n * @param arr The input array.\n * @returns The result array with duplicates removed.\n */\nfunction removeDuplicates(arr) {\n const result = [];\n for (const i of arr) {\n let found = false;\n for (const j of result) {\n if (fhirPathEquals(i, j)) {\n found = true;\n break;\n }\n }\n if (!found) {\n result.push(i);\n }\n }\n return result;\n}\n/**\n * Determines if two values are equal according to FHIRPath equality rules.\n * @param x The first value.\n * @param y The second value.\n * @returns True if equal.\n */\nfunction fhirPathEquals(x, y) {\n if (isFalsy(x) && isFalsy(y)) {\n return true;\n }\n if (isEmptyArray(x) || isEmptyArray(y)) {\n return [];\n }\n if (typeof x === 'number' && typeof y === 'number') {\n return Math.abs(x - y) < 1e-8;\n }\n if (isQuantity(x) && isQuantity(y)) {\n return isQuantityEquivalent(x, y);\n }\n if (Array.isArray(x) && Array.isArray(y)) {\n return x.length === y.length && x.every((val, index) => fhirPathEquals(val, y[index]));\n }\n if (typeof x === 'object' && typeof y === 'object') {\n return deepEquals(x, y);\n }\n return x === y;\n}\n/**\n * Determines if two values are equal according to FHIRPath equality rules.\n * @param x The first value.\n * @param y The second value.\n * @returns True if equal.\n */\nfunction fhirPathEquivalent(x, y) {\n if (isFalsy(x) && isFalsy(y)) {\n return true;\n }\n if (isEmptyArray(x) || isEmptyArray(y)) {\n // Note that this implies that if the collections have a different number of items to compare,\n // or if one input is a value and the other is empty ({ }), the result will be false.\n return false;\n }\n if (typeof x === 'number' && typeof y === 'number') {\n // Use more generous threshold than equality\n // Decimal: values must be equal, comparison is done on values rounded to the precision of the least precise operand.\n // Trailing zeroes after the decimal are ignored in determining precision.\n return Math.abs(x - y) < 0.01;\n }\n if (isQuantity(x) && isQuantity(y)) {\n return isQuantityEquivalent(x, y);\n }\n if (Array.isArray(x) && Array.isArray(y)) {\n // If both operands are collections with multiple items:\n // 1) Each item must be equivalent\n // 2) Comparison is not order dependent\n x.sort();\n y.sort();\n return x.length === y.length && x.every((val, index) => fhirPathEquals(val, y[index]));\n }\n if (typeof x === 'object' && typeof y === 'object') {\n return deepEquals(x, y);\n }\n if (typeof x === 'string' && typeof y === 'string') {\n // String: the strings must be the same, ignoring case and locale, and normalizing whitespace\n // (see String Equivalence for more details).\n return x.toLowerCase() === y.toLowerCase();\n }\n return x === y;\n}\nfunction fhirPathIs(value, desiredType) {\n if (value === undefined || value === null) {\n return false;\n }\n switch (desiredType) {\n case 'Boolean':\n return typeof value === 'boolean';\n case 'Decimal':\n case 'Integer':\n return typeof value === 'number';\n case 'Date':\n return typeof value === 'string' && !!value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/);\n case 'DateTime':\n return typeof value === 'string' && !!value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?T/);\n case 'Time':\n return typeof value === 'string' && !!value.match(/^T\\d/);\n case 'Period':\n return isPeriod(value);\n case 'Quantity':\n return isQuantity(value);\n default:\n return typeof value === 'object' && (value === null || value === void 0 ? void 0 : value.resourceType) === desiredType;\n }\n}\n/**\n * Determines if the input is a Period object.\n * This is heuristic based, as we do not have strong typing at runtime.\n * @param input The input value.\n * @returns True if the input is a period.\n */\nfunction isPeriod(input) {\n return !!(input && typeof input === 'object' && 'start' in input);\n}\n/**\n * Determines if the input is a Quantity object.\n * This is heuristic based, as we do not have strong typing at runtime.\n * @param input The input value.\n * @returns True if the input is a quantity.\n */\nfunction isQuantity(input) {\n return !!(input && typeof input === 'object' && 'value' in input && typeof input.value === 'number');\n}\nfunction isQuantityEquivalent(x, y) {\n return (Math.abs(x.value - y.value) < 0.01 &&\n (x.unit === y.unit || x.code === y.code || x.unit === y.code || x.code === y.unit));\n}\n/**\n * Resource equality.\n * Ignores meta.versionId and meta.lastUpdated.\n * See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality\n * @param object1 The first object.\n * @param object2 The second object.\n * @returns True if the objects are equal.\n */\nfunction deepEquals(object1, object2) {\n const keys1 = Object.keys(object1);\n const keys2 = Object.keys(object2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n const val1 = object1[key];\n const val2 = object2[key];\n if (isObject(val1) && isObject(val2)) {\n if (!deepEquals(val1, val2)) {\n return false;\n }\n }\n else {\n if (val1 !== val2) {\n return false;\n }\n }\n }\n return true;\n}\nfunction isObject(object) {\n return object !== null && typeof object === 'object';\n}\n\nclass FhirPathAtom {\n constructor(original, child) {\n this.original = original;\n this.child = child;\n }\n eval(context) {\n try {\n const result = applyMaybeArray(context, (e) => this.child.eval(e));\n if (Array.isArray(result)) {\n return result.flat();\n }\n else if (result === undefined || result === null) {\n return [];\n }\n else {\n return [result];\n }\n }\n catch (error) {\n throw new Error(`FhirPathError on \"${this.original}\": ${error}`);\n }\n }\n}\nclass LiteralAtom {\n constructor(value) {\n this.value = value;\n }\n eval() {\n return this.value;\n }\n}\nclass SymbolAtom {\n constructor(name) {\n this.name = name;\n }\n eval(context) {\n if (this.name === '$this') {\n return context;\n }\n return applyMaybeArray(context, (e) => {\n if (e && typeof e === 'object') {\n if ('resourceType' in e && e.resourceType === this.name) {\n return e;\n }\n if (this.name in e) {\n return e[this.name];\n }\n const propertyName = Object.keys(e).find((k) => k.startsWith(this.name));\n if (propertyName) {\n return e[propertyName];\n }\n }\n return undefined;\n });\n }\n}\nclass EmptySetAtom {\n eval() {\n return [];\n }\n}\nclass UnaryOperatorAtom {\n constructor(child, impl) {\n this.child = child;\n this.impl = impl;\n }\n eval(context) {\n return this.impl(this.child.eval(context));\n }\n}\nclass AsAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n return this.left.eval(context);\n }\n}\nclass ArithemticOperatorAtom {\n constructor(left, right, impl) {\n this.left = left;\n this.right = right;\n this.impl = impl;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (isQuantity(leftValue) && isQuantity(rightValue)) {\n return Object.assign(Object.assign({}, leftValue), { value: this.impl(leftValue.value, rightValue.value) });\n }\n else {\n return this.impl(leftValue, rightValue);\n }\n }\n}\nclass ComparisonOperatorAtom {\n constructor(left, right, impl) {\n this.left = left;\n this.right = right;\n this.impl = impl;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (isQuantity(leftValue) && isQuantity(rightValue)) {\n return this.impl(leftValue.value, rightValue.value);\n }\n else {\n return this.impl(leftValue, rightValue);\n }\n }\n}\nclass ConcatAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n const result = [];\n function add(value) {\n if (value) {\n if (Array.isArray(value)) {\n result.push(...value);\n }\n else {\n result.push(value);\n }\n }\n }\n add(leftValue);\n add(rightValue);\n if (result.length > 0 && result.every((e) => typeof e === 'string')) {\n return result.join('');\n }\n return result;\n }\n}\nclass ContainsAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return ensureArray(leftValue).includes(rightValue);\n }\n}\nclass InAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return ensureArray(rightValue).includes(leftValue);\n }\n}\nclass DotAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n return this.right.eval(this.left.eval(context));\n }\n}\nclass UnionAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n let resultArray;\n if (leftResult !== undefined && rightResult !== undefined) {\n resultArray = [leftResult, rightResult].flat();\n }\n else if (leftResult !== undefined) {\n resultArray = ensureArray(leftResult);\n }\n else if (rightResult !== undefined) {\n resultArray = ensureArray(rightResult);\n }\n else {\n resultArray = [];\n }\n return removeDuplicates(resultArray);\n }\n}\nclass EqualsAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (Array.isArray(leftValue) && Array.isArray(rightValue)) {\n return fhirPathEquals(leftValue.flat(), rightValue);\n }\n return applyMaybeArray(leftValue, (e) => fhirPathEquals(e, rightValue));\n }\n}\nclass NotEqualsAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n let result;\n if (Array.isArray(rightValue)) {\n result = fhirPathEquals(leftValue, rightValue);\n }\n else {\n result = applyMaybeArray(leftValue, (e) => fhirPathEquals(e, rightValue));\n }\n return !toJsBoolean(result);\n }\n}\nclass EquivalentAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (Array.isArray(rightValue)) {\n return fhirPathEquivalent(leftValue, rightValue);\n }\n return applyMaybeArray(leftValue, (e) => fhirPathEquivalent(e, rightValue));\n }\n}\nclass NotEquivalentAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n let result;\n if (Array.isArray(rightValue)) {\n result = fhirPathEquivalent(leftValue, rightValue);\n }\n else {\n result = applyMaybeArray(leftValue, (e) => fhirPathEquivalent(e, rightValue));\n }\n return !toJsBoolean(result);\n }\n}\nclass IsAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const typeName = this.right.name;\n return applyMaybeArray(this.left.eval(context), (e) => fhirPathIs(e, typeName));\n }\n}\n/**\n * 6.5.1. and\n * Returns true if both operands evaluate to true, false if either operand evaluates to false, and the empty collection ({ }) otherwise.\n */\nclass AndAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (leftValue === true && rightValue === true) {\n return true;\n }\n if (leftValue === false || rightValue === false) {\n return false;\n }\n return [];\n }\n}\nclass OrAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n if (toJsBoolean(leftValue)) {\n return leftValue;\n }\n const rightValue = this.right.eval(context);\n if (toJsBoolean(rightValue)) {\n return rightValue;\n }\n return [];\n }\n}\n/**\n * 6.5.4. xor\n * Returns true if exactly one of the operands evaluates to true,\n * false if either both operands evaluate to true or both operands evaluate to false,\n * and the empty collection ({ }) otherwise:\n */\nclass XorAtom {\n constructor(left, right) {\n this.left = left;\n this.right = right;\n }\n eval(context) {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if ((leftValue === true && rightValue !== true) || (leftValue !== true && rightValue === true)) {\n return true;\n }\n if ((leftValue === true && rightValue === true) || (leftValue === false && rightValue === false)) {\n return false;\n }\n return [];\n }\n}\nclass FunctionAtom {\n constructor(name, args, impl) {\n this.name = name;\n this.args = args;\n this.impl = impl;\n }\n eval(context) {\n return this.impl(ensureArray(context), ...this.args);\n }\n}\nclass IndexerAtom {\n constructor(left, expr) {\n this.left = left;\n this.expr = expr;\n }\n eval(context) {\n const index = this.expr.eval(context);\n if (typeof index !== 'number') {\n throw new Error(`Invalid indexer expression: should return integer}`);\n }\n const leftResult = this.left.eval(context);\n if (!(index in leftResult)) {\n return [];\n }\n return leftResult[index];\n }\n}\n\nfunction parseDateString(str) {\n if (str.startsWith('T')) {\n // If a time string,\n // then normalize to full length.\n return str + 'T00:00:00.000Z'.substring(str.length);\n }\n if (str.length <= 10) {\n // If a local date (i.e., \"2021-01-01\"),\n // then return as-is.\n return str;\n }\n try {\n // Try to normalize to UTC\n return new Date(str).toISOString();\n }\n catch (e) {\n // Fallback to original input\n // This happens on unsupported time formats such as \"2021-01-01T12\"\n return str;\n }\n}\n\n/*\n * Collection of FHIRPath\n * See: https://hl7.org/fhirpath/#functions\n */\n/**\n * Temporary placholder for unimplemented methods.\n */\nconst stub = () => [];\n/*\n * 5.1 Existence\n * See: https://hl7.org/fhirpath/#existence\n */\n/**\n * Returns true if the input collection is empty ({ }) and false otherwise.\n *\n * See: https://hl7.org/fhirpath/#empty-boolean\n *\n * @param input The input collection.\n * @returns True if the input collection is empty ({ }) and false otherwise.\n */\nfunction empty(input) {\n return [input.length === 0];\n}\n/**\n * Returns true if the collection has unknown elements, and false otherwise.\n * This is the opposite of empty(), and as such is a shorthand for empty().not().\n * If the input collection is empty ({ }), the result is false.\n *\n * The function can also take an optional criteria to be applied to the collection\n * prior to the determination of the exists. In this case, the function is shorthand\n * for where(criteria).exists().\n *\n * See: https://hl7.org/fhirpath/#existscriteria-expression-boolean\n *\n * @param input\n * @param criteria\n * @returns True if the collection has unknown elements, and false otherwise.\n */\nfunction exists(input, criteria) {\n if (criteria) {\n return [input.filter((e) => toJsBoolean(criteria.eval(e))).length > 0];\n }\n else {\n return [input.length > 0];\n }\n}\n/**\n * Returns true if for every element in the input collection, criteria evaluates to true.\n * Otherwise, the result is false.\n *\n * If the input collection is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#allcriteria-expression-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if for every element in the input collection, criteria evaluates to true.\n */\nfunction all(input, criteria) {\n return [input.every((e) => toJsBoolean(criteria.eval(e)))];\n}\n/**\n * Takes a collection of Boolean values and returns true if all the items are true.\n * If unknown items are false, the result is false.\n * If the input is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#alltrue-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if all the items are true.\n */\nfunction allTrue(input) {\n for (const value of input) {\n if (!value) {\n return [false];\n }\n }\n return [true];\n}\n/**\n * Takes a collection of Boolean values and returns true if unknown of the items are true.\n * If all the items are false, or if the input is empty ({ }), the result is false.\n *\n * See: https://hl7.org/fhirpath/#anytrue-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if unknown of the items are true.\n */\nfunction anyTrue(input) {\n for (const value of input) {\n if (value) {\n return [true];\n }\n }\n return [false];\n}\n/**\n * Takes a collection of Boolean values and returns true if all the items are false.\n * If unknown items are true, the result is false.\n * If the input is empty ({ }), the result is true.\n *\n * See: https://hl7.org/fhirpath/#allfalse-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if all the items are false.\n */\nfunction allFalse(input) {\n for (const value of input) {\n if (value) {\n return [false];\n }\n }\n return [true];\n}\n/**\n * Takes a collection of Boolean values and returns true if unknown of the items are false.\n * If all the items are true, or if the input is empty ({ }), the result is false.\n *\n * See: https://hl7.org/fhirpath/#anyfalse-boolean\n *\n * @param input The input collection.\n * @param criteria The evaluation criteria.\n * @returns True if for every element in the input collection, criteria evaluates to true.\n */\nfunction anyFalse(input) {\n for (const value of input) {\n if (!value) {\n return [true];\n }\n }\n return [false];\n}\n/**\n * Returns true if all items in the input collection are members of the collection passed\n * as the other argument. Membership is determined using the = (Equals) (=) operation.\n *\n * Conceptually, this function is evaluated by testing each element in the input collection\n * for membership in the other collection, with a default of true. This means that if the\n * input collection is empty ({ }), the result is true, otherwise if the other collection\n * is empty ({ }), the result is false.\n *\n * See: http://hl7.org/fhirpath/#subsetofother-collection-boolean\n */\nconst subsetOf = stub;\n/**\n * Returns true if all items in the collection passed as the other argument are members of\n * the input collection. Membership is determined using the = (Equals) (=) operation.\n *\n * Conceptually, this function is evaluated by testing each element in the other collection\n * for membership in the input collection, with a default of true. This means that if the\n * other collection is empty ({ }), the result is true, otherwise if the input collection\n * is empty ({ }), the result is false.\n *\n * See: http://hl7.org/fhirpath/#supersetofother-collection-boolean\n */\nconst supersetOf = stub;\n/**\n * Returns the integer count of the number of items in the input collection.\n * Returns 0 when the input collection is empty.\n *\n * See: https://hl7.org/fhirpath/#count-integer\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\nfunction count(input) {\n return [input.length];\n}\n/**\n * Returns a collection containing only the unique items in the input collection.\n * To determine whether two items are the same, the = (Equals) (=) operator is used,\n * as defined below.\n *\n * If the input collection is empty ({ }), the result is empty.\n *\n * Note that the order of elements in the input collection is not guaranteed to be\n * preserved in the result.\n *\n * See: https://hl7.org/fhirpath/#distinct-collection\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\nfunction distinct(input) {\n return Array.from(new Set(input));\n}\n/**\n * Returns true if all the items in the input collection are distinct.\n * To determine whether two items are distinct, the = (Equals) (=) operator is used,\n * as defined below.\n *\n * See: https://hl7.org/fhirpath/#isdistinct-boolean\n *\n * @param input The input collection.\n * @returns The integer count of the number of items in the input collection.\n */\nfunction isDistinct(input) {\n return [input.length === new Set(input).size];\n}\n/*\n * 5.2 Filtering and projection\n */\n/**\n * Returns a collection containing only those elements in the input collection\n * for which the stated criteria expression evaluates to true.\n * Elements for which the expression evaluates to false or empty ({ }) are not\n * included in the result.\n *\n * If the input collection is empty ({ }), the result is empty.\n *\n * If the result of evaluating the condition is other than a single boolean value,\n * the evaluation will end and signal an error to the calling environment,\n * consistent with singleton evaluation of collections behavior.\n *\n * See: https://hl7.org/fhirpath/#wherecriteria-expression-collection\n *\n * @param input The input collection.\n * @param condition The condition atom.\n * @returns A collection containing only those elements in the input collection for which the stated criteria expression evaluates to true.\n */\nfunction where(input, criteria) {\n return input.filter((e) => toJsBoolean(criteria.eval(e)));\n}\n/**\n * Evaluates the projection expression for each item in the input collection.\n * The result of each evaluation is added to the output collection. If the\n * evaluation results in a collection with multiple items, all items are added\n * to the output collection (collections resulting from evaluation of projection\n * are flattened). This means that if the evaluation for an element results in\n * the empty collection ({ }), no element is added to the result, and that if\n * the input collection is empty ({ }), the result is empty as well.\n *\n * See: http://hl7.org/fhirpath/#selectprojection-expression-collection\n */\nfunction select(input, criteria) {\n return ensureArray(input.map((e) => criteria.eval(e)).flat());\n}\n/**\n * A version of select that will repeat the projection and add it to the output\n * collection, as long as the projection yields new items (as determined by\n * the = (Equals) (=) operator).\n *\n * See: http://hl7.org/fhirpath/#repeatprojection-expression-collection\n */\nconst repeat = stub;\n/**\n * Returns a collection that contains all items in the input collection that\n * are of the given type or a subclass thereof. If the input collection is\n * empty ({ }), the result is empty. The type argument is an identifier that\n * must resolve to the name of a type in a model\n *\n * See: http://hl7.org/fhirpath/#oftypetype-type-specifier-collection\n */\nconst ofType = stub;\n/*\n * 5.3 Subsetting\n */\n/**\n * Will return the single item in the input if there is just one item.\n * If the input collection is empty ({ }), the result is empty.\n * If there are multiple items, an error is signaled to the evaluation environment.\n * This function is useful for ensuring that an error is returned if an assumption\n * about cardinality is violated at run-time.\n *\n * See: https://hl7.org/fhirpath/#single-collection\n *\n * @param input The input collection.\n * @returns The single item in the input if there is just one item.\n */\nfunction single(input) {\n if (input.length > 1) {\n throw new Error('Expected input length one for single()');\n }\n return input.length === 0 ? [] : input.slice(0, 1);\n}\n/**\n * Returns a collection containing only the first item in the input collection.\n * This function is equivalent to item[0], so it will return an empty collection if the input collection has no items.\n *\n * See: https://hl7.org/fhirpath/#first-collection\n *\n * @param input The input collection.\n * @returns A collection containing only the first item in the input collection.\n */\nfunction first(input) {\n return input.length === 0 ? [] : [input[0]];\n}\n/**\n * Returns a collection containing only the last item in the input collection.\n * Will return an empty collection if the input collection has no items.\n *\n * See: https://hl7.org/fhirpath/#last-collection\n *\n * @param input The input collection.\n * @returns A collection containing only the last item in the input collection.\n */\nfunction last(input) {\n return input.length === 0 ? [] : [input[input.length - 1]];\n}\n/**\n * Returns a collection containing all but the first item in the input collection.\n * Will return an empty collection if the input collection has no items, or only one item.\n *\n * See: https://hl7.org/fhirpath/#tail-collection\n *\n * @param input The input collection.\n * @returns A collection containing all but the first item in the input collection.\n */\nfunction tail(input) {\n return input.length === 0 ? [] : input.slice(1, input.length);\n}\n/**\n * Returns a collection containing all but the first num items in the input collection.\n * Will return an empty collection if there are no items remaining after the\n * indicated number of items have been skipped, or if the input collection is empty.\n * If num is less than or equal to zero, the input collection is simply returned.\n *\n * See: https://hl7.org/fhirpath/#skipnum-integer-collection\n *\n * @param input The input collection.\n * @returns A collection containing all but the first item in the input collection.\n */\nfunction skip(input, num) {\n const numValue = num.eval(0);\n if (typeof numValue !== 'number') {\n throw new Error('Expected a number for skip(num)');\n }\n if (numValue >= input.length) {\n return [];\n }\n if (numValue <= 0) {\n return input;\n }\n return input.slice(numValue, input.length);\n}\n/**\n * Returns a collection containing the first num items in the input collection,\n * or less if there are less than num items.\n * If num is less than or equal to 0, or if the input collection is empty ({ }),\n * take returns an empty collection.\n *\n * See: https://hl7.org/fhirpath/#takenum-integer-collection\n *\n * @param input The input collection.\n * @returns A collection containing the first num items in the input collection.\n */\nfunction take(input, num) {\n const numValue = num.eval(0);\n if (typeof numValue !== 'number') {\n throw new Error('Expected a number for take(num)');\n }\n if (numValue >= input.length) {\n return input;\n }\n if (numValue <= 0) {\n return [];\n }\n return input.slice(0, numValue);\n}\n/**\n * Returns the set of elements that are in both collections.\n * Duplicate items will be eliminated by this function.\n * Order of items is not guaranteed to be preserved in the result of this function.\n *\n * See: http://hl7.org/fhirpath/#intersectother-collection-collection\n */\nfunction intersect(input, other) {\n if (!other) {\n return input;\n }\n const otherArray = ensureArray(other.eval(0));\n return removeDuplicates(input.filter((e) => otherArray.includes(e)));\n}\n/**\n * Returns the set of elements that are not in the other collection.\n * Duplicate items will not be eliminated by this function, and order will be preserved.\n *\n * e.g. (1 | 2 | 3).exclude(2) returns (1 | 3).\n *\n * See: http://hl7.org/fhirpath/#excludeother-collection-collection\n */\nfunction exclude(input, other) {\n if (!other) {\n return input;\n }\n const otherArray = ensureArray(other.eval(0));\n return input.filter((e) => !otherArray.includes(e));\n}\n/*\n * 5.4. Combining\n *\n * See: https://hl7.org/fhirpath/#combining\n */\n/**\n * Merge the two collections into a single collection,\n * eliminating unknown duplicate values (using = (Equals) (=) to determine equality).\n * There is no expectation of order in the resulting collection.\n *\n * In other words, this function returns the distinct list of elements from both inputs.\n *\n * See: http://hl7.org/fhirpath/#unionother-collection\n */\nfunction union(input, other) {\n if (!other) {\n return input;\n }\n return removeDuplicates([input, other.eval(0)].flat());\n}\n/**\n * Merge the input and other collections into a single collection\n * without eliminating duplicate values. Combining an empty collection\n * with a non-empty collection will return the non-empty collection.\n *\n * There is no expectation of order in the resulting collection.\n *\n * See: http://hl7.org/fhirpath/#combineother-collection-collection\n */\nfunction combine(input, other) {\n if (!other) {\n return input;\n }\n return [input, other.eval(0)].flat();\n}\n/*\n * 5.5. Conversion\n *\n * See: https://hl7.org/fhirpath/#conversion\n */\n/**\n * The iif function in FHIRPath is an immediate if,\n * also known as a conditional operator (such as C’s ? : operator).\n *\n * The criterion expression is expected to evaluate to a Boolean.\n *\n * If criterion is true, the function returns the value of the true-result argument.\n *\n * If criterion is false or an empty collection, the function returns otherwise-result,\n * unless the optional otherwise-result is not given, in which case the function returns an empty collection.\n *\n * Note that short-circuit behavior is expected in this function. In other words,\n * true-result should only be evaluated if the criterion evaluates to true,\n * and otherwise-result should only be evaluated otherwise. For implementations,\n * this means delaying evaluation of the arguments.\n *\n * @param input\n * @param criterion\n * @param trueResult\n * @param otherwiseResult\n * @returns\n */\nfunction iif(input, criterion, trueResult, otherwiseResult) {\n const evalResult = ensureArray(criterion.eval(input));\n if (evalResult.length > 1 || (evalResult.length === 1 && typeof evalResult[0] !== 'boolean')) {\n throw new Error('Expected criterion to evaluate to a Boolean');\n }\n if (toJsBoolean(evalResult)) {\n return ensureArray(trueResult.eval(input));\n }\n if (otherwiseResult) {\n return ensureArray(otherwiseResult.eval(input));\n }\n return [];\n}\n/**\n * Converts an input collection to a boolean.\n *\n * If the input collection contains a single item, this function will return a single boolean if:\n * 1) the item is a Boolean\n * 2) the item is an Integer and is equal to one of the possible integer representations of Boolean values\n * 3) the item is a Decimal that is equal to one of the possible decimal representations of Boolean values\n * 4) the item is a String that is equal to one of the possible string representations of Boolean values\n *\n * If the item is not one the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#toboolean-boolean\n *\n * @param input\n * @returns\n */\nfunction toBoolean(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value === 'boolean') {\n return [value];\n }\n if (typeof value === 'number') {\n if (value === 0 || value === 1) {\n return [!!value];\n }\n }\n if (typeof value === 'string') {\n const lowerStr = value.toLowerCase();\n if (['true', 't', 'yes', 'y', '1', '1.0'].includes(lowerStr)) {\n return [true];\n }\n if (['false', 'f', 'no', 'n', '0', '0.0'].includes(lowerStr)) {\n return [false];\n }\n }\n return [];\n}\n/**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Boolean\n * 2) the item is an Integer that is equal to one of the possible integer representations of Boolean values\n * 3) the item is a Decimal that is equal to one of the possible decimal representations of Boolean values\n * 4) the item is a String that is equal to one of the possible string representations of Boolean values\n *\n * If the item is not one of the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is false.\n *\n * Possible values for Integer, Decimal, and String are described in the toBoolean() function.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: http://hl7.org/fhirpath/#convertstoboolean-boolean\n *\n * @param input\n * @returns\n */\nfunction convertsToBoolean(input) {\n if (input.length === 0) {\n return [];\n }\n return [toBoolean(input).length === 1];\n}\n/**\n * Returns the integer representation of the input.\n *\n * If the input collection contains a single item, this function will return a single integer if:\n * 1) the item is an Integer\n * 2) the item is a String and is convertible to an integer\n * 3) the item is a Boolean, where true results in a 1 and false results in a 0.\n *\n * If the item is not one the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to an integer (using the regex format (\\\\+|-)?\\d+), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tointeger-integer\n *\n * @param input The input collection.\n * @returns The string representation of the input.\n */\nfunction toInteger(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value === 'number') {\n return [value];\n }\n if (typeof value === 'string' && value.match(/^[+-]?\\d+$/)) {\n return [parseInt(value, 10)];\n }\n if (typeof value === 'boolean') {\n return [value ? 1 : 0];\n }\n return [];\n}\n/**\n * Returns true if the input can be converted to string.\n *\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is an Integer\n * 2) the item is a String and is convertible to an Integer\n * 3) the item is a Boolean\n * 4) If the item is not one of the above types, or the item is a String, but is not convertible to an Integer (using the regex format (\\\\+|-)?\\d+), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstointeger-boolean\n *\n * @param input The input collection.\n * @returns\n */\nfunction convertsToInteger(input) {\n if (input.length === 0) {\n return [];\n }\n return [toInteger(input).length === 1];\n}\n/**\n * If the input collection contains a single item, this function will return a single date if:\n * 1) the item is a Date\n * 2) the item is a DateTime\n * 3) the item is a String and is convertible to a Date\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Date (using the format YYYY-MM-DD), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#todate-date\n */\nfunction toDate(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value === 'string' && value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/)) {\n return [parseDateString(value)];\n }\n return [];\n}\n/**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Date\n * 2) the item is a DateTime\n * 3) the item is a String and is convertible to a Date\n *\n * If the item is not one of the above types, or is not convertible to a Date (using the format YYYY-MM-DD), the result is false.\n *\n * If the item contains a partial date (e.g. '2012-01'), the result is a partial date.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstodate-boolean\n */\nfunction convertsToDate(input) {\n if (input.length === 0) {\n return [];\n }\n return [toDate(input).length === 1];\n}\n/**\n * If the input collection contains a single item, this function will return a single datetime if:\n * 1) the item is a DateTime\n * 2) the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)\n * 3) the item is a String and is convertible to a DateTime\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is empty.\n *\n * If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is a partial datetime.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n\n * See: https://hl7.org/fhirpath/#todatetime-datetime\n *\n * @param input\n * @returns\n */\nfunction toDateTime(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value === 'string' && value.match(/^\\d{4}(-\\d{2}(-\\d{2})?)?/)) {\n return [parseDateString(value)];\n }\n return [];\n}\n/**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a DateTime\n * 2) the item is a Date\n * 3) the item is a String and is convertible to a DateTime\n *\n * If the item is not one of the above types, or is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstodatetime-boolean\n *\n * @param input\n * @returns\n */\nfunction convertsToDateTime(input) {\n if (input.length === 0) {\n return [];\n }\n return [toDateTime(input).length === 1];\n}\n/**\n * If the input collection contains a single item, this function will return a single decimal if:\n * 1) the item is an Integer or Decimal\n * 2) the item is a String and is convertible to a Decimal\n * 3) the item is a Boolean, where true results in a 1.0 and false results in a 0.0.\n * 4) If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Decimal (using the regex format (\\\\+|-)?\\d+(\\.\\d+)?), the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#decimal-conversion-functions\n *\n * @param input The input collection.\n * @returns\n */\nfunction toDecimal(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value === 'number') {\n return [value];\n }\n if (typeof value === 'string' && value.match(/^-?\\d{1,9}(\\.\\d{1,9})?$/)) {\n return [parseFloat(value)];\n }\n if (typeof value === 'boolean') {\n return [value ? 1 : 0];\n }\n return [];\n}\n/**\n * If the input collection contains a single item, this function will true if:\n * 1) the item is an Integer or Decimal\n * 2) the item is a String and is convertible to a Decimal\n * 3) the item is a Boolean\n *\n * If the item is not one of the above types, or is not convertible to a Decimal (using the regex format (\\\\+|-)?\\d+(\\.\\d+)?), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n\n * See: https://hl7.org/fhirpath/#convertstodecimal-boolean\n *\n * @param input The input collection.\n * @returns\n */\nfunction convertsToDecimal(input) {\n if (input.length === 0) {\n return [];\n }\n return [toDecimal(input).length === 1];\n}\n/**\n * If the input collection contains a single item, this function will return a single quantity if:\n * 1) the item is an Integer, or Decimal, where the resulting quantity will have the default unit ('1')\n * 2) the item is a Quantity\n * 3) the item is a String and is convertible to a Quantity\n * 4) the item is a Boolean, where true results in the quantity 1.0 '1', and false results in the quantity 0.0 '1'\n *\n * If the item is not one of the above types, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#quantity-conversion-functions\n *\n * @param input The input collection.\n * @returns\n */\nfunction toQuantity(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (isQuantity(value)) {\n return [value];\n }\n if (typeof value === 'number') {\n return [{ value, unit: '1' }];\n }\n if (typeof value === 'string' && value.match(/^-?\\d{1,9}(\\.\\d{1,9})?/)) {\n return [{ value: parseFloat(value), unit: '1' }];\n }\n if (typeof value === 'boolean') {\n return [{ value: value ? 1 : 0, unit: '1' }];\n }\n return [];\n}\n/**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is an Integer, Decimal, or Quantity\n * 2) the item is a String that is convertible to a Quantity\n * 3) the item is a Boolean\n *\n * If the item is not one of the above types, or is not convertible to a Quantity using the following regex format:\n *\n * (?'value'(\\+|-)?\\d+(\\.\\d+)?)\\s*('(?'unit'[^']+)'|(?'time'[a-zA-Z]+))?\n *\n * then the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the unit argument is provided, it must be the string representation of a UCUM code (or a FHIRPath calendar duration keyword), and is used to determine whether the input quantity can be converted to the given unit, according to the unit conversion rules specified by UCUM. If the input quantity can be converted, the result is true, otherwise, the result is false.\n *\n * See: https://hl7.org/fhirpath/#convertstoquantityunit-string-boolean\n *\n * @param input The input collection.\n * @returns\n */\nfunction convertsToQuantity(input) {\n if (input.length === 0) {\n return [];\n }\n return [toQuantity(input).length === 1];\n}\n/**\n * Returns the string representation of the input.\n *\n * If the input collection contains a single item, this function will return a single String if:\n *\n * 1) the item in the input collection is a String\n * 2) the item in the input collection is an Integer, Decimal, Date, Time, DateTime, or Quantity the output will contain its String representation\n * 3) the item is a Boolean, where true results in 'true' and false in 'false'.\n *\n * If the item is not one of the above types, the result is false.\n *\n * See: https://hl7.org/fhirpath/#tostring-string\n *\n * @param input The input collection.\n * @returns The string representation of the input.\n */\nfunction toString(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (value === null || value === undefined) {\n return [];\n }\n if (isQuantity(value)) {\n return [`${value.value} '${value.unit}'`];\n }\n return [value.toString()];\n}\n/**\n * Returns true if the input can be converted to string.\n *\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a String\n * 2) the item is an Integer, Decimal, Date, Time, or DateTime\n * 3) the item is a Boolean\n * 4) the item is a Quantity\n *\n * If the item is not one of the above types, the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tostring-string\n *\n * @param input The input collection.\n * @returns\n */\nfunction convertsToString(input) {\n if (input.length === 0) {\n return [];\n }\n return [toString(input).length === 1];\n}\n/**\n * If the input collection contains a single item, this function will return a single time if:\n * 1) the item is a Time\n * 2) the item is a String and is convertible to a Time\n *\n * If the item is not one of the above types, the result is empty.\n *\n * If the item is a String, but the string is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is empty.\n *\n * If the item contains a partial time (e.g. '10:00'), the result is a partial time.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#totime-time\n *\n * @param input\n * @returns\n */\nfunction toTime(input) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value === 'string') {\n const match = value.match(/^T?(\\d{2}(:\\d{2}(:\\d{2})?)?)/);\n if (match) {\n return [parseDateString('T' + match[1])];\n }\n }\n return [];\n}\n/**\n * If the input collection contains a single item, this function will return true if:\n * 1) the item is a Time\n * 2) the item is a String and is convertible to a Time\n *\n * If the item is not one of the above types, or is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is false.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * If the input collection is empty, the result is empty.\n *\n * See: https://hl7.org/fhirpath/#convertstotime-boolean\n *\n * @param input\n * @returns\n */\nfunction convertsToTime(input) {\n if (input.length === 0) {\n return [];\n }\n return [toTime(input).length === 1];\n}\n/*\n * 5.6. String Manipulation.\n *\n * See: https://hl7.org/fhirpath/#string-manipulation\n */\n/**\n * Returns the 0-based index of the first position substring is found in the input string, or -1 if it is not found.\n *\n * If substring is an empty string (''), the function returns 0.\n *\n * If the input or substring is empty ({ }), the result is empty ({ }).\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#indexofsubstring-string-integer\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction indexOf(input, substringAtom) {\n return applyStringFunc((str, substring) => str.indexOf(substring), input, substringAtom);\n}\n/**\n * Returns the part of the string starting at position start (zero-based). If length is given, will return at most length number of characters from the input string.\n *\n * If start lies outside the length of the string, the function returns empty ({ }). If there are less remaining characters in the string than indicated by length, the function returns just the remaining characters.\n *\n * If the input or start is empty, the result is empty.\n *\n * If an empty length is provided, the behavior is the same as if length had not been provided.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction substring(input, startAtom, lengthAtom) {\n return applyStringFunc((str, start, length) => {\n const startIndex = start;\n const endIndex = length ? startIndex + length : str.length;\n return startIndex < 0 || startIndex >= str.length ? undefined : str.substring(startIndex, endIndex);\n }, input, startAtom, lengthAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction startsWith(input, prefixAtom) {\n return applyStringFunc((str, prefix) => str.startsWith(prefix), input, prefixAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction endsWith(input, suffixAtom) {\n return applyStringFunc((str, suffix) => str.endsWith(suffix), input, suffixAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction contains(input, substringAtom) {\n return applyStringFunc((str, substring) => str.includes(substring), input, substringAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction upper(input) {\n return applyStringFunc((str) => str.toUpperCase(), input);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction lower(input) {\n return applyStringFunc((str) => str.toLowerCase(), input);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction replace(input, patternAtom, substitionAtom) {\n return applyStringFunc((str, pattern, substition) => str.replaceAll(pattern, substition), input, patternAtom, substitionAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction matches(input, regexAtom) {\n return applyStringFunc((str, regex) => !!str.match(regex), input, regexAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction replaceMatches(input, regexAtom, substitionAtom) {\n return applyStringFunc((str, pattern, substition) => str.replaceAll(pattern, substition), input, regexAtom, substitionAtom);\n}\n/**\n *\n * @param input The input collection.\n * @returns The index of the substring.\n */\nfunction length(input) {\n return applyStringFunc((str) => str.length, input);\n}\n/**\n * Returns the list of characters in the input string. If the input collection is empty ({ }), the result is empty.\n *\n * See: https://hl7.org/fhirpath/#tochars-collection\n *\n * @param input The input collection.\n */\nfunction toChars(input) {\n return applyStringFunc((str) => (str ? str.split('') : undefined), input);\n}\n/*\n * 5.7. Math\n */\n/**\n * Returns the absolute value of the input. When taking the absolute value of a quantity, the unit is unchanged.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#abs-integer-decimal-quantity\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction abs(input) {\n return applyMathFunc(Math.abs, input);\n}\n/**\n * Returns the first integer greater than or equal to the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#ceiling-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction ceiling(input) {\n return applyMathFunc(Math.ceil, input);\n}\n/**\n * Returns e raised to the power of the input.\n *\n * If the input collection contains an Integer, it will be implicitly converted to a Decimal and the result will be a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#exp-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction exp(input) {\n return applyMathFunc(Math.exp, input);\n}\n/**\n * Returns the first integer less than or equal to the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#floor-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction floor(input) {\n return applyMathFunc(Math.floor, input);\n}\n/**\n * Returns the natural logarithm of the input (i.e. the logarithm base e).\n *\n * When used with an Integer, it will be implicitly converted to a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#ln-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction ln(input) {\n return applyMathFunc(Math.log, input);\n}\n/**\n * Returns the logarithm base base of the input number.\n *\n * When used with Integers, the arguments will be implicitly converted to Decimal.\n *\n * If base is empty, the result is empty.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#logbase-decimal-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction log(input, baseAtom) {\n return applyMathFunc((value, base) => Math.log(value) / Math.log(base), input, baseAtom);\n}\n/**\n * Raises a number to the exponent power. If this function is used with Integers, the result is an Integer. If the function is used with Decimals, the result is a Decimal. If the function is used with a mixture of Integer and Decimal, the Integer is implicitly converted to a Decimal and the result is a Decimal.\n *\n * If the power cannot be represented (such as the -1 raised to the 0.5), the result is empty.\n *\n * If the input is empty, or exponent is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#powerexponent-integer-decimal-integer-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction power(input, expAtom) {\n return applyMathFunc(Math.pow, input, expAtom);\n}\n/**\n * Rounds the decimal to the nearest whole number using a traditional round (i.e. 0.5 or higher will round to 1). If specified, the precision argument determines the decimal place at which the rounding will occur. If not specified, the rounding will default to 0 decimal places.\n *\n * If specified, the number of digits of precision must be >= 0 or the evaluation will end and signal an error to the calling environment.\n *\n * If the input collection contains a single item of type Integer, it will be implicitly converted to a Decimal.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#roundprecision-integer-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction round(input) {\n return applyMathFunc(Math.round, input);\n}\n/**\n * Returns the square root of the input number as a Decimal.\n *\n * If the square root cannot be represented (such as the square root of -1), the result is empty.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * Note that this function is equivalent to raising a number of the power of 0.5 using the power() function.\n *\n * See: https://hl7.org/fhirpath/#sqrt-decimal\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction sqrt(input) {\n return applyMathFunc(Math.sqrt, input);\n}\n/**\n * Returns the integer portion of the input.\n *\n * If the input collection is empty, the result is empty.\n *\n * If the input collection contains multiple items, the evaluation of the expression will end and signal an error to the calling environment.\n *\n * See: https://hl7.org/fhirpath/#truncate-integer\n *\n * @param input The input collection.\n * @returns A collection containing the result.\n */\nfunction truncate(input) {\n return applyMathFunc((x) => x | 0, input);\n}\n/*\n * 5.8. Tree navigation\n */\nconst children = stub;\nconst descendants = stub;\n/*\n * 5.9. Utility functions\n */\n/**\n * Adds a String representation of the input collection to the diagnostic log,\n * using the name argument as the name in the log. This log should be made available\n * to the user in some appropriate fashion. Does not change the input, so returns\n * the input collection as output.\n *\n * If the projection argument is used, the trace would log the result of evaluating\n * the project expression on the input, but still return the input to the trace\n * function unchanged.\n *\n * See: https://hl7.org/fhirpath/#tracename-string-projection-expression-collection\n *\n * @param input The input collection.\n * @param nameAtom The log name.\n */\nfunction trace(input, nameAtom) {\n console.log('trace', input, nameAtom);\n return input;\n}\n/**\n * Returns the current date and time, including timezone offset.\n *\n * See: https://hl7.org/fhirpath/#now-datetime\n */\nfunction now() {\n return [new Date().toISOString()];\n}\n/**\n * Returns the current time.\n *\n * See: https://hl7.org/fhirpath/#timeofday-time\n */\nfunction timeOfDay() {\n return [new Date().toISOString().substring(11)];\n}\n/**\n * Returns the current date.\n *\n * See: https://hl7.org/fhirpath/#today-date\n */\nfunction today() {\n return [new Date().toISOString().substring(0, 10)];\n}\n/*\n * 6.3 Types\n */\n/**\n * The is() function is supported for backwards compatibility with previous\n * implementations of FHIRPath. Just as with the is keyword, the type argument\n * is an identifier that must resolve to the name of a type in a model.\n *\n * For implementations with compile-time typing, this requires special-case\n * handling when processing the argument to treat it as a type specifier rather\n * than an identifier expression:\n *\n * @param input\n * @param typeAtom\n * @returns\n */\nfunction is(input, typeAtom) {\n const typeName = typeAtom.name;\n return input.map((value) => fhirPathIs(value, typeName));\n}\n/*\n * 6.5 Boolean logic\n */\n/**\n * 6.5.3. not() : Boolean\n *\n * Returns true if the input collection evaluates to false, and false if it evaluates to true. Otherwise, the result is empty ({ }):\n *\n * @param input\n * @returns\n */\nfunction not(input) {\n return toBoolean(input).map((value) => !value);\n}\n/*\n * Additional functions\n * See: https://hl7.org/fhir/fhirpath.html#functions\n */\n/**\n * For each item in the collection, if it is a string that is a uri (or canonical or url), locate the target of the reference, and add it to the resulting collection. If the item does not resolve to a resource, the item is ignored and nothing is added to the output collection.\n * The items in the collection may also represent a Reference, in which case the Reference.reference is resolved.\n * @param input The input collection.\n * @returns\n */\nfunction resolve(input) {\n return input\n .map((e) => {\n let refStr;\n if (typeof e === 'string') {\n refStr = e;\n }\n else if (typeof e === 'object') {\n const ref = e;\n if (ref.resource) {\n return ref.resource;\n }\n refStr = ref.reference;\n }\n if (!refStr) {\n return undefined;\n }\n const [resourceType, id] = refStr.split('/');\n return { resourceType, id };\n })\n .filter((e) => !!e);\n}\n/**\n * The as operator can be used to treat a value as a specific type.\n * @param context The context value.\n * @returns The value as the specific type.\n */\nfunction as(context) {\n return context;\n}\n/*\n * 12. Formal Specifications\n */\n/**\n * Returns the type of the input.\n *\n * 12.2. Model Information\n *\n * The model information returned by the reflection function type() is specified as an\n * XML Schema document (xsd) and included in this specification at the following link:\n * https://hl7.org/fhirpath/modelinfo.xsd\n *\n * See: https://hl7.org/fhirpath/#model-information\n *\n * @param input The input collection.\n * @returns\n */\nfunction type(input) {\n return input.map((value) => {\n if (typeof value === 'boolean') {\n return { namespace: 'System', name: 'Boolean' };\n }\n if (typeof value === 'number') {\n return { namespace: 'System', name: 'Integer' };\n }\n if (value && typeof value === 'object' && 'resourceType' in value) {\n return { namespace: 'FHIR', name: value.resourceType };\n }\n return null;\n });\n}\nfunction conformsTo(input, systemAtom) {\n const system = systemAtom.eval(undefined);\n if (!system.startsWith('http://hl7.org/fhir/StructureDefinition/')) {\n throw new Error('Expected a StructureDefinition URL');\n }\n const expectedResourceType = system.replace('http://hl7.org/fhir/StructureDefinition/', '');\n return input.map((resource) => (resource === null || resource === void 0 ? void 0 : resource.resourceType) === expectedResourceType);\n}\n/*\n * Helper utilities\n */\nfunction applyStringFunc(func, input, ...argsAtoms) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n if (typeof value !== 'string') {\n throw new Error('String function cannot be called with non-string');\n }\n const result = func(value, ...argsAtoms.map((atom) => atom && atom.eval(value)));\n return result === undefined ? [] : [result];\n}\nfunction applyMathFunc(func, input, ...argsAtoms) {\n if (input.length === 0) {\n return [];\n }\n const [value] = validateInput(input, 1);\n const quantity = isQuantity(value);\n const numberInput = quantity ? value.value : value;\n if (typeof numberInput !== 'number') {\n throw new Error('Math function cannot be called with non-number');\n }\n const result = func(numberInput, ...argsAtoms.map((atom) => atom.eval(undefined)));\n return quantity ? [Object.assign(Object.assign({}, value), { value: result })] : [result];\n}\nfunction validateInput(input, count) {\n if (input.length !== count) {\n throw new Error(`Expected ${count} arguments`);\n }\n return input;\n}\n\nvar functions = /*#__PURE__*/Object.freeze({\n __proto__: null,\n empty: empty,\n exists: exists,\n all: all,\n allTrue: allTrue,\n anyTrue: anyTrue,\n allFalse: allFalse,\n anyFalse: anyFalse,\n subsetOf: subsetOf,\n supersetOf: supersetOf,\n count: count,\n distinct: distinct,\n isDistinct: isDistinct,\n where: where,\n select: select,\n repeat: repeat,\n ofType: ofType,\n single: single,\n first: first,\n last: last,\n tail: tail,\n skip: skip,\n take: take,\n intersect: intersect,\n exclude: exclude,\n union: union,\n combine: combine,\n iif: iif,\n toBoolean: toBoolean,\n convertsToBoolean: convertsToBoolean,\n toInteger: toInteger,\n convertsToInteger: convertsToInteger,\n toDate: toDate,\n convertsToDate: convertsToDate,\n toDateTime: toDateTime,\n convertsToDateTime: convertsToDateTime,\n toDecimal: toDecimal,\n convertsToDecimal: convertsToDecimal,\n toQuantity: toQuantity,\n convertsToQuantity: convertsToQuantity,\n toString: toString,\n convertsToString: convertsToString,\n toTime: toTime,\n convertsToTime: convertsToTime,\n indexOf: indexOf,\n substring: substring,\n startsWith: startsWith,\n endsWith: endsWith,\n contains: contains,\n upper: upper,\n lower: lower,\n replace: replace,\n matches: matches,\n replaceMatches: replaceMatches,\n length: length,\n toChars: toChars,\n abs: abs,\n ceiling: ceiling,\n exp: exp,\n floor: floor,\n ln: ln,\n log: log,\n power: power,\n round: round,\n sqrt: sqrt,\n truncate: truncate,\n children: children,\n descendants: descendants,\n trace: trace,\n now: now,\n timeOfDay: timeOfDay,\n today: today,\n is: is,\n not: not,\n resolve: resolve,\n as: as,\n type: type,\n conformsTo: conformsTo\n});\n\nvar _Tokenizer_instances, _Tokenizer_str, _Tokenizer_pos, _Tokenizer_peekToken, _Tokenizer_consumeToken, _Tokenizer_consumeWhitespace, _Tokenizer_consumeMultiLineComment, _Tokenizer_consumeSingleLineComment, _Tokenizer_consumeString, _Tokenizer_consumeBacktickSymbol, _Tokenizer_consumeDateTime, _Tokenizer_consumeNumber, _Tokenizer_consumeSymbol, _Tokenizer_consumeOperator, _Tokenizer_consumeWhile, _Tokenizer_curr, _Tokenizer_prev, _Tokenizer_peek;\nfunction tokenize(str) {\n return new Tokenizer(str).tokenize();\n}\nconst STANDARD_UNITS = [\n 'year',\n 'years',\n 'month',\n 'months',\n 'week',\n 'weeks',\n 'day',\n 'days',\n 'hour',\n 'hours',\n 'minute',\n 'minutes',\n 'second',\n 'seconds',\n 'millisecond',\n 'milliseconds',\n];\nconst TWO_CHAR_OPERATORS = ['!=', '!~', '<=', '>=', '{}'];\nclass Tokenizer {\n constructor(str) {\n _Tokenizer_instances.add(this);\n _Tokenizer_str.set(this, void 0);\n _Tokenizer_pos.set(this, void 0);\n __classPrivateFieldSet(this, _Tokenizer_str, str, \"f\");\n __classPrivateFieldSet(this, _Tokenizer_pos, 0, \"f\");\n }\n tokenize() {\n const result = [];\n while (__classPrivateFieldGet(this, _Tokenizer_pos, \"f\") < __classPrivateFieldGet(this, _Tokenizer_str, \"f\").length) {\n const token = __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeToken).call(this);\n if (token) {\n result.push(token);\n }\n }\n return result;\n }\n}\n_Tokenizer_str = new WeakMap(), _Tokenizer_pos = new WeakMap(), _Tokenizer_instances = new WeakSet(), _Tokenizer_peekToken = function _Tokenizer_peekToken() {\n const start = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\");\n const token = __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeToken).call(this);\n __classPrivateFieldSet(this, _Tokenizer_pos, start, \"f\");\n return token;\n}, _Tokenizer_consumeToken = function _Tokenizer_consumeToken() {\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhitespace).call(this);\n const c = __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this);\n if (!c) {\n return undefined;\n }\n const next = __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_peek).call(this);\n if (c === '/' && next === '*') {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeMultiLineComment).call(this);\n }\n if (c === '/' && next === '/') {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeSingleLineComment).call(this);\n }\n if (c === \"'\") {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeString).call(this);\n }\n if (c === '`') {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeBacktickSymbol).call(this);\n }\n if (c === '@') {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeDateTime).call(this);\n }\n if (c.match(/\\d/)) {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeNumber).call(this);\n }\n if (c.match(/\\w/)) {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeSymbol).call(this);\n }\n if (c === '$' && next.match(/\\w/)) {\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeSymbol).call(this);\n }\n return __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeOperator).call(this);\n}, _Tokenizer_consumeWhitespace = function _Tokenizer_consumeWhitespace() {\n return buildToken('Whitespace', __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/\\s/)));\n}, _Tokenizer_consumeMultiLineComment = function _Tokenizer_consumeMultiLineComment() {\n const start = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\");\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) !== '*' || __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_peek).call(this) !== '/');\n __classPrivateFieldSet(this, _Tokenizer_pos, __classPrivateFieldGet(this, _Tokenizer_pos, \"f\") + 2, \"f\");\n return buildToken('Comment', __classPrivateFieldGet(this, _Tokenizer_str, \"f\").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, \"f\")));\n}, _Tokenizer_consumeSingleLineComment = function _Tokenizer_consumeSingleLineComment() {\n return buildToken('Comment', __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) !== '\\n'));\n}, _Tokenizer_consumeString = function _Tokenizer_consumeString() {\n var _a, _b;\n __classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _a++, _a), \"f\");\n const result = buildToken('String', __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_prev).call(this) === '\\\\' || __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) !== \"'\"));\n __classPrivateFieldSet(this, _Tokenizer_pos, (_b = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _b++, _b), \"f\");\n return result;\n}, _Tokenizer_consumeBacktickSymbol = function _Tokenizer_consumeBacktickSymbol() {\n var _a, _b;\n __classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _a++, _a), \"f\");\n const result = buildToken('Symbol', __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) !== '`'));\n __classPrivateFieldSet(this, _Tokenizer_pos, (_b = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _b++, _b), \"f\");\n return result;\n}, _Tokenizer_consumeDateTime = function _Tokenizer_consumeDateTime() {\n var _a, _b, _c, _d, _e;\n const start = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\");\n __classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _a++, _a), \"f\");\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/[\\d-]/));\n if (__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === 'T') {\n __classPrivateFieldSet(this, _Tokenizer_pos, (_b = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _b++, _b), \"f\");\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/[\\d:]/));\n if (__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === '.' && __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_peek).call(this).match(/\\d/)) {\n __classPrivateFieldSet(this, _Tokenizer_pos, (_c = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _c++, _c), \"f\");\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/[\\d]/));\n }\n if (__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === 'Z') {\n __classPrivateFieldSet(this, _Tokenizer_pos, (_d = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _d++, _d), \"f\");\n }\n else if (__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === '+' || __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === '-') {\n __classPrivateFieldSet(this, _Tokenizer_pos, (_e = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _e++, _e), \"f\");\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/[\\d:]/));\n }\n }\n return buildToken('DateTime', __classPrivateFieldGet(this, _Tokenizer_str, \"f\").substring(start + 1, __classPrivateFieldGet(this, _Tokenizer_pos, \"f\")));\n}, _Tokenizer_consumeNumber = function _Tokenizer_consumeNumber() {\n var _a;\n const start = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\");\n let id = 'Number';\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/\\d/));\n if (__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === '.' && __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_peek).call(this).match(/\\d/)) {\n __classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _a++, _a), \"f\");\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/\\d/));\n }\n if (__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this) === ' ') {\n if (isUnitToken(__classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_peekToken).call(this))) {\n id = 'Quantity';\n __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeToken).call(this);\n }\n }\n return buildToken(id, __classPrivateFieldGet(this, _Tokenizer_str, \"f\").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, \"f\")));\n}, _Tokenizer_consumeSymbol = function _Tokenizer_consumeSymbol() {\n return buildToken('Symbol', __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_consumeWhile).call(this, () => __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this).match(/[$\\w]/)));\n}, _Tokenizer_consumeOperator = function _Tokenizer_consumeOperator() {\n var _a;\n const c = __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_curr).call(this);\n const next = __classPrivateFieldGet(this, _Tokenizer_instances, \"m\", _Tokenizer_peek).call(this);\n const twoCharOp = c + next;\n if (TWO_CHAR_OPERATORS.includes(twoCharOp)) {\n __classPrivateFieldSet(this, _Tokenizer_pos, __classPrivateFieldGet(this, _Tokenizer_pos, \"f\") + 2, \"f\");\n return buildToken(twoCharOp, twoCharOp);\n }\n __classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _a++, _a), \"f\");\n return buildToken(c, c);\n}, _Tokenizer_consumeWhile = function _Tokenizer_consumeWhile(condition) {\n var _a;\n const start = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\");\n while (__classPrivateFieldGet(this, _Tokenizer_pos, \"f\") < __classPrivateFieldGet(this, _Tokenizer_str, \"f\").length && condition()) {\n __classPrivateFieldSet(this, _Tokenizer_pos, (_a = __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"), _a++, _a), \"f\");\n }\n return __classPrivateFieldGet(this, _Tokenizer_str, \"f\").substring(start, __classPrivateFieldGet(this, _Tokenizer_pos, \"f\"));\n}, _Tokenizer_curr = function _Tokenizer_curr() {\n return __classPrivateFieldGet(this, _Tokenizer_str, \"f\")[__classPrivateFieldGet(this, _Tokenizer_pos, \"f\")];\n}, _Tokenizer_prev = function _Tokenizer_prev() {\n var _a;\n return (_a = __classPrivateFieldGet(this, _Tokenizer_str, \"f\")[__classPrivateFieldGet(this, _Tokenizer_pos, \"f\") - 1]) !== null && _a !== void 0 ? _a : '';\n}, _Tokenizer_peek = function _Tokenizer_peek() {\n var _a;\n return (_a = __classPrivateFieldGet(this, _Tokenizer_str, \"f\")[__classPrivateFieldGet(this, _Tokenizer_pos, \"f\") + 1]) !== null && _a !== void 0 ? _a : '';\n};\nfunction buildToken(id, value) {\n return { id, value };\n}\nfunction isUnitToken(token) {\n if (token) {\n if (token.id === 'String') {\n return true;\n }\n if (token.id === 'Symbol' && STANDARD_UNITS.includes(token.value)) {\n return true;\n }\n }\n return false;\n}\n\nvar _ParserBuilder_prefixParselets, _ParserBuilder_infixParselets, _Parser_instances, _Parser_tokens, _Parser_prefixParselets, _Parser_infixParselets, _Parser_getPrecedence, _Parser_consume, _Parser_look;\nclass ParserBuilder {\n constructor() {\n _ParserBuilder_prefixParselets.set(this, {});\n _ParserBuilder_infixParselets.set(this, {});\n }\n registerInfix(tokenType, parselet) {\n __classPrivateFieldGet(this, _ParserBuilder_infixParselets, \"f\")[tokenType] = parselet;\n return this;\n }\n registerPrefix(tokenType, parselet) {\n __classPrivateFieldGet(this, _ParserBuilder_prefixParselets, \"f\")[tokenType] = parselet;\n return this;\n }\n prefix(tokenType, precedence, builder) {\n return this.registerPrefix(tokenType, {\n parse(parser, token) {\n const right = parser.consumeAndParse(precedence);\n return builder(token, right);\n },\n });\n }\n infixLeft(tokenType, precedence, builder) {\n return this.registerInfix(tokenType, {\n parse(parser, left, token) {\n const right = parser.consumeAndParse(precedence);\n return builder(left, token, right);\n },\n precedence,\n });\n }\n construct(input) {\n return new Parser(tokenize(input), __classPrivateFieldGet(this, _ParserBuilder_prefixParselets, \"f\"), __classPrivateFieldGet(this, _ParserBuilder_infixParselets, \"f\"));\n }\n}\n_ParserBuilder_prefixParselets = new WeakMap(), _ParserBuilder_infixParselets = new WeakMap();\nclass Parser {\n constructor(tokens, prefixParselets, infixParselets) {\n _Parser_instances.add(this);\n _Parser_tokens.set(this, void 0);\n _Parser_prefixParselets.set(this, void 0);\n _Parser_infixParselets.set(this, void 0);\n __classPrivateFieldSet(this, _Parser_tokens, tokens, \"f\");\n __classPrivateFieldSet(this, _Parser_prefixParselets, prefixParselets, \"f\");\n __classPrivateFieldSet(this, _Parser_infixParselets, infixParselets, \"f\");\n }\n match(expected) {\n const token = __classPrivateFieldGet(this, _Parser_instances, \"m\", _Parser_look).call(this);\n if ((token === null || token === void 0 ? void 0 : token.id) !== expected) {\n return false;\n }\n __classPrivateFieldGet(this, _Parser_instances, \"m\", _Parser_consume).call(this);\n return true;\n }\n consumeAndParse(precedence = 100 /* MaximumPrecedence */) {\n const token = __classPrivateFieldGet(this, _Parser_instances, \"m\", _Parser_consume).call(this);\n const prefix = __classPrivateFieldGet(this, _Parser_prefixParselets, \"f\")[token.id];\n if (!prefix) {\n throw Error(`Parse error at ${token.value}. No matching prefix parselet.`);\n }\n let left = prefix.parse(this, token);\n while (precedence > __classPrivateFieldGet(this, _Parser_instances, \"m\", _Parser_getPrecedence).call(this)) {\n const next = __classPrivateFieldGet(this, _Parser_instances, \"m\", _Parser_consume).call(this);\n const infix = __classPrivateFieldGet(this, _Parser_infixParselets, \"f\")[next.id];\n left = infix.parse(this, left, next);\n }\n return left;\n }\n}\n_Parser_tokens = new WeakMap(), _Parser_prefixParselets = new WeakMap(), _Parser_infixParselets = new WeakMap(), _Parser_instances = new WeakSet(), _Parser_getPrecedence = function _Parser_getPrecedence() {\n const nextToken = __classPrivateFieldGet(this, _Parser_instances, \"m\", _Parser_look).call(this);\n if (!nextToken) {\n return 100 /* MaximumPrecedence */;\n }\n const parser = __classPrivateFieldGet(this, _Parser_infixParselets, \"f\")[nextToken.id];\n if (parser) {\n return parser.precedence;\n }\n return 100 /* MaximumPrecedence */;\n}, _Parser_consume = function _Parser_consume() {\n if (!__classPrivateFieldGet(this, _Parser_tokens, \"f\").length) {\n throw Error('Cant consume unknown more tokens.');\n }\n return __classPrivateFieldGet(this, _Parser_tokens, \"f\").shift();\n}, _Parser_look = function _Parser_look() {\n return __classPrivateFieldGet(this, _Parser_tokens, \"f\").length > 0 ? __classPrivateFieldGet(this, _Parser_tokens, \"f\")[0] : undefined;\n};\nconst PARENTHESES_PARSELET = {\n parse(parser) {\n const expr = parser.consumeAndParse();\n if (!parser.match(')')) {\n throw new Error('Parse error: expected `)`');\n }\n return expr;\n },\n};\nconst INDEXER_PARSELET = {\n parse(parser, left) {\n const expr = parser.consumeAndParse();\n if (!parser.match(']')) {\n throw new Error('Parse error: expected `]`');\n }\n return new IndexerAtom(left, expr);\n },\n precedence: 2 /* Indexer */,\n};\nconst FUNCTION_CALL_PARSELET = {\n parse(parser, left) {\n if (!(left instanceof SymbolAtom)) {\n throw new Error('Unexpected parentheses');\n }\n if (!(left.name in functions)) {\n throw new Error('Unrecognized function: ' + left.name);\n }\n const args = [];\n while (!parser.match(')')) {\n args.push(parser.consumeAndParse());\n parser.match(',');\n }\n return new FunctionAtom(left.name, args, functions[left.name]);\n },\n precedence: 0 /* FunctionCall */,\n};\nfunction parseQuantity(str) {\n const parts = str.split(' ');\n const value = parseFloat(parts[0]);\n let unit = parts[1];\n if (unit && unit.startsWith(\"'\") && unit.endsWith(\"'\")) {\n unit = unit.substring(1, unit.length - 1);\n }\n else {\n unit = '{' + unit + '}';\n }\n return { value, unit };\n}\nconst parserBuilder = new ParserBuilder()\n .registerPrefix('String', {\n parse: (_, token) => new LiteralAtom(token.value),\n})\n .registerPrefix('DateTime', {\n parse: (_, token) => new LiteralAtom(parseDateString(token.value)),\n})\n .registerPrefix('Quantity', {\n parse: (_, token) => new LiteralAtom(parseQuantity(token.value)),\n})\n .registerPrefix('Number', {\n parse: (_, token) => new LiteralAtom(parseFloat(token.value)),\n})\n .registerPrefix('Symbol', {\n parse: (_, token) => {\n if (token.value === 'false') {\n return new LiteralAtom(false);\n }\n if (token.value === 'true') {\n return new LiteralAtom(true);\n }\n return new SymbolAtom(token.value);\n },\n})\n .registerPrefix('{}', { parse: () => new EmptySetAtom() })\n .registerPrefix('(', PARENTHESES_PARSELET)\n .registerInfix('[', INDEXER_PARSELET)\n .registerInfix('(', FUNCTION_CALL_PARSELET)\n .prefix('+', 3 /* UnaryAdd */, (_, right) => new UnaryOperatorAtom(right, (x) => x))\n .prefix('-', 3 /* UnarySubtract */, (_, right) => new ArithemticOperatorAtom(right, right, (_, y) => -y))\n .infixLeft('.', 1 /* Dot */, (left, _, right) => new DotAtom(left, right))\n .infixLeft('/', 4 /* Divide */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x / y))\n .infixLeft('*', 4 /* Multiply */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x * y))\n .infixLeft('+', 5 /* Add */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x + y))\n .infixLeft('-', 5 /* Subtract */, (left, _, right) => new ArithemticOperatorAtom(left, right, (x, y) => x - y))\n .infixLeft('|', 7 /* Union */, (left, _, right) => new UnionAtom(left, right))\n .infixLeft('=', 9 /* Equals */, (left, _, right) => new EqualsAtom(left, right))\n .infixLeft('!=', 9 /* Equals */, (left, _, right) => new NotEqualsAtom(left, right))\n .infixLeft('~', 9 /* Equivalent */, (left, _, right) => new EquivalentAtom(left, right))\n .infixLeft('!~', 9 /* NotEquivalent */, (left, _, right) => new NotEquivalentAtom(left, right))\n .infixLeft('<', 8 /* LessThan */, (left, _, right) => new ComparisonOperatorAtom(left, right, (x, y) => x < y))\n .infixLeft('<=', 8 /* LessThanOrEquals */, (left, _, right) => new ComparisonOperatorAtom(left, right, (x, y) => x <= y))\n .infixLeft('>', 8 /* GreaterThan */, (left, _, right) => new ComparisonOperatorAtom(left, right, (x, y) => x > y))\n .infixLeft('>=', 8 /* GreaterThanOrEquals */, (left, _, right) => new ComparisonOperatorAtom(left, right, (x, y) => x >= y))\n .infixLeft('&', 5 /* Ampersand */, (left, _, right) => new ConcatAtom(left, right))\n .infixLeft('Symbol', 6 /* Is */, (left, symbol, right) => {\n switch (symbol.value) {\n case 'and':\n return new AndAtom(left, right);\n case 'as':\n return new AsAtom(left, right);\n case 'contains':\n return new ContainsAtom(left, right);\n case 'div':\n return new ArithemticOperatorAtom(left, right, (x, y) => (x / y) | 0);\n case 'in':\n return new InAtom(left, right);\n case 'is':\n return new IsAtom(left, right);\n case 'mod':\n return new ArithemticOperatorAtom(left, right, (x, y) => x % y);\n case 'or':\n return new OrAtom(left, right);\n case 'xor':\n return new XorAtom(left, right);\n default:\n throw new Error('Cannot use ' + symbol.value + ' as infix operator');\n }\n});\n/**\n * Parses a FHIRPath expression into an AST.\n * The result can be used to evaluate the expression against a resource or other object.\n * This method is useful if you know that you will evaluate the same expression many times\n * against different resources.\n * @param input The FHIRPath expression to parse.\n * @returns The AST representing the expression.\n */\nfunction parseFhirPath(input) {\n try {\n return new FhirPathAtom(input, parserBuilder.construct(input).consumeAndParse());\n }\n catch (error) {\n throw new Error(`FhirPathError on \"${input}\": ${error}`);\n }\n}\n/**\n * Evaluates a FHIRPath expression against a resource or other object.\n * @param input The FHIRPath expression to parse.\n * @param context The resource or object to evaluate the expression against.\n * @returns The result of the FHIRPath expression against the resource or object.\n */\nfunction evalFhirPath(input, context) {\n return parseFhirPath(input).eval(context);\n}\n\nexport { evalFhirPath, parseFhirPath, tokenize };\n//# sourceMappingURL=index.js.map\n","import { Filter, Operator, SearchRequest } from '@medplum/core';\nimport { evalFhirPath } from '@medplum/fhirpath';\nimport { Bundle, BundleEntry, Resource } from '@medplum/fhirtypes';\n\nexport class MemoryRepository {\n readonly #resources: Record<string, Record<string, Resource>>;\n readonly #history: Record<string, Record<string, Resource[]>>;\n\n constructor() {\n this.#resources = {};\n this.#history = {};\n }\n\n createResource<T extends Resource>(resource: T): T {\n const result = resource;\n\n if (!result.id) {\n result.id = this.generateId();\n }\n\n if (!result.meta) {\n result.meta = {};\n }\n\n if (!result.meta?.versionId) {\n result.meta.versionId = this.generateId();\n }\n\n const { resourceType, id } = resource as { resourceType: string; id: string };\n\n if (!(resourceType in this.#resources)) {\n this.#resources[resourceType] = {};\n }\n\n if (!(resourceType in this.#history)) {\n this.#history[resourceType] = {};\n }\n\n if (!(id in this.#history[resourceType])) {\n this.#history[resourceType][id] = [];\n }\n\n this.#resources[resourceType][id] = resource;\n this.#history[resourceType][id].push(result);\n return result;\n }\n\n readResource<T extends Resource>(resourceType: string, id: string): T | undefined {\n return this.#resources?.[resourceType]?.[id] as T | undefined;\n }\n\n readHistory<T extends Resource>(resourceType: string, id: string): Bundle<T> {\n return {\n resourceType: 'Bundle',\n type: 'history',\n entry: ((this.#history?.[resourceType]?.[id] ?? []) as T[])\n .sort(\n (version1, version2) =>\n -(version1.meta?.lastUpdated?.localeCompare(version2.meta?.lastUpdated as string) as number)\n )\n .map((version) => ({ resource: version })),\n };\n }\n\n readVersion<T extends Resource>(resourceType: string, id: string, versionId: string): T | undefined {\n return this.#history?.[resourceType]?.[id]?.find((v) => v.meta?.versionId === versionId) as T | undefined;\n }\n\n search<T extends Resource>(searchRequest: SearchRequest): Bundle<T> {\n const { resourceType } = searchRequest;\n const resources = this.#resources[resourceType] ?? {};\n const result = Object.values(resources).filter((resource) => matchesSearchRequest(resource, searchRequest));\n return {\n resourceType: 'Bundle',\n type: 'searchset',\n entry: result.map((resource) => ({ resource })) as BundleEntry<T>[],\n total: result.length,\n };\n }\n\n deleteResource(resourceType: string, id: string): void {\n if (this.#resources?.[resourceType]?.[id]) {\n delete this.#resources[resourceType][id];\n }\n }\n\n private generateId(): string {\n return Date.now().toString(36);\n }\n}\n\n/**\n * Determines if the resource matches the search request.\n * @param resource The resource that was created or updated.\n * @param searchRequest The subscription criteria as a search request.\n * @returns True if the resource satisfies the search request.\n */\nexport function matchesSearchRequest(resource: Resource, searchRequest: SearchRequest): boolean {\n if (searchRequest.resourceType !== resource.resourceType) {\n return false;\n }\n if (searchRequest.filters) {\n for (const filter of searchRequest.filters) {\n if (!matchesSearchFilter(resource, filter)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * Determines if the resource matches the search filter.\n * @param resource The resource that was created or updated.\n * @param filter One of the filters of a subscription criteria.\n * @returns True if the resource satisfies the search filter.\n */\nfunction matchesSearchFilter(resource: Resource, filter: Filter): boolean {\n const expression = filter.code.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n const values = evalFhirPath(expression as string, resource);\n const result = values.some((value) => JSON.stringify(value).toLowerCase().includes(filter.value.toLowerCase()));\n return filter.operator === Operator.NOT_EQUALS ? !result : result;\n}\n","import {\n allOk,\n badRequest,\n getStatus,\n LoginState,\n MedplumClient,\n notFound,\n parseSearchDefinition,\n ProfileResource,\n} from '@medplum/core';\nimport { Binary, Bundle, BundleEntry, Practitioner } from '@medplum/fhirtypes';\nimport {\n BartSimpson,\n DifferentOrganization,\n DrAliceSmith,\n DrAliceSmithPreviousVersion,\n DrAliceSmithSchedule,\n DrAliceSmithSlots,\n ExampleBot,\n ExampleClient,\n ExampleQuestionnaire,\n ExampleQuestionnaireResponse,\n ExampleSubscription,\n exampleValueSet,\n GraphQLSchemaResponse,\n HomerCommunication,\n HomerDiagnosticReport,\n HomerEncounter,\n HomerMedia,\n HomerObservation1,\n HomerObservation2,\n HomerObservation3,\n HomerObservation4,\n HomerObservation5,\n HomerObservation6,\n HomerServiceRequest,\n HomerSimpson,\n HomerSimpsonPreviousVersion,\n HomerSimpsonSpecimen,\n TestOrganization,\n} from './mocks';\nimport { ExampleAccessPolicy, ExampleStatusValueSet, ExampleUserConfiguration } from './mocks/accesspolicy';\nimport { MemoryRepository } from './repo';\n\nexport interface MockClientOptions {\n readonly debug?: boolean;\n}\n\nexport class MockClient extends MedplumClient {\n activeLoginOverride?: LoginState;\n\n constructor(clientOptions?: MockClientOptions) {\n super({\n baseUrl: 'https://example.com/',\n clientId: 'my-client-id',\n fetch: (url: string, options: any) => {\n const method = options.method || 'GET';\n const path = url.replace('https://example.com/', '');\n\n if (clientOptions?.debug) {\n console.log('MockClient', method, path);\n }\n\n const response = mockHandler(method, path, options);\n\n if (clientOptions?.debug && !response) {\n console.log('MockClient: not found', method, path);\n }\n\n if (clientOptions?.debug) {\n console.log('MockClient', JSON.stringify(response, null, 2));\n }\n\n return Promise.resolve({\n blob: () => Promise.resolve(response),\n json: () => Promise.resolve(response),\n });\n },\n });\n }\n\n clear(): void {\n super.clear();\n this.activeLoginOverride = undefined;\n }\n\n getProfile(): ProfileResource {\n return {\n resourceType: 'Practitioner',\n id: '123',\n meta: {\n versionId: '456',\n },\n } as Practitioner;\n }\n\n setActiveLoginOverride(activeLoginOverride: LoginState): void {\n this.activeLoginOverride = activeLoginOverride;\n }\n\n getActiveLogin(): LoginState | undefined {\n if (this.activeLoginOverride !== undefined) {\n return this.activeLoginOverride;\n }\n return super.getActiveLogin();\n }\n\n createBinary(_data: any, filename: string, contentType: string): Promise<Binary> {\n if (filename.endsWith('.exe')) {\n return Promise.reject(badRequest('Invalid file type'));\n }\n\n return Promise.resolve({\n resourceType: 'Binary',\n title: filename,\n contentType,\n url: 'https://example.com/binary/123',\n });\n }\n}\n\nfunction mockHandler(method: string, path: string, options: any): any {\n if (path.startsWith('admin/')) {\n return mockAdminHandler(method, path);\n } else if (path.startsWith('auth/')) {\n return mockAuthHandler(method, path, options);\n } else if (path.startsWith('fhir/R4')) {\n return mockFhirHandler(method, path, options);\n } else {\n return null;\n }\n}\n\nfunction mockAdminHandler(_method: string, path: string): any {\n if (path.startsWith('admin/projects/123')) {\n return {\n project: { id: '123', name: 'Project 123' },\n members: [\n { id: '123', profile: { reference: 'Practitioner/123', display: 'Alice Smith' }, role: 'owner' },\n { id: '888', profile: { reference: 'ClientApplication/123', display: 'Test Client' }, role: 'client' },\n { id: '999', profile: { reference: 'Bot/123', display: 'Test Bot' }, role: 'bot' },\n ],\n };\n }\n\n return {\n ok: true,\n };\n}\n\nfunction mockAuthHandler(method: string, path: string, options: any): any {\n if (path.startsWith('auth/changepassword')) {\n return mockChangePasswordHandler(method, path, options);\n }\n\n if (path.startsWith('auth/login')) {\n return mockLoginHandler(method, path, options);\n }\n\n if (path.startsWith('auth/setpassword')) {\n return mockSetPasswordHandler(method, path, options);\n }\n\n if (path.startsWith('auth/register')) {\n return mockRegisterHandler(method, path, options);\n }\n\n if (path.startsWith('auth/resetpassword')) {\n return mockResetPasswordHandler(method, path, options);\n }\n\n if (path.startsWith('auth/me')) {\n return {\n profile: { reference: 'Practitioner/123' },\n };\n }\n\n return null;\n}\n\nfunction mockChangePasswordHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { oldPassword } = JSON.parse(body);\n if (oldPassword === 'orange') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['oldPassword'],\n details: {\n text: 'Incorrect password',\n },\n },\n ],\n };\n }\n}\n\nfunction mockLoginHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { password } = JSON.parse(body);\n if (password === 'password') {\n return {\n profile: { reference: 'Practitioner/123' },\n };\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['password'],\n details: {\n text: 'Invalid password',\n },\n },\n ],\n };\n }\n}\n\nfunction mockSetPasswordHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { password } = JSON.parse(body);\n if (password === 'orange') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['password'],\n details: {\n text: 'Invalid password',\n },\n },\n ],\n };\n }\n}\n\nfunction mockRegisterHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { email, password } = JSON.parse(body);\n if (email === 'george@example.com' && password === 'password') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n details: {\n text: 'Invalid',\n },\n },\n ],\n };\n }\n}\n\nfunction mockResetPasswordHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { email } = JSON.parse(body);\n if (email === 'admin@example.com') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['email'],\n details: {\n text: 'Email not found',\n },\n },\n ],\n };\n }\n}\n\nconst mockRepo = new MemoryRepository();\nmockRepo.createResource(HomerSimpsonPreviousVersion);\nmockRepo.createResource(HomerSimpson);\nmockRepo.createResource(ExampleAccessPolicy);\nmockRepo.createResource(ExampleStatusValueSet);\nmockRepo.createResource(ExampleUserConfiguration);\nmockRepo.createResource(ExampleBot);\nmockRepo.createResource(ExampleClient);\nmockRepo.createResource(HomerDiagnosticReport);\nmockRepo.createResource(HomerEncounter);\nmockRepo.createResource(HomerCommunication);\nmockRepo.createResource(HomerMedia);\nmockRepo.createResource(HomerObservation1);\nmockRepo.createResource(HomerObservation2);\nmockRepo.createResource(HomerObservation3);\nmockRepo.createResource(HomerObservation4);\nmockRepo.createResource(HomerObservation5);\nmockRepo.createResource(HomerObservation6);\nmockRepo.createResource(HomerSimpsonSpecimen);\nmockRepo.createResource(TestOrganization);\nmockRepo.createResource(DifferentOrganization);\nmockRepo.createResource(ExampleQuestionnaire);\nmockRepo.createResource(ExampleQuestionnaireResponse);\nmockRepo.createResource(HomerServiceRequest);\nmockRepo.createResource(ExampleSubscription);\nmockRepo.createResource(BartSimpson);\nmockRepo.createResource(DrAliceSmithPreviousVersion);\nmockRepo.createResource(DrAliceSmith);\nmockRepo.createResource(DrAliceSmithSchedule);\nDrAliceSmithSlots.forEach((slot) => mockRepo.createResource(slot));\n\nfunction mockFhirHandler(method: string, url: string, options: any): any {\n const path = url.includes('?') ? url.substring(0, url.indexOf('?')) : url;\n const match = /fhir\\/R4\\/?([^/]+)?\\/?([^/]+)?\\/?([^/]+)?\\/?([^/]+)?/.exec(path);\n const resourceType = match?.[1];\n const id = match?.[2];\n const history = match?.[3];\n const versionId = match?.[4];\n if (path.startsWith('fhir/R4/ValueSet/%24expand')) {\n return exampleValueSet;\n } else if (path === 'fhir/R4/%24graphql') {\n return mockFhirGraphqlHandler(method, path, options);\n } else if (path === 'not-found' || id === 'not-found') {\n return notFound;\n } else if (method === 'POST') {\n if (resourceType) {\n return mockRepo.createResource(JSON.parse(options.body));\n } else {\n return mockFhirBatchHandler(method, path, options);\n }\n } else if (method === 'GET') {\n if (resourceType && id && versionId) {\n return mockRepo.readVersion(resourceType, id, versionId);\n } else if (resourceType && id && history) {\n return mockRepo.readHistory(resourceType, id);\n } else if (resourceType && id) {\n return mockRepo.readResource(resourceType, id);\n } else if (resourceType) {\n return mockRepo.search(parseSearchDefinition(url));\n }\n } else if (method === 'PUT') {\n return mockRepo.createResource(JSON.parse(options.body));\n } else if (method === 'DELETE') {\n if (resourceType && id) {\n return mockRepo.deleteResource(resourceType, id);\n } else {\n return notFound;\n }\n }\n}\n\nfunction mockFhirGraphqlHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n if (body.includes('ResourceList: ServiceRequestList')) {\n return {\n data: {\n ResourceList: [\n {\n ...HomerServiceRequest,\n ObservationList: [\n HomerObservation1,\n HomerObservation2,\n HomerObservation3,\n HomerObservation4,\n HomerObservation5,\n HomerObservation6,\n ],\n },\n ],\n },\n };\n }\n return GraphQLSchemaResponse;\n}\n\nfunction mockFhirBatchHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const request = JSON.parse(body) as Bundle;\n return {\n resourceType: 'Bundle',\n type: 'batch-response',\n entry: request.entry?.map((e: BundleEntry) => {\n const url = 'fhir/R4/' + e?.request?.url;\n const method = e?.request?.method as string;\n const resource = mockHandler(method, url, null);\n if (resource?.resourceType === 'OperationOutcome') {\n return { resource, response: { status: getStatus(resource).toString() } };\n } else if (resource) {\n return { resource, response: { status: '200' } };\n } else {\n return { resource: notFound, response: { status: '404' } };\n }\n }),\n };\n}\n"],"names":["ExampleAccessPolicy","resourceType","id","name","ExampleStatusValueSet","compose","include","concept","code","ExampleUserConfiguration","option","valueString","TestOrganization","meta","versionId","DifferentOrganization","DrAliceSmith","lastUpdated","author","reference","given","family","photo","contentType","url","DrAliceSmithPreviousVersion","DrAliceSmithSchedule","actor","display","DrAliceSmithSlots","schedule","createReference","result","slotDate","Date","day","hour","setHours","push","start","toISOString","setDate","getDate","ExampleBot","ExampleClient","ExampleQuestionnaire","title","subjectType","item","linkId","text","type","ExampleQuestionnaireResponse","questionnaire","subject","source","HomerSimpson","identifier","system","value","active","birthDate","telecom","use","address","line","city","state","postalCode","HomerSimpsonPreviousVersion","HomerEncounter","HomerCommunication","payload","contentString","HomerMedia","content","HomerDiagnosticReport","resultsInterpreter","HomerObservation1","HomerObservation2","valueQuantity","unit","referenceRange","low","HomerObservation3","high","HomerObservation4","comparator","interpretation","HomerObservation5","HomerObservation6","component","HomerSimpsonSpecimen","collection","collectedDateTime","HomerServiceRequest","coding","status","orderDetail","specimen","authoredOn","BartSimpson","ExampleSubscription","ExampleAuditEvent","PatientSearchParameters","base","expression","target","GraphQLSchemaResponse","data","StructureDefinitionList","SearchParameterList","exampleValueSet","expansion","contains","__classPrivateFieldGet","receiver","kind","f","TypeError","has","call","get","__classPrivateFieldSet","set","ensureArray","input","Array","isArray","applyMaybeArray","context","fn","undefined","map","e","filter","flat","isEmptyArray","obj","length","isFalsy","toJsBoolean","removeDuplicates","arr","i","found","j","fhirPathEquals","x","y","Math","abs","isQuantity","isQuantityEquivalent","every","val","index","deepEquals","fhirPathEquivalent","sort","toLowerCase","fhirPathIs","desiredType","match","object1","object2","keys1","Object","keys","keys2","key","val1","val2","isObject","object","FhirPathAtom","constructor","original","child","this","eval","error","Error","LiteralAtom","SymbolAtom","propertyName","find","k","startsWith","EmptySetAtom","UnaryOperatorAtom","impl","AsAtom","left","right","ArithemticOperatorAtom","leftValue","rightValue","assign","ComparisonOperatorAtom","ConcatAtom","add","join","ContainsAtom","includes","InAtom","DotAtom","UnionAtom","leftResult","rightResult","resultArray","EqualsAtom","NotEqualsAtom","EquivalentAtom","NotEquivalentAtom","IsAtom","typeName","AndAtom","OrAtom","XorAtom","FunctionAtom","args","IndexerAtom","expr","parseDateString","str","substring","stub","subsetOf","supersetOf","repeat","ofType","toBoolean","validateInput","lowerStr","toInteger","parseInt","toDate","toDateTime","toDecimal","parseFloat","toQuantity","toString","toTime","children","descendants","applyStringFunc","func","argsAtoms","atom","applyMathFunc","quantity","numberInput","count","_Tokenizer_instances","_Tokenizer_str","_Tokenizer_pos","_Tokenizer_peekToken","_Tokenizer_consumeToken","_Tokenizer_consumeWhitespace","_Tokenizer_consumeMultiLineComment","_Tokenizer_consumeSingleLineComment","_Tokenizer_consumeString","_Tokenizer_consumeBacktickSymbol","_Tokenizer_consumeDateTime","_Tokenizer_consumeNumber","_Tokenizer_consumeSymbol","_Tokenizer_consumeOperator","_Tokenizer_consumeWhile","_Tokenizer_curr","_Tokenizer_prev","_Tokenizer_peek","functions","freeze","__proto__","empty","exists","criteria","all","allTrue","anyTrue","allFalse","anyFalse","distinct","from","Set","isDistinct","size","where","select","single","slice","first","last","tail","skip","num","numValue","take","intersect","other","otherArray","exclude","union","combine","iif","criterion","trueResult","otherwiseResult","evalResult","convertsToBoolean","convertsToInteger","convertsToDate","convertsToDateTime","convertsToDecimal","convertsToQuantity","convertsToString","convertsToTime","indexOf","substringAtom","startAtom","lengthAtom","startIndex","endIndex","prefixAtom","prefix","endsWith","suffixAtom","suffix","upper","toUpperCase","lower","replace","patternAtom","substitionAtom","pattern","substition","replaceAll","matches","regexAtom","regex","replaceMatches","toChars","split","ceiling","ceil","exp","floor","ln","log","baseAtom","power","expAtom","pow","round","sqrt","truncate","trace","nameAtom","console","now","timeOfDay","today","is","typeAtom","not","resolve","refStr","ref","resource","as","namespace","conformsTo","systemAtom","expectedResourceType","STANDARD_UNITS","TWO_CHAR_OPERATORS","Tokenizer","tokenize","token","buildToken","_ParserBuilder_prefixParselets","_ParserBuilder_infixParselets","_Parser_instances","_Parser_tokens","_Parser_prefixParselets","_Parser_infixParselets","_Parser_getPrecedence","_Parser_consume","_Parser_look","WeakMap","WeakSet","c","next","_a","_b","_c","_d","_e","isUnitToken","twoCharOp","condition","Parser","tokens","prefixParselets","infixParselets","expected","consumeAndParse","precedence","parse","nextToken","parser","shift","PARENTHESES_PARSELET","INDEXER_PARSELET","FUNCTION_CALL_PARSELET","parserBuilder","registerInfix","tokenType","parselet","registerPrefix","builder","infixLeft","construct","_","parts","parseQuantity","symbol","evalFhirPath","parseFhirPath","matchesSearchFilter","letter","some","JSON","stringify","operator","Operator","NOT_EQUALS","MockClient","MedplumClient","clientOptions","super","baseUrl","clientId","fetch","options","method","path","debug","response","mockHandler","Promise","blob","json","clear","activeLoginOverride","getProfile","setActiveLoginOverride","getActiveLogin","createBinary","_data","filename","reject","badRequest","_method","project","members","profile","role","ok","mockAdminHandler","_path","body","oldPassword","allOk","issue","details","mockChangePasswordHandler","password","mockLoginHandler","mockSetPasswordHandler","email","mockRegisterHandler","mockResetPasswordHandler","mockAuthHandler","exec","history","ResourceList","ObservationList","mockFhirGraphqlHandler","notFound","mockRepo","createResource","request","entry","getStatus","mockFhirBatchHandler","readVersion","readHistory","readResource","search","parseSearchDefinition","deleteResource","mockFhirHandler","_MemoryRepository_resources","_MemoryRepository_history","generateId","version1","version2","localeCompare","version","v","searchRequest","resources","values","filters","matchesSearchRequest","total","forEach","slot"],"mappings":"oKAEa,MAAAA,EAAoC,CAC/CC,aAAc,eACdC,GAAI,MACJC,KAAM,yBAGKC,EAAkC,CAC7CH,aAAc,WACdC,GAAI,mBACJG,QAAS,CACPC,QAAS,CACP,CACEC,QAAS,CACP,CAAEC,KAAM,WACR,CAAEA,KAAM,oBACR,CAAEA,KAAM,oBACR,CAAEA,KAAM,iBACR,CAAEA,KAAM,qBAOLC,EAA8C,CACzDR,aAAc,oBACdC,GAAI,MACJC,KAAM,6BACNO,OAAQ,CACN,CACER,GAAI,iBACJS,YAAa,+BC9BNC,EAAiC,CAC5CX,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,KAEbX,KAAM,qBAGKY,EAAsC,CACjDd,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,KAEbX,KAAM,aAGKa,EAA6B,CACxCf,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,IACXG,YAAa,uBACbC,OAAQ,CACNC,UAAW,qBAGfhB,KAAM,CACJ,CACEiB,MAAO,CAAC,SACRC,OAAQ,UAGZC,MAAO,CACL,CACEC,YAAa,YACbC,IAAK,oDAKEC,EAA4C,CACvDxB,aAAc,e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c,GACxBgc,GAASC,eAAehc,GACxB+b,GAASC,eAAeha,GACxB+Z,GAASC,eAAeta,GACxBqa,GAASC,eAAera,GACxBoa,GAASC,eAAela,GACxBia,GAASC,eAAe9Z,GACxB6Z,GAASC,eAAe7Z,GACxB4Z,GAASC,eAAexZ,GACxBuZ,GAASC,eAAetZ,GACxBqZ,GAASC,eAAenZ,GACxBkZ,GAASC,eAAelZ,GACxBiZ,GAASC,eAAehZ,GACxB+Y,GAASC,eAAehe,GACxB+d,GAASC,eAAe7d,GACxB4d,GAASC,eAAe/b,GACxB8b,GAASC,eAAexb,GACxBub,GAASC,eAAe7Y,GACxB4Y,GAASC,eAAetY,GACxBqY,GAASC,eAAevY,GACxBsY,GAASC,eAAend,GACxBkd,GAASC,eAAe5d,GACxB2d,GAASC,eAAeld,GACxBG,EAAkBye,SAASC,GAAS5B,GAASC,eAAe2B"}
1
+ {"version":3,"file":"index.min.js","sources":["../../../src/mocks/accesspolicy.ts","../../../src/mocks/alice.ts","../../../src/mocks/bot.ts","../../../src/mocks/questionnaire.ts","../../../src/mocks/simpsons.ts","../../../src/mocks/subscription.ts","../../../src/mocks/types.ts","../../../src/mocks/valueset.ts","../../../../node_modules/tslib/tslib.es6.js","../../../src/repo.ts","../../../src/client.ts"],"sourcesContent":["import { AccessPolicy, UserConfiguration, ValueSet } from '@medplum/fhirtypes';\n\nexport const ExampleAccessPolicy: AccessPolicy = {\n resourceType: 'AccessPolicy',\n id: '123',\n name: 'Example Access Policy',\n};\n\nexport const ExampleStatusValueSet: ValueSet = {\n resourceType: 'ValueSet',\n id: 'example-statuses',\n compose: {\n include: [\n {\n concept: [\n { code: 'ORDERED' },\n { code: 'SENT_TO_CUSTOMER' },\n { code: 'SENT_BACK_TO_LAB' },\n { code: 'LAB_PROCESSED' },\n { code: 'LAB_COMPLETE' },\n ],\n },\n ],\n },\n};\n\nexport const ExampleUserConfiguration: UserConfiguration = {\n resourceType: 'UserConfiguration',\n id: '123',\n name: 'Example User Configuration',\n option: [\n {\n id: 'statusValueSet',\n valueString: 'ValueSet/example-statuses',\n },\n ],\n};\n","import { createReference } from '@medplum/core';\nimport { Organization, Practitioner, Schedule, Slot } from '@medplum/fhirtypes';\n\nexport const TestOrganization: Organization = {\n resourceType: 'Organization',\n id: '123',\n meta: {\n versionId: '1',\n },\n name: 'Test Organization',\n};\n\nexport const DifferentOrganization: Organization = {\n resourceType: 'Organization',\n id: '456',\n meta: {\n versionId: '1',\n },\n name: 'Different',\n};\n\nexport const DrAliceSmith: Practitioner = {\n resourceType: 'Practitioner',\n id: '123',\n meta: {\n versionId: '2',\n lastUpdated: '2021-01-02T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n name: [\n {\n given: ['Alice'],\n family: 'Smith',\n },\n ],\n photo: [\n {\n contentType: 'image/png',\n url: 'https://docs.medplum.com/img/cdc-femaledoc.png',\n },\n ],\n};\n\nexport const DrAliceSmithPreviousVersion: Practitioner = {\n resourceType: 'Practitioner',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2021-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n name: [{ given: ['Medplum'], family: 'Admin' }],\n};\n\nexport const DrAliceSmithSchedule: Schedule = {\n resourceType: 'Schedule',\n id: '123',\n actor: [\n {\n reference: 'Practitioner/123',\n display: 'Dr. Alice Smith',\n },\n ],\n};\n\nexport const DrAliceSmithSlots: Slot[] = (() => {\n const schedule = createReference(DrAliceSmithSchedule);\n const result: Slot[] = [];\n const slotDate = new Date();\n for (let day = 0; day < 60; day++) {\n for (const hour of [9, 10, 11, 13, 14, 15]) {\n slotDate.setHours(hour, 0, 0, 0);\n result.push({\n resourceType: 'Slot',\n id: `slot-${day}-${hour}`,\n start: slotDate.toISOString(),\n schedule,\n });\n }\n slotDate.setDate(slotDate.getDate() + 1);\n }\n return result;\n})();\n","import { Bot, ClientApplication } from '@medplum/fhirtypes';\n\nexport const ExampleBot: Bot = {\n resourceType: 'Bot',\n id: '123',\n name: 'Test Bot',\n code: 'console.log(\"hello world\");',\n};\n\nexport const ExampleClient: ClientApplication = {\n resourceType: 'ClientApplication',\n id: '123',\n name: 'Test Client',\n};\n","import { Questionnaire, QuestionnaireResponse } from '@medplum/fhirtypes';\n\nexport const ExampleQuestionnaire: Questionnaire = {\n resourceType: 'Questionnaire',\n id: '123',\n name: 'Vitals',\n title: 'Vitals',\n subjectType: ['Patient'],\n item: [\n {\n linkId: '1',\n text: 'First question',\n type: 'string',\n },\n ],\n};\n\nexport const ExampleQuestionnaireResponse: QuestionnaireResponse = {\n resourceType: 'QuestionnaireResponse',\n id: '123',\n questionnaire: 'Questionnaire/123',\n subject: {\n reference: 'Patient/123',\n },\n source: {\n reference: 'Practitioner/123',\n },\n};\n","import { createReference } from '@medplum/core';\nimport {\n Communication,\n DiagnosticReport,\n Encounter,\n Media,\n Observation,\n Patient,\n ServiceRequest,\n Specimen,\n} from '@medplum/fhirtypes';\n\nexport const HomerSimpson: Patient = {\n resourceType: 'Patient',\n id: '123',\n meta: {\n versionId: '2',\n lastUpdated: '2020-01-02T00:00:00.000Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n identifier: [\n { system: 'abc', value: '123' },\n { system: 'def', value: '456' },\n ],\n active: true,\n birthDate: '1956-05-12',\n name: [\n {\n given: ['Homer'],\n family: 'Simpson',\n },\n ],\n photo: [\n {\n contentType: 'image/png',\n url: 'https://docs.medplum.com/img/homer-simpson.png',\n },\n ],\n telecom: [\n {\n system: 'phone',\n use: 'home',\n value: '555-7334',\n },\n {\n system: 'email',\n use: 'home',\n value: 'chunkylover53@aol.com',\n },\n ],\n address: [\n {\n use: 'home',\n line: ['742 Evergreen Terrace'],\n city: 'Springfield',\n state: 'IL',\n postalCode: '12345',\n },\n ],\n};\n\nexport const HomerSimpsonPreviousVersion: Patient = {\n resourceType: 'Patient',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-01T00:00:00.000Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n name: [\n {\n given: ['Homer'],\n family: 'Simpson',\n },\n ],\n photo: [\n {\n contentType: 'image/png',\n url: 'https://docs.medplum.com/img/homer-simpson.png',\n },\n ],\n};\n\nexport const HomerEncounter: Encounter = {\n resourceType: 'Encounter',\n id: '123',\n meta: {\n versionId: '456',\n lastUpdated: '2020-01-01T00:00:00.000Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n};\n\nexport const HomerCommunication: Communication = {\n resourceType: 'Communication',\n id: '123',\n meta: {\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n payload: [\n {\n contentString: 'Hello world',\n },\n ],\n};\n\nexport const HomerMedia: Media = {\n resourceType: 'Media',\n id: '123',\n meta: {\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n content: {\n contentType: 'text/plain',\n url: 'https://example.com/test.txt',\n },\n};\n\nexport const HomerDiagnosticReport: DiagnosticReport = {\n resourceType: 'DiagnosticReport',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-02T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n subject: {\n reference: 'Patient/123',\n display: 'Homer Simpson',\n },\n resultsInterpreter: [\n {\n reference: 'Practitioner/123',\n display: 'Dr. Alice Smith',\n },\n ],\n result: [\n { reference: 'Observation/1' },\n { reference: 'Observation/2' },\n { reference: 'Observation/3' },\n { reference: 'Observation/4' },\n { reference: 'Observation/5' },\n { reference: 'Observation/6' },\n ],\n};\n\nexport const HomerObservation1: Observation = {\n resourceType: 'Observation',\n id: '1',\n code: {\n text: 'Test 1',\n },\n valueString: 'test',\n};\n\nexport const HomerObservation2: Observation = {\n resourceType: 'Observation',\n id: '2',\n code: {\n text: 'Test 2',\n },\n valueQuantity: {\n value: 20,\n unit: 'x',\n },\n referenceRange: [\n {\n low: {\n value: 10,\n },\n },\n ],\n};\n\nexport const HomerObservation3: Observation = {\n resourceType: 'Observation',\n id: '3',\n code: {\n text: 'Test 3',\n },\n valueQuantity: {\n value: 30,\n unit: 'x',\n },\n referenceRange: [\n {\n high: {\n value: 50,\n },\n },\n ],\n};\n\nexport const HomerObservation4: Observation = {\n resourceType: 'Observation',\n id: '4',\n code: {\n text: 'Test 4',\n },\n valueQuantity: {\n value: 50,\n unit: 'x',\n comparator: '>',\n },\n referenceRange: [\n {\n low: {\n value: 10,\n unit: 'x',\n },\n high: {\n value: 50,\n unit: 'x',\n },\n },\n ],\n interpretation: [\n {\n text: 'HIGH',\n },\n ],\n};\n\nexport const HomerObservation5: Observation = {\n resourceType: 'Observation',\n id: '5',\n code: {\n text: 'Test 5',\n },\n valueQuantity: {\n value: 100,\n unit: 'x',\n },\n referenceRange: [{}],\n interpretation: [{}],\n};\n\nexport const HomerObservation6: Observation = {\n resourceType: 'Observation',\n id: '6',\n code: {\n text: 'Test 6',\n },\n component: [\n {\n valueQuantity: {\n value: 110,\n unit: 'mmHg',\n system: 'http://unitsofmeasure.org',\n },\n },\n {\n valueQuantity: {\n value: 75,\n unit: 'mmHg',\n system: 'http://unitsofmeasure.org',\n },\n },\n ],\n};\n\nexport const HomerSimpsonSpecimen: Specimen = {\n id: '123',\n resourceType: 'Specimen',\n subject: createReference(HomerSimpson),\n collection: {\n collectedDateTime: '2020-01-01T12:00:00Z',\n },\n};\n\nexport const HomerServiceRequest: ServiceRequest = {\n resourceType: 'ServiceRequest',\n id: '123',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n identifier: [\n {\n system: 'https://example.com',\n value: '9001',\n },\n ],\n code: {\n coding: [\n {\n system: 'http://snomed.info/sct',\n code: 'SERVICE_REQUEST_CODE',\n },\n ],\n },\n subject: {\n reference: 'Patient/123',\n display: 'Homer Simpson',\n },\n status: 'active',\n orderDetail: [\n {\n text: 'ORDERED',\n },\n ],\n specimen: [createReference(HomerSimpsonSpecimen)],\n authoredOn: '2020-01-01T12:00:00Z',\n};\n\nexport const BartSimpson: Patient = {\n resourceType: 'Patient',\n id: '555',\n meta: {\n versionId: '1',\n lastUpdated: '2020-01-01T12:00:00Z',\n author: {\n reference: 'Practitioner/123',\n },\n },\n birthDate: '1979-12-17',\n name: [\n {\n given: ['Bart'],\n family: 'Simpson',\n },\n ],\n photo: [\n {\n contentType: 'image/jpeg',\n url: 'https://example.com/picture.jpg',\n },\n ],\n telecom: [\n {\n system: 'phone',\n use: 'home',\n value: '555-1239',\n },\n {\n system: 'email',\n use: 'home',\n value: 'bart@thesimpsons.com',\n },\n ],\n};\n","import { AuditEvent, Subscription } from '@medplum/fhirtypes';\n\nexport const ExampleSubscription: Subscription = {\n resourceType: 'Subscription',\n id: '123',\n meta: {\n versionId: '456',\n },\n};\n\nexport const ExampleAuditEvent: AuditEvent = {\n resourceType: 'AuditEvent',\n id: '123',\n meta: {\n lastUpdated: new Date().toISOString(),\n versionId: '456',\n author: {\n reference: 'Practitioner/123',\n },\n },\n};\n","import { SearchParameter } from '@medplum/fhirtypes';\nimport StructureDefinitionList from './structuredefinitions.json';\n\nexport const PatientSearchParameters: SearchParameter[] = [\n {\n resourceType: 'SearchParameter',\n id: 'Patient-name',\n base: ['Patient'],\n code: 'name',\n name: 'name',\n type: 'string',\n expression: 'Patient.name',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Patient-birthdate',\n base: ['Patient'],\n code: 'birthdate',\n name: 'birthdate',\n type: 'date',\n expression: 'Patient.birthDate',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Patient-organization',\n base: ['Patient'],\n code: 'organization',\n name: 'organization',\n type: 'reference',\n expression: 'Patient.managingOrganization',\n target: ['Organization'],\n },\n {\n resourceType: 'SearchParameter',\n id: 'Patient-active',\n base: ['Patient'],\n code: 'active',\n name: 'active',\n type: 'token',\n expression: 'Patient.active',\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-telecom',\n base: ['Patient', 'Practitioner'],\n code: 'telecom',\n name: 'telecom',\n type: 'token',\n expression: 'Patient.telecom | Practitioner.telecom',\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-email',\n base: ['Patient', 'Practitioner'],\n code: 'email',\n name: 'email',\n type: 'token',\n expression: \"Patient.telecom.where(system='email') | Practitioner.telecom.where(system='email')\",\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-phone',\n base: ['Patient', 'Practitioner'],\n code: 'phone',\n name: 'phone',\n type: 'token',\n expression: \"Patient.telecom.where(system='phone') | Practitioner.telecom.where(system='phone')\",\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-address-city',\n base: ['Patient', 'Practitioner'],\n code: 'address-city',\n name: 'address-city',\n type: 'token',\n expression: 'Patient.address.city | Practitioner.address.city',\n },\n {\n resourceType: 'SearchParameter',\n id: 'individual-address-state',\n base: ['Patient', 'Practitioner'],\n code: 'address-state',\n name: 'address-state',\n type: 'token',\n expression: 'Patient.address.state | Practitioner.address.state',\n },\n {\n resourceType: 'SearchParameter',\n id: 'ServiceRequest-subject',\n code: 'subject',\n base: ['ServiceRequest'],\n type: 'reference',\n expression: 'ServiceRequest.subject',\n target: ['Group', 'Device', 'Patient', 'Location'],\n },\n {\n resourceType: 'SearchParameter',\n id: 'ServiceRequest-authored',\n code: 'authored',\n base: ['ServiceRequest'],\n type: 'date',\n expression: 'ServiceRequest.authoredOn',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Observation-value-quantity',\n code: 'value-quantity',\n base: ['Observation'],\n type: 'quantity',\n expression: '(Observation.value as Quantity) | (Observation.value as SampledData)',\n },\n {\n resourceType: 'SearchParameter',\n id: 'Encounter-length',\n code: 'length',\n base: ['Encounter'],\n type: 'quantity',\n expression: 'Encounter.length',\n },\n];\n\nexport const GraphQLSchemaResponse = {\n data: {\n StructureDefinitionList,\n SearchParameterList: [...PatientSearchParameters],\n },\n};\n","import { ValueSet } from '@medplum/fhirtypes';\n\nexport const exampleValueSet: ValueSet = {\n resourceType: 'ValueSet',\n expansion: {\n contains: [\n {\n system: 'x',\n code: 'test-code',\n display: 'Test Display',\n },\n ],\n },\n};\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import { evalFhirPath, Filter, Operator, SearchRequest } from '@medplum/core';\nimport { Bundle, BundleEntry, Resource } from '@medplum/fhirtypes';\n\nexport class MemoryRepository {\n readonly #resources: Record<string, Record<string, Resource>>;\n readonly #history: Record<string, Record<string, Resource[]>>;\n\n constructor() {\n this.#resources = {};\n this.#history = {};\n }\n\n createResource<T extends Resource>(resource: T): T {\n const result = resource;\n\n if (!result.id) {\n result.id = this.generateId();\n }\n\n if (!result.meta) {\n result.meta = {};\n }\n\n if (!result.meta?.versionId) {\n result.meta.versionId = this.generateId();\n }\n\n const { resourceType, id } = resource as { resourceType: string; id: string };\n\n if (!(resourceType in this.#resources)) {\n this.#resources[resourceType] = {};\n }\n\n if (!(resourceType in this.#history)) {\n this.#history[resourceType] = {};\n }\n\n if (!(id in this.#history[resourceType])) {\n this.#history[resourceType][id] = [];\n }\n\n this.#resources[resourceType][id] = resource;\n this.#history[resourceType][id].push(result);\n return result;\n }\n\n readResource<T extends Resource>(resourceType: string, id: string): T | undefined {\n return this.#resources?.[resourceType]?.[id] as T | undefined;\n }\n\n readHistory<T extends Resource>(resourceType: string, id: string): Bundle<T> {\n return {\n resourceType: 'Bundle',\n type: 'history',\n entry: ((this.#history?.[resourceType]?.[id] ?? []) as T[])\n .sort(\n (version1, version2) =>\n -(version1.meta?.lastUpdated?.localeCompare(version2.meta?.lastUpdated as string) as number)\n )\n .map((version) => ({ resource: version })),\n };\n }\n\n readVersion<T extends Resource>(resourceType: string, id: string, versionId: string): T | undefined {\n return this.#history?.[resourceType]?.[id]?.find((v) => v.meta?.versionId === versionId) as T | undefined;\n }\n\n search<T extends Resource>(searchRequest: SearchRequest): Bundle<T> {\n const { resourceType } = searchRequest;\n const resources = this.#resources[resourceType] ?? {};\n const result = Object.values(resources).filter((resource) => matchesSearchRequest(resource, searchRequest));\n return {\n resourceType: 'Bundle',\n type: 'searchset',\n entry: result.map((resource) => ({ resource })) as BundleEntry<T>[],\n total: result.length,\n };\n }\n\n deleteResource(resourceType: string, id: string): void {\n if (this.#resources?.[resourceType]?.[id]) {\n delete this.#resources[resourceType][id];\n }\n }\n\n private generateId(): string {\n return Date.now().toString(36);\n }\n}\n\n/**\n * Determines if the resource matches the search request.\n * @param resource The resource that was created or updated.\n * @param searchRequest The subscription criteria as a search request.\n * @returns True if the resource satisfies the search request.\n */\nexport function matchesSearchRequest(resource: Resource, searchRequest: SearchRequest): boolean {\n if (searchRequest.resourceType !== resource.resourceType) {\n return false;\n }\n if (searchRequest.filters) {\n for (const filter of searchRequest.filters) {\n if (!matchesSearchFilter(resource, filter)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * Determines if the resource matches the search filter.\n * @param resource The resource that was created or updated.\n * @param filter One of the filters of a subscription criteria.\n * @returns True if the resource satisfies the search filter.\n */\nfunction matchesSearchFilter(resource: Resource, filter: Filter): boolean {\n for (const filterValue of filter.value.split(',')) {\n if (matchesSearchFilterValue(resource, filter, filterValue)) {\n return true;\n }\n }\n return false;\n}\n\nfunction matchesSearchFilterValue(resource: Resource, filter: Filter, filterValue: string): boolean {\n const expression = filter.code.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n const values = evalFhirPath(expression as string, resource);\n const result = values.some((value) => JSON.stringify(value).toLowerCase().includes(filterValue.toLowerCase()));\n return filter.operator === Operator.NOT_EQUALS ? !result : result;\n}\n","import {\n allOk,\n badRequest,\n getStatus,\n LoginState,\n MedplumClient,\n notFound,\n parseSearchDefinition,\n ProfileResource,\n} from '@medplum/core';\nimport { Binary, Bundle, BundleEntry, Practitioner } from '@medplum/fhirtypes';\nimport {\n BartSimpson,\n DifferentOrganization,\n DrAliceSmith,\n DrAliceSmithPreviousVersion,\n DrAliceSmithSchedule,\n DrAliceSmithSlots,\n ExampleBot,\n ExampleClient,\n ExampleQuestionnaire,\n ExampleQuestionnaireResponse,\n ExampleSubscription,\n exampleValueSet,\n GraphQLSchemaResponse,\n HomerCommunication,\n HomerDiagnosticReport,\n HomerEncounter,\n HomerMedia,\n HomerObservation1,\n HomerObservation2,\n HomerObservation3,\n HomerObservation4,\n HomerObservation5,\n HomerObservation6,\n HomerServiceRequest,\n HomerSimpson,\n HomerSimpsonPreviousVersion,\n HomerSimpsonSpecimen,\n TestOrganization,\n} from './mocks';\nimport { ExampleAccessPolicy, ExampleStatusValueSet, ExampleUserConfiguration } from './mocks/accesspolicy';\nimport { MemoryRepository } from './repo';\n\nexport interface MockClientOptions {\n readonly debug?: boolean;\n}\n\nexport class MockClient extends MedplumClient {\n activeLoginOverride?: LoginState;\n\n constructor(clientOptions?: MockClientOptions) {\n super({\n baseUrl: 'https://example.com/',\n clientId: 'my-client-id',\n fetch: (url: string, options: any) => {\n const method = options.method || 'GET';\n const path = url.replace('https://example.com/', '');\n\n if (clientOptions?.debug) {\n console.log('MockClient', method, path);\n }\n\n const response = mockHandler(method, path, options);\n\n if (clientOptions?.debug && !response) {\n console.log('MockClient: not found', method, path);\n }\n\n if (clientOptions?.debug) {\n console.log('MockClient', JSON.stringify(response, null, 2));\n }\n\n return Promise.resolve({\n blob: () => Promise.resolve(response),\n json: () => Promise.resolve(response),\n });\n },\n });\n }\n\n clear(): void {\n super.clear();\n this.activeLoginOverride = undefined;\n }\n\n getProfile(): ProfileResource {\n return {\n resourceType: 'Practitioner',\n id: '123',\n meta: {\n versionId: '456',\n },\n } as Practitioner;\n }\n\n setActiveLoginOverride(activeLoginOverride: LoginState): void {\n this.activeLoginOverride = activeLoginOverride;\n }\n\n getActiveLogin(): LoginState | undefined {\n if (this.activeLoginOverride !== undefined) {\n return this.activeLoginOverride;\n }\n return super.getActiveLogin();\n }\n\n createBinary(_data: any, filename: string, contentType: string): Promise<Binary> {\n if (filename.endsWith('.exe')) {\n return Promise.reject(badRequest('Invalid file type'));\n }\n\n return Promise.resolve({\n resourceType: 'Binary',\n title: filename,\n contentType,\n url: 'https://example.com/binary/123',\n });\n }\n}\n\nfunction mockHandler(method: string, path: string, options: any): any {\n if (path.startsWith('admin/')) {\n return mockAdminHandler(method, path);\n } else if (path.startsWith('auth/')) {\n return mockAuthHandler(method, path, options);\n } else if (path.startsWith('fhir/R4')) {\n return mockFhirHandler(method, path, options);\n } else {\n return null;\n }\n}\n\nfunction mockAdminHandler(_method: string, path: string): any {\n if (path.startsWith('admin/projects/123')) {\n return {\n project: { id: '123', name: 'Project 123' },\n members: [\n { id: '123', profile: { reference: 'Practitioner/123', display: 'Alice Smith' }, role: 'owner' },\n { id: '888', profile: { reference: 'ClientApplication/123', display: 'Test Client' }, role: 'client' },\n { id: '999', profile: { reference: 'Bot/123', display: 'Test Bot' }, role: 'bot' },\n ],\n };\n }\n\n return {\n ok: true,\n };\n}\n\nfunction mockAuthHandler(method: string, path: string, options: any): any {\n if (path.startsWith('auth/changepassword')) {\n return mockChangePasswordHandler(method, path, options);\n }\n\n if (path.startsWith('auth/login')) {\n return mockLoginHandler(method, path, options);\n }\n\n if (path.startsWith('auth/setpassword')) {\n return mockSetPasswordHandler(method, path, options);\n }\n\n if (path.startsWith('auth/register')) {\n return mockRegisterHandler(method, path, options);\n }\n\n if (path.startsWith('auth/resetpassword')) {\n return mockResetPasswordHandler(method, path, options);\n }\n\n if (path.startsWith('auth/me')) {\n return {\n profile: { reference: 'Practitioner/123' },\n };\n }\n\n return null;\n}\n\nfunction mockChangePasswordHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { oldPassword } = JSON.parse(body);\n if (oldPassword === 'orange') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['oldPassword'],\n details: {\n text: 'Incorrect password',\n },\n },\n ],\n };\n }\n}\n\nfunction mockLoginHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { password } = JSON.parse(body);\n if (password === 'password') {\n return {\n profile: { reference: 'Practitioner/123' },\n };\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['password'],\n details: {\n text: 'Invalid password',\n },\n },\n ],\n };\n }\n}\n\nfunction mockSetPasswordHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { password } = JSON.parse(body);\n if (password === 'orange') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['password'],\n details: {\n text: 'Invalid password',\n },\n },\n ],\n };\n }\n}\n\nfunction mockRegisterHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { email, password } = JSON.parse(body);\n if (email === 'george@example.com' && password === 'password') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n details: {\n text: 'Invalid',\n },\n },\n ],\n };\n }\n}\n\nfunction mockResetPasswordHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const { email } = JSON.parse(body);\n if (email === 'admin@example.com') {\n return allOk;\n } else {\n return {\n resourceType: 'OperationOutcome',\n issue: [\n {\n expression: ['email'],\n details: {\n text: 'Email not found',\n },\n },\n ],\n };\n }\n}\n\nconst mockRepo = new MemoryRepository();\nmockRepo.createResource(HomerSimpsonPreviousVersion);\nmockRepo.createResource(HomerSimpson);\nmockRepo.createResource(ExampleAccessPolicy);\nmockRepo.createResource(ExampleStatusValueSet);\nmockRepo.createResource(ExampleUserConfiguration);\nmockRepo.createResource(ExampleBot);\nmockRepo.createResource(ExampleClient);\nmockRepo.createResource(HomerDiagnosticReport);\nmockRepo.createResource(HomerEncounter);\nmockRepo.createResource(HomerCommunication);\nmockRepo.createResource(HomerMedia);\nmockRepo.createResource(HomerObservation1);\nmockRepo.createResource(HomerObservation2);\nmockRepo.createResource(HomerObservation3);\nmockRepo.createResource(HomerObservation4);\nmockRepo.createResource(HomerObservation5);\nmockRepo.createResource(HomerObservation6);\nmockRepo.createResource(HomerSimpsonSpecimen);\nmockRepo.createResource(TestOrganization);\nmockRepo.createResource(DifferentOrganization);\nmockRepo.createResource(ExampleQuestionnaire);\nmockRepo.createResource(ExampleQuestionnaireResponse);\nmockRepo.createResource(HomerServiceRequest);\nmockRepo.createResource(ExampleSubscription);\nmockRepo.createResource(BartSimpson);\nmockRepo.createResource(DrAliceSmithPreviousVersion);\nmockRepo.createResource(DrAliceSmith);\nmockRepo.createResource(DrAliceSmithSchedule);\nDrAliceSmithSlots.forEach((slot) => mockRepo.createResource(slot));\n\nfunction mockFhirHandler(method: string, url: string, options: any): any {\n const path = url.includes('?') ? url.substring(0, url.indexOf('?')) : url;\n const match = /fhir\\/R4\\/?([^/]+)?\\/?([^/]+)?\\/?([^/]+)?\\/?([^/]+)?/.exec(path);\n const resourceType = match?.[1];\n const id = match?.[2];\n const operation = match?.[3];\n const versionId = match?.[4];\n if (path.startsWith('fhir/R4/ValueSet/$expand')) {\n return exampleValueSet;\n } else if (path === 'fhir/R4/$graphql') {\n return mockFhirGraphqlHandler(method, path, options);\n } else if (path === 'not-found' || id === 'not-found') {\n return notFound;\n } else if (method === 'POST') {\n if (resourceType && id && operation) {\n return {};\n } else if (resourceType) {\n return mockRepo.createResource(JSON.parse(options.body));\n } else {\n return mockFhirBatchHandler(method, path, options);\n }\n } else if (method === 'GET') {\n if (resourceType && id && versionId) {\n return mockRepo.readVersion(resourceType, id, versionId);\n } else if (resourceType && id && operation === '_history') {\n return mockRepo.readHistory(resourceType, id);\n } else if (resourceType && id) {\n return mockRepo.readResource(resourceType, id);\n } else if (resourceType) {\n return mockRepo.search(parseSearchDefinition(url));\n }\n } else if (method === 'PUT') {\n return mockRepo.createResource(JSON.parse(options.body));\n } else if (method === 'DELETE') {\n if (resourceType && id) {\n return mockRepo.deleteResource(resourceType, id);\n } else {\n return notFound;\n }\n }\n}\n\nfunction mockFhirGraphqlHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n if (body.includes('ResourceList: ServiceRequestList')) {\n return {\n data: {\n ResourceList: [\n {\n ...HomerServiceRequest,\n ObservationList: [\n HomerObservation1,\n HomerObservation2,\n HomerObservation3,\n HomerObservation4,\n HomerObservation5,\n HomerObservation6,\n ],\n },\n ],\n },\n };\n }\n return GraphQLSchemaResponse;\n}\n\nfunction mockFhirBatchHandler(_method: string, _path: string, options: any): any {\n const { body } = options;\n const request = JSON.parse(body) as Bundle;\n return {\n resourceType: 'Bundle',\n type: 'batch-response',\n entry: request.entry?.map((e: BundleEntry) => {\n const url = 'fhir/R4/' + e?.request?.url;\n const method = e?.request?.method as string;\n const resource = mockHandler(method, url, null);\n if (resource?.resourceType === 'OperationOutcome') {\n return { resource, response: { status: getStatus(resource).toString() } };\n } else if (resource) {\n return { resource, response: { status: '200' } };\n } else {\n return { resource: notFound, response: { status: '404' } };\n }\n }),\n };\n}\n"],"names":["ExampleAccessPolicy","resourceType","id","name","ExampleStatusValueSet","compose","include","concept","code","ExampleUserConfiguration","option","valueString","TestOrganization","meta","versionId","DifferentOrganization","DrAliceSmith","lastUpdated","author","reference","given","family","photo","contentType","url","DrAliceSmithPreviousVersion","DrAliceSmithSchedule","actor","display","DrAliceSmithSlots","schedule","createReference","result","slotDate","Date","day","hour","setHours","push","start","toISOString","setDate","getDate","ExampleBot","ExampleClient","ExampleQuestionnaire","title","subjectType","item","linkId","text","type","ExampleQuestionnaireResponse","questionnaire","subject","source","HomerSimpson","identifier","system","value","active","birthDate","telecom","use","address","line","city","state","postalCode","HomerSimpsonPreviousVersion","HomerEncounter","HomerCommunication","payload","contentString","HomerMedia","content","HomerDiagnosticReport","resultsInterpreter","HomerObservation1","HomerObservation2","valueQuantity","unit","referenceRange","low","HomerObservation3","high","HomerObservation4","comparator","interpretation","HomerObservation5","HomerObservation6","component","HomerSimpsonSpecimen","collection","collectedDateTime","HomerServiceRequest","coding","status","orderDetail","specimen","authoredOn","BartSimpson","ExampleSubscription","ExampleAuditEvent","PatientSearchParameters","base","expression","target","GraphQLSchemaResponse","data","StructureDefinitionList","SearchParameterList","exampleValueSet","expansion","contains","__classPrivateFieldGet","receiver","kind","f","TypeError","has","call","get","__classPrivateFieldSet","set","matchesSearchFilter","resource","filter","filterValue","split","matchesSearchFilterValue","replace","_","letter","toUpperCase","evalFhirPath","some","JSON","stringify","toLowerCase","includes","operator","Operator","NOT_EQUALS","MockClient","MedplumClient","constructor","clientOptions","super","baseUrl","clientId","fetch","options","method","path","debug","console","log","response","mockHandler","Promise","resolve","blob","json","clear","this","activeLoginOverride","undefined","getProfile","setActiveLoginOverride","getActiveLogin","createBinary","_data","filename","endsWith","reject","badRequest","startsWith","_method","project","members","profile","role","ok","mockAdminHandler","_path","body","oldPassword","parse","allOk","issue","details","mockChangePasswordHandler","password","mockLoginHandler","mockSetPasswordHandler","email","mockRegisterHandler","mockResetPasswordHandler","mockAuthHandler","substring","indexOf","match","exec","operation","ResourceList","ObservationList","mockFhirGraphqlHandler","notFound","mockRepo","createResource","request","entry","_a","map","e","_b","getStatus","toString","mockFhirBatchHandler","readVersion","readHistory","readResource","search","parseSearchDefinition","deleteResource","mockFhirHandler","_MemoryRepository_resources","_MemoryRepository_history","generateId","_c","sort","version1","version2","localeCompare","version","find","v","searchRequest","resources","Object","values","filters","matchesSearchRequest","total","length","now","forEach","slot"],"mappings":"sLAEa,MAAAA,EAAoC,CAC/CC,aAAc,eACdC,GAAI,MACJC,KAAM,yBAGKC,EAAkC,CAC7CH,aAAc,WACdC,GAAI,mBACJG,QAAS,CACPC,QAAS,CACP,CACEC,QAAS,CACP,CAAEC,KAAM,WACR,CAAEA,KAAM,oBACR,CAAEA,KAAM,oBACR,CAAEA,KAAM,iBACR,CAAEA,KAAM,qBAOLC,EAA8C,CACzDR,aAAc,oBACdC,GAAI,MACJC,KAAM,6BACNO,OAAQ,CACN,CACER,GAAI,iBACJS,YAAa,+BC9BNC,EAAiC,CAC5CX,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,KAEbX,KAAM,qBAGKY,EAAsC,CACjDd,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,KAEbX,KAAM,aAGKa,EAA6B,CACxCf,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,IACXG,YAAa,uBACbC,OAAQ,CACNC,UAAW,qBAGfhB,KAAM,CACJ,CACEiB,MAAO,CAAC,SACRC,OAAQ,UAGZC,MAAO,CACL,CACEC,YAAa,YACbC,IAAK,oDAKEC,EAA4C,CACvDxB,aAAc,eACdC,GAAI,MACJW,KAAM,CACJC,UAAW,IACXG,YAAa,uBACbC,OAAQ,CACNC,UAAW,qBAGfhB,KAAM,CAAC,CAAEiB,MAAO,CAAC,WAAYC,OAAQ,WAG1BK,EAAiC,CAC5CzB,aAAc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