@medplum/mock 2.0.1 → 2.0.3

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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@medplum/core'), require('fast-json-patch')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@medplum/core', 'fast-json-patch'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.medplum = global.medplum || {}, global.medplum.mock = {}), global.medplum.core, global["fast-json-patch"]));
5
- })(this, (function (exports, core, fastJsonPatch) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@medplum/core'), require('rfc6902')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@medplum/core', 'rfc6902'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.medplum = global.medplum || {}, global.medplum.mock = {}), global.medplum.core, global.rfc6902));
5
+ })(this, (function (exports, core, rfc6902) { 'use strict';
6
6
 
7
7
  const ExampleAccessPolicy = {
8
8
  resourceType: 'AccessPolicy',
@@ -16595,17 +16595,14 @@
16595
16595
  }
16596
16596
  async patchResource(resourceType, id, patch) {
16597
16597
  const resource = this.readResource(resourceType, id);
16598
- let patchResult;
16599
- try {
16600
- patchResult = fastJsonPatch.applyPatch(resource, patch, true);
16601
- }
16602
- catch (err) {
16603
- const patchError = err;
16604
- const message = patchError.message?.split('\n')?.[0] || 'JSONPatch error';
16605
- throw core.badRequest(message);
16598
+ const patchErrors = rfc6902.applyPatch(resource, patch);
16599
+ for (const error of patchErrors) {
16600
+ if (error) {
16601
+ const message = error.message?.split('\n')?.[0] || 'JSONPatch error';
16602
+ throw core.badRequest(message);
16603
+ }
16606
16604
  }
16607
- const patchedResource = patchResult.newDocument;
16608
- return this.updateResource(patchedResource);
16605
+ return this.updateResource(resource);
16609
16606
  }
16610
16607
  readResource(resourceType, id) {
16611
16608
  const resource = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")?.[resourceType]?.[id];
@@ -16688,7 +16685,11 @@
16688
16685
  menu: [
16689
16686
  {
16690
16687
  title: 'Favorites',
16691
- link: [{ name: 'Patients', target: '/Patient' }],
16688
+ link: [
16689
+ { name: 'Patients', target: '/Patient' },
16690
+ { name: 'Active Orders', target: '/ServiceRequest?status=active' },
16691
+ { name: 'Completed Orders', target: '/ServiceRequest?status=completed' },
16692
+ ],
16692
16693
  },
16693
16694
  {
16694
16695
  title: 'Admin',
@@ -16749,6 +16750,7 @@
16749
16750
  }
16750
16751
  return Promise.resolve({
16751
16752
  ok: true,
16753
+ status: response?.resourceType === 'OperationOutcome' ? core.getStatus(response) : 200,
16752
16754
  blob: () => Promise.resolve(response),
16753
16755
  json: () => Promise.resolve(response),
16754
16756
  });