@medplum/core 4.0.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.
@@ -1069,8 +1069,8 @@ export declare const FHIRCAST_EVENT_RESOURCES: {
1069
1069
  };
1070
1070
  readonly select: {
1071
1071
  readonly resourceType: "*";
1072
- readonly array: true;
1073
1072
  readonly reference: true;
1073
+ readonly manyAllowed: true;
1074
1074
  };
1075
1075
  };
1076
1076
  readonly 'DiagnosticReport-update': {
@@ -1115,8 +1115,8 @@ export declare type FhircastConnectEvent = {
1115
1115
  * To close the connection, call `connection.disconnect()` and listen to the `disconnect` event to know when the connection has been disconnected.
1116
1116
  */
1117
1117
  export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap> {
1118
- subRequest: SubscriptionRequest;
1119
- private websocket;
1118
+ readonly subRequest: SubscriptionRequest;
1119
+ private readonly websocket;
1120
1120
  /**
1121
1121
  * Creates a new `FhircastConnection`.
1122
1122
  * @param subRequest - The subscription request to initialize the connection from.
@@ -1196,8 +1196,6 @@ export declare type FhircastMessagePayload<EventName extends FhircastEventName =
1196
1196
  event: FhircastEventPayload<EventName>;
1197
1197
  };
1198
1198
 
1199
- export declare type FhircastMultiReferenceContext = FhircastSelectContext;
1200
-
1201
1199
  export declare type FhircastOperationOutcomeContext = {
1202
1200
  key: 'operationoutcome';
1203
1201
  resource: OperationOutcome;
@@ -1217,6 +1215,8 @@ export declare type FhircastPatientReferenceContext = {
1217
1215
  reference: Reference<Patient>;
1218
1216
  };
1219
1217
 
1218
+ export declare type FhircastReferenceContext = FhircastReportReferenceContext | FhircastPatientReferenceContext | FhircastSelectContext;
1219
+
1220
1220
  export declare type FhircastReportContext = {
1221
1221
  key: 'report';
1222
1222
  resource: DiagnosticReport;
@@ -1235,11 +1235,9 @@ export declare type FhircastResourceType = (typeof FHIRCAST_RESOURCE_TYPES)[numb
1235
1235
 
1236
1236
  export declare type FhircastSelectContext = {
1237
1237
  key: 'select';
1238
- reference: Reference[];
1238
+ reference: Reference;
1239
1239
  };
1240
1240
 
1241
- export declare type FhircastSingleReferenceContext = FhircastReportReferenceContext | FhircastPatientReferenceContext;
1242
-
1243
1241
  export declare type FhircastStudyContext = {
1244
1242
  key: 'study';
1245
1243
  resource: ImagingStudy;
@@ -1412,10 +1410,19 @@ export declare function findObservationInterval(definition: ObservationDefinitio
1412
1410
  * Tries to find an observation reference range for the given patient and condition names.
1413
1411
  * @param definition - The observation definition.
1414
1412
  * @param patient - The patient.
1415
- * @param names - The condition names.
1413
+ * @param names - Optional condition names.
1416
1414
  * @returns The observation interval if found; otherwise undefined.
1417
1415
  */
1418
- 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[];
1419
1426
 
1420
1427
  /**
1421
1428
  * Finds the first resource in the input array that matches the specified code and system.
@@ -1905,6 +1912,15 @@ export declare class Hl7Field {
1905
1912
  * @param context - Optional HL7 parsing context.
1906
1913
  */
1907
1914
  constructor(components: string[][], context?: Hl7Context);
1915
+ /**
1916
+ * Returns an HL7 component by index.
1917
+ * @param component - The component index.
1918
+ * @param subcomponent - Optional subcomponent index.
1919
+ * @param repetition - Optional repetition index.
1920
+ * @returns The string value of the specified component.
1921
+ * @deprecated Use getComponent() instead. This method will be removed in a future release.
1922
+ */
1923
+ get(component: number, subcomponent?: number, repetition?: number): string;
1908
1924
  /**
1909
1925
  * Returns an HL7 component by index.
1910
1926
  *
@@ -1952,6 +1968,20 @@ export declare class Hl7Message {
1952
1968
  * @returns The HL7 message header.
1953
1969
  */
1954
1970
  get header(): Hl7Segment;
1971
+ /**
1972
+ * Returns an HL7 segment by index or by name.
1973
+ * @param index - The HL7 segment index or name.
1974
+ * @returns The HL7 segment if found; otherwise, undefined.
1975
+ * @deprecated Use getSegment() instead. This method will be removed in a future release.
1976
+ */
1977
+ get(index: number | string): Hl7Segment | undefined;
1978
+ /**
1979
+ * Returns all HL7 segments of a given name.
1980
+ * @param name - The HL7 segment name.
1981
+ * @returns An array of HL7 segments with the specified name.
1982
+ * @deprecated Use getAllSegments() instead. This method will be removed in a future release.
1983
+ */
1984
+ getAll(name: string): Hl7Segment[];
1955
1985
  /**
1956
1986
  * Returns an HL7 segment by index or by name.
1957
1987
  *
@@ -2003,6 +2033,13 @@ export declare class Hl7Segment {
2003
2033
  * @param context - Optional HL7 parsing context.
2004
2034
  */
2005
2035
  constructor(fields: Hl7Field[] | string[], context?: Hl7Context);
2036
+ /**
2037
+ * Returns an HL7 field by index.
2038
+ * @param index - The HL7 field index.
2039
+ * @returns The HL7 field.
2040
+ * @deprecated Use getSegment() instead. This method includes the segment name in the index, which leads to confusing behavior. This method will be removed in a future release.
2041
+ */
2042
+ get(index: number): Hl7Field;
2006
2043
  /**
2007
2044
  * Returns an HL7 field by index.
2008
2045
  *
@@ -2548,6 +2585,50 @@ export declare type IWebSocketEventMap = {
2548
2585
  open: Event;
2549
2586
  };
2550
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
+
2551
2632
  /**
2552
2633
  * Memoizes the result of a parameterless function
2553
2634
  * @param fn - The function to be wrapped
@@ -2843,6 +2924,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
2843
2924
  private medplumServer?;
2844
2925
  private clientId?;
2845
2926
  private clientSecret?;
2927
+ private credentialsInHeader;
2846
2928
  private autoBatchTimerId?;
2847
2929
  private accessToken?;
2848
2930
  private accessTokenExpires?;
@@ -3513,6 +3595,17 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3513
3595
  * @returns The result of the create operation.
3514
3596
  */
3515
3597
  createAttachment(createBinaryOptions: CreateBinaryOptions, requestOptions?: MedplumRequestOptions): Promise<Attachment>;
3598
+ /**
3599
+ * @category Create
3600
+ * @param data - The binary data to upload.
3601
+ * @param filename - Optional filename for the binary.
3602
+ * @param contentType - Content type for the binary.
3603
+ * @param onProgress - Optional callback for progress events. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3604
+ * @param options - Optional fetch options. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3605
+ * @returns The result of the create operation.
3606
+ * @deprecated Use `createAttachment` with `CreateBinaryOptions` instead. To be removed in a future version.
3607
+ */
3608
+ createAttachment(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<Attachment>;
3516
3609
  /**
3517
3610
  * Creates a FHIR `Binary` resource with the provided data content.
3518
3611
  *
@@ -3538,6 +3631,17 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3538
3631
  * @returns The result of the create operation.
3539
3632
  */
3540
3633
  createBinary(createBinaryOptions: CreateBinaryOptions, requestOptions?: MedplumRequestOptions): Promise<WithId<Binary>>;
3634
+ /**
3635
+ * @category Create
3636
+ * @param data - The binary data to upload.
3637
+ * @param filename - Optional filename for the binary.
3638
+ * @param contentType - Content type for the binary.
3639
+ * @param onProgress - Optional callback for progress events. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3640
+ * @param options - Optional fetch options. **NOTE:** only `options.signal` is respected when `onProgress` is also provided.
3641
+ * @returns The result of the create operation.
3642
+ * @deprecated Use `createBinary` with `CreateBinaryOptions` instead. To be removed in a future version.
3643
+ */
3644
+ createBinary(data: BinarySource, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<WithId<Binary>>;
3541
3645
  uploadwithProgress(url: URL, data: BinarySource, contentType: string, onProgress: (e: ProgressEvent) => void, options?: MedplumRequestOptions): Promise<any>;
3542
3646
  /**
3543
3647
  * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
@@ -3563,6 +3667,16 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3563
3667
  * @returns The result of the create operation.
3564
3668
  */
3565
3669
  createPdf(createPdfOptions: CreatePdfOptions, requestOptions?: MedplumRequestOptions): Promise<WithId<Binary>>;
3670
+ /**
3671
+ * @category Media
3672
+ * @param docDefinition - The PDF document definition.
3673
+ * @param filename - Optional filename for the PDF binary resource.
3674
+ * @param tableLayouts - Optional pdfmake custom table layout.
3675
+ * @param fonts - Optional pdfmake custom font dictionary.
3676
+ * @returns The result of the create operation.
3677
+ * @deprecated Use `createPdf` with `CreatePdfOptions` instead. To be removed in a future version.
3678
+ */
3679
+ createPdf(docDefinition: TDocumentDefinitions, filename: string | undefined, tableLayouts?: Record<string, CustomTableLayout>, fonts?: TFontDictionary): Promise<WithId<Binary>>;
3566
3680
  /**
3567
3681
  * Creates a FHIR `Communication` resource with the provided data content.
3568
3682
  *
@@ -3950,6 +4064,17 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3950
4064
  * @returns The new media resource.
3951
4065
  */
3952
4066
  createMedia(createMediaOptions: CreateMediaOptions, requestOptions?: MedplumRequestOptions): Promise<Media>;
4067
+ /**
4068
+ * Upload media to the server and create a Media instance for the uploaded content.
4069
+ * @param contents - The contents of the media file, as a string, Uint8Array, File, or Blob.
4070
+ * @param contentType - The media type of the content.
4071
+ * @param filename - Optional filename for the binary, or extended upload options (see `BinaryUploadOptions`).
4072
+ * @param additionalFields - Additional fields for Media.
4073
+ * @param options - Optional fetch options.
4074
+ * @returns Promise that resolves to the created Media
4075
+ * @deprecated Use `createMedia` with `CreateMediaOptions` instead. To be removed in a future version.
4076
+ */
4077
+ uploadMedia(contents: string | Uint8Array | File | Blob, contentType: string, filename: string | undefined, additionalFields?: Partial<Media>, options?: MedplumRequestOptions): Promise<Media>;
3953
4078
  /**
3954
4079
  * Performs Bulk Data Export operation request flow. See The FHIR "Bulk Data Export" for full details: https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-export
3955
4080
  * @param exportLevel - Optional export level. Defaults to system level export. 'Group/:id' - Group of Patients, 'Patient' - All Patients.
@@ -4216,7 +4341,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4216
4341
  /**
4217
4342
  * Makes a POST request to the tokens endpoint.
4218
4343
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
4219
- * @param formBody - Token parameters in URL encoded format.
4344
+ * @param params - Token parameters.
4220
4345
  * @returns The user profile resource.
4221
4346
  */
4222
4347
  private fetchTokens;
@@ -4411,6 +4536,12 @@ export declare interface MedplumClientOptions {
4411
4536
  * Access Token used to connect to make request to FHIR servers
4412
4537
  */
4413
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';
4414
4545
  /**
4415
4546
  * Number of resources to store in the cache.
4416
4547
  *
@@ -4751,7 +4882,7 @@ export declare interface MedplumSourceInfraConfig {
4751
4882
  * The MemoryStorage class is a minimal in-memory implementation of the Storage interface.
4752
4883
  */
4753
4884
  export declare class MemoryStorage implements Storage {
4754
- private data;
4885
+ private readonly data;
4755
4886
  constructor();
4756
4887
  /**
4757
4888
  * Returns the number of key/value pairs.
@@ -4795,7 +4926,7 @@ export declare type Message = string | ArrayBuffer | Blob | ArrayBufferView;
4795
4926
  */
4796
4927
  export declare class MockAsyncClientStorage extends ClientStorage implements IClientStorage {
4797
4928
  private initialized;
4798
- private initPromise;
4929
+ private readonly initPromise;
4799
4930
  private initResolve;
4800
4931
  constructor();
4801
4932
  setInitialized(): void;
@@ -5079,7 +5210,7 @@ export declare function parseHl7DateTime(hl7DateTime: string | undefined, option
5079
5210
  * @param token - JWT token.
5080
5211
  * @returns Collection of key value claims in the JWT payload.
5081
5212
  */
5082
- export declare function parseJWTPayload(token: string): Record<string, number | string>;
5213
+ export declare function parseJWTPayload(token: string): JWTPayload;
5083
5214
 
5084
5215
  export declare function parseLogLevel(level: string): LogLevel;
5085
5216
 
@@ -5094,8 +5225,8 @@ export declare function parseParameter(searchParam: SearchParameter, modifier: s
5094
5225
 
5095
5226
  export declare class Parser {
5096
5227
  private tokens;
5097
- private prefixParselets;
5098
- private infixParselets;
5228
+ private readonly prefixParselets;
5229
+ private readonly infixParselets;
5099
5230
  constructor(tokens: Token[], prefixParselets: Record<string, PrefixParselet>, infixParselets: Record<string, InfixParselet>);
5100
5231
  hasMore(): boolean;
5101
5232
  match(expected: string): boolean;
@@ -5341,7 +5472,7 @@ export declare type QueryTypes = URLSearchParams | string[][] | Record<string, s
5341
5472
  */
5342
5473
  export declare class ReadablePromise<T> implements Promise<T> {
5343
5474
  readonly [Symbol.toStringTag]: string;
5344
- private suspender;
5475
+ private readonly suspender;
5345
5476
  private status;
5346
5477
  private response;
5347
5478
  private error;
@@ -5396,7 +5527,7 @@ export declare class ReconnectingWebSocket<WS extends IWebSocket = WebSocket> ex
5396
5527
  private _binaryType;
5397
5528
  private _closeCalled;
5398
5529
  private _messageQueue;
5399
- private _debugLogger;
5530
+ private readonly _debugLogger;
5400
5531
  protected _url: string;
5401
5532
  protected _protocols?: ProtocolsProvider;
5402
5533
  protected _options: Options<WS>;
@@ -5489,10 +5620,10 @@ export declare class ReconnectingWebSocket<WS extends IWebSocket = WebSocket> ex
5489
5620
  private _handleTimeout;
5490
5621
  private _disconnect;
5491
5622
  private _acceptOpen;
5492
- private _handleOpen;
5493
- private _handleMessage;
5494
- private _handleError;
5495
- private _handleClose;
5623
+ private readonly _handleOpen;
5624
+ private readonly _handleMessage;
5625
+ private readonly _handleError;
5626
+ private readonly _handleClose;
5496
5627
  private _removeListeners;
5497
5628
  private _addListeners;
5498
5629
  private _clearTimeouts;
@@ -5814,7 +5945,7 @@ export declare interface SubManagerOptions {
5814
5945
  * - `heartbeat` - A `heartbeat` message has been received.
5815
5946
  */
5816
5947
  export declare class SubscriptionEmitter extends TypedEventTarget<SubscriptionEventMap> {
5817
- private criteria;
5948
+ private readonly criteria;
5818
5949
  constructor(...criteria: string[]);
5819
5950
  getCriteria(): Set<string>;
5820
5951
  /**
@@ -5864,13 +5995,13 @@ export declare type SubscriptionEventMap = {
5864
5995
 
5865
5996
  export declare class SubscriptionManager {
5866
5997
  private readonly medplum;
5867
- private ws;
5998
+ private readonly ws;
5868
5999
  private masterSubEmitter?;
5869
- private criteriaEntries;
5870
- private criteriaEntriesBySubscriptionId;
6000
+ private readonly criteriaEntries;
6001
+ private readonly criteriaEntriesBySubscriptionId;
5871
6002
  private wsClosed;
5872
6003
  private pingTimer;
5873
- private pingIntervalMs;
6004
+ private readonly pingIntervalMs;
5874
6005
  private waitingForPong;
5875
6006
  private currentProfile;
5876
6007
  constructor(medplum: MedplumClient, wsUrl: URL | string, options?: SubManagerOptions);
@@ -6026,7 +6157,7 @@ export declare function tryGetJwtExpiration(token: string): number | undefined;
6026
6157
  export declare function tryGetProfile(profileUrl: string): InternalTypeSchema | undefined;
6027
6158
 
6028
6159
  export declare class TypedEventTarget<TEvents extends Record<string, Event_2>> {
6029
- private emitter;
6160
+ private readonly emitter;
6030
6161
  dispatchEvent<TEventType extends keyof TEvents & string>(event: TEvents[TEventType]): void;
6031
6162
  addEventListener<TEventType extends keyof TEvents & string>(type: TEventType, handler: (event: TEvents[TEventType]) => void): void;
6032
6163
  removeEventListener<TEventType extends keyof TEvents & string>(type: TEventType, handler: (event: TEvents[TEventType]) => void): void;