@medplum/mock 1.0.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.min.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,42 +1,5 @@
1
- import { createReference, getReferenceString, deepClone, badRequest, notFound, matchesSearchRequest, MedplumClient, allOk, isOk, parseSearchDefinition, getStatus } from '@medplum/core';
2
-
3
- /******************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
-
18
- function __awaiter(thisArg, _arguments, P, generator) {
19
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
- return new (P || (P = Promise))(function (resolve, reject) {
21
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
- step((generator = generator.apply(thisArg, _arguments || [])).next());
25
- });
26
- }
27
-
28
- function __classPrivateFieldGet(receiver, state, kind, f) {
29
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
30
- 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");
31
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
32
- }
33
-
34
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
35
- if (kind === "m") throw new TypeError("Private method is not writable");
36
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
37
- 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");
38
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
39
- }
1
+ import { createReference, getReferenceString, deepClone, badRequest, notFound, matchesSearchRequest, MedplumClient, isOk, allOk, parseSearchDefinition, getStatus } from '@medplum/core';
2
+ import { applyPatch } from 'fast-json-patch';
40
3
 
41
4
  const ExampleAccessPolicy = {
42
5
  resourceType: 'AccessPolicy',
@@ -16551,6 +16514,34 @@ const ExampleSmartClientApplication = {
16551
16514
  launchUri: 'https://inferno.healthit.gov/suites/custom/smart/launch',
16552
16515
  };
16553
16516
 
16517
+ /******************************************************************************
16518
+ Copyright (c) Microsoft Corporation.
16519
+
16520
+ Permission to use, copy, modify, and/or distribute this software for any
16521
+ purpose with or without fee is hereby granted.
16522
+
16523
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16524
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16525
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16526
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16527
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16528
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16529
+ PERFORMANCE OF THIS SOFTWARE.
16530
+ ***************************************************************************** */
16531
+
16532
+ function __classPrivateFieldGet(receiver, state, kind, f) {
16533
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
16534
+ 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");
16535
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
16536
+ }
16537
+
16538
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
16539
+ if (kind === "m") throw new TypeError("Private method is not writable");
16540
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
16541
+ 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");
16542
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16543
+ }
16544
+
16554
16545
  var _MemoryRepository_resources, _MemoryRepository_history;
