@medplum/core 0.9.18 → 0.9.21

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
@@ -6342,22 +6342,24 @@ class MedplumClient extends EventTarget {
6342
6342
  * @returns Promise to the authentication response.
6343
6343
  */
6344
6344
  startLogin(loginRequest) {
6345
+ var _a, _b;
6345
6346
  return __awaiter(this, void 0, void 0, function* () {
6346
6347
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
6347
- return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: DEFAULT_SCOPE, codeChallengeMethod: 'S256', codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
6348
+ return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: 'S256', codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
6348
6349
  });
6349
6350
  }
6350
6351
  /**
6351
6352
  * Tries to sign in with Google authentication.
6352
6353
  * The response parameter is the result of a Google authentication.
6353
6354
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
6354
- * @param googleResponse The Google credential response.
6355
+ * @param loginRequest Login request including Google credential response.
6355
6356
  * @returns Promise to the authentication response.
6356
6357
  */
6357
- startGoogleLogin(googleResponse) {
6358
+ startGoogleLogin(loginRequest) {
6359
+ var _a, _b;
6358
6360
  return __awaiter(this, void 0, void 0, function* () {
6359
6361
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
6360
- return this.post('auth/google', googleResponse);
6362
+ return this.post('auth/google', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE }));
6361
6363
  });
6362
6364
  }
6363
6365
  /**
@@ -6958,6 +6960,56 @@ class MedplumClient extends EventTarget {
6958
6960
  this.invalidateSearches(resourceType);
6959
6961
  return this.delete(this.fhirUrl(resourceType, id));
6960
6962
  }
6963
+ /**
6964
+ * Executes a batch or transaction of FHIR operations.
6965
+ *
6966
+ * Example:
6967
+ *
6968
+ * ```typescript
6969
+ * await medplum.executeBatch({
6970
+ * "resourceType": "Bundle",
6971
+ * "type": "transaction",
6972
+ * "entry": [
6973
+ * {
6974
+ * "fullUrl": "urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a",
6975
+ * "resource": {
6976
+ * "resourceType": "Patient",
6977
+ * "name": [{ "use": "official", "given": ["Alice"], "family": "Smith" }],
6978
+ * "gender": "female",
6979
+ * "birthDate": "1974-12-25"
6980
+ * },
6981
+ * "request": {
6982
+ * "method": "POST",
6983
+ * "url": "Patient"
6984
+ * }
6985
+ * },
6986
+ * {
6987
+ * "fullUrl": "urn:uuid:88f151c0-a954-468a-88bd-5ae15c08e059",
6988
+ * "resource": {
6989
+ * "resourceType": "Patient",
6990
+ * "identifier": [{ "system": "http:/example.org/fhir/ids", "value": "234234" }],
6991
+ * "name": [{ "use": "official", "given": ["Bob"], "family": "Jones" }],
6992
+ * "gender": "male",
6993
+ * "birthDate": "1974-12-25"
6994
+ * },
6995
+ * "request": {
6996
+ * "method": "POST",
6997
+ * "url": "Patient",
6998
+ * "ifNoneExist": "identifier=http:/example.org/fhir/ids|234234"
6999
+ * }
7000
+ * }
7001
+ * ]
7002
+ * });
7003
+ * ```
7004
+ *
7005
+ * See The FHIR "batch/transaction" section for full details: https://hl7.org/fhir/http.html#transaction
7006
+ *
7007
+ * @param bundle The FHIR batch/transaction bundle.
7008
+ * @returns The FHIR batch/transaction response bundle.
7009
+ */
7010
+ executeBatch(bundle) {
7011
+ return this.post('fhir/R4', bundle);
7012
+ }
6961
7013
  /**
6962
7014
  * Sends an email using the Medplum Email API.
6963
7015
  *
@@ -6998,8 +7050,55 @@ class MedplumClient extends EventTarget {
6998
7050
  sendEmail(email) {
6999
7051
  return this.post('email/v1/send', email, 'application/json');
7000
7052
  }
7001
- graphql(query, options) {
7002
- return this.post(this.fhirUrl('$graphql'), { query }, JSON_CONTENT_TYPE, options);
7053
+ /**
7054
+ * Executes a GraphQL query.
7055
+ *
7056
+ * Example:
7057
+ *
7058
+ * ```typescript
7059
+ * const result = await medplum.graphql(`{
7060
+ * Patient(id: "123") {
7061
+ * resourceType
7062
+ * id
7063
+ * name {
7064
+ * given
7065
+ * family
7066
+ * }
7067
+ * }
7068
+ * }`);
7069
+ * ```
7070
+ *
7071
+ * Advanced queries such as named operations and variable substitution are supported:
7072
+ *
7073
+ * ```typescript
7074
+ * const result = await medplum.graphql(
7075
+ * `query GetPatientById($patientId: ID!) {
7076
+ * Patient(id: $patientId) {
7077
+ * resourceType
7078
+ * id
7079
+ * name {
7080
+ * given
7081
+ * family
7082
+ * }
7083
+ * }
7084
+ * }`,
7085
+ * 'GetPatientById',
7086
+ * { patientId: '123' }
7087
+ * );
7088
+ * ```
7089
+ *
7090
+ * See the GraphQL documentation for more details: https://graphql.org/learn/
7091
+ *
7092
+ * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
7093
+ *
7094
+ * @param query The GraphQL query.
7095
+ * @param operationName Optional GraphQL operation name.
7096
+ * @param variables Optional GraphQL variables.
7097
+ * @param options Optional fetch options.
7098
+ * @returns The GraphQL result.
7099
+ */
7100
+ graphql(query, operationName, variables, options) {
7101
+ return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);
7003
7102
  }
7004
7103
  getActiveLogin() {
7005
7104
  return __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('activeLogin');