@medplum/mock 0.9.29 → 0.9.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,5 +1,42 @@
1
- import { createReference, getReferenceString, deepClone, badRequest, notFound, evalFhirPath, Operator, MedplumClient, isOk, allOk, parseSearchDefinition, getStatus } from '@medplum/core';
2
- import { applyPatch } from 'fast-json-patch';
1
+ import { createReference, getReferenceString, deepClone, badRequest, notFound, evalFhirPath, Operator, 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
+ }
3
40
 
4
41
  const ExampleAccessPolicy = {
5
42
  resourceType: 'AccessPolicy',
@@ -6715,10 +6752,256 @@ var StructureDefinitionList = [
6715
6752
  ]
6716
6753
  }
6717
6754
  },
6755
+ {
6756
+ resourceType: "StructureDefinition",
6757
+ id: "Project",
6758
+ name: "Project",
6759
+ type: "Project",
6760
+ snapshot: {
6761
+ element: [
6762
+ {
6763
+ id: "Project.id",
6764
+ path: "Project.id",
6765
+ min: 0,
6766
+ max: "1",
6767
+ type: [
6768
+ {
6769
+ code: "string"
6770
+ }
6771
+ ]
6772
+ },
6773
+ {
6774
+ id: "Project.meta",
6775
+ path: "Project.meta",
6776
+ min: 0,
6777
+ max: "1",
6778
+ type: [
6779
+ {
6780
+ code: "Meta"
6781
+ }
6782
+ ]
6783
+ },
6784
+ {
6785
+ id: "Project.implicitRules",
6786
+ path: "Project.implicitRules",
6787
+ min: 0,
6788
+ max: "1",
6789
+ type: [
6790
+ {
6791
+ code: "uri"
6792
+ }
6793
+ ]
6794
+ },
6795
+ {
6796
+ id: "Project.language",
6797
+ path: "Project.language",
6798
+ min: 0,
6799
+ max: "1",
6800
+ type: [
6801
+ {
6802
+ code: "code"
6803
+ }
6804
+ ]
6805
+ },
6806
+ {
6807
+ id: "Project.name",
6808
+ path: "Project.name",
6809
+ min: 0,
6810
+ max: "1",
6811
+ type: [
6812
+ {
6813
+ code: "string"
6814
+ }
6815
+ ]
6816
+ },
6817
+ {
6818
+ id: "Project.description",
6819
+ path: "Project.description",
6820
+ min: 0,
6821
+ max: "1",
6822
+ type: [
6823
+ {
6824
+ code: "string"
6825
+ }
6826
+ ]
6827
+ },
6828
+ {
6829
+ id: "Project.superAdmin",
6830
+ path: "Project.superAdmin",
6831
+ min: 0,
6832
+ max: "1",
6833
+ type: [
6834
+ {
6835
+ code: "boolean"
6836
+ }
6837
+ ]
6838
+ },
6839
+ {
6840
+ id: "Project.owner",
6841
+ path: "Project.owner",
6842
+ min: 0,
6843
+ max: "1",
6844
+ type: [
6845
+ {
6846
+ code: "Reference",
6847
+ targetProfile: [
6848
+ "https://medplum.com/fhir/StructureDefinition/User"
6849
+ ]
6850
+ }
6851
+ ]
6852
+ },
6853
+ {
6854
+ id: "Project.features",
6855
+ path: "Project.features",
6856
+ min: 0,
6857
+ max: "*",
6858
+ type: [
6859
+ {
6860
+ code: "code"
6861
+ }
6862
+ ]
6863
+ },
6864
+ {
6865
+ id: "Project.defaultPatientAccessPolicy",
6866
+ path: "Project.defaultPatientAccessPolicy",
6867
+ min: 0,
6868
+ max: "1",
6869
+ type: [
6870
+ {
6871
+ code: "Reference",
6872
+ targetProfile: [
6873
+ "https://medplum.com/fhir/StructureDefinition/AccessPolicy"
6874
+ ]
6875
+ }
6876
+ ]
6877
+ },
6878
+ {
6879
+ id: "Project.secret",
6880
+ path: "Project.secret",
6881
+ min: 0,
6882
+ max: "*",
6883
+ type: [
6884
+ {
6885
+ code: "BackboneElement"
6886
+ }
6887
+ ]
6888
+ },
6889
+ {
6890
+ id: "Project.secret.name",
6891
+ path: "Project.secret.name",
6892
+ min: 1,
6893
+ max: "1",
6894
+ type: [
6895
+ {
6896
+ code: "string"
6897
+ }
6898
+ ]
6899
+ },
6900
+ {
6901
+ id: "Project.secret.value[x]",
6902
+ path: "Project.secret.value[x]",
6903
+ min: 1,
6904
+ max: "1",
6905
+ type: [
6906
+ {
6907
+ code: "string"
6908
+ },
6909
+ {
6910
+ code: "boolean"
6911
+ },
6912
+ {
6913
+ code: "decimal"
6914
+ },
6915
+ {
6916
+ code: "integer"
6917
+ }
6918
+ ]
6919
+ },
6920
+ {
6921
+ id: "Project.site",
6922
+ path: "Project.site",
6923
+ min: 0,
6924
+ max: "*",
6925
+ type: [
6926
+ {
6927
+ code: "BackboneElement"
6928
+ }
6929
+ ]
6930
+ },
6931
+ {
6932
+ id: "Project.site.name",
6933
+ path: "Project.site.name",
6934
+ min: 1,
6935
+ max: "1",
6936
+ type: [
6937
+ {
6938
+ code: "string"
6939
+ }
6940
+ ]
6941
+ },
6942
+ {
6943
+ id: "Project.site.domain",
6944
+ path: "Project.site.domain",
6945
+ min: 1,
6946
+ max: "*",
6947
+ type: [
6948
+ {
6949
+ code: "string"
6950
+ }
6951
+ ]
6952
+ },
6953
+ {
6954
+ id: "Project.site.googleClientId",
6955
+ path: "Project.site.googleClientId",
6956
+ min: 0,
6957
+ max: "1",
6958
+ type: [
6959
+ {
6960
+ code: "string"
6961
+ }
6962
+ ]
6963
+ },
6964
+ {
6965
+ id: "Project.site.googleClientSecret",
6966
+ path: "Project.site.googleClientSecret",
6967
+ min: 0,
6968
+ max: "1",
6969
+ type: [
6970
+ {
6971
+ code: "string"
6972
+ }
6973
+ ]
6974
+ },
6975
+ {
6976
+ id: "Project.site.recaptchaSiteKey",
6977
+ path: "Project.site.recaptchaSiteKey",
6978
+ min: 0,
6979
+ max: "1",
6980
+ type: [
6981
+ {
6982
+ code: "string"
6983
+ }
6984
+ ]
6985
+ },
6986
+ {
6987
+ id: "Project.site.recaptchaSecretKey",
6988
+ path: "Project.site.recaptchaSecretKey",
6989
+ min: 0,
6990
+ max: "1",
6991
+ type: [
6992
+ {
6993
+ code: "string"
6994
+ }
6995
+ ]
6996
+ }
6997
+ ]
6998
+ }
6999
+ },
6718
7000
  {
6719
7001
  resourceType: "StructureDefinition",
6720
7002
  id: "Bot",
6721
7003
  name: "Bot",
7004
+ type: "Bot",
6722
7005
  snapshot: {
6723
7006
  element: [
6724
7007
  {
@@ -7096,34 +7379,6 @@ const ExampleWorkflowRequestGroup = {
7096
7379
  ],
7097
7380
  };
7098
7381
 
7099
- /******************************************************************************
7100
- Copyright (c) Microsoft Corporation.
7101
-
7102
- Permission to use, copy, modify, and/or distribute this software for any
7103
- purpose with or without fee is hereby granted.
7104
-
7105
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7106
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
7107
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
7108
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
7109
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
7110
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
7111
- PERFORMANCE OF THIS SOFTWARE.
7112
- ***************************************************************************** */
7113
-
7114
- function __classPrivateFieldGet(receiver, state, kind, f) {
7115
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
7116
- 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");
7117
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7118
- }
7119
-
7120
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
7121
- if (kind === "m") throw new TypeError("Private method is not writable");
7122
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
7123
- 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");
7124
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7125
- }
7126
-
7127
7382
  var _MemoryRepository_resources, _MemoryRepository_history;
7128
7383
  class MemoryRepository {
7129
7384
  constructor() {
@@ -7175,18 +7430,21 @@ class MemoryRepository {
7175
7430
  }
7176
7431
  patchResource(resourceType, id, patch) {
7177
7432
  var _a, _b;
7178
- const resource = this.readResource(resourceType, id);
7179
- let patchResult;
7180
- try {
7181
- patchResult = applyPatch(resource, patch, true);
7182
- }
7183
- catch (err) {
7184
- const patchError = err;
7185
- 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';
7186
- throw badRequest(message);
7187
- }
7188
- const patchedResource = patchResult.newDocument;
7189
- return this.updateResource(patchedResource);
7433
+ return __awaiter(this, void 0, void 0, function* () {
7434
+ const resource = this.readResource(resourceType, id);
7435
+ let patchResult;
7436
+ try {
7437
+ const { applyPatch } = yield import('fast-json-patch');
7438
+ patchResult = applyPatch(resource, patch, true);
7439
+ }
7440
+ catch (err) {
7441
+ const patchError = err;
7442
+ 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';
7443
+ throw badRequest(message);
7444
+ }
7445
+ const patchedResource = patchResult.newDocument;
7446
+ return this.updateResource(patchedResource);
7447
+ });
7190
7448
  }
7191
7449
  readResource(resourceType, id) {
7192
7450
  var _a, _b;
@@ -7354,25 +7612,27 @@ class MockFetchClient {
7354
7612
  this.initMockRepo();
7355
7613
  }
7356
7614
  mockFetch(url, options) {
7357
- const method = options.method || 'GET';
7358
- const path = url.replace('https://example.com/', '');
7359
- if (this.debug) {
7360
- console.log('MockClient', method, path);
7361
- }
7362
- const response = this.mockHandler(method, path, options);
7363
- if (this.debug && !response) {
7364
- console.log('MockClient: not found', method, path);
7365
- }
7366
- if (this.debug) {
7367
- console.log('MockClient', JSON.stringify(response, null, 2));
7368
- }
7369
- if ((response === null || response === void 0 ? void 0 : response.resourceType) === 'OperationOutcome' && !isOk(response)) {
7370
- return Promise.reject(response);
7371
- }
7372
- return Promise.resolve({
7373
- ok: true,
7374
- blob: () => Promise.resolve(response),
7375
- json: () => Promise.resolve(response),
7615
+ return __awaiter(this, void 0, void 0, function* () {
7616
+ const method = options.method || 'GET';
7617
+ const path = url.replace('https://example.com/', '');
7618
+ if (this.debug) {
7619
+ console.log('MockClient', method, path);
7620
+ }
7621
+ const response = yield this.mockHandler(method, path, options);
7622
+ if (this.debug && !response) {
7623
+ console.log('MockClient: not found', method, path);
7624
+ }
7625
+ if (this.debug) {
7626
+ console.log('MockClient', JSON.stringify(response, null, 2));
7627
+ }
7628
+ if ((response === null || response === void 0 ? void 0 : response.resourceType) === 'OperationOutcome' && !isOk(response)) {
7629
+ return Promise.reject(response);
7630
+ }
7631
+ return Promise.resolve({
7632
+ ok: true,
7633
+ blob: () => Promise.resolve(response),
7634
+ json: () => Promise.resolve(response),
7635
+ });
7376
7636
  });
7377
7637
  }
7378
7638
  mockCreatePdf(docDefinition, tableLayouts, fonts) {
@@ -7385,21 +7645,23 @@ class MockFetchClient {
7385
7645
  return Promise.resolve({});
7386
7646
  }
7387
7647
  mockHandler(method, path, options) {
7388
- if (path.startsWith('admin/')) {
7389
- return this.mockAdminHandler(method, path);
7390
- }
7391
- else if (path.startsWith('auth/')) {
7392
- return this.mockAuthHandler(method, path, options);
7393
- }
7394
- else if (path.startsWith('oauth2/')) {
7395
- return this.mockOAuthHandler(method, path, options);
7396
- }
7397
- else if (path.startsWith('fhir/R4')) {
7398
- return this.mockFhirHandler(method, path, options);
7399
- }
7400
- else {
7401
- return null;
7402
- }
7648
+ return __awaiter(this, void 0, void 0, function* () {
7649
+ if (path.startsWith('admin/')) {
7650
+ return this.mockAdminHandler(method, path);
7651
+ }
7652
+ else if (path.startsWith('auth/')) {
7653
+ return this.mockAuthHandler(method, path, options);
7654
+ }
7655
+ else if (path.startsWith('oauth2/')) {
7656
+ return this.mockOAuthHandler(method, path, options);
7657
+ }
7658
+ else if (path.startsWith('fhir/R4')) {
7659
+ return this.mockFhirHandler(method, path, options);
7660
+ }
7661
+ else {
7662
+ return null;
7663
+ }
7664
+ });
7403
7665
  }
7404
7666
  mockAdminHandler(_method, path) {
7405
7667
  if (path.startsWith('admin/projects/123')) {
@@ -7594,64 +7856,66 @@ class MockFetchClient {
7594
7856
  DrAliceSmithSlots.forEach((slot) => this.mockRepo.createResource(slot));
7595
7857
  }
7596
7858
  mockFhirHandler(method, url, options) {
7597
- const path = url.includes('?') ? url.substring(0, url.indexOf('?')) : url;
7598
- const match = /fhir\/R4\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?/.exec(path);
7599
- const resourceType = match === null || match === void 0 ? void 0 : match[1];
7600
- const id = match === null || match === void 0 ? void 0 : match[2];
7601
- const operation = match === null || match === void 0 ? void 0 : match[3];
7602
- const versionId = match === null || match === void 0 ? void 0 : match[4];
7603
- if (path.startsWith('fhir/R4/ValueSet/$expand')) {
7604
- return exampleValueSet;
7605
- }
7606
- else if (path === 'fhir/R4/$graphql') {
7607
- return this.mockFhirGraphqlHandler(method, path, options);
7608
- }
7609
- else if (path === 'not-found' || id === 'not-found') {
7610
- return notFound;
7611
- }
7612
- else if (method === 'POST') {
7613
- if (resourceType && id && operation) {
7614
- return allOk;
7615
- }
7616
- else if (resourceType) {
7617
- return this.mockRepo.createResource(JSON.parse(options.body));
7859
+ return __awaiter(this, void 0, void 0, function* () {
7860
+ const path = url.includes('?') ? url.substring(0, url.indexOf('?')) : url;
7861
+ const match = /fhir\/R4\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?/.exec(path);
7862
+ const resourceType = match === null || match === void 0 ? void 0 : match[1];
7863
+ const id = match === null || match === void 0 ? void 0 : match[2];
7864
+ const operation = match === null || match === void 0 ? void 0 : match[3];
7865
+ const versionId = match === null || match === void 0 ? void 0 : match[4];
7866
+ if (path.startsWith('fhir/R4/ValueSet/$expand')) {
7867
+ return exampleValueSet;
7618
7868
  }
7619
- else {
7620
- return this.mockFhirBatchHandler(method, path, options);
7621
- }
7622
- }
7623
- else if (method === 'GET') {
7624
- if (resourceType && id && versionId) {
7625
- return this.mockRepo.readVersion(resourceType, id, versionId);
7869
+ else if (path === 'fhir/R4/$graphql') {
7870
+ return this.mockFhirGraphqlHandler(method, path, options);
7626
7871
  }
7627
- else if (resourceType && id && operation === '_history') {
7628
- return this.mockRepo.readHistory(resourceType, id);
7872
+ else if (path === 'not-found' || id === 'not-found') {
7873
+ return notFound;
7629
7874
  }
7630
- else if (resourceType && id === '$csv') {
7631
- return allOk;
7875
+ else if (method === 'POST') {
7876
+ if (resourceType && id && operation) {
7877
+ return allOk;
7878
+ }
7879
+ else if (resourceType) {
7880
+ return this.mockRepo.createResource(JSON.parse(options.body));
7881
+ }
7882
+ else {
7883
+ return this.mockFhirBatchHandler(method, path, options);
7884
+ }
7632
7885
  }
7633
- else if (resourceType && id) {
7634
- return this.mockRepo.readResource(resourceType, id);
7886
+ else if (method === 'GET') {
7887
+ if (resourceType && id && versionId) {
7888
+ return this.mockRepo.readVersion(resourceType, id, versionId);
7889
+ }
7890
+ else if (resourceType && id && operation === '_history') {
7891
+ return this.mockRepo.readHistory(resourceType, id);
7892
+ }
7893
+ else if (resourceType && id === '$csv') {
7894
+ return allOk;
7895
+ }
7896
+ else if (resourceType && id) {
7897
+ return this.mockRepo.readResource(resourceType, id);
7898
+ }
7899
+ else if (resourceType) {
7900
+ return this.mockRepo.search(parseSearchDefinition(url));
7901
+ }
7635
7902
  }
7636
- else if (resourceType) {
7637
- return this.mockRepo.search(parseSearchDefinition(url));
7903
+ else if (method === 'PUT') {
7904
+ return this.mockRepo.updateResource(JSON.parse(options.body));
7638
7905
  }
7639
- }
7640
- else if (method === 'PUT') {
7641
- return this.mockRepo.updateResource(JSON.parse(options.body));
7642
- }
7643
- else if (method === 'PATCH') {
7644
- if (resourceType && id) {
7645
- return this.mockRepo.patchResource(resourceType, id, JSON.parse(options.body));
7906
+ else if (method === 'PATCH') {
7907
+ if (resourceType && id) {
7908
+ return this.mockRepo.patchResource(resourceType, id, JSON.parse(options.body));
7909
+ }
7646
7910
  }
7647
- }
7648
- else if (method === 'DELETE') {
7649
- if (resourceType && id) {
7650
- this.mockRepo.deleteResource(resourceType, id);
7651
- return allOk;
7911
+ else if (method === 'DELETE') {
7912
+ if (resourceType && id) {
7913
+ this.mockRepo.deleteResource(resourceType, id);
7914
+ return allOk;
7915
+ }
7652
7916
  }
7653
- }
7654
- throw notFound;
7917
+ throw notFound;
7918
+ });
7655
7919
  }
7656
7920
  mockFhirGraphqlHandler(_method, _path, options) {
7657
7921
  const { body } = options;
@@ -7674,45 +7938,55 @@ class MockFetchClient {
7674
7938
  return GraphQLSchemaResponse;
7675
7939
  }
7676
7940
  mockFhirBatchHandler(_method, _path, options) {
7677
- var _a;
7678
- const { body } = options;
7679
- const request = JSON.parse(body);
7680
- return {
7681
- resourceType: 'Bundle',
7682
- type: 'batch-response',
7683
- entry: (_a = request.entry) === null || _a === void 0 ? void 0 : _a.map((e) => this.handleBatchEntry(e)),
7684
- };
7941
+ return __awaiter(this, void 0, void 0, function* () {
7942
+ const { body } = options;
7943
+ const request = JSON.parse(body);
7944
+ let entry;
7945
+ if (request.entry) {
7946
+ entry = [];
7947
+ for (const input of request.entry) {
7948
+ entry.push(yield this.handleBatchEntry(input));
7949
+ }
7950
+ }
7951
+ return {
7952
+ resourceType: 'Bundle',
7953
+ type: 'batch-response',
7954
+ entry,
7955
+ };
7956
+ });
7685
7957
  }
7686
7958
  handleBatchEntry(input) {
7687
7959
  var _a, _b;
7688
- try {
7689
- const url = 'fhir/R4/' + ((_a = input.request) === null || _a === void 0 ? void 0 : _a.url);
7690
- const method = (_b = input.request) === null || _b === void 0 ? void 0 : _b.method;
7691
- const resource = this.mockHandler(method, url, {
7692
- body: input.resource ? JSON.stringify(input.resource) : undefined,
7693
- });
7694
- if ((resource === null || resource === void 0 ? void 0 : resource.resourceType) === 'OperationOutcome') {
7960
+ return __awaiter(this, void 0, void 0, function* () {
7961
+ try {
7962
+ const url = 'fhir/R4/' + ((_a = input.request) === null || _a === void 0 ? void 0 : _a.url);
7963
+ const method = (_b = input.request) === null || _b === void 0 ? void 0 : _b.method;
7964
+ const resource = yield this.mockHandler(method, url, {
7965
+ body: input.resource ? JSON.stringify(input.resource) : undefined,
7966
+ });
7967
+ if ((resource === null || resource === void 0 ? void 0 : resource.resourceType) === 'OperationOutcome') {
7968
+ return {
7969
+ resource,
7970
+ response: { status: getStatus(resource).toString() },
7971
+ };
7972
+ }
7973
+ else if (resource) {
7974
+ return { resource, response: { status: '200' } };
7975
+ }
7976
+ else {
7977
+ return { resource: notFound, response: { status: '404' } };
7978
+ }
7979
+ }
7980
+ catch (err) {
7981
+ const outcome = err;
7695
7982
  return {
7696
- resource,
7697
- response: { status: getStatus(resource).toString() },
7983
+ response: {
7984
+ status: getStatus(outcome).toString(),
7985
+ outcome,
7986
+ },
7698
7987
  };
7699
7988
  }
7700
- else if (resource) {
7701
- return { resource, response: { status: '200' } };
7702
- }
7703
- else {
7704
- return { resource: notFound, response: { status: '404' } };
7705
- }
7706
- }
7707
- catch (err) {
7708
- const outcome = err;
7709
- return {
7710
- response: {
7711
- status: getStatus(outcome).toString(),
7712
- outcome,
7713
- },
7714
- };
7715
- }
7989
+ });
7716
7990
  }
7717
7991
  }
7718
7992