@medplum/core 0.9.19 → 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.
@@ -140,6 +140,9 @@ export interface LoginRequest {
140
140
  readonly password: string;
141
141
  readonly remember?: boolean;
142
142
  readonly projectId?: string;
143
+ readonly clientId?: string;
144
+ readonly scope?: string;
145
+ readonly nonce?: string;
143
146
  }
144
147
  export interface RegisterRequest {
145
148
  readonly firstName: string;
@@ -154,6 +157,13 @@ export interface GoogleCredentialResponse {
154
157
  readonly clientId: string;
155
158
  readonly credential: string;
156
159
  }
160
+ export interface GoogleLoginRequest {
161
+ readonly googleClientId: string;
162
+ readonly googleCredential: string;
163
+ readonly clientId?: string;
164
+ readonly scope?: string;
165
+ readonly nonce?: string;
166
+ }
157
167
  export interface LoginAuthenticationResponse {
158
168
  readonly login: string;
159
169
  readonly code?: string;
@@ -297,20 +307,24 @@ export declare class MedplumClient extends EventTarget {
297
307
  * Returns the current base URL for all API requests.
298
308
  * By default, this is set to `https://api.medplum.com/`.
299
309
  * This can be overridden by setting the `baseUrl` option when creating the client.
310
+ * @category HTTP
300
311
  * @returns The current base URL for all API requests.
301
312
  */
302
313
  getBaseUrl(): string;
303
314
  /**
304
315
  * Clears all auth state including local storage and session storage.
316
+ * @category Authentication
305
317
  */
306
318
  clear(): void;
307
319
  /**
308
320
  * Invalidates any cached values or cached requests for the given URL.
321
+ * @category Caching
309
322
  * @param url The URL to invalidate.
310
323
  */
311
324
  invalidateUrl(url: URL | string): void;
312
325
  /**
313
326
  * Invalidates all cached search results or cached requests for the given resourceType.
327
+ * @category Caching
314
328
  * @param resourceType The resource type to invalidate.
315
329
  */
316
330
  invalidateSearches<K extends ResourceType>(resourceType: K): void;
@@ -321,6 +335,7 @@ export declare class MedplumClient extends EventTarget {
321
335
  * For common operations, we recommend using higher level methods
322
336
  * such as `readResource()`, `search()`, etc.
323
337
  *
338
+ * @category HTTP
324
339
  * @param url The target URL.
325
340
  * @param options Optional fetch options.
326
341
  * @returns Promise to the response content.
@@ -333,6 +348,7 @@ export declare class MedplumClient extends EventTarget {
333
348
  * For common operations, we recommend using higher level methods
334
349
  * such as `createResource()`.
335
350
  *
351
+ * @category HTTP
336
352
  * @param url The target URL.
337
353
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
338
354
  * @param contentType The content type to be included in the "Content-Type" header.
@@ -347,6 +363,7 @@ export declare class MedplumClient extends EventTarget {
347
363
  * For common operations, we recommend using higher level methods
348
364
  * such as `updateResource()`.
349
365
  *
366
+ * @category HTTP
350
367
  * @param url The target URL.
351
368
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
352
369
  * @param contentType The content type to be included in the "Content-Type" header.
@@ -361,6 +378,7 @@ export declare class MedplumClient extends EventTarget {
361
378
  * For common operations, we recommend using higher level methods
362
379
  * such as `patchResource()`.
363
380
  *
381
+ * @category HTTP
364
382
  * @param url The target URL.
365
383
  * @param operations Array of JSONPatch operations.
366
384
  * @param options Optional fetch options.
@@ -370,10 +388,12 @@ export declare class MedplumClient extends EventTarget {
370
388
  /**
371
389
  * Makes an HTTP DELETE request to the specified URL.
372
390
  *
391
+ *
373
392
  * This is a lower level method for custom requests.
374
393
  * For common operations, we recommend using higher level methods
375
394
  * such as `deleteResource()`.
376
395
  *
396
+ * @category HTTP
377
397
  * @param url The target URL.
378
398
  * @param options Optional fetch options.
379
399
  * @returns Promise to the response content.
@@ -381,12 +401,14 @@ export declare class MedplumClient extends EventTarget {
381
401
  delete(url: URL | string, options?: RequestInit): Promise<any>;
382
402
  /**
383
403
  * Tries to register a new user.
404
+ * @category Authentication
384
405
  * @param request The registration request.
385
406
  * @returns Promise to the authentication response.
386
407
  */
387
408
  register(request: RegisterRequest): Promise<void>;
388
409
  /**
389
410
  * Initiates a user login flow.
411
+ * @category Authentication
390
412
  * @param loginRequest Login request including email and password.
391
413
  * @returns Promise to the authentication response.
392
414
  */
@@ -395,35 +417,42 @@ export declare class MedplumClient extends EventTarget {
395
417
  * Tries to sign in with Google authentication.
396
418
  * The response parameter is the result of a Google authentication.
397
419
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
398
- * @param googleResponse The Google credential response.
420
+ * @category Authentication
421
+ * @param loginRequest Login request including Google credential response.
399
422
  * @returns Promise to the authentication response.
400
423
  */
401
- startGoogleLogin(googleResponse: GoogleCredentialResponse): Promise<LoginAuthenticationResponse>;
424
+ startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse>;
402
425
  /**
403
426
  * Signs out locally.
404
427
  * Does not invalidate tokens with the server.
428
+ * @category Authentication
405
429
  */
406
430
  signOut(): Promise<void>;
407
431
  /**
408
432
  * Tries to sign in the user.
409
433
  * Returns true if the user is signed in.
410
434
  * This may result in navigating away to the sign in page.
435
+ * @category Authentication
411
436
  */
412
437
  signInWithRedirect(): Promise<ProfileResource | void> | undefined;
413
438
  /**
414
439
  * Tries to sign out the user.
415
440
  * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
441
+ * @category Authentication
416
442
  */
417
443
  signOutWithRedirect(): void;
418
444
  /**
419
445
  * Builds a FHIR URL from a collection of URL path components.
420
446
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
447
+ * @category HTTP
421
448
  * @param path The path component of the URL.
422
449
  * @returns The well-formed FHIR URL.
423
450
  */
424
451
  fhirUrl(...path: string[]): URL;
425
452
  /**
426
453
  * Builds a FHIR search URL from a search query or structured query object.
454
+ * @category HTTP
455
+ * @category Search
427
456
  * @param query The FHIR search query or structured query object.
428
457
  * @returns The well-formed FHIR URL.
429
458
  */
@@ -465,6 +494,7 @@ export declare class MedplumClient extends EventTarget {
465
494
  *
466
495
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
467
496
  *
497
+ * @category Search
468
498
  * @param query The search query as either a string or a structured search object.
469
499
  * @returns Promise to the search result bundle.
470
500
  */
@@ -485,6 +515,7 @@ export declare class MedplumClient extends EventTarget {
485
515
  *
486
516
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
487
517
  *
518
+ * @category Search
488
519
  * @param query The search query as either a string or a structured search object.
489
520
  * @returns Promise to the search result bundle.
490
521
  */
@@ -505,6 +536,7 @@ export declare class MedplumClient extends EventTarget {
505
536
  *
506
537
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
507
538
  *
539
+ * @category Search
508
540
  * @param query The search query as either a string or a structured search object.
509
541
  * @returns Promise to the search result bundle.
510
542
  */
@@ -512,6 +544,8 @@ export declare class MedplumClient extends EventTarget {
512
544
  /**
513
545
  * Searches a ValueSet resource using the "expand" operation.
514
546
  * See: https://www.hl7.org/fhir/operation-valueset-expand.html
547
+ *
548
+ * @category Search
515
549
  * @param system The ValueSet system url.
516
550
  * @param filter The search string.
517
551
  * @returns Promise to expanded ValueSet.
@@ -519,6 +553,7 @@ export declare class MedplumClient extends EventTarget {
519
553
  searchValueSet(system: string, filter: string, options?: RequestInit): ReadablePromise<ValueSet>;
520
554
  /**
521
555
  * Returns a cached resource if it is available.
556
+ * @category Caching
522
557
  * @param resourceType The FHIR resource type.
523
558
  * @param id The FHIR resource ID.
524
559
  * @returns The resource if it is available in the cache; undefined otherwise.
@@ -526,6 +561,7 @@ export declare class MedplumClient extends EventTarget {
526
561
  getCached<K extends ResourceType>(resourceType: K, id: string): ExtractResource<K> | undefined;
527
562
  /**
528
563
  * Returns a cached resource if it is available.
564
+ * @category Caching
529
565
  * @param resourceType The FHIR resource type.
530
566
  * @param id The FHIR resource ID.
531
567
  * @returns The resource if it is available in the cache; undefined otherwise.
@@ -543,6 +579,7 @@ export declare class MedplumClient extends EventTarget {
543
579
  *
544
580
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
545
581
  *
582
+ * @category Caching
546
583
  * @param resourceType The FHIR resource type.
547
584
  * @param id The resource ID.
548
585
  * @returns The resource if available; undefined otherwise.
@@ -563,6 +600,7 @@ export declare class MedplumClient extends EventTarget {
563
600
  *
564
601
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
565
602
  *
603
+ * @category Read
566
604
  * @param reference The FHIR reference object.
567
605
  * @returns The resource if available; undefined otherwise.
568
606
  */
@@ -571,6 +609,7 @@ export declare class MedplumClient extends EventTarget {
571
609
  * Returns a cached schema for a resource type.
572
610
  * If the schema is not cached, returns undefined.
573
611
  * It is assumed that a client will call requestSchema before using this method.
612
+ * @category Schema
574
613
  * @param resourceType The FHIR resource type.
575
614
  * @returns The schema if immediately available, undefined otherwise.
576
615
  * @deprecated Use globalSchema instead.
@@ -579,6 +618,7 @@ export declare class MedplumClient extends EventTarget {
579
618
  /**
580
619
  * Requests the schema for a resource type.
581
620
  * If the schema is already cached, the promise is resolved immediately.
621
+ * @category Schema
582
622
  * @param resourceType The FHIR resource type.
583
623
  * @returns Promise to a schema with the requested resource type.
584
624
  */
@@ -597,6 +637,7 @@ export declare class MedplumClient extends EventTarget {
597
637
  *
598
638
  * See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
599
639
  *
640
+ * @category Read
600
641
  * @param resourceType The FHIR resource type.
601
642
  * @param id The resource ID.
602
643
  * @returns Promise to the resource history.
@@ -614,11 +655,18 @@ export declare class MedplumClient extends EventTarget {
614
655
  *
615
656
  * See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
616
657
  *
658
+ * @category Read
617
659
  * @param resourceType The FHIR resource type.
618
660
  * @param id The resource ID.
619
661
  * @returns The resource if available; undefined otherwise.
620
662
  */
621
663
  readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string): ReadablePromise<ExtractResource<K>>;
664
+ /**
665
+ *
666
+ * @category Read
667
+ * @param id The Patient Id
668
+ * @returns A Bundle of all Resources related to the Patient
669
+ */
622
670
  readPatientEverything(id: string): ReadablePromise<Bundle>;
623
671
  /**
624
672
  * Creates a new FHIR resource.
@@ -640,6 +688,7 @@ export declare class MedplumClient extends EventTarget {
640
688
  *
641
689
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
642
690
  *
691
+ * @category Create
643
692
  * @param resource The FHIR resource to create.
644
693
  * @returns The result of the create operation.
645
694
  */
@@ -678,6 +727,7 @@ export declare class MedplumClient extends EventTarget {
678
727
  *
679
728
  * See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
680
729
  *
730
+ * @category Create
681
731
  * @param resource The FHIR resource to create.
682
732
  * @param query The search query for an equivalent resource.
683
733
  * @returns The result of the create operation.
@@ -701,6 +751,7 @@ export declare class MedplumClient extends EventTarget {
701
751
  *
702
752
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
703
753
  *
754
+ * @category Create
704
755
  * @param data The binary data to upload.
705
756
  * @param filename Optional filename for the binary.
706
757
  * @param contentType Content type for the binary.
@@ -725,6 +776,7 @@ export declare class MedplumClient extends EventTarget {
725
776
  *
726
777
  * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
727
778
  *
779
+ * @category Media
728
780
  * @param docDefinition The PDF document definition.
729
781
  * @returns The result of the create operation.
730
782
  */
@@ -736,6 +788,7 @@ export declare class MedplumClient extends EventTarget {
736
788
  *
737
789
  * This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.
738
790
  *
791
+ * @category Create
739
792
  * @param resource The FHIR resource to comment on.
740
793
  * @param text The text of the comment.
741
794
  * @returns The result of the create operation.
@@ -762,6 +815,7 @@ export declare class MedplumClient extends EventTarget {
762
815
  *
763
816
  * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
764
817
  *
818
+ * @category Write
765
819
  * @param resource The FHIR resource to update.
766
820
  * @returns The result of the update operation.
767
821
  */
@@ -784,6 +838,7 @@ export declare class MedplumClient extends EventTarget {
784
838
  *
785
839
  * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
786
840
  *
841
+ * @category Write
787
842
  * @param resourceType The FHIR resource type.
788
843
  * @param id The resource ID.
789
844
  * @param operations The JSONPatch operations.
@@ -801,11 +856,60 @@ export declare class MedplumClient extends EventTarget {
801
856
  *
802
857
  * See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
803
858
  *
859
+ * @category Delete
804
860
  * @param resourceType The FHIR resource type.
805
861
  * @param id The resource ID.
806
862
  * @returns The result of the delete operation.
807
863
  */
808
864
  deleteResource(resourceType: ResourceType, id: string): Promise<any>;
865
+ /**
866
+ * Executes a batch or transaction of FHIR operations.
867
+ *
868
+ * Example:
869
+ *
870
+ * ```typescript
871
+ * await medplum.executeBatch({
872
+ * "resourceType": "Bundle",
873
+ * "type": "transaction",
874
+ * "entry": [
875
+ * {
876
+ * "fullUrl": "urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a",
877
+ * "resource": {
878
+ * "resourceType": "Patient",
879
+ * "name": [{ "use": "official", "given": ["Alice"], "family": "Smith" }],
880
+ * "gender": "female",
881
+ * "birthDate": "1974-12-25"
882
+ * },
883
+ * "request": {
884
+ * "method": "POST",
885
+ * "url": "Patient"
886
+ * }
887
+ * },
888
+ * {
889
+ * "fullUrl": "urn:uuid:88f151c0-a954-468a-88bd-5ae15c08e059",
890
+ * "resource": {
891
+ * "resourceType": "Patient",
892
+ * "identifier": [{ "system": "http:/example.org/fhir/ids", "value": "234234" }],
893
+ * "name": [{ "use": "official", "given": ["Bob"], "family": "Jones" }],
894
+ * "gender": "male",
895
+ * "birthDate": "1974-12-25"
896
+ * },
897
+ * "request": {
898
+ * "method": "POST",
899
+ * "url": "Patient",
900
+ * "ifNoneExist": "identifier=http:/example.org/fhir/ids|234234"
901
+ * }
902
+ * }
903
+ * ]
904
+ * });
905
+ * ```
906
+ *
907
+ * See The FHIR "batch/transaction" section for full details: https://hl7.org/fhir/http.html#transaction
908
+ * @category Batch
909
+ * @param bundle The FHIR batch/transaction bundle.
910
+ * @returns The FHIR batch/transaction response bundle.
911
+ */
912
+ executeBatch(bundle: Bundle): Promise<Bundle>;
809
913
  /**
810
914
  * Sends an email using the Medplum Email API.
811
915
  *
@@ -839,7 +943,7 @@ export declare class MedplumClient extends EventTarget {
839
943
  * ```
840
944
  *
841
945
  * See options here: https://nodemailer.com/extras/mailcomposer/
842
- *
946
+ * @category Media
843
947
  * @param options The MailComposer options.
844
948
  * @returns Promise to the operation outcome.
845
949
  */
@@ -885,6 +989,7 @@ export declare class MedplumClient extends EventTarget {
885
989
  *
886
990
  * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
887
991
  *
992
+ * @category Read
888
993
  * @param query The GraphQL query.
889
994
  * @param operationName Optional GraphQL operation name.
890
995
  * @param variables Optional GraphQL variables.
@@ -892,17 +997,47 @@ export declare class MedplumClient extends EventTarget {
892
997
  * @returns The GraphQL result.
893
998
  */
894
999
  graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any>;
1000
+ /**
1001
+ * @category Authentication
1002
+ * @returns The Login State
1003
+ */
895
1004
  getActiveLogin(): LoginState | undefined;
1005
+ /**
1006
+ * @category Authentication
1007
+ */
896
1008
  setActiveLogin(login: LoginState): Promise<void>;
1009
+ /**
1010
+ * @category Authentication
1011
+ */
897
1012
  getAccessToken(): string | undefined;
1013
+ /**
1014
+ * @category Authentication
1015
+ */
898
1016
  setAccessToken(accessToken: string): void;
1017
+ /**
1018
+ * @category Authentication
1019
+ */
899
1020
  getLogins(): LoginState[];
1021
+ /**
1022
+ * @category Authentication
1023
+ */
900
1024
  isLoading(): boolean;
1025
+ /**
1026
+ * @category User Profile
1027
+ */
901
1028
  getProfile(): ProfileResource | undefined;
1029
+ /**
1030
+ * @category User Profile
1031
+ */
902
1032
  getProfileAsync(): Promise<ProfileResource | undefined>;
1033
+ /**
1034
+ * @category User Profile
1035
+ */
903
1036
  getUserConfiguration(): UserConfiguration | undefined;
904
1037
  /**
905
1038
  * Downloads the URL as a blob.
1039
+ *
1040
+ * @category Read
906
1041
  * @param url The URL to request.
907
1042
  * @returns Promise to the response body as a blob.
908
1043
  */
@@ -916,6 +1051,7 @@ export declare class MedplumClient extends EventTarget {
916
1051
  /**
917
1052
  * Starts a new OAuth2 client credentials flow.
918
1053
  * See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
1054
+ * @category Authentication
919
1055
  * @param clientId The client ID.
920
1056
  * @param clientSecret The client secret.
921
1057
  * @returns Promise that resolves to the client profile.
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "0.9.19",
3
+ "version": "0.9.22",
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.19",
21
- "@medplum/fhirtypes": "0.9.19"
20
+ "@medplum/definitions": "0.9.22",
21
+ "@medplum/fhirtypes": "0.9.22"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "pdfmake": "0.2.5"