@medplum/core 0.9.21 → 0.9.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -6190,6 +6190,7 @@
6190
6190
  * Returns the current base URL for all API requests.
6191
6191
  * By default, this is set to `https://api.medplum.com/`.
6192
6192
  * This can be overridden by setting the `baseUrl` option when creating the client.
6193
+ * @category HTTP
6193
6194
  * @returns The current base URL for all API requests.
6194
6195
  */
6195
6196
  getBaseUrl() {
@@ -6197,6 +6198,7 @@
6197
6198
  }
6198
6199
  /**
6199
6200
  * Clears all auth state including local storage and session storage.
6201
+ * @category Authentication
6200
6202
  */
6201
6203
  clear() {
6202
6204
  __classPrivateFieldGet(this, _MedplumClient_storage, "f").clear();
@@ -6209,6 +6211,7 @@
6209
6211
  }
6210
6212
  /**
6211
6213
  * Invalidates any cached values or cached requests for the given URL.
6214
+ * @category Caching
6212
6215
  * @param url The URL to invalidate.
6213
6216
  */
6214
6217
  invalidateUrl(url) {
@@ -6217,6 +6220,7 @@
6217
6220
  }
6218
6221
  /**
6219
6222
  * Invalidates all cached search results or cached requests for the given resourceType.
6223
+ * @category Caching
6220
6224
  * @param resourceType The resource type to invalidate.
6221
6225
  */
6222
6226
  invalidateSearches(resourceType) {
@@ -6234,6 +6238,7 @@
6234
6238
  * For common operations, we recommend using higher level methods
6235
6239
  * such as `readResource()`, `search()`, etc.
6236
6240
  *
6241
+ * @category HTTP
6237
6242
  * @param url The target URL.
6238
6243
  * @param options Optional fetch options.
6239
6244
  * @returns Promise to the response content.
@@ -6255,6 +6260,7 @@
6255
6260
  * For common operations, we recommend using higher level methods
6256
6261
  * such as `createResource()`.
6257
6262
  *
6263
+ * @category HTTP
6258
6264
  * @param url The target URL.
6259
6265
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
6260
6266
  * @param contentType The content type to be included in the "Content-Type" header.
@@ -6279,6 +6285,7 @@
6279
6285
  * For common operations, we recommend using higher level methods
6280
6286
  * such as `updateResource()`.
6281
6287
  *
6288
+ * @category HTTP
6282
6289
  * @param url The target URL.
6283
6290
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
6284
6291
  * @param contentType The content type to be included in the "Content-Type" header.
@@ -6303,6 +6310,7 @@
6303
6310
  * For common operations, we recommend using higher level methods
6304
6311
  * such as `patchResource()`.
6305
6312
  *
6313
+ * @category HTTP
6306
6314
  * @param url The target URL.
6307
6315
  * @param operations Array of JSONPatch operations.
6308
6316
  * @param options Optional fetch options.
@@ -6318,10 +6326,12 @@
6318
6326
  /**
6319
6327
  * Makes an HTTP DELETE request to the specified URL.
6320
6328
  *
6329
+ *
6321
6330
  * This is a lower level method for custom requests.
6322
6331
  * For common operations, we recommend using higher level methods
6323
6332
  * such as `deleteResource()`.
6324
6333
  *
6334
+ * @category HTTP
6325
6335
  * @param url The target URL.
6326
6336
  * @param options Optional fetch options.
6327
6337
  * @returns Promise to the response content.
@@ -6333,6 +6343,7 @@
6333
6343
  }
6334
6344
  /**
6335
6345
  * Tries to register a new user.
6346
+ * @category Authentication
6336
6347
  * @param request The registration request.
6337
6348
  * @returns Promise to the authentication response.
6338
6349
  */
@@ -6344,6 +6355,7 @@
6344
6355
  }
6345
6356
  /**
6346
6357
  * Initiates a user login flow.
6358
+ * @category Authentication
6347
6359
  * @param loginRequest Login request including email and password.
6348
6360
  * @returns Promise to the authentication response.
6349
6361
  */
@@ -6358,6 +6370,7 @@
6358
6370
  * Tries to sign in with Google authentication.
6359
6371
  * The response parameter is the result of a Google authentication.
6360
6372
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
6373
+ * @category Authentication
6361
6374
  * @param loginRequest Login request including Google credential response.
6362
6375
  * @returns Promise to the authentication response.
6363
6376
  */
@@ -6371,6 +6384,7 @@
6371
6384
  /**
6372
6385
  * Signs out locally.
6373
6386
  * Does not invalidate tokens with the server.
6387
+ * @category Authentication
6374
6388
  */