16555
16546
  class MemoryRepository {
16556
16547
  constructor() {
@@ -16560,7 +16551,6 @@ class MemoryRepository {
16560
16551
  __classPrivateFieldSet(this, _MemoryRepository_history, {}, "f");
16561
16552
  }
16562
16553
  createResource(resource) {
16563
- var _a, _b;
16564
16554
  const result = deepClone(resource);
16565
16555
  if (!result.id) {
16566
16556
  result.id = this.generateId();
@@ -16568,10 +16558,10 @@ class MemoryRepository {
16568
16558
  if (!result.meta) {
16569
16559
  result.meta = {};
16570
16560
  }
16571
- if (!((_a = result.meta) === null || _a === void 0 ? void 0 : _a.versionId)) {
16561
+ if (!result.meta?.versionId) {
16572
16562
  result.meta.versionId = this.generateId();
16573
16563
  }
16574
- if (!((_b = result.meta) === null || _b === void 0 ? void 0 : _b.lastUpdated)) {
16564
+ if (!result.meta?.lastUpdated) {
16575
16565
  result.meta.lastUpdated = new Date().toISOString();
16576
16566
  }
16577
16567
  const { resourceType, id } = result;
@@ -16600,56 +16590,48 @@ class MemoryRepository {
16600
16590
  }
16601
16591
  return this.createResource(result);
16602
16592
  }
16603
- patchResource(resourceType, id, patch) {
16604
- var _a, _b;
16605
- return __awaiter(this, void 0, void 0, function* () {
16606
- const resource = this.readResource(resourceType, id);
16607
- let patchResult;
16608
- try {
16609
- const { applyPatch } = yield import('fast-json-patch');
16610
- patchResult = applyPatch(resource, patch, true);
16611
- }
16612
- catch (err) {
16613
- const patchError = err;
16614
- const message = ((_b = (_a = patchError.message) === null || _a === void 0 ? void 0 : _a.split('\n')) === null || _b === void 0 ? void 0 : _b[0]) || 'JSONPatch error';
16615
- throw badRequest(message);
16616
- }
16617
- const patchedResource = patchResult.newDocument;
16618
- return this.updateResource(patchedResource);
16619
- });
16593
+ async patchResource(resourceType, id, patch) {
16594
+ const resource = this.readResource(resourceType, id);
16595
+ let patchResult;
16596
+ try {
16597
+ patchResult = applyPatch(resource, patch, true);
16598
+ }
16599
+ catch (err) {
16600
+ const patchError = err;
16601
+ const message = patchError.message?.split('\n')?.[0] || 'JSONPatch error';
16602
+ throw badRequest(message);
16603
+ }
16604
+ const patchedResource = patchResult.newDocument;
16605
+ return this.updateResource(patchedResource);
16620
16606
  }
16621
16607
  readResource(resourceType, id) {
16622
- var _a, _b;
16623
- const resource = (_b = (_a = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")) === null || _a === void 0 ? void 0 : _a[resourceType]) === null || _b === void 0 ? void 0 : _b[id];
16608
+ const resource = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")?.[resourceType]?.[id];
16624
16609
  if (!resource) {
16625
16610
  throw notFound;
16626
16611
  }
16627
16612
  return deepClone(resource);
16628
16613
  }
16629
16614
  readHistory(resourceType, id) {
16630
- var _a, _b, _c;
16631
16615
  this.readResource(resourceType, id);
16632
16616
  return {
16633
16617
  resourceType: 'Bundle',
16634
16618
  type: 'history',
16635
- entry: ((_c = (_b = (_a = __classPrivateFieldGet(this, _MemoryRepository_history, "f")) === null || _a === void 0 ? void 0 : _a[resourceType]) === null || _b === void 0 ? void 0 : _b[id]) !== null && _c !== void 0 ? _c : [])
16619
+ entry: (__classPrivateFieldGet(this, _MemoryRepository_history, "f")?.[resourceType]?.[id] ?? [])
16636
16620
  .reverse()
16637
16621
  .map((version) => ({ resource: deepClone(version) })),
16638
16622
  };
16639
16623
  }
16640
16624
  readVersion(resourceType, id, versionId) {
16641
- var _a, _b, _c;
16642
16625
  this.readResource(resourceType, id);
16643
- const version = (_c = (_b = (_a = __classPrivateFieldGet(this, _MemoryRepository_history, "f")) === null || _a === void 0 ? void 0 : _a[resourceType]) === null || _b === void 0 ? void 0 : _b[id]) === null || _c === void 0 ? void 0 : _c.find((v) => { var _a; return ((_a = v.meta) === null || _a === void 0 ? void 0 : _a.versionId) === versionId; });
16626
+ const version = __classPrivateFieldGet(this, _MemoryRepository_history, "f")?.[resourceType]?.[id]?.find((v) => v.meta?.versionId === versionId);
16644
16627
  if (!version) {
16645
16628
  throw notFound;
16646
16629
  }
16647
16630
  return deepClone(version);
16648
16631
  }
16649
16632
  search(searchRequest) {
16650
- var _a;
16651
16633
  const { resourceType } = searchRequest;
16652
- const resources = (_a = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType]) !== null && _a !== void 0 ? _a : {};
16634
+ const resources = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType] ?? {};
16653
16635
  const result = Object.values(resources).filter((resource) => matchesSearchRequest(resource, searchRequest));
16654
16636
  return {
16655
16637
  resourceType: 'Bundle',
@@ -16659,8 +16641,7 @@ class MemoryRepository {
16659
16641
  };
16660
16642
  }
16661
16643
  deleteResource(resourceType, id) {
16662
- var _a, _b;
16663
- if ((_b = (_a = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")) === null || _a === void 0 ? void 0 : _a[resourceType]) === null || _b === void 0 ? void 0 : _b[id]) {
16644
+ if (__classPrivateFieldGet(this, _MemoryRepository_resources, "f")?.[resourceType]?.[id]) {
16664
16645
  delete __classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType][id];
16665
16646
  }
16666
16647
  }
@@ -16680,7 +16661,7 @@ _MemoryRepository_resources = new WeakMap(), _MemoryRepository_history = new Wea
16680
16661
 
16681
16662
  class MockClient extends MedplumClient {
16682
16663
  constructor(clientOptions) {
16683
- const mockFetchClient = new MockFetchClient(clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug);
16664
+ const mockFetchClient = new MockFetchClient(clientOptions?.debug);
16684
16665
  super({
16685
16666
  baseUrl: 'https://example.com/',
16686
16667
  clientId: 'my-client-id',
@@ -16689,7 +16670,7 @@ class MockClient extends MedplumClient {
16689
16670
  return mockFetchClient.mockFetch(url, options);
16690
16671
  },
16691
16672
  });
16692
- this.debug = !!(clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug);
16673
+ this.debug = !!clientOptions?.debug;
16693
16674
  }
16694
16675
  clear() {
16695
16676
  super.clear();
@@ -16725,22 +16706,20 @@ class MockClient extends MedplumClient {
16725
16706
  }
16726
16707
  return super.getActiveLogin();
16727
16708
  }
16728
- createBinary(data, filename, contentType, onProgress) {
16729
- return __awaiter(this, void 0, void 0, function* () {
16730
- if (filename === null || filename === void 0 ? void 0 : filename.endsWith('.exe')) {
16731
- return Promise.reject(badRequest('Invalid file type'));
16732
- }
16733
- if (onProgress) {
16734
- onProgress({ loaded: 0, lengthComputable: false });
16735
- onProgress({ loaded: 0, total: 100, lengthComputable: true });
16736
- onProgress({ loaded: 100, total: 100, lengthComputable: true });
16737
- }
16738
- return {
16739
- resourceType: 'Binary',
16740
- contentType,
16741
- url: 'https://example.com/binary/123',
16742
- };
16743
- });
16709
+ async createBinary(data, filename, contentType, onProgress) {
16710
+ if (filename?.endsWith('.exe')) {
16711
+ return Promise.reject(badRequest('Invalid file type'));
16712
+ }
16713
+ if (onProgress) {
16714
+ onProgress({ loaded: 0, lengthComputable: false });
16715
+ onProgress({ loaded: 0, total: 100, lengthComputable: true });
16716
+ onProgress({ loaded: 100, total: 100, lengthComputable: true });
16717
+ }
16718
+ return {
16719
+ resourceType: 'Binary',
16720
+ contentType,
16721
+ url: 'https://example.com/binary/123',
16722
+ };
16744
16723
  }
16745
16724
  }
16746
16725
  class MockFetchClient {
@@ -16749,28 +16728,26 @@ class MockFetchClient {
16749
16728
  this.mockRepo = new MemoryRepository();
16750
16729
  this.initMockRepo();
16751
16730
  }
16752
- mockFetch(url, options) {
16753
- return __awaiter(this, void 0, void 0, function* () {
16754
- const method = options.method || 'GET';
16755
- const path = url.replace('https://example.com/', '');
16756
- if (this.debug) {
16757
- console.log('MockClient', method, path);
16758
- }
16759
- const response = yield this.mockHandler(method, path, options);
16760
- if (this.debug && !response) {
16761
- console.log('MockClient: not found', method, path);
16762
- }
16763
- if (this.debug) {
16764
- console.log('MockClient', JSON.stringify(response, null, 2));
16765
- }
16766
- if ((response === null || response === void 0 ? void 0 : response.resourceType) === 'OperationOutcome' && !isOk(response)) {
16767
- return Promise.reject(response);
16768
- }
16769
- return Promise.resolve({
16770
- ok: true,
16771
- blob: () => Promise.resolve(response),
16772
- json: () => Promise.resolve(response),
16773
- });
16731
+ async mockFetch(url, options) {
16732
+ const method = options.method || 'GET';
16733
+ const path = url.replace('https://example.com/', '');
16734
+ if (this.debug) {
16735
+ console.log('MockClient', method, path);
16736
+ }
16737
+ const response = await this.mockHandler(method, path, options);
16738
+ if (this.debug && !response) {
16739
+ console.log('MockClient: not found', method, path);
16740
+ }
16741
+ if (this.debug) {
16742
+ console.log('MockClient', JSON.stringify(response, null, 2));
16743
+ }
16744
+ if (response?.resourceType === 'OperationOutcome' && !isOk(response)) {
16745
+ return Promise.reject(response);
16746
+ }
16747
+ return Promise.resolve({
16748
+ ok: true,
16749
+ blob: () => Promise.resolve(response),
16750
+ json: () => Promise.resolve(response),
16774
16751
  });
16775
16752
  }
16776
16753
  mockCreatePdf(docDefinition, tableLayouts, fonts) {
@@ -16782,24 +16759,22 @@ class MockFetchClient {
16782
16759
  }
16783
16760
  return Promise.resolve({});
16784
16761
  }
16785
- mockHandler(method, path, options) {
16786
- return __awaiter(this, void 0, void 0, function* () {
16787
- if (path.startsWith('admin/')) {
16788
- return this.mockAdminHandler(method, path);
16789
- }
16790
- else if (path.startsWith('auth/')) {
16791
- return this.mockAuthHandler(method, path, options);
16792
- }
16793
- else if (path.startsWith('oauth2/')) {
16794
- return this.mockOAuthHandler(method, path, options);
16795
- }
16796
- else if (path.startsWith('fhir/R4')) {
16797
- return this.mockFhirHandler(method, path, options);
16798
- }
16799
- else {
16800
- return null;
16801
- }
16802
- });
16762
+ async mockHandler(method, path, options) {
16763
+ if (path.startsWith('admin/')) {
16764
+ return this.mockAdminHandler(method, path);
16765
+ }
16766
+ else if (path.startsWith('auth/')) {
16767
+ return this.mockAuthHandler(method, path, options);
16768
+ }
16769
+ else if (path.startsWith('oauth2/')) {
16770
+ return this.mockOAuthHandler(method, path, options);
16771
+ }
16772
+ else if (path.startsWith('fhir/R4')) {
16773
+ return this.mockFhirHandler(method, path, options);
16774
+ }
16775
+ else {
16776
+ return null;
16777
+ }
16803
16778
  }
16804
16779
  mockAdminHandler(_method, path) {
16805
16780
  if (path.startsWith('admin/projects/123')) {
@@ -16817,6 +16792,9 @@ class MockFetchClient {
16817
16792
  };
16818
16793
  }
16819
16794
  mockAuthHandler(method, path, options) {
16795
+ if (path.startsWith('auth/method')) {
16796
+ return {};
16797
+ }
16820
16798
  if (path.startsWith('auth/changepassword')) {
16821
16799
  return this.mockChangePasswordHandler(method, path, options);
16822
16800
  }
@@ -17028,67 +17006,65 @@ class MockFetchClient {
17028
17006
  this.mockRepo.createResource(ExampleSmartClientApplication);
17029
17007
  DrAliceSmithSlots.forEach((slot) => this.mockRepo.createResource(slot));
17030
17008
  }
17031
- mockFhirHandler(method, url, options) {
17032
- return __awaiter(this, void 0, void 0, function* () {
17033
- const path = url.includes('?') ? url.substring(0, url.indexOf('?')) : url;
17034
- const match = /fhir\/R4\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?/.exec(path);
17035
- const resourceType = match === null || match === void 0 ? void 0 : match[1];
17036
- const id = match === null || match === void 0 ? void 0 : match[2];
17037
- const operation = match === null || match === void 0 ? void 0 : match[3];
17038
- const versionId = match === null || match === void 0 ? void 0 : match[4];
17039
- if (path.startsWith('fhir/R4/ValueSet/$expand')) {
17040
- return exampleValueSet;
17009
+ async mockFhirHandler(method, url, options) {
17010
+ const path = url.includes('?') ? url.substring(0, url.indexOf('?')) : url;
17011
+ const match = /fhir\/R4\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?/.exec(path);
17012
+ const resourceType = match?.[1];
17013
+ const id = match?.[2];
17014
+ const operation = match?.[3];
17015
+ const versionId = match?.[4];
17016
+ if (path.startsWith('fhir/R4/ValueSet/$expand')) {
17017
+ return exampleValueSet;
17018
+ }
17019
+ else if (path === 'fhir/R4/$graphql') {
17020
+ return this.mockFhirGraphqlHandler(method, path, options);
17021
+ }
17022
+ else if (path === 'not-found' || id === 'not-found') {
17023
+ return notFound;
17024
+ }
17025
+ else if (method === 'POST') {
17026
+ if (resourceType && id && operation) {
17027
+ return allOk;
17041
17028
  }
17042
- else if (path === 'fhir/R4/$graphql') {
17043
- return this.mockFhirGraphqlHandler(method, path, options);
17029
+ else if (resourceType) {
17030
+ return this.mockRepo.createResource(JSON.parse(options.body));
17044
17031
  }
17045
- else if (path === 'not-found' || id === 'not-found') {
17046
- return notFound;
17032
+ else {
17033
+ return this.mockFhirBatchHandler(method, path, options);
17047
17034
  }
17048
- else if (method === 'POST') {
17049
- if (resourceType && id && operation) {
17050
- return allOk;
17051
- }
17052
- else if (resourceType) {
17053
- return this.mockRepo.createResource(JSON.parse(options.body));
17054
- }
17055
- else {
17056
- return this.mockFhirBatchHandler(method, path, options);
17057
- }
17035
+ }
17036
+ else if (method === 'GET') {
17037
+ if (resourceType && id && versionId) {
17038
+ return this.mockRepo.readVersion(resourceType, id, versionId);
17058
17039
  }
17059
- else if (method === 'GET') {
17060
- if (resourceType && id && versionId) {
17061
- return this.mockRepo.readVersion(resourceType, id, versionId);
17062
- }
17063
- else if (resourceType && id && operation === '_history') {
17064
- return this.mockRepo.readHistory(resourceType, id);
17065
- }
17066
- else if (resourceType && id === '$csv') {
17067
- return allOk;
17068
- }
17069
- else if (resourceType && id) {
17070
- return this.mockRepo.readResource(resourceType, id);
17071
- }
17072
- else if (resourceType) {
17073
- return this.mockRepo.search(parseSearchDefinition(url));
17074
- }
17040
+ else if (resourceType && id && operation === '_history') {
17041
+ return this.mockRepo.readHistory(resourceType, id);
17075
17042
  }
17076
- else if (method === 'PUT') {
17077
- return this.mockRepo.updateResource(JSON.parse(options.body));
17043
+ else if (resourceType && id === '$csv') {
17044
+ return allOk;
17078
17045
  }
17079
- else if (method === 'PATCH') {
17080
- if (resourceType && id) {
17081
- return this.mockRepo.patchResource(resourceType, id, JSON.parse(options.body));
17082
- }
17046
+ else if (resourceType && id) {
17047
+ return this.mockRepo.readResource(resourceType, id);
17083
17048
  }
17084
- else if (method === 'DELETE') {
17085
- if (resourceType && id) {
17086
- this.mockRepo.deleteResource(resourceType, id);
17087
- return allOk;
17088
- }
17049
+ else if (resourceType) {
17050
+ return this.mockRepo.search(parseSearchDefinition(url));
17089
17051
  }
17090
- throw notFound;
17091
- });
17052
+ }
17053
+ else if (method === 'PUT') {
17054
+ return this.mockRepo.updateResource(JSON.parse(options.body));
17055
+ }
17056
+ else if (method === 'PATCH') {
17057
+ if (resourceType && id) {
17058
+ return this.mockRepo.patchResource(resourceType, id, JSON.parse(options.body));
17059
+ }
17060
+ }
17061
+ else if (method === 'DELETE') {
17062
+ if (resourceType && id) {
17063
+ this.mockRepo.deleteResource(resourceType, id);
17064
+ return allOk;
17065
+ }
17066
+ }
17067
+ throw notFound;
17092
17068
  }
17093
17069
  mockFhirGraphqlHandler(_method, _path, options) {
17094
17070
  const { body } = options;
@@ -17096,72 +17072,70 @@ class MockFetchClient {
17096
17072
  return {
17097
17073
  data: {
17098
17074
  ResourceList: [
17099
- Object.assign(Object.assign({}, HomerServiceRequest), { ObservationList: [
17075
+ {
17076
+ ...HomerServiceRequest,
17077
+ ObservationList: [
17100
17078
  HomerObservation1,
17101
17079
  HomerObservation2,
17102
17080
  HomerObservation3,
17103
17081
  HomerObservation4,
17104
17082
  HomerObservation5,
17105
17083
  HomerObservation6,
17106
- ] }),
17084
+ ],
17085
+ },
17107
17086
  ],
17108
17087
  },
17109
17088
  };
17110
17089
  }
17111
17090
  return GraphQLSchemaResponse;
17112
17091
  }
17113
- mockFhirBatchHandler(_method, _path, options) {
17114
- return __awaiter(this, void 0, void 0, function* () {
17115
- const { body } = options;
17116
- const request = JSON.parse(body);
17117
- let entry;
17118
- if (request.entry) {
17119
- entry = [];
17120
- for (const input of request.entry) {
17121
- entry.push(yield this.handleBatchEntry(input));
17122
- }
17092
+ async mockFhirBatchHandler(_method, _path, options) {
17093
+ const { body } = options;
17094
+ const request = JSON.parse(body);
17095
+ let entry;
17096
+ if (request.entry) {
17097
+ entry = [];
17098
+ for (const input of request.entry) {
17099
+ entry.push(await this.handleBatchEntry(input));
17123
17100
  }
17124
- return {
17125
- resourceType: 'Bundle',
17126
- type: 'batch-response',
17127
- entry,
17128
- };
17129
- });
17101
+ }
17102
+ return {
17103
+ resourceType: 'Bundle',
17104
+ type: 'batch-response',
17105
+ entry,
17106
+ };
17130
17107
  }
17131
- handleBatchEntry(input) {
17132
- var _a, _b;
17133
- return __awaiter(this, void 0, void 0, function* () {
17134
- try {
17135
- const url = 'fhir/R4/' + ((_a = input.request) === null || _a === void 0 ? void 0 : _a.url);
17136
- const method = (_b = input.request) === null || _b === void 0 ? void 0 : _b.method;
17137
- const resource = yield this.mockHandler(method, url, {
17138
- body: input.resource ? JSON.stringify(input.resource) : undefined,
17139
- });
17140
- if ((resource === null || resource === void 0 ? void 0 : resource.resourceType) === 'OperationOutcome') {
17141
- return {
17142
- resource,
17143
- response: { status: getStatus(resource).toString() },
17144
- };
17145
- }
17146
- else if (resource) {
17147
- return { resource, response: { status: '200' } };
17148
- }
17149
- else {
17150
- return { resource: notFound, response: { status: '404' } };
17151
- }
17152
- }
17153
- catch (err) {
17154
- const outcome = err;
17108
+ async handleBatchEntry(input) {
17109
+ try {
17110
+ const url = 'fhir/R4/' + input.request?.url;
17111
+ const method = input.request?.method;
17112
+ const resource = await this.mockHandler(method, url, {
17113
+ body: input.resource ? JSON.stringify(input.resource) : undefined,
17114
+ });
17115
+ if (resource?.resourceType === 'OperationOutcome') {
17155
17116
  return {
17156
- response: {
17157
- status: getStatus(outcome).toString(),
17158
- outcome,
17159
- },
17117
+ resource,
17118
+ response: { status: getStatus(resource).toString() },
17160
17119
  };
17161
17120
  }
17162
- });
17121
+ else if (resource) {
17122
+ return { resource, response: { status: '200' } };
17123
+ }
17124
+ else {
17125
+ return { resource: notFound, response: { status: '404' } };
17126
+ }
17127
+ }
17128
+ catch (err) {
17129
+ const outcome = err;
17130
+ return {
17131
+ response: {
17132
+ status: getStatus(outcome).toString(),
17133
+ outcome,
17134
+ },
17135
+ };
17136
+ }
17163
17137
  }
17164
17138
  }
17165
17139
 
17166
17140
  export { BartSimpson, DifferentOrganization, DrAliceSmith, DrAliceSmithPreviousVersion, DrAliceSmithSchedule, DrAliceSmithSlots, ExampleAccessPolicy, ExampleAuditEvent, ExampleBot, ExampleClient, ExampleQuestionnaire, ExampleQuestionnaireResponse, ExampleStatusValueSet, ExampleSubscription, ExampleUserConfiguration, ExampleWorkflowPlanDefinition, ExampleWorkflowQuestionnaire1, ExampleWorkflowQuestionnaire2, ExampleWorkflowQuestionnaire3, ExampleWorkflowQuestionnaireResponse1, ExampleWorkflowRequestGroup, ExampleWorkflowTask1, ExampleWorkflowTask2, ExampleWorkflowTask3, GraphQLSchemaResponse, HomerBartRelatedPerson, HomerCommunication, HomerDiagnosticReport, HomerEncounter, HomerLisaRelatedPerson, HomerMedia, HomerObservation1, HomerObservation2, HomerObservation3, HomerObservation4, HomerObservation5, HomerObservation6, HomerObservation7, HomerObservation8, HomerServiceRequest, HomerSimpson, HomerSimpsonPreviousVersion, HomerSimpsonSpecimen, LisaSimpson, MargeSimpson, MockClient, SimpsonsFamily, TestOrganization, exampleValueSet };
17167
- //# sourceMappingURL=index.js.map
17141
+ //# sourceMappingURL=index.mjs.map