@medplum/core 1.0.0 → 1.0.1

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.
@@ -8,6 +8,7 @@ export interface SearchRequest {
8
8
  fields?: string[];
9
9
  name?: string;
10
10
  total?: 'none' | 'estimate' | 'accurate';
11
+ revInclude?: string;
11
12
  }
12
13
  export interface Filter {
13
14
  code: string;
@@ -203,6 +203,13 @@ export declare function findObservationReferenceRange(definition: ObservationDef
203
203
  * @returns True if the value is within the range.
204
204
  */
205
205
  export declare function matchesRange(value: number, range: Range, precision?: number): boolean;
206
+ /**
207
+ * Returns the input number rounded to the specified number of digits.
208
+ * @param a The input number.
209
+ * @param precision The precision in number of digits.
210
+ * @returns The number rounded to the specified number of digits.
211
+ */
212
+ export declare function preciseRound(a: number, precision: number): number;
206
213
  /**
207
214
  * Returns true if the two numbers are equal to the given precision.
208
215
  * @param a The first number.
@@ -136,10 +136,7 @@ export interface CreatePdfFunction {
136
136
  [name: string]: CustomTableLayout;
137
137
  } | undefined, fonts?: TFontDictionary | undefined): Promise<any>;
138
138
  }
139
- export interface LoginRequest {
140
- readonly email: string;
141
- readonly password: string;
142
- readonly remember?: boolean;
139
+ export interface BaseLoginRequest {
143
140
  readonly projectId?: string;
144
141
  readonly clientId?: string;
145
142
  readonly resourceType?: string;
@@ -147,6 +144,13 @@ export interface LoginRequest {
147
144
  readonly nonce?: string;
148
145
  readonly codeChallenge?: string;
149
146
  readonly codeChallengeMethod?: string;
147
+ readonly googleClientId?: string;
148
+ readonly launch?: string;
149
+ }
150
+ export interface EmailPasswordLoginRequest extends BaseLoginRequest {
151
+ readonly email: string;
152
+ readonly password: string;
153
+ readonly remember?: boolean;
150
154
  }
151
155
  export interface NewUserRequest {
152
156
  readonly firstName: string;
@@ -170,16 +174,9 @@ export interface GoogleCredentialResponse {
170
174
  readonly clientId: string;
171
175
  readonly credential: string;
172
176
  }
173
- export interface GoogleLoginRequest {
177
+ export interface GoogleLoginRequest extends BaseLoginRequest {
174
178
  readonly googleClientId: string;
175
179
  readonly googleCredential: string;
176
- readonly projectId?: string;
177
- readonly clientId?: string;
178
- readonly resourceType?: string;
179
- readonly scope?: string;
180
- readonly nonce?: string;
181
- readonly codeChallenge?: string;
182
- readonly codeChallengeMethod?: string;
183
180
  readonly createUser?: boolean;
184
181
  }
185
182
  export interface LoginAuthenticationResponse {
@@ -318,6 +315,11 @@ export interface MailOptions {
318
315
  * const bundle = await medplum.search('Patient', 'name=Alice');
319
316
  * console.log(bundle.total);
320
317
  * ```
318
+ *
319
+ * <head>
320
+ * <meta name="algolia:pageRank" content="100" />
321
+ * </head>
322
+
321
323
  */
322
324
  export declare class MedplumClient extends EventTarget {
323
325
  #private;
@@ -454,7 +456,7 @@ export declare class MedplumClient extends EventTarget {
454
456
  * @param loginRequest Login request including email and password.
455
457
  * @returns Promise to the authentication response.
456
458
  */
457
- startLogin(loginRequest: LoginRequest): Promise<LoginAuthenticationResponse>;
459
+ startLogin(loginRequest: EmailPasswordLoginRequest): Promise<LoginAuthenticationResponse>;
458
460
  /**
459
461
  * Tries to sign in with Google authentication.
460
462
  * The response parameter is the result of a Google authentication.
@@ -464,7 +466,7 @@ export declare class MedplumClient extends EventTarget {
464
466
  * @returns Promise to the authentication response.
465
467
  */
466
468
  startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse>;
467
- getCodeChallenge(loginRequest: LoginRequest | GoogleLoginRequest): {
469
+ getCodeChallenge(loginRequest: BaseLoginRequest): {
468
470
  codeChallenge?: string;
469
471
  codeChallengeMethod?: string;
470
472
  };
@@ -724,6 +726,16 @@ export declare class MedplumClient extends EventTarget {
724
726
  */
725
727
  readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
726
728
  /**
729
+ * Executes the Patient "everything" operation for a patient.
730
+ *
731
+ * Example:
732
+ *
733
+ * ```typescript
734
+ * const bundle = await medplum.readPatientEverything('123');
735
+ * console.log(bundle);
736
+ * ```
737
+ *
738
+ * See the FHIR "patient-everything" operation for full details: https://hl7.org/fhir/operation-patient-everything.html
727
739
  *
728
740
  * @category Read
729
741
  * @param id The Patient Id
@@ -11,9 +11,8 @@ import { createReference, arrayBufferToBase64 } from './utils.js';
11
11
  // PKCE auth based on:
12
12
  // https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
13
13
  var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_clientId, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
14
- const MEDPLUM_VERSION = "1.0.0-a614a88a";
14
+ const MEDPLUM_VERSION = "1.0.1-69d972ca";
15
15
  const DEFAULT_BASE_URL = 'https://api.medplum.com/';
16
- const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
17
16
  const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
18
17
  const DEFAULT_CACHE_TIME = 60000; // 60 seconds
19
18
  const JSON_CONTENT_TYPE = 'application/json';
@@ -65,6 +64,11 @@ const PATCH_CONTENT_TYPE = 'application/json-patch+json';
65
64
  * const bundle = await medplum.search('Patient', 'name=Alice');
66
65
  * console.log(bundle.total);
67
66
  * ```
67
+ *
68
+ * <head>
69
+ * <meta name="algolia:pageRank" content="100" />
70
+ * </head>
71
+
68
72
  */
69
73
  class MedplumClient extends EventTarget {
70
74
  constructor(options) {
@@ -317,10 +321,10 @@ class MedplumClient extends EventTarget {
317
321
  * @returns Promise to the authentication response.
318
322
  */
319
323
  startLogin(loginRequest) {
320
- var _a, _b;
324
+ var _a;
321
325
  return __awaiter(this, void 0, void 0, function* () {
322
326
  const { codeChallenge, codeChallengeMethod } = this.getCodeChallenge(loginRequest);
323
- 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,
327
+ 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: loginRequest.scope, codeChallengeMethod,
324
328
  codeChallenge }));
325
329
  });
326
330
  }
@@ -333,10 +337,10 @@ class MedplumClient extends EventTarget {
333
337
  * @returns Promise to the authentication response.
334
338
  */
335
339
  startGoogleLogin(loginRequest) {
336
- var _a, _b;
340
+ var _a;
337
341
  return __awaiter(this, void 0, void 0, function* () {
338
342
  const { codeChallenge, codeChallengeMethod } = this.getCodeChallenge(loginRequest);
339
- 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, codeChallengeMethod,
343
+ 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: loginRequest.scope, codeChallengeMethod,
340
344
  codeChallenge }));
341
345
  });
342
346
  }
@@ -740,6 +744,16 @@ class MedplumClient extends EventTarget {
740
744
  return this.get(this.fhirUrl(resourceType, id, '_history', vid), options);
741
745
  }
742
746
  /**
747
+ * Executes the Patient "everything" operation for a patient.
748
+ *
749
+ * Example:
750
+ *
751
+ * ```typescript
752
+ * const bundle = await medplum.readPatientEverything('123');
753
+ * console.log(bundle);
754
+ * ```
755
+ *
756
+ * See the FHIR "patient-everything" operation for full details: https://hl7.org/fhir/operation-patient-everything.html
743
757
  *
744
758
  * @category Read
745
759
  * @param id The Patient Id
@@ -1470,7 +1484,6 @@ _MedplumClient_fetch = new WeakMap(), _MedplumClient_createPdf = new WeakMap(),
1470
1484
  url.searchParams.set('state', sessionStorage.getItem('pkceState'));
1471
1485
  url.searchParams.set('client_id', __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
1472
1486
  url.searchParams.set('redirect_uri', getBaseUrl());
1473
- url.searchParams.set('scope', DEFAULT_SCOPE);
1474
1487
  url.searchParams.set('code_challenge_method', 'S256');
1475
1488
  url.searchParams.set('code_challenge', sessionStorage.getItem('codeChallenge'));
1476
1489
  window.location.assign(url.toString());