6375
6389
  signOut() {
6376
6390
  this.clear();
@@ -6380,6 +6394,7 @@
6380
6394
  * Tries to sign in the user.
6381
6395
  * Returns true if the user is signed in.
6382
6396
  * This may result in navigating away to the sign in page.
6397
+ * @category Authentication
6383
6398
  */
6384
6399
  signInWithRedirect() {
6385
6400
  const urlParams = new URLSearchParams(window.location.search);
@@ -6395,6 +6410,7 @@
6395
6410
  /**
6396
6411
  * Tries to sign out the user.
6397
6412
  * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
6413
+ * @category Authentication
6398
6414
  */
6399
6415
  signOutWithRedirect() {
6400
6416
  window.location.assign(__classPrivateFieldGet(this, _MedplumClient_logoutUrl, "f"));
@@ -6402,6 +6418,7 @@
6402
6418
  /**
6403
6419
  * Builds a FHIR URL from a collection of URL path components.
6404
6420
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
6421
+ * @category HTTP
6405
6422
  * @param path The path component of the URL.
6406
6423
  * @returns The well-formed FHIR URL.
6407
6424
  */
@@ -6410,6 +6427,8 @@
6410
6427
  }
6411
6428
  /**
6412
6429
  * Builds a FHIR search URL from a search query or structured query object.
6430
+ * @category HTTP
6431
+ * @category Search
6413
6432
  * @param query The FHIR search query or structured query object.
6414
6433
  * @returns The well-formed FHIR URL.
6415
6434
  */
@@ -6457,6 +6476,7 @@
6457
6476
  *
6458
6477
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
6459
6478
  *
6479
+ * @category Search
6460
6480
  * @param query The search query as either a string or a structured search object.
6461
6481
  * @returns Promise to the search result bundle.
6462
6482
  */
@@ -6479,6 +6499,7 @@
6479
6499
  *
6480
6500
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
6481
6501
  *
6502
+ * @category Search
6482
6503
  * @param query The search query as either a string or a structured search object.
6483
6504
  * @returns Promise to the search result bundle.
6484
6505
  */
@@ -6511,6 +6532,7 @@
6511
6532
  *
6512
6533
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
6513
6534
  *
6535
+ * @category Search
6514
6536
  * @param query The search query as either a string or a structured search object.
6515
6537
  * @returns Promise to the search result bundle.
6516
6538
  */
@@ -6528,6 +6550,8 @@
6528
6550
  /**
6529
6551
  * Searches a ValueSet resource using the "expand" operation.
6530
6552
  * See: https://www.hl7.org/fhir/operation-valueset-expand.html
6553
+ *
6554
+ * @category Search
6531
6555
  * @param system The ValueSet system url.
6532
6556
  * @param filter The search string.
6533
6557
  * @returns Promise to expanded ValueSet.
@@ -6540,6 +6564,7 @@
6540
6564
  }
6541
6565
  /**
6542
6566
  * Returns a cached resource if it is available.
6567
+ * @category Caching
6543
6568
  * @param resourceType The FHIR resource type.
6544
6569
  * @param id The FHIR resource ID.
6545
6570
  * @returns The resource if it is available in the cache; undefined otherwise.
@@ -6551,6 +6576,7 @@
6551
6576
  }
6552
6577
  /**
6553
6578
  * Returns a cached resource if it is available.
6579
+ * @category Caching
6554
6580
  * @param resourceType The FHIR resource type.
6555
6581
  * @param id The FHIR resource ID.
6556
6582
  * @returns The resource if it is available in the cache; undefined otherwise.
@@ -6578,6 +6604,7 @@
6578
6604
  *
6579
6605
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
6580
6606
  *
6607
+ * @category Caching
6581
6608
  * @param resourceType The FHIR resource type.
6582
6609
  * @param id The resource ID.
6583
6610
  * @returns The resource if available; undefined otherwise.
@@ -6600,6 +6627,7 @@
6600
6627
  *
6601
6628
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
6602
6629
  *
6630
+ * @category Read
6603
6631
  * @param reference The FHIR reference object.
6604
6632
  * @returns The resource if available; undefined otherwise.
6605
6633
  */
@@ -6618,6 +6646,7 @@
6618
6646
  * Returns a cached schema for a resource type.
6619
6647
  * If the schema is not cached, returns undefined.
6620
6648
  * It is assumed that a client will call requestSchema before using this method.
6649
+ * @category Schema
6621
6650
  * @param resourceType The FHIR resource type.
6622
6651
  * @returns The schema if immediately available, undefined otherwise.
6623
6652
  * @deprecated Use globalSchema instead.
@@ -6628,6 +6657,7 @@
6628
6657
  /**
6629
6658
  * Requests the schema for a resource type.
6630
6659
  * If the schema is already cached, the promise is resolved immediately.
6660
+ * @category Schema
6631
6661
  * @param resourceType The FHIR resource type.
6632
6662
  * @returns Promise to a schema with the requested resource type.
6633
6663
  */
@@ -6689,6 +6719,7 @@
6689
6719
  *
6690
6720
  * See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
6691
6721
  *
6722
+ * @category Read
6692
6723
  * @param resourceType The FHIR resource type.
6693
6724
  * @param id The resource ID.
6694
6725
  * @returns Promise to the resource history.
@@ -6708,6 +6739,7 @@
6708
6739
  *
6709
6740
  * See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
6710
6741
  *
6742
+ * @category Read
6711
6743
  * @param resourceType The FHIR resource type.
6712
6744
  * @param id The resource ID.
6713
6745
  * @returns The resource if available; undefined otherwise.
@@ -6715,6 +6747,12 @@
6715
6747
  readVersion(resourceType, id, vid) {
6716
6748
  return this.get(this.fhirUrl(resourceType, id, '_history', vid));
6717
6749
  }
6750
+ /**
6751
+ *
6752
+ * @category Read
6753
+ * @param id The Patient Id
6754
+ * @returns A Bundle of all Resources related to the Patient
6755
+ */
6718
6756
  readPatientEverything(id) {
6719
6757
  return this.get(this.fhirUrl('Patient', id, '$everything'));
6720
6758
  }
@@ -6738,6 +6776,7 @@
6738
6776
  *
6739
6777
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
6740
6778
  *
6779
+ * @category Create
6741
6780
  * @param resource The FHIR resource to create.
6742
6781
  * @returns The result of the create operation.
6743
6782
  */
@@ -6782,6 +6821,7 @@
6782
6821
  *
6783
6822
  * See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
6784
6823
  *
6824
+ * @category Create
6785
6825
  * @param resource The FHIR resource to create.
6786
6826
  * @param query The search query for an equivalent resource.
6787
6827
  * @returns The result of the create operation.
@@ -6810,6 +6850,7 @@
6810
6850
  *
6811
6851
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
6812
6852
  *
6853
+ * @category Create
6813
6854
  * @param data The binary data to upload.
6814
6855
  * @param filename Optional filename for the binary.
6815
6856
  * @param contentType Content type for the binary.
@@ -6840,6 +6881,7 @@
6840
6881
  *
6841
6882
  * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
6842
6883
  *
6884
+ * @category Media
6843
6885
  * @param docDefinition The PDF document definition.
6844
6886
  * @returns The result of the create operation.
6845
6887
  */
@@ -6857,6 +6899,7 @@
6857
6899
  *
6858
6900
  * This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.
6859
6901
  *
6902
+ * @category Create
6860
6903
  * @param resource The FHIR resource to comment on.
6861
6904
  * @param text The text of the comment.
6862
6905
  * @returns The result of the create operation.
@@ -6907,6 +6950,7 @@
6907
6950
  *
6908
6951
  * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
6909
6952
  *
6953
+ * @category Write
6910
6954
  * @param resource The FHIR resource to update.
6911
6955
  * @returns The result of the update operation.
6912
6956
  */
@@ -6938,6 +6982,7 @@
6938
6982
  *
6939
6983
  * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
6940
6984
  *
6985
+ * @category Write
6941
6986
  * @param resourceType The FHIR resource type.
6942
6987
  * @param id The resource ID.
6943
6988
  * @param operations The JSONPatch operations.
@@ -6958,6 +7003,7 @@
6958
7003
  *
6959
7004
  * See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
6960
7005
  *
7006
+ * @category Delete
6961
7007
  * @param resourceType The FHIR resource type.
6962
7008
  * @param id The resource ID.
6963
7009
  * @returns The result of the delete operation.
@@ -7009,7 +7055,7 @@
7009
7055
  * ```
7010
7056
  *
7011
7057
  * See The FHIR "batch/transaction" section for full details: https://hl7.org/fhir/http.html#transaction
7012
- *
7058
+ * @category Batch
7013
7059
  * @param bundle The FHIR batch/transaction bundle.
7014
7060
  * @returns The FHIR batch/transaction response bundle.
7015
7061
  */
@@ -7049,7 +7095,7 @@
7049
7095
  * ```
7050
7096
  *
7051
7097
  * See options here: https://nodemailer.com/extras/mailcomposer/
7052
- *
7098
+ * @category Media
7053
7099
  * @param options The MailComposer options.
7054
7100
  * @returns Promise to the operation outcome.
7055
7101
  */
@@ -7097,6 +7143,7 @@
7097
7143
  *
7098
7144
  * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
7099
7145
  *
7146
+ * @category Read
7100
7147
  * @param query The GraphQL query.
7101
7148
  * @param operationName Optional GraphQL operation name.
7102
7149
  * @param variables Optional GraphQL variables.
@@ -7106,9 +7153,16 @@
7106
7153
  graphql(query, operationName, variables, options) {
7107
7154
  return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);
7108
7155
  }
7156
+ /**
7157
+ * @category Authentication
7158
+ * @returns The Login State
7159
+ */
7109
7160
  getActiveLogin() {
7110
7161
  return __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('activeLogin');
7111
7162
  }
7163
+ /**
7164
+ * @category Authentication
7165
+ */
7112
7166
  setActiveLogin(login) {
7113
7167
  return __awaiter(this, void 0, void 0, function* () {
7114
7168
  __classPrivateFieldSet(this, _MedplumClient_accessToken, login.accessToken, "f");
@@ -7122,25 +7176,43 @@
7122
7176
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
7123
7177
  });
7124
7178
  }
7179
+ /**
7180
+ * @category Authentication
7181
+ */
7125
7182
  getAccessToken() {
7126
7183
  return __classPrivateFieldGet(this, _MedplumClient_accessToken, "f");
7127
7184
  }
7185
+ /**
7186
+ * @category Authentication
7187
+ */
7128
7188
  setAccessToken(accessToken) {
7129
7189
  __classPrivateFieldSet(this, _MedplumClient_accessToken, accessToken, "f");
7130
7190
  __classPrivateFieldSet(this, _MedplumClient_refreshToken, undefined, "f");
7131
7191
  __classPrivateFieldSet(this, _MedplumClient_profile, undefined, "f");
7132
7192
  __classPrivateFieldSet(this, _MedplumClient_config, undefined, "f");
7133
7193
  }
7194
+ /**
7195
+ * @category Authentication
7196
+ */
7134
7197
  getLogins() {
7135
7198
  var _a;
7136
7199
  return (_a = __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('logins')) !== null && _a !== void 0 ? _a : [];
7137
7200
  }
7201
+ /**
7202
+ * @category Authentication
7203
+ */
7138
7204
  isLoading() {
7139
7205
  return !!__classPrivateFieldGet(this, _MedplumClient_profilePromise, "f");
7140
7206
  }
7207
+ /**
7208
+ * @category User Profile
7209
+ */
7141
7210
  getProfile() {
7142
7211
  return __classPrivateFieldGet(this, _MedplumClient_profile, "f");
7143
7212
  }
7213
+ /**
7214
+ * @category User Profile
7215
+ */
7144
7216
  getProfileAsync() {
7145
7217
  return __awaiter(this, void 0, void 0, function* () {
7146
7218
  if (__classPrivateFieldGet(this, _MedplumClient_profilePromise, "f")) {
@@ -7149,11 +7221,16 @@
7149
7221
  return this.getProfile();
7150
7222
  });
7151
7223
  }
7224
+ /**
7225
+ * @category User Profile
7226
+ */
7152
7227
  getUserConfiguration() {
7153
7228
  return __classPrivateFieldGet(this, _MedplumClient_config, "f");
7154
7229
  }
7155
7230
  /**
7156
7231
  * Downloads the URL as a blob.
7232
+ *
7233
+ * @category Read
7157
7234
  * @param url The URL to request.
7158
7235
  * @returns Promise to the response body as a blob.
7159
7236
  */
@@ -7194,6 +7271,7 @@
7194
7271
  /**
7195
7272
  * Starts a new OAuth2 client credentials flow.
7196
7273
  * See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
7274
+ * @category Authentication
7197
7275
  * @param clientId The client ID.
7198
7276
  * @param clientSecret The client secret.
7199
7277
  * @returns Promise that resolves to the client profile.
@@ -7401,6 +7479,7 @@
7401
7479
  };
7402
7480
  /**
7403
7481
  * Returns the base URL for the current page.
7482
+ * @category HTTP
7404
7483
  */
7405
7484
  function getBaseUrl() {
7406
7485
  return window.location.protocol + '//' + window.location.host + '/';