@medplum/core 3.3.0 → 4.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.
@@ -262,9 +262,6 @@ export declare interface AsyncCrawlerVisitor {
262
262
  visitPropertyAsync: (parent: TypedValueWithPath, key: string, path: string, value: TypedValueWithPath | TypedValueWithPath[], schema: InternalTypeSchema) => Promise<void>;
263
263
  }
264
264
 
265
- /** @deprecated - Use AsyncCrawlerVisitor instead */
266
- export declare type AsyncResourceVisitor = AsyncCrawlerVisitor;
267
-
268
265
  export declare interface Atom {
269
266
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
270
267
  toString(): string;
@@ -581,45 +578,6 @@ export declare interface CrawlerVisitor {
581
578
  visitProperty: (parent: TypedValueWithPath, key: string, path: string, propertyValues: (TypedValueWithPath | TypedValueWithPath[])[], schema: InternalTypeSchema) => void;
582
579
  }
583
580
 
584
- /**
585
- * Crawls the resource synchronously.
586
- * @param resource - The resource to crawl.
587
- * @param visitor - The visitor functions to apply while crawling.
588
- * @param schema - The schema to use for the resource.
589
- * @param initialPath - The path within the resource form which to start crawling.
590
- * @deprecated - Use crawlTypedValue instead
591
- */
592
- export declare function crawlResource(resource: Resource, visitor: CrawlerVisitor, schema?: InternalTypeSchema, initialPath?: string): void;
593
-
594
- /**
595
- * Crawls the resource asynchronously.
596
- * @param resource - The resource to crawl.
597
- * @param visitor - The visitor functions to apply while crawling.
598
- * @param options - Options for how to crawl the resource.
599
- * @returns void
600
- * @deprecated - Use crawlTypedValueAsync instead
601
- */
602
- export declare function crawlResource(resource: Resource, visitor: AsyncCrawlerVisitor, options: CrawlerOptions): Promise<void>;
603
-
604
- /**
605
- * Crawls the resource synchronously.
606
- * @param resource - The resource to crawl.
607
- * @param visitor - The visitor functions to apply while crawling.
608
- * @param options - Options for how to crawl the resource.
609
- * @deprecated - Use crawlTypedValue instead
610
- */
611
- export declare function crawlResource(resource: Resource, visitor: CrawlerVisitor, options?: CrawlerOptions): void;
612
-
613
- /**
614
- * Crawls the resource asynchronously.
615
- * @param resource - The resource to crawl.
616
- * @param visitor - The visitor functions to apply while crawling.
617
- * @param options - Options for how to crawl the resource.
618
- * @returns Promise
619
- * @deprecated - Use crawlTypedValueAsync instead
620
- */
621
- export declare function crawlResourceAsync(resource: Resource, visitor: AsyncCrawlerVisitor, options: CrawlerOptions): Promise<void>;
622
-
623
581
  /**
624
582
  * Crawls the typed value synchronously.
625
583
  * @param typedValue - The typed value to crawl.
@@ -1111,8 +1069,8 @@ export declare const FHIRCAST_EVENT_RESOURCES: {
1111
1069
  };
1112
1070
  readonly select: {
1113
1071
  readonly resourceType: "*";
1114
- readonly array: true;
1115
1072
  readonly reference: true;
1073
+ readonly manyAllowed: true;
1116
1074
  };
1117
1075
  };
1118
1076
  readonly 'DiagnosticReport-update': {
@@ -1157,8 +1115,8 @@ export declare type FhircastConnectEvent = {
1157
1115
  * To close the connection, call `connection.disconnect()` and listen to the `disconnect` event to know when the connection has been disconnected.
1158
1116
  */
1159
1117
  export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap> {
1160
- subRequest: SubscriptionRequest;
1161
- private websocket;
1118
+ readonly subRequest: SubscriptionRequest;
1119
+ private readonly websocket;
1162
1120
  /**
1163
1121
  * Creates a new `FhircastConnection`.
1164
1122
  * @param subRequest - The subscription request to initialize the connection from.
@@ -1238,8 +1196,6 @@ export declare type FhircastMessagePayload<EventName extends FhircastEventName =
1238
1196
  event: FhircastEventPayload<EventName>;
1239
1197
  };
1240
1198
 
1241
- export declare type FhircastMultiReferenceContext = FhircastSelectContext;
1242
-
1243
1199
  export declare type FhircastOperationOutcomeContext = {
1244
1200
  key: 'operationoutcome';
1245
1201
  resource: OperationOutcome;
@@ -1259,6 +1215,8 @@ export declare type FhircastPatientReferenceContext = {
1259
1215
  reference: Reference<Patient>;
1260
1216
  };
1261
1217
 
1218
+ export declare type FhircastReferenceContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastSelectContext;
1219
+
1262
1220
  export declare type FhircastReportContext = {
1263
1221
  key: 'report';
1264
1222
  resource: DiagnosticReport;
@@ -1277,11 +1235,9 @@ export declare type FhircastResourceType = (typeof FHIRCAST_RESOURCE_TYPES)[numb
1277
1235
 
1278
1236
  export declare type FhircastSelectContext = {
1279
1237
  key: 'select';
1280
- reference: Reference[];
1238
+ reference: Reference;
1281
1239
  };
1282
1240
 
1283
- export declare type FhircastSingleReferenceContext = FhircastReportReferenceContext | FhircastPatientReferenceContext;
1284
-
1285
1241
  export declare type FhircastStudyContext = {
1286
1242
  key: 'study';
1287
1243
  resource: ImagingStudy;
@@ -1454,10 +1410,19 @@ export declare function findObservationInterval(definition: ObservationDefinitio
1454
1410
  * Tries to find an observation reference range for the given patient and condition names.
1455
1411
  * @param definition - The observation definition.
1456
1412
  * @param patient - The patient.
1457
- * @param names - The condition names.
1413
+ * @param names - Optional condition names.
1458
1414
  * @returns The observation interval if found; otherwise undefined.
1459
1415
  */
1460
- export declare function findObservationReferenceRange(definition: ObservationDefinition, patient: Patient, names: string[]): ObservationDefinitionQualifiedInterval | undefined;
1416
+ export declare function findObservationReferenceRange(definition: ObservationDefinition, patient: Patient, names?: string[]): ObservationDefinitionQualifiedInterval | undefined;
1417
+
1418
+ /**
1419
+ * Returns all matching observation reference range for the given patient and condition names.
1420
+ * @param definition - The observation definition.
1421
+ * @param patient - The patient.
1422
+ * @param names - Optional condition names.
1423
+ * @returns The observation intervals if found; otherwise an empty array.
1424
+ */
1425
+ export declare function findObservationReferenceRanges(definition: ObservationDefinition, patient: Patient, names?: string[]): ObservationDefinitionQualifiedInterval[];
1461
1426
 
1462
1427
  /**
1463
1428
  * Finds the first resource in the input array that matches the specified code and system.
@@ -1786,7 +1751,11 @@ export declare function getRandomString(): string;
1786
1751
  * @param input - The FHIR resource or reference.
1787
1752
  * @returns A reference string of the form resourceType/id.
1788
1753
  */
1789
- export declare function getReferenceString(input: Reference | Resource): string;
1754
+ export declare function getReferenceString(input: (Reference & {
1755
+ reference: string;
1756
+ }) | WithId<Resource>): string;
1757
+
1758
+ export declare function getReferenceString(input: Reference | Resource): string | undefined;
1790
1759
 
1791
1760
  /**
1792
1761
  * Returns an array of all resource types.
@@ -2452,7 +2421,7 @@ export declare function isQuantityEquivalent(x: Quantity, y: Quantity): boolean;
2452
2421
  export declare function isRedirect(outcome: OperationOutcome): boolean;
2453
2422
 
2454
2423
  /**
2455
- * Typeguard to validate that an object is a FHIR resource
2424
+ * Type guard to validate that an object is a FHIR reference
2456
2425
  * @param value - The object to check
2457
2426
  * @returns True if the input is of type 'object' and contains property 'reference'
2458
2427
  */
@@ -2461,11 +2430,12 @@ export declare function isReference(value: unknown): value is Reference & {
2461
2430
  };
2462
2431
 
2463
2432
  /**
2464
- * Typeguard to validate that an object is a FHIR resource
2433
+ * Type guard to validate that an object is a FHIR resource
2465
2434
  * @param value - The object to check
2435
+ * @param resourceType - Checks that the resource is of the given type
2466
2436
  * @returns True if the input is of type 'object' and contains property 'resourceType'
2467
2437
  */
2468
- export declare function isResource(value: unknown): value is Resource;
2438
+ export declare function isResource<T extends Resource>(value: unknown, resourceType?: T['resourceType']): value is T;
2469
2439
 
2470
2440
  /**
2471
2441
  * Returns true if the given string is a valid FHIR resource type.
@@ -2488,6 +2458,8 @@ export declare function isResourceType(resourceType: string): boolean;
2488
2458
  */
2489
2459
  export declare function isResourceTypeSchema(typeSchema: InternalTypeSchema): boolean;
2490
2460
 
2461
+ export declare function isResourceWithId<T extends Resource>(resource: unknown, resourceType?: T['resourceType']): resource is WithId<T>;
2462
+
2491
2463
  export declare function isSliceDefinitionWithTypes(slice: SliceDefinition): slice is SliceDefinitionWithTypes;
2492
2464
 
2493
2465
  /**
@@ -2613,6 +2585,50 @@ export declare type IWebSocketEventMap = {
2613
2585
  open: Event;
2614
2586
  };
2615
2587
 
2588
+ /**
2589
+ * Recognized JWT Claims Set members, any other members may also be present.
2590
+ * @see {@link https://github.com/panva/jose/blob/main/src/types.d.ts#L532}
2591
+ */
2592
+ export declare interface JWTPayload {
2593
+ /**
2594
+ * JWT Issuer
2595
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1|RFC7519#section-4.1.1}
2596
+ */
2597
+ iss?: string;
2598
+ /**
2599
+ * JWT Subject
2600
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.2|RFC7519#section-4.1.2}
2601
+ */
2602
+ sub?: string;
2603
+ /**
2604
+ * JWT Audience
2605
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3|RFC7519#section-4.1.3}
2606
+ */
2607
+ aud?: string | string[];
2608
+ /**
2609
+ * JWT ID
2610
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.7|RFC7519#section-4.1.7}
2611
+ */
2612
+ jti?: string;
2613
+ /**
2614
+ * JWT Not Before
2615
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5|RFC7519#section-4.1.5}
2616
+ */
2617
+ nbf?: number;
2618
+ /**
2619
+ * JWT Expiration Time
2620
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4|RFC7519#section-4.1.4}
2621
+ */
2622
+ exp?: number;
2623
+ /**
2624
+ * JWT Issued At
2625
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6|RFC7519#section-4.1.6}
2626
+ */
2627
+ iat?: number;
2628
+ /** Any other JWT Claim Set member. */
2629
+ [propName: string]: unknown;
2630
+ }
2631
+
2616
2632
  /**
2617
2633
  * Memoizes the result of a parameterless function
2618
2634
  * @param fn - The function to be wrapped
@@ -2806,16 +2822,6 @@ export declare interface Marker {
2806
2822
 
2807
2823
  export declare function matchDiscriminant(value: TypedValue | TypedValue[] | undefined, discriminator: SliceDiscriminator, slice: SliceDefinition, elements?: Record<string, InternalSchemaElement>): boolean;
2808
2824
 
2809
- /**
2810
- * Returns true if the resource satisfies the current access policy.
2811
- * @param accessPolicy - The access policy.
2812
- * @param resource - The resource.
2813
- * @param readonlyMode - True if the resource is being read.
2814
- * @returns True if the resource matches the access policy.
2815
- * @deprecated Use satisfiedAccessPolicy() instead.
2816
- */
2817
- export declare function matchesAccessPolicy(accessPolicy: AccessPolicy, resource: Resource, readonlyMode: boolean): boolean;
2818
-
2819
2825
  /**
2820
2826
  * Returns true if the value is in the range accounting for precision.
2821
2827
  * @param value - The numeric value.
@@ -2918,6 +2924,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
2918
2924
  private medplumServer?;
2919
2925
  private clientId?;
2920
2926
  private clientSecret?;
2927
+ private credentialsInHeader;
2921
2928
  private autoBatchTimerId?;
2922
2929
  private accessToken?;
2923
2930
  private accessTokenExpires?;
@@ -3014,7 +3021,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3014
3021
  * @category Caching
3015
3022
  * @param resourceType - The resource type to invalidate.
3016
3023
  */
3017
- invalidateSearches<K extends ResourceType>(resourceType: K): void;
3024
+ invalidateSearches(resourceType: ResourceType): void;
3018
3025
  /**
3019
3026
  * Makes an HTTP GET request to the specified URL.
3020
3027
  *
@@ -3255,7 +3262,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3255
3262
  * @param options - Optional fetch options.
3256
3263
  * @returns Promise to the search result bundle.
3257
3264
  */
3258
- search<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<Bundle<ExtractResource<K>>>;
3265
+ search<RT extends ResourceType>(resourceType: RT, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<Bundle<WithId<ExtractResource<RT>>>>;
3259
3266
  /**
3260
3267
  * Sends a FHIR search request for a single resource.
3261
3268
  *
@@ -3278,7 +3285,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3278
3285
  * @param options - Optional fetch options.
3279
3286
  * @returns Promise to the first search result.
3280
3287
  */
3281
- searchOne<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<ExtractResource<K> | undefined>;
3288
+ searchOne<RT extends ResourceType>(resourceType: RT, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>> | undefined>;
3282
3289
  /**
3283
3290
  * Sends a FHIR search request for an array of resources.
3284
3291
  *
@@ -3301,7 +3308,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3301
3308
  * @param options - Optional fetch options.
3302
3309
  * @returns Promise to the array of search results.
3303
3310
  */
3304
- searchResources<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<ResourceArray<ExtractResource<K>>>;
3311
+ searchResources<RT extends ResourceType>(resourceType: RT, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<ResourceArray<WithId<ExtractResource<RT>>>>;
3305
3312
  /**
3306
3313
  * Creates an
3307
3314
  * [async generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator)
@@ -3326,18 +3333,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3326
3333
  * @param options - Optional fetch options.
3327
3334
  * @yields An async generator, where each result is an array of resources for each page.
3328
3335
  */
3329
- searchResourcePages<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: MedplumRequestOptions): AsyncGenerator<ResourceArray<ExtractResource<K>>>;
3330
- /**
3331
- * Searches a ValueSet resource using the "expand" operation.
3332
- * See: https://www.hl7.org/fhir/operation-valueset-expand.html
3333
- * @category Search
3334
- * @param system - The ValueSet system url.
3335
- * @param filter - The search string.
3336
- * @param options - Optional fetch options.
3337
- * @returns Promise to expanded ValueSet.
3338
- * @deprecated Use `valueSetExpand()` instead.
3339
- */
3340
- searchValueSet(system: string, filter: string, options?: MedplumRequestOptions): ReadablePromise<ValueSet>;
3336
+ searchResourcePages<RT extends ResourceType>(resourceType: RT, query?: QueryTypes, options?: MedplumRequestOptions): AsyncGenerator<ResourceArray<WithId<ExtractResource<RT>>>>;
3341
3337
  /**
3342
3338
  * Searches a ValueSet resource using the "expand" operation.
3343
3339
  * See: https://www.hl7.org/fhir/operation-valueset-expand.html
@@ -3354,7 +3350,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3354
3350
  * @param id - The FHIR resource ID.
3355
3351
  * @returns The resource if it is available in the cache; undefined otherwise.
3356
3352
  */
3357
- getCached<K extends ResourceType>(resourceType: K, id: string): ExtractResource<K> | undefined;
3353
+ getCached<RT extends ResourceType>(resourceType: RT, id: string): WithId<ExtractResource<RT>> | undefined;
3358
3354
  /**
3359
3355
  * Returns a cached resource if it is available.
3360
3356
  * @category Caching
@@ -3380,7 +3376,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3380
3376
  * @param options - Optional fetch options.
3381
3377
  * @returns The resource if available.
3382
3378
  */
3383
- readResource<K extends ResourceType>(resourceType: K, id: string, options?: MedplumRequestOptions): ReadablePromise<ExtractResource<K>>;
3379
+ readResource<RT extends ResourceType>(resourceType: RT, id: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>>>;
3384
3380
  /**
3385
3381
  * Reads a resource by `Reference`.
3386
3382
  *
@@ -3401,7 +3397,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3401
3397
  * @param options - Optional fetch options.
3402
3398
  * @returns The resource if available.
3403
3399
  */
3404
- readReference<T extends Resource>(reference: Reference<T>, options?: MedplumRequestOptions): ReadablePromise<T>;
3400
+ readReference<T extends Resource>(reference: Reference<T>, options?: MedplumRequestOptions): ReadablePromise<WithId<T>>;
3405
3401
  /**
3406
3402
  * Requests the schema for a resource type.
3407
3403
  * If the schema is already cached, the promise is resolved immediately.
@@ -3439,7 +3435,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3439
3435
  * @param options - Optional fetch options.
3440
3436
  * @returns Promise to the resource history.
3441
3437
  */
3442
- readHistory<K extends ResourceType>(resourceType: K, id: string, options?: MedplumRequestOptions): ReadablePromise<Bundle<ExtractResource<K>>>;
3438
+ readHistory<RT extends ResourceType>(resourceType: RT, id: string, options?: MedplumRequestOptions): ReadablePromise<Bundle<WithId<ExtractResource<RT>>>>;
3443
3439
  /**
3444
3440
  * Reads a specific version of a resource by resource type, ID, and version ID.
3445
3441
  *
@@ -3459,7 +3455,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3459
3455
  * @param options - Optional fetch options.
3460
3456
  * @returns The resource if available.
3461
3457
  */
3462
- readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string, options?: MedplumRequestOptions): ReadablePromise<ExtractResource<K>>;
3458
+ readVersion<RT extends ResourceType>(resourceType: RT, id: string, vid: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>>>;
3463
3459
  /**
3464
3460
  * Executes the Patient "everything" operation for a patient.
3465
3461
  *
@@ -3523,7 +3519,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3523
3519
  * @param options - Optional fetch options.
3524
3520
  * @returns The result of the create operation.
3525
3521
  */
3526
- createResource<T extends Resource>(resource: T, options?: MedplumRequestOptions): Promise<T>;
3522
+ createResource<T extends Resource>(resource: T, options?: MedplumRequestOptions): Promise<WithId<T>>;
3527
3523
  /**
3528
3524
  * Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.
3529
3525
  *
@@ -3565,7 +3561,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3565
3561
  * @param options - Optional fetch options.
3566
3562
  * @returns The result of the create operation.
3567
3563
  */
3568
- createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: MedplumRequestOptions): Promise<T>;
3564
+ createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: MedplumRequestOptions): Promise<WithId<T>>;
3569
3565
  /**
3570
3566
  * Upsert a resource: update it in place if it exists, otherwise create it. This is done in a single, transactional
3571
3567
  * request to guarantee data consistency.
@@ -3574,7 +3570,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3574
3570
  * @param options - Optional fetch options.
3575
3571
  * @returns The updated/created resource.
3576
3572
  */
3577
- upsertResource<T extends Resource>(resource: T, query: QueryTypes, options?: MedplumRequestOptions): Promise<T>;
3573
+ upsertResource<T extends Resource>(resource: T, query: QueryTypes, options?: MedplumRequestOptions): Promise<WithId<T>>;
3578
3574
  /**
3579
3575
  * Creates a FHIR `Attachment` with the provided data content.
3580
3576
  *
@@ -3607,7 +3603,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3607
3603
  * @param onProgress - Optional callback for progress events. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3608
3604
  * @param options - Optional fetch options. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3609
3605
  * @returns The result of the create operation.
3610
- * @deprecated Use `createAttachment` with `CreateBinaryOptions` instead. To be removed in Medplum 4.0.
3606
+ * @deprecated Use `createAttachment` with `CreateBinaryOptions` instead. To be removed in a future version.
3611
3607
  */
3612
3608
  createAttachment(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<Attachment>;
3613
3609
  /**
@@ -3634,7 +3630,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3634
3630
  * @param requestOptions - Optional fetch options. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3635
3631
  * @returns The result of the create operation.
3636
3632
  */
3637
- createBinary(createBinaryOptions: CreateBinaryOptions, requestOptions?: MedplumRequestOptions): Promise<Binary>;
3633
+ createBinary(createBinaryOptions: CreateBinaryOptions, requestOptions?: MedplumRequestOptions): Promise<WithId<Binary>>;
3638
3634
  /**
3639
3635
  * @category Create
3640
3636
  * @param data - The binary data to upload.
@@ -3643,9 +3639,9 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3643
3639
  * @param onProgress - Optional callback for progress events. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3644
3640
  * @param options - Optional fetch options. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3645
3641
  * @returns The result of the create operation.
3646
- * @deprecated Use `createBinary` with `CreateBinaryOptions` instead. To be removed in Medplum 4.0.
3642
+ * @deprecated Use `createBinary` with `CreateBinaryOptions` instead. To be removed in a future version.
3647
3643
  */
3648
- createBinary(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<Binary>;
3644
+ createBinary(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<WithId<Binary>>;
3649
3645
  uploadwithProgress(url: URL, data: BinarySource, contentType: string, onProgress: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<any>;
3650
3646
  /**
3651
3647
  * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
@@ -3670,7 +3666,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3670
3666
  * @param requestOptions - Optional fetch options.
3671
3667
  * @returns The result of the create operation.
3672
3668
  */
3673
- createPdf(createPdfOptions: CreatePdfOptions, requestOptions?: MedplumRequestOptions): Promise<Binary>;
3669
+ createPdf(createPdfOptions: CreatePdfOptions, requestOptions?: MedplumRequestOptions): Promise<WithId<Binary>>;
3674
3670
  /**
3675
3671
  * @category Media
3676
3672
  * @param docDefinition - The PDF document definition.
@@ -3678,9 +3674,9 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3678
3674
  * @param tableLayouts - Optional pdfmake custom table layout.
3679
3675
  * @param fonts - Optional pdfmake custom font dictionary.
3680
3676
  * @returns The result of the create operation.
3681
- * @deprecated Use `createPdf` with `CreatePdfOptions` instead. To be removed in Medplum 4.0.
3677
+ * @deprecated Use `createPdf` with `CreatePdfOptions` instead. To be removed in a future version.
3682
3678
  */
3683
- createPdf(docDefinition: TDocumentDefinitions, filename: string | undefined, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<Binary>;
3679
+ createPdf(docDefinition: TDocumentDefinitions, filename: string | undefined, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<WithId<Binary>>;
3684
3680
  /**
3685
3681
  * Creates a FHIR `Communication` resource with the provided data content.
3686
3682
  *
@@ -3691,7 +3687,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3691
3687
  * @param options - Optional fetch options.
3692
3688
  * @returns The result of the create operation.
3693
3689
  */
3694
- createComment(resource: Resource, text: string, options?: MedplumRequestOptions): Promise<Communication>;
3690
+ createComment(resource: Resource, text: string, options?: MedplumRequestOptions): Promise<WithId<Communication>>;
3695
3691
  /**
3696
3692
  * Updates a FHIR resource.
3697
3693
  *
@@ -3718,7 +3714,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3718
3714
  * @param options - Optional fetch options.
3719
3715
  * @returns The result of the update operation.
3720
3716
  */
3721
- updateResource<T extends Resource>(resource: T, options?: MedplumRequestOptions): Promise<T>;
3717
+ updateResource<T extends Resource>(resource: T, options?: MedplumRequestOptions): Promise<WithId<T>>;
3722
3718
  /**
3723
3719
  * Updates a FHIR resource using JSONPatch operations.
3724
3720
  *
@@ -3744,7 +3740,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3744
3740
  * @param options - Optional fetch options.
3745
3741
  * @returns The result of the patch operations.
3746
3742
  */
3747
- patchResource<K extends ResourceType>(resourceType: K, id: string, operations: PatchOperation[], options?: MedplumRequestOptions): Promise<ExtractResource<K>>;
3743
+ patchResource<RT extends ResourceType>(resourceType: RT, id: string, operations: PatchOperation[], options?: MedplumRequestOptions): Promise<WithId<ExtractResource<RT>>>;
3748
3744
  /**
3749
3745
  * Deletes a FHIR resource by resource type and ID.
3750
3746
  *
@@ -3942,7 +3938,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3942
3938
  * @param options - Optional fetch options.
3943
3939
  * @returns A Bundle
3944
3940
  */
3945
- readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string, options?: MedplumRequestOptions): ReadablePromise<Bundle>;
3941
+ readResourceGraph(resourceType: ResourceType, id: string, graphName: string, options?: MedplumRequestOptions): ReadablePromise<Bundle>;
3946
3942
  /**
3947
3943
  * Pushes a message to an agent.
3948
3944
  *
@@ -4038,13 +4034,13 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4038
4034
  * @returns The current user profile resource.
4039
4035
  * @category User Profile
4040
4036
  */
4041
- getProfileAsync(): Promise<ProfileResource | undefined>;
4037
+ getProfileAsync(): Promise<WithId<ProfileResource> | undefined>;
4042
4038
  /**
4043
4039
  * Returns the current user configuration if available.
4044
4040
  * @returns The current user configuration if available.
4045
4041
  * @category User Profile
4046
4042
  */
4047
- getUserConfiguration(): UserConfiguration | undefined;
4043
+ getUserConfiguration(): WithId<UserConfiguration> | undefined;
4048
4044
  /**
4049
4045
  * Returns the current user access policy if available.
4050
4046
  * @returns The current user access policy if available.
@@ -4076,7 +4072,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4076
4072
  * @param additionalFields - Additional fields for Media.
4077
4073
  * @param options - Optional fetch options.
4078
4074
  * @returns Promise that resolves to the created Media
4079
- * @deprecated Use `createMedia` with `CreateMediaOptions` instead. To be removed in Medplum 4.0.
4075
+ * @deprecated Use `createMedia` with `CreateMediaOptions` instead. To be removed in a future version.
4080
4076
  */
4081
4077
  uploadMedia(contents: string | Uint8Array | File | Blob, contentType: string, filename: string | undefined, additionalFields?: Partial<Media>, options?: MedplumRequestOptions): Promise<Media>;
4082
4078
  /**
@@ -4345,7 +4341,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4345
4341
  /**
4346
4342
  * Makes a POST request to the tokens endpoint.
4347
4343
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
4348
- * @param formBody - Token parameters in URL encoded format.
4344
+ * @param params - Token parameters.
4349
4345
  * @returns The user profile resource.
4350
4346
  */
4351
4347
  private fetchTokens;
@@ -4540,6 +4536,12 @@ export declare interface MedplumClientOptions {
4540
4536
  * Access Token used to connect to make request to FHIR servers
4541
4537
  */
4542
4538
  accessToken?: string;
4539
+ /**
4540
+ * Specifies through which part of the HTTP request the client credentials should be sent.
4541
+ *
4542
+ * Body is the default for backwards compatibility, but header may be more desirable for applications.
4543
+ */
4544
+ authCredentialsMethod?: 'body' | 'header';
4543
4545
  /**
4544
4546
  * Number of resources to store in the cache.
4545
4547
  *
@@ -4880,7 +4882,7 @@ export declare interface MedplumSourceInfraConfig {
4880
4882
  * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
4881
4883
  */
4882
4884
  export declare class MemoryStorage implements Storage {
4883
- private data;
4885
+ private readonly data;
4884
4886
  constructor();
4885
4887
  /**
4886
4888
  * Returns the number of key/value pairs.
@@ -4924,7 +4926,7 @@ export declare type Message = string | ArrayBuffer | Blob | ArrayBufferView;
4924
4926
  */
4925
4927
  export declare class MockAsyncClientStorage extends ClientStorage implements IClientStorage {
4926
4928
  private initialized;
4927
- private initPromise;
4929
+ private readonly initPromise;
4928
4930
  private initResolve;
4929
4931
  constructor();
4930
4932
  setInitialized(): void;
@@ -5172,15 +5174,6 @@ export declare class OrAtom extends BooleanInfixOperatorAtom {
5172
5174
  */
5173
5175
  export declare type OutputRow = Record<string, any>;
5174
5176
 
5175
- /**
5176
- * Parses a FHIR criteria string into a SearchRequest.
5177
- * FHIR criteria strings are found on resources such as Subscription.
5178
- * @param criteria - The FHIR criteria string.
5179
- * @returns Parsed search definition.
5180
- * @deprecated Use parseSearchRequest instead.
5181
- */
5182
- export declare function parseCriteriaAsSearchRequest<T extends Resource = Resource>(criteria: string): SearchRequest<T>;
5183
-
5184
5177
  /**
5185
5178
  * Parses a FHIRPath expression into an AST.
5186
5179
  * The result can be used to evaluate the expression against a resource or other object.
@@ -5217,7 +5210,7 @@ export declare function parseHl7DateTime(hl7DateTime: string | undefined, option
5217
5210
  * @param token - JWT token.
5218
5211
  * @returns Collection of key value claims in the JWT payload.
5219
5212
  */
5220
- export declare function parseJWTPayload(token: string): Record<string, number | string>;
5213
+ export declare function parseJWTPayload(token: string): JWTPayload;
5221
5214
 
5222
5215
  export declare function parseLogLevel(level: string): LogLevel;
5223
5216
 
@@ -5232,8 +5225,8 @@ export declare function parseParameter(searchParam: SearchParameter, modifier: s
5232
5225
 
5233
5226
  export declare class Parser {
5234
5227
  private tokens;
5235
- private prefixParselets;
5236
- private infixParselets;
5228
+ private readonly prefixParselets;
5229
+ private readonly infixParselets;
5237
5230
  constructor(tokens: Token[], prefixParselets: Record<string, PrefixParselet>, infixParselets: Record<string, InfixParselet>);
5238
5231
  hasMore(): boolean;
5239
5232
  match(expected: string): boolean;
@@ -5262,14 +5255,6 @@ export declare class ParserBuilder {
5262
5255
  */
5263
5256
  export declare function parseReference<T extends Resource>(reference: Reference<T> | undefined): [T['resourceType'], string];
5264
5257
 
5265
- /**
5266
- * Parses a URL string into a SearchRequest.
5267
- * @param url - The URL to parse.
5268
- * @returns Parsed search definition.
5269
- * @deprecated Use parseSearchRequest instead.
5270
- */
5271
- export declare function parseSearchDefinition<T extends Resource = Resource>(url: string): SearchRequest<T>;
5272
-
5273
5258
  /**
5274
5259
  * Parses a search URL into a search request.
5275
5260
  * @param url - The original search URL or the FHIR resource type.
@@ -5278,14 +5263,6 @@ export declare function parseSearchDefinition<T extends Resource = Resource>(url
5278
5263
  */
5279
5264
  export declare function parseSearchRequest<T extends Resource = Resource>(url: T['resourceType'] | URL | string, query?: Record<string, string[] | string | undefined>): SearchRequest<T>;
5280
5265
 
5281
- /**
5282
- * Parses a search URL into a search request.
5283
- * @param url - The search URL.
5284
- * @returns A parsed SearchRequest.
5285
- * @deprecated Use parseSearchRequest instead.
5286
- */
5287
- export declare function parseSearchUrl<T extends Resource = Resource>(url: URL): SearchRequest<T>;
5288
-
5289
5266
  /**
5290
5267
  * Parses a StructureDefinition resource into an internal schema better suited for
5291
5268
  * programmatic validation and usage in internal systems
@@ -5495,7 +5472,7 @@ export declare type QueryTypes = URLSearchParams | string[][] | Record<string, s
5495
5472
  */
5496
5473
  export declare class ReadablePromise<T> implements Promise<T> {
5497
5474
  readonly [Symbol.toStringTag]: string;
5498
- private suspender;
5475
+ private readonly suspender;
5499
5476
  private status;
5500
5477
  private response;
5501
5478
  private error;
@@ -5550,7 +5527,7 @@ export declare class ReconnectingWebSocket<WS extends IWebSocket = WebSocket> ex
5550
5527
  private _binaryType;
5551
5528
  private _closeCalled;
5552
5529
  private _messageQueue;
5553
- private _debugLogger;
5530
+ private readonly _debugLogger;
5554
5531
  protected _url: string;
5555
5532
  protected _protocols?: ProtocolsProvider;
5556
5533
  protected _options: Options<WS>;
@@ -5643,10 +5620,10 @@ export declare class ReconnectingWebSocket<WS extends IWebSocket = WebSocket> ex
5643
5620
  private _handleTimeout;
5644
5621
  private _disconnect;
5645
5622
  private _acceptOpen;
5646
- private _handleOpen;
5647
- private _handleMessage;
5648
- private _handleError;
5649
- private _handleClose;
5623
+ private readonly _handleOpen;
5624
+ private readonly _handleMessage;
5625
+ private readonly _handleError;
5626
+ private readonly _handleClose;
5650
5627
  private _removeListeners;
5651
5628
  private _addListeners;
5652
5629
  private _clearTimeouts;
@@ -5710,9 +5687,6 @@ export declare type ResourceArray<T extends Resource = Resource> = T[] & {
5710
5687
  bundle: Bundle<T>;
5711
5688
  };
5712
5689
 
5713
- /** @deprecated - Use CrawlerOptions instead */
5714
- export declare type ResourceCrawlerOptions = CrawlerOptions;
5715
-
5716
5690
  export declare type ResourceMatchesSubscriptionCriteria = {
5717
5691
  resource: Resource;
5718
5692
  subscription: Subscription;
@@ -5723,9 +5697,6 @@ export declare type ResourceMatchesSubscriptionCriteria = {
5723
5697
 
5724
5698
  export declare function resourceMatchesSubscriptionCriteria({ resource, subscription, context, getPreviousResource, logger, }: ResourceMatchesSubscriptionCriteria): Promise<boolean>;
5725
5699
 
5726
- /** @deprecated - Use CrawlerVisitor instead */
5727
- export declare type ResourceVisitor = CrawlerVisitor;
5728
-
5729
5700
  export declare type ResourceWithCode = Resource & Code;
5730
5701
 
5731
5702
  export declare const RXNORM = "http://www.nlm.nih.gov/research/umls/rxnorm";
@@ -5974,7 +5945,7 @@ export declare interface SubManagerOptions {
5974
5945
  * - `heartbeat` - A `heartbeat` message has been received.
5975
5946
  */
5976
5947
  export declare class SubscriptionEmitter extends TypedEventTarget<SubscriptionEventMap> {
5977
- private criteria;
5948
+ private readonly criteria;
5978
5949
  constructor(...criteria: string[]);
5979
5950
  getCriteria(): Set<string>;
5980
5951
  /**
@@ -6024,13 +5995,13 @@ export declare type SubscriptionEventMap = {
6024
5995
 
6025
5996
  export declare class SubscriptionManager {
6026
5997
  private readonly medplum;
6027
- private ws;
5998
+ private readonly ws;
6028
5999
  private masterSubEmitter?;
6029
- private criteriaEntries;
6030
- private criteriaEntriesBySubscriptionId;
6000
+ private readonly criteriaEntries;
6001
+ private readonly criteriaEntriesBySubscriptionId;
6031
6002
  private wsClosed;
6032
6003
  private pingTimer;
6033
- private pingIntervalMs;
6004
+ private readonly pingIntervalMs;
6034
6005
  private waitingForPong;
6035
6006
  private currentProfile;
6036
6007
  constructor(medplum: MedplumClient, wsUrl: URL | string, options?: SubManagerOptions);
@@ -6186,7 +6157,7 @@ export declare function tryGetJwtExpiration(token: string): number | undefined;
6186
6157
  export declare function tryGetProfile(profileUrl: string): InternalTypeSchema | undefined;
6187
6158
 
6188
6159
  export declare class TypedEventTarget<TEvents extends Record<string, Event_2>> {
6189
- private emitter;
6160
+ private readonly emitter;
6190
6161
  dispatchEvent<TEventType extends keyof TEvents & string>(event: TEvents[TEventType]): void;
6191
6162
  addEventListener<TEventType extends keyof TEvents & string>(type: TEventType, handler: (event: TEvents[TEventType]) => void): void;
6192
6163
  removeEventListener<TEventType extends keyof TEvents & string>(type: TEventType, handler: (event: TEvents[TEventType]) => void): void;
@@ -6335,6 +6306,10 @@ declare type WebSocketEventMap_2 = {
6335
6306
  };
6336
6307
  export { WebSocketEventMap_2 as WebSocketEventMap }
6337
6308
 
6309
+ export declare type WithId<T> = T & {
6310
+ id: string;
6311
+ };
6312
+
6338
6313
  /**
6339
6314
  * Returns a word-wrapped string.
6340
6315
  * Based on: https://stackoverflow.com/a/38709683