@medplum/core 5.1.29 → 5.1.30

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.
@@ -16,6 +16,7 @@ import type { CustomTableLayout } from 'pdfmake/interfaces';
16
16
  import type { Device } from '@medplum/fhirtypes';
17
17
  import type { DiagnosticReport } from '@medplum/fhirtypes';
18
18
  import type { DocumentReference } from '@medplum/fhirtypes';
19
+ import type { Duration } from '@medplum/fhirtypes';
19
20
  import type { ElementDefinition } from '@medplum/fhirtypes';
20
21
  import type { ElementDefinitionBinding } from '@medplum/fhirtypes';
21
22
  import type { Encounter } from '@medplum/fhirtypes';
@@ -936,14 +937,19 @@ export declare function conceptMapTranslate(map: ConceptMap, params: ConceptMapT
936
937
  export declare interface ConceptMapTranslateMatch {
937
938
  equivalence?: string;
938
939
  concept?: Coding;
939
- property?: ConceptMapTranslateMatchAttribute[];
940
+ property?: ConceptMapTranslateMatchProperty[];
940
941
  dependsOn?: ConceptMapTranslateMatchAttribute[];
941
942
  product?: ConceptMapTranslateMatchAttribute[];
942
943
  source?: string;
943
944
  }
944
945
 
945
946
  export declare interface ConceptMapTranslateMatchAttribute {
946
- key: string;
947
+ attribute: string;
948
+ value: TypedValue;
949
+ }
950
+
951
+ export declare interface ConceptMapTranslateMatchProperty {
952
+ uri: string;
947
953
  value: TypedValue;
948
954
  }
949
955
 
@@ -1071,6 +1077,17 @@ export declare interface CopyOperation {
1071
1077
  path: string;
1072
1078
  }
1073
1079
 
1080
+ /**
1081
+ * Counts iterable elements by a key function, returning a sparse map of key to count.
1082
+ * Matches Lodash `countBy` semantics (no zero-fill for missing keys).
1083
+ * @param items - The items to count.
1084
+ * @param keyFn - The function to extract the key from each item.
1085
+ * @returns A map of key to count for keys that appear at least once.
1086
+ */
1087
+ export declare function countBy<T, K extends keyof any>(items: Iterable<T>, keyFn: (value: T) => K): Partial<Record<K, number>>;
1088
+
1089
+ export declare function countWhere<T>(items: Iterable<T>, fn: (value: T) => boolean): number;
1090
+
1074
1091
  export declare const CPT = "http://www.ama-assn.org/go/cpt";
1075
1092
 
1076
1093
  export declare interface CrawlerOptions {
@@ -1872,7 +1889,11 @@ export declare type FhircastConnectEvent = {
1872
1889
  * 2. `message` - Contains a `payload` field containing a `FHIRcast` message payload exactly as it comes in over WebSockets.
1873
1890
  * 3. `disconnect` - An event to signal when a WebSocket connection has been closed. Fired as soon as a WebSocket emits `close`.
1874
1891
  *
1875
- * To close the connection, call `connection.disconnect()` and listen to the `disconnect` event to know when the connection has been disconnected.
1892
+ * The underlying socket reconnects on its own, so `disconnect` followed by `connect` is the normal
1893
+ * shape of a dropped connection rather than the end of the session. A subscription endpoint stays
1894
+ * valid for the lease the Hub granted it, so reconnecting resubscribes without a new `hub.subscribe`
1895
+ * request. Two things end a connection for good: calling `connection.disconnect()`, and the Hub
1896
+ * denying the subscription — after either, `connect` will not fire again.
1876
1897
  */
1877
1898
  export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap> {
1878
1899
  readonly subRequest: SubscriptionRequest;
@@ -1880,11 +1901,17 @@ export declare class FhircastConnection extends TypedEventTarget<FhircastSubscri
1880
1901
  /**
1881
1902
  * Creates a new `FhircastConnection`.
1882
1903
  * @param subRequest - The subscription request to initialize the connection from.
1904
+ * @param options - Options for the underlying `ReconnectingWebSocket`.
1883
1905
  */
1884
- constructor(subRequest: SubscriptionRequest);
1906
+ constructor(subRequest: SubscriptionRequest, options?: FhircastConnectionOptions);
1885
1907
  disconnect(): void;
1886
1908
  }
1887
1909
 
1910
+ export declare type FhircastConnectionOptions = Options & {
1911
+ /** An alternate `ReconnectingWebSocket` implementation to open the connection with. */
1912
+ ReconnectingWebSocket?: IReconnectingWebSocketCtor;
1913
+ };
1914
+
1888
1915
  export declare type FhircastContextResourceType<EventName extends FhircastEventName, K extends FhircastEventKeys<EventName>> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName][K] extends {
1889
1916
  resourceType: infer R;
1890
1917
  } ? R : never;
@@ -6153,9 +6180,10 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
6153
6180
  *
6154
6181
  * @category FHIRcast
6155
6182
  * @param subRequest - The `SubscriptionRequest` to use for connecting.
6183
+ * @param options - Options for the underlying `ReconnectingWebSocket`.
6156
6184
  * @returns A `FhircastConnection` which emits lifecycle events for the `FHIRcast` WebSocket connection.
6157
6185
  */
6158
- fhircastConnect(subRequest: SubscriptionRequest): FhircastConnection;
6186
+ fhircastConnect(subRequest: SubscriptionRequest, options?: FhircastConnectionOptions): FhircastConnection;
6159
6187
  /**
6160
6188
  * Publishes a new context to a given topic for a specified event type.
6161
6189
  *
@@ -8250,6 +8278,15 @@ export declare class ParserBuilder {
8250
8278
  */
8251
8279
  export declare function satisfiedAccessPolicy(resource: Resource, interaction: AccessPolicyInteraction, accessPolicy: AccessPolicy | undefined): AccessPolicyResource | undefined;
8252
8280
 
8281
+ /**
8282
+ * Converts a SchedulingParameters duration to minutes.
8283
+ *
8284
+ * @param duration - The duration to convert.
8285
+ * @returns The length in minutes, or undefined when the duration has no value, a
8286
+ * negative value, or a unit scheduling does not accept.
8287
+ */
8288
+ export declare function schedulingDurationToMinutes(duration: Duration | undefined): number | undefined;
8289
+
8253
8290
  export declare const SchedulingEncounterCodingURI = "https://medplum.com/fhir/StructureDefinition/SchedulingEncounterCoding";
8254
8291
 
8255
8292
  export declare const SchedulingParametersURI = "https://medplum.com/fhir/StructureDefinition/SchedulingParameters";
@@ -8732,6 +8769,8 @@ export declare class ParserBuilder {
8732
8769
  [index: string]: any;
8733
8770
  }): string[];
8734
8771
 
8772
+ export declare function sumBy<T>(items: Iterable<T>, fn: (value: T) => number): number;
8773
+
8735
8774
  /**
8736
8775
  * Summarizes a group of Observations into a single computed summary value, with the individual values
8737
8776
  * preserved in `Observation.component.valueSampledData`.
@@ -16,6 +16,7 @@ import type { CustomTableLayout } from 'pdfmake/interfaces';
16
16
  import type { Device } from '@medplum/fhirtypes';
17
17
  import type { DiagnosticReport } from '@medplum/fhirtypes';
18
18
  import type { DocumentReference } from '@medplum/fhirtypes';
19
+ import type { Duration } from '@medplum/fhirtypes';
19
20
  import type { ElementDefinition } from '@medplum/fhirtypes';
20
21
  import type { ElementDefinitionBinding } from '@medplum/fhirtypes';
21
22
  import type { Encounter } from '@medplum/fhirtypes';
@@ -936,14 +937,19 @@ export declare function conceptMapTranslate(map: ConceptMap, params: ConceptMapT
936
937
  export declare interface ConceptMapTranslateMatch {
937
938
  equivalence?: string;
938
939
  concept?: Coding;
939
- property?: ConceptMapTranslateMatchAttribute[];
940
+ property?: ConceptMapTranslateMatchProperty[];
940
941
  dependsOn?: ConceptMapTranslateMatchAttribute[];
941
942
  product?: ConceptMapTranslateMatchAttribute[];
942
943
  source?: string;
943
944
  }
944
945
 
945
946
  export declare interface ConceptMapTranslateMatchAttribute {
946
- key: string;
947
+ attribute: string;
948
+ value: TypedValue;
949
+ }
950
+
951
+ export declare interface ConceptMapTranslateMatchProperty {
952
+ uri: string;
947
953
  value: TypedValue;
948
954
  }
949
955
 
@@ -1071,6 +1077,17 @@ export declare interface CopyOperation {
1071
1077
  path: string;
1072
1078
  }
1073
1079
 
1080
+ /**
1081
+ * Counts iterable elements by a key function, returning a sparse map of key to count.
1082
+ * Matches Lodash `countBy` semantics (no zero-fill for missing keys).
1083
+ * @param items - The items to count.
1084
+ * @param keyFn - The function to extract the key from each item.
1085
+ * @returns A map of key to count for keys that appear at least once.
1086
+ */
1087
+ export declare function countBy<T, K extends keyof any>(items: Iterable<T>, keyFn: (value: T) => K): Partial<Record<K, number>>;
1088
+
1089
+ export declare function countWhere<T>(items: Iterable<T>, fn: (value: T) => boolean): number;
1090
+
1074
1091
  export declare const CPT = "http://www.ama-assn.org/go/cpt";
1075
1092
 
1076
1093
  export declare interface CrawlerOptions {
@@ -1872,7 +1889,11 @@ export declare type FhircastConnectEvent = {
1872
1889
  * 2. `message` - Contains a `payload` field containing a `FHIRcast` message payload exactly as it comes in over WebSockets.
1873
1890
  * 3. `disconnect` - An event to signal when a WebSocket connection has been closed. Fired as soon as a WebSocket emits `close`.
1874
1891
  *
1875
- * To close the connection, call `connection.disconnect()` and listen to the `disconnect` event to know when the connection has been disconnected.
1892
+ * The underlying socket reconnects on its own, so `disconnect` followed by `connect` is the normal
1893
+ * shape of a dropped connection rather than the end of the session. A subscription endpoint stays
1894
+ * valid for the lease the Hub granted it, so reconnecting resubscribes without a new `hub.subscribe`
1895
+ * request. Two things end a connection for good: calling `connection.disconnect()`, and the Hub
1896
+ * denying the subscription — after either, `connect` will not fire again.
1876
1897
  */
1877
1898
  export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap> {
1878
1899
  readonly subRequest: SubscriptionRequest;
@@ -1880,11 +1901,17 @@ export declare class FhircastConnection extends TypedEventTarget<FhircastSubscri
1880
1901
  /**
1881
1902
  * Creates a new `FhircastConnection`.
1882
1903
  * @param subRequest - The subscription request to initialize the connection from.
1904
+ * @param options - Options for the underlying `ReconnectingWebSocket`.
1883
1905
  */
1884
- constructor(subRequest: SubscriptionRequest);
1906
+ constructor(subRequest: SubscriptionRequest, options?: FhircastConnectionOptions);
1885
1907
  disconnect(): void;
1886
1908
  }
1887
1909
 
1910
+ export declare type FhircastConnectionOptions = Options & {
1911
+ /** An alternate `ReconnectingWebSocket` implementation to open the connection with. */
1912
+ ReconnectingWebSocket?: IReconnectingWebSocketCtor;
1913
+ };
1914
+
1888
1915
  export declare type FhircastContextResourceType<EventName extends FhircastEventName, K extends FhircastEventKeys<EventName>> = (typeof FHIRCAST_EVENT_RESOURCES)[EventName][K] extends {
1889
1916
  resourceType: infer R;
1890
1917
  } ? R : never;
@@ -6153,9 +6180,10 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
6153
6180
  *
6154
6181
  * @category FHIRcast
6155
6182
  * @param subRequest - The `SubscriptionRequest` to use for connecting.
6183
+ * @param options - Options for the underlying `ReconnectingWebSocket`.
6156
6184
  * @returns A `FhircastConnection` which emits lifecycle events for the `FHIRcast` WebSocket connection.
6157
6185
  */
6158
- fhircastConnect(subRequest: SubscriptionRequest): FhircastConnection;
6186
+ fhircastConnect(subRequest: SubscriptionRequest, options?: FhircastConnectionOptions): FhircastConnection;
6159
6187
  /**
6160
6188
  * Publishes a new context to a given topic for a specified event type.
6161
6189
  *
@@ -8250,6 +8278,15 @@ export declare class ParserBuilder {
8250
8278
  */
8251
8279
  export declare function satisfiedAccessPolicy(resource: Resource, interaction: AccessPolicyInteraction, accessPolicy: AccessPolicy | undefined): AccessPolicyResource | undefined;
8252
8280
 
8281
+ /**
8282
+ * Converts a SchedulingParameters duration to minutes.
8283
+ *
8284
+ * @param duration - The duration to convert.
8285
+ * @returns The length in minutes, or undefined when the duration has no value, a
8286
+ * negative value, or a unit scheduling does not accept.
8287
+ */
8288
+ export declare function schedulingDurationToMinutes(duration: Duration | undefined): number | undefined;
8289
+
8253
8290
  export declare const SchedulingEncounterCodingURI = "https://medplum.com/fhir/StructureDefinition/SchedulingEncounterCoding";
8254
8291
 
8255
8292
  export declare const SchedulingParametersURI = "https://medplum.com/fhir/StructureDefinition/SchedulingParameters";
@@ -8732,6 +8769,8 @@ export declare class ParserBuilder {
8732
8769
  [index: string]: any;
8733
8770
  }): string[];
8734
8771
 
8772
+ export declare function sumBy<T>(items: Iterable<T>, fn: (value: T) => number): number;
8773
+
8735
8774
  /**
8736
8775
  * Summarizes a group of Observations into a single computed summary value, with the individual values
8737
8776
  * preserved in `Observation.component.valueSampledData`.