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