@medplum/core 0.9.21 → 0.9.24

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.
@@ -145,13 +145,13 @@ export interface LoginRequest {
145
145
  readonly nonce?: string;
146
146
  }
147
147
  export interface RegisterRequest {
148
+ readonly projectName?: string;
148
149
  readonly firstName: string;
149
150
  readonly lastName: string;
150
- readonly projectName: string;
151
151
  readonly email: string;
152
- readonly password: string;
152
+ readonly password?: string;
153
153
  readonly remember?: boolean;
154
- readonly recaptchaToken: string;
154
+ readonly recaptchaToken?: string;
155
155
  }
156
156
  export interface GoogleCredentialResponse {
157
157
  readonly clientId: string;
@@ -307,20 +307,24 @@ export declare class MedplumClient extends EventTarget {
307
307
  * Returns the current base URL for all API requests.
308
308
  * By default, this is set to `https://api.medplum.com/`.
309
309
  * This can be overridden by setting the `baseUrl` option when creating the client.
310
+ * @category HTTP
310
311
  * @returns The current base URL for all API requests.
311
312
  */
312
313
  getBaseUrl(): string;
313
314
  /**
314
315
  * Clears all auth state including local storage and session storage.
316
+ * @category Authentication
315
317
  */
316
318
  clear(): void;
317
319
  /**
318
320
  * Invalidates any cached values or cached requests for the given URL.
321
+ * @category Caching
319
322
  * @param url The URL to invalidate.
320
323
  */
321
324
  invalidateUrl(url: URL | string): void;
322
325
  /**
323
326
  * Invalidates all cached search results or cached requests for the given resourceType.
327
+ * @category Caching
324
328
  * @param resourceType The resource type to invalidate.
325
329
  */
326
330
  invalidateSearches<K extends ResourceType>(resourceType: K): void;
@@ -331,6 +335,7 @@ export declare class MedplumClient extends EventTarget {
331
335
  * For common operations, we recommend using higher level methods
332
336
  * such as `readResource()`, `search()`, etc.
333
337
  *
338
+ * @category HTTP
334
339
  * @param url The target URL.
335
340
  * @param options Optional fetch options.
336
341
  * @returns Promise to the response content.
@@ -343,6 +348,7 @@ export declare class MedplumClient extends EventTarget {
343
348
  * For common operations, we recommend using higher level methods
344
349
  * such as `createResource()`.
345
350
  *
351
+ * @category HTTP
346
352
  * @param url The target URL.
347
353
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
348
354
  * @param contentType The content type to be included in the "Content-Type" header.
@@ -357,6 +363,7 @@ export declare class MedplumClient extends EventTarget {
357
363
  * For common operations, we recommend using higher level methods
358
364
  * such as `updateResource()`.
359
365
  *
366
+ * @category HTTP
360
367
  * @param url The target URL.
361
368
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
362
369
  * @param contentType The content type to be included in the "Content-Type" header.
@@ -371,6 +378,7 @@ export declare class MedplumClient extends EventTarget {
371
378
  * For common operations, we recommend using higher level methods
372
379
  * such as `patchResource()`.
373
380
  *
381
+ * @category HTTP
374
382
  * @param url The target URL.
375
383
  * @param operations Array of JSONPatch operations.
376
384
  * @param options Optional fetch options.
@@ -380,23 +388,52 @@ export declare class MedplumClient extends EventTarget {
380
388
  /**
381
389
  * Makes an HTTP DELETE request to the specified URL.
382
390
  *
391
+ *
383
392
  * This is a lower level method for custom requests.
384
393
  * For common operations, we recommend using higher level methods
385
394
  * such as `deleteResource()`.
386
395
  *
396
+ * @category HTTP
387
397
  * @param url The target URL.
388
398
  * @param options Optional fetch options.
389
399
  * @returns Promise to the response content.
390
400
  */
391
401
  delete(url: URL | string, options?: RequestInit): Promise<any>;
392
402
  /**
393
- * Tries to register a new user.
394
- * @param request The registration request.
403
+ * Initiates a new user flow.
404
+ *
405
+ * This method is part of the two different user registration flows:
406
+ * 1) New Practitioner and new Project
407
+ * 2) New Patient registration
408
+ *
409
+ * @category Authentication
410
+ * @param registerRequest Register request including email and password.
411
+ * @returns Promise to the authentication response.
412
+ */
413
+ startNewUser(registerRequest: RegisterRequest): Promise<LoginAuthenticationResponse>;
414
+ /**
415
+ * Initiates a new project flow.
416
+ *
417
+ * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
418
+ *
419
+ * @param registerRequest Register request including email and password.
420
+ * @param login The partial login to complete. This should come from the `startNewUser` method.
421
+ * @returns Promise to the authentication response.
422
+ */
423
+ startNewProject(registerRequest: RegisterRequest, login: LoginAuthenticationResponse): Promise<LoginAuthenticationResponse>;
424
+ /**
425
+ * Initiates a new patient flow.
426
+ *
427
+ * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
428
+ *
429
+ * @param registerRequest Register request including email and password.
430
+ * @param login The partial login to complete. This should come from the `startNewUser` method.
395
431
  * @returns Promise to the authentication response.
396
432
  */
397
- register(request: RegisterRequest): Promise<void>;
433
+ startNewPatient(registerRequest: RegisterRequest, login: LoginAuthenticationResponse): Promise<LoginAuthenticationResponse>;
398
434
  /**
399
435
  * Initiates a user login flow.
436
+ * @category Authentication
400
437
  * @param loginRequest Login request including email and password.
401
438
  * @returns Promise to the authentication response.
402
439
  */
@@ -405,6 +442,7 @@ export declare class MedplumClient extends EventTarget {
405
442
  * Tries to sign in with Google authentication.
406
443
  * The response parameter is the result of a Google authentication.
407
444
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
445
+ * @category Authentication
408
446
  * @param loginRequest Login request including Google credential response.
409
447
  * @returns Promise to the authentication response.
410
448
  */
@@ -412,28 +450,34 @@ export declare class MedplumClient extends EventTarget {
412
450
  /**
413
451
  * Signs out locally.
414
452
  * Does not invalidate tokens with the server.
453
+ * @category Authentication
415
454
  */
416
455
  signOut(): Promise<void>;
417
456
  /**
418
457
  * Tries to sign in the user.
419
458
  * Returns true if the user is signed in.
420
459
  * This may result in navigating away to the sign in page.
460
+ * @category Authentication
421
461
  */
422
462
  signInWithRedirect(): Promise<ProfileResource | void> | undefined;
423
463
  /**
424
464
  * Tries to sign out the user.
425
465
  * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
466
+ * @category Authentication
426
467
  */
427
468
  signOutWithRedirect(): void;
428
469
  /**
429
470
  * Builds a FHIR URL from a collection of URL path components.
430
471
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
472
+ * @category HTTP
431
473
  * @param path The path component of the URL.
432
474
  * @returns The well-formed FHIR URL.
433
475
  */
434
476
  fhirUrl(...path: string[]): URL;
435
477
  /**
436
478
  * Builds a FHIR search URL from a search query or structured query object.
479
+ * @category HTTP
480
+ * @category Search
437
481
  * @param query The FHIR search query or structured query object.
438
482
  * @returns The well-formed FHIR URL.
439
483
  */
@@ -475,6 +519,7 @@ export declare class MedplumClient extends EventTarget {
475
519
  *
476
520
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
477
521
  *
522
+ * @category Search
478
523
  * @param query The search query as either a string or a structured search object.
479
524
  * @returns Promise to the search result bundle.
480
525
  */
@@ -495,6 +540,7 @@ export declare class MedplumClient extends EventTarget {
495
540
  *
496
541
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
497
542
  *
543
+ * @category Search
498
544
  * @param query The search query as either a string or a structured search object.
499
545
  * @returns Promise to the search result bundle.
500
546
  */
@@ -515,6 +561,7 @@ export declare class MedplumClient extends EventTarget {
515
561
  *
516
562
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
517
563
  *
564
+ * @category Search
518
565
  * @param query The search query as either a string or a structured search object.
519
566
  * @returns Promise to the search result bundle.
520
567
  */
@@ -522,6 +569,8 @@ export declare class MedplumClient extends EventTarget {
522
569
  /**
523
570
  * Searches a ValueSet resource using the "expand" operation.
524
571
  * See: https://www.hl7.org/fhir/operation-valueset-expand.html
572
+ *
573
+ * @category Search
525
574
  * @param system The ValueSet system url.
526
575
  * @param filter The search string.
527
576
  * @returns Promise to expanded ValueSet.
@@ -529,6 +578,7 @@ export declare class MedplumClient extends EventTarget {
529
578
  searchValueSet(system: string, filter: string, options?: RequestInit): ReadablePromise<ValueSet>;
530
579
  /**
531
580
  * Returns a cached resource if it is available.
581
+ * @category Caching
532
582
  * @param resourceType The FHIR resource type.
533
583
  * @param id The FHIR resource ID.
534
584
  * @returns The resource if it is available in the cache; undefined otherwise.
@@ -536,6 +586,7 @@ export declare class MedplumClient extends EventTarget {
536
586
  getCached<K extends ResourceType>(resourceType: K, id: string): ExtractResource<K> | undefined;
537
587
  /**
538
588
  * Returns a cached resource if it is available.
589
+ * @category Caching
539
590
  * @param resourceType The FHIR resource type.
540
591
  * @param id The FHIR resource ID.
541
592
  * @returns The resource if it is available in the cache; undefined otherwise.
@@ -553,6 +604,7 @@ export declare class MedplumClient extends EventTarget {
553
604
  *
554
605
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
555
606
  *
607
+ * @category Caching
556
608
  * @param resourceType The FHIR resource type.
557
609
  * @param id The resource ID.
558
610
  * @returns The resource if available; undefined otherwise.
@@ -573,6 +625,7 @@ export declare class MedplumClient extends EventTarget {
573
625
  *
574
626
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
575
627
  *
628
+ * @category Read
576
629
  * @param reference The FHIR reference object.
577
630
  * @returns The resource if available; undefined otherwise.
578
631
  */
@@ -581,6 +634,7 @@ export declare class MedplumClient extends EventTarget {
581
634
  * Returns a cached schema for a resource type.
582
635
  * If the schema is not cached, returns undefined.
583
636
  * It is assumed that a client will call requestSchema before using this method.
637
+ * @category Schema
584
638
  * @param resourceType The FHIR resource type.
585
639
  * @returns The schema if immediately available, undefined otherwise.
586
640
  * @deprecated Use globalSchema instead.
@@ -589,6 +643,7 @@ export declare class MedplumClient extends EventTarget {
589
643
  /**
590
644
  * Requests the schema for a resource type.
591
645
  * If the schema is already cached, the promise is resolved immediately.
646
+ * @category Schema
592
647
  * @param resourceType The FHIR resource type.
593
648
  * @returns Promise to a schema with the requested resource type.
594
649
  */
@@ -607,6 +662,7 @@ export declare class MedplumClient extends EventTarget {
607
662
  *
608
663
  * See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
609
664
  *
665
+ * @category Read
610
666
  * @param resourceType The FHIR resource type.
611
667
  * @param id The resource ID.
612
668
  * @returns Promise to the resource history.
@@ -624,11 +680,18 @@ export declare class MedplumClient extends EventTarget {
624
680
  *
625
681
  * See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
626
682
  *
683
+ * @category Read
627
684
  * @param resourceType The FHIR resource type.
628
685
  * @param id The resource ID.
629
686
  * @returns The resource if available; undefined otherwise.
630
687
  */
631
688
  readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string): ReadablePromise<ExtractResource<K>>;
689
+ /**
690
+ *
691
+ * @category Read
692
+ * @param id The Patient Id
693
+ * @returns A Bundle of all Resources related to the Patient
694
+ */
632
695
  readPatientEverything(id: string): ReadablePromise<Bundle>;
633
696
  /**
634
697
  * Creates a new FHIR resource.
@@ -650,6 +713,7 @@ export declare class MedplumClient extends EventTarget {
650
713
  *
651
714
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
652
715
  *
716
+ * @category Create
653
717
  * @param resource The FHIR resource to create.
654
718
  * @returns The result of the create operation.
655
719
  */
@@ -688,6 +752,7 @@ export declare class MedplumClient extends EventTarget {
688
752
  *
689
753
  * See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
690
754
  *
755
+ * @category Create
691
756
  * @param resource The FHIR resource to create.
692
757
  * @param query The search query for an equivalent resource.
693
758
  * @returns The result of the create operation.
@@ -711,6 +776,7 @@ export declare class MedplumClient extends EventTarget {
711
776
  *
712
777
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
713
778
  *
779
+ * @category Create
714
780
  * @param data The binary data to upload.
715
781
  * @param filename Optional filename for the binary.
716
782
  * @param contentType Content type for the binary.
@@ -735,6 +801,7 @@ export declare class MedplumClient extends EventTarget {
735
801
  *
736
802
  * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
737
803
  *
804
+ * @category Media
738
805
  * @param docDefinition The PDF document definition.
739
806
  * @returns The result of the create operation.
740
807
  */
@@ -746,6 +813,7 @@ export declare class MedplumClient extends EventTarget {
746
813
  *
747
814
  * This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.
748
815
  *
816
+ * @category Create
749
817
  * @param resource The FHIR resource to comment on.
750
818
  * @param text The text of the comment.
751
819
  * @returns The result of the create operation.
@@ -772,6 +840,7 @@ export declare class MedplumClient extends EventTarget {
772
840
  *
773
841
  * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
774
842
  *
843
+ * @category Write
775
844
  * @param resource The FHIR resource to update.
776
845
  * @returns The result of the update operation.
777
846
  */
@@ -794,6 +863,7 @@ export declare class MedplumClient extends EventTarget {
794
863
  *
795
864
  * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
796
865
  *
866
+ * @category Write
797
867
  * @param resourceType The FHIR resource type.
798
868
  * @param id The resource ID.
799
869
  * @param operations The JSONPatch operations.
@@ -811,6 +881,7 @@ export declare class MedplumClient extends EventTarget {
811
881
  *
812
882
  * See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
813
883
  *
884
+ * @category Delete
814
885
  * @param resourceType The FHIR resource type.
815
886
  * @param id The resource ID.
816
887
  * @returns The result of the delete operation.
@@ -859,7 +930,7 @@ export declare class MedplumClient extends EventTarget {
859
930
  * ```
860
931
  *
861
932
  * See The FHIR "batch/transaction" section for full details: https://hl7.org/fhir/http.html#transaction
862
- *
933
+ * @category Batch
863
934
  * @param bundle The FHIR batch/transaction bundle.
864
935
  * @returns The FHIR batch/transaction response bundle.
865
936
  */
@@ -897,7 +968,7 @@ export declare class MedplumClient extends EventTarget {
897
968
  * ```
898
969
  *
899
970
  * See options here: https://nodemailer.com/extras/mailcomposer/
900
- *
971
+ * @category Media
901
972
  * @param options The MailComposer options.
902
973
  * @returns Promise to the operation outcome.
903
974
  */
@@ -943,6 +1014,7 @@ export declare class MedplumClient extends EventTarget {
943
1014
  *
944
1015
  * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
945
1016
  *
1017
+ * @category Read
946
1018
  * @param query The GraphQL query.
947
1019
  * @param operationName Optional GraphQL operation name.
948
1020
  * @param variables Optional GraphQL variables.
@@ -950,17 +1022,47 @@ export declare class MedplumClient extends EventTarget {
950
1022
  * @returns The GraphQL result.
951
1023
  */
952
1024
  graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any>;
1025
+ /**
1026
+ * @category Authentication
1027
+ * @returns The Login State
1028
+ */
953
1029
  getActiveLogin(): LoginState | undefined;
1030
+ /**
1031
+ * @category Authentication
1032
+ */
954
1033
  setActiveLogin(login: LoginState): Promise<void>;
1034
+ /**
1035
+ * @category Authentication
1036
+ */
955
1037
  getAccessToken(): string | undefined;
1038
+ /**
1039
+ * @category Authentication
1040
+ */
956
1041
  setAccessToken(accessToken: string): void;
1042
+ /**
1043
+ * @category Authentication
1044
+ */
957
1045
  getLogins(): LoginState[];
1046
+ /**
1047
+ * @category Authentication
1048
+ */
958
1049
  isLoading(): boolean;
1050
+ /**
1051
+ * @category User Profile
1052
+ */
959
1053
  getProfile(): ProfileResource | undefined;
1054
+ /**
1055
+ * @category User Profile
1056
+ */
960
1057
  getProfileAsync(): Promise<ProfileResource | undefined>;
1058
+ /**
1059
+ * @category User Profile
1060
+ */
961
1061
  getUserConfiguration(): UserConfiguration | undefined;
962
1062
  /**
963
1063
  * Downloads the URL as a blob.
1064
+ *
1065
+ * @category Read
964
1066
  * @param url The URL to request.
965
1067
  * @returns Promise to the response body as a blob.
966
1068
  */
@@ -974,6 +1076,7 @@ export declare class MedplumClient extends EventTarget {
974
1076
  /**
975
1077
  * Starts a new OAuth2 client credentials flow.
976
1078
  * See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
1079
+ * @category Authentication
977
1080
  * @param clientId The client ID.
978
1081
  * @param clientSecret The client secret.
979
1082
  * @returns Promise that resolves to the client profile.
@@ -3,6 +3,7 @@ export * from './client';
3
3
  export * from './fhirpath';
4
4
  export * from './format';
5
5
  export * from './hl7';
6
+ export * from './jwt';
6
7
  export * from './outcomes';
7
8
  export * from './readablepromise';
8
9
  export * from './search';
@@ -1,4 +1,7 @@
1
1
  import { CodeableConcept, ObservationDefinition, ObservationDefinitionQualifiedInterval, Patient, Practitioner, QuestionnaireResponse, QuestionnaireResponseItemAnswer, Range, Reference, RelatedPerson, Resource } from '@medplum/fhirtypes';
2
+ /**
3
+ * @internal
4
+ */
2
5
  export declare type ProfileResource = Patient | Practitioner | RelatedPerson;
3
6
  /**
4
7
  * Creates a reference resource.
@@ -163,6 +166,14 @@ export declare function setCodeBySystem(concept: CodeableConcept, system: string
163
166
  * @returns The observation interval if found; otherwise undefined.
164
167
  */
165
168
  export declare function findObservationInterval(definition: ObservationDefinition, patient: Patient, value: number, category?: 'reference' | 'critical' | 'absolute'): ObservationDefinitionQualifiedInterval | undefined;
169
+ /**
170
+ * Tries to find an observation reference range for the given patient and condition names.
171
+ * @param definition The observation definition.
172
+ * @param patient The patient.
173
+ * @param names The condition names.
174
+ * @returns The observation interval if found; otherwise undefined.
175
+ */
176
+ export declare function findObservationReferenceRange(definition: ObservationDefinition, patient: Patient, names: string[]): ObservationDefinitionQualifiedInterval | undefined;
166
177
  /**
167
178
  * Returns true if the value is in the range accounting for precision.
168
179
  * @param value The numeric value.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "0.9.21",
3
+ "version": "0.9.24",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -17,8 +17,8 @@
17
17
  "test": "jest"
18
18
  },
19
19
  "devDependencies": {
20
- "@medplum/definitions": "0.9.21",
21
- "@medplum/fhirtypes": "0.9.21"
20
+ "@medplum/definitions": "0.9.24",
21
+ "@medplum/fhirtypes": "0.9.24"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "pdfmake": "0.2.5"