@medplum/core 3.0.1 → 3.0.3

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.
@@ -395,6 +395,7 @@ export declare const ContentType: {
395
395
  readonly SVG: "image/svg+xml";
396
396
  readonly TEXT: "text/plain";
397
397
  readonly TYPESCRIPT: "text/typescript";
398
+ readonly PING: "x-application/ping";
398
399
  };
399
400
 
400
401
  /**
@@ -1197,9 +1198,10 @@ export declare function getDisplayString(resource: Resource): string;
1197
1198
  * Returns an element definition by type and property name.
1198
1199
  * @param typeName - The type name.
1199
1200
  * @param propertyName - The property name.
1201
+ * @param profileUrl - (optional) The URL of the current resource profile
1200
1202
  * @returns The element definition if found.
1201
1203
  */
1202
- export declare function getElementDefinition(typeName: string, propertyName: string): InternalSchemaElement | undefined;
1204
+ export declare function getElementDefinition(typeName: string, propertyName: string, profileUrl?: string): InternalSchemaElement | undefined;
1203
1205
 
1204
1206
  /**
1205
1207
  * Returns an element definition from mapping of elements by property name.
@@ -1255,7 +1257,9 @@ export declare function getIdentifier(resource: Resource, system: string): strin
1255
1257
  */
1256
1258
  export declare function getImageSrc(resource: Resource): string | undefined;
1257
1259
 
1258
- export declare function getNestedProperty(value: TypedValue, key: string): (TypedValue | TypedValue[] | undefined)[];
1260
+ export declare function getNestedProperty(value: TypedValue, key: string, options?: {
1261
+ profileUrl?: string;
1262
+ }): (TypedValue | TypedValue[] | undefined)[];
1259
1263
 
1260
1264
  /**
1261
1265
  * Returns a human friendly display name for a FHIR element definition path.
@@ -1338,18 +1342,24 @@ export declare function getStatus(outcome: OperationOutcome): number;
1338
1342
  * This function returns the value and the type.
1339
1343
  * @param input - The base context (FHIR resource or backbone element).
1340
1344
  * @param path - The property path.
1345
+ * @param options - (optional) Additional options
1341
1346
  * @returns The value of the property and the property type.
1342
1347
  */
1343
- export declare function getTypedPropertyValue(input: TypedValue, path: string): TypedValue[] | TypedValue | undefined;
1348
+ export declare function getTypedPropertyValue(input: TypedValue, path: string, options?: GetTypedPropertyValueOptions): TypedValue[] | TypedValue | undefined;
1349
+
1350
+ export declare interface GetTypedPropertyValueOptions {
1351
+ /** (optional) URL of a resource profile for type resolution */
1352
+ profileUrl?: string;
1353
+ }
1344
1354
 
1345
1355
  /**
1346
1356
  * Returns the value of the property and the property type using a type schema.
1347
- * @param value - The base context (FHIR resource or backbone element).
1357
+ * @param typedValue - The base context (FHIR resource or backbone element).
1348
1358
  * @param path - The property path.
1349
1359
  * @param element - The property element definition.
1350
1360
  * @returns The value of the property and the property type.
1351
1361
  */
1352
- export declare function getTypedPropertyValueWithSchema(value: TypedValue['value'], path: string, element: InternalSchemaElement): TypedValue[] | TypedValue | undefined;
1362
+ export declare function getTypedPropertyValueWithSchema(typedValue: TypedValue, path: string, element: InternalSchemaElement): TypedValue[] | TypedValue | undefined;
1353
1363
 
1354
1364
  /**
1355
1365
  * Global schema singleton.
@@ -1778,6 +1788,20 @@ export declare function isCreated(outcome: OperationOutcome): boolean;
1778
1788
 
1779
1789
  export declare function isDataTypeLoaded(type: string): boolean;
1780
1790
 
1791
+ /**
1792
+ * Returns true if the input value is a YYYY-MM-DD date string.
1793
+ * @param input - Unknown input value.
1794
+ * @returns True if the input is a date string.
1795
+ */
1796
+ export declare function isDateString(input: unknown): input is string;
1797
+
1798
+ /**
1799
+ * Returns true if the input value is a YYYY-MM-DDThh:mm:ss.sssZ date/time string.
1800
+ * @param input - Unknown input value.
1801
+ * @returns True if the input is a date/time string.
1802
+ */
1803
+ export declare function isDateTimeString(input: unknown): input is string;
1804
+
1781
1805
  /**
1782
1806
  * Returns true if the value is empty (null, undefined, empty string, or empty object).
1783
1807
  * @param v - Any value.
@@ -2130,6 +2154,8 @@ export declare const MEDPLUM_VERSION: any;
2130
2154
  * 6. Searching
2131
2155
  * 7. Making GraphQL queries
2132
2156
  *
2157
+ * The client can also be used to integrate with other FHIR servers. For an example, see the Epic Connection Demo Bot [here](https://github.com/medplum/medplum/tree/main/examples/medplum-demo-bots/src/epic).
2158
+ *
2133
2159
  * @example
2134
2160
  * Here is a quick example of how to use the client:
2135
2161
  *
@@ -2631,7 +2657,7 @@ export declare class MedplumClient extends EventTarget_2 {
2631
2657
  * @param resourceType - The FHIR resource type.
2632
2658
  * @param id - The resource ID.
2633
2659
  * @param options - Optional fetch options.
2634
- * @returns The resource if available; undefined otherwise.
2660
+ * @returns The resource if available.
2635
2661
  */
2636
2662
  readResource<K extends ResourceType>(resourceType: K, id: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
2637
2663
  /**
@@ -2652,7 +2678,7 @@ export declare class MedplumClient extends EventTarget_2 {
2652
2678
  * @category Read
2653
2679
  * @param reference - The FHIR reference object.
2654
2680
  * @param options - Optional fetch options.
2655
- * @returns The resource if available; undefined otherwise.
2681
+ * @returns The resource if available.
2656
2682
  */
2657
2683
  readReference<T extends Resource>(reference: Reference<T>, options?: RequestInit): ReadablePromise<T>;
2658
2684
  /**
@@ -2668,9 +2694,10 @@ export declare class MedplumClient extends EventTarget_2 {
2668
2694
  * If the schema is already cached, the promise is resolved immediately.
2669
2695
  * @category Schema
2670
2696
  * @param profileUrl - The FHIR URL of the profile
2671
- * @returns Promise to a schema with the requested profile.
2697
+ * @param options - (optional) Additional options
2698
+ * @returns Promise with an array of URLs of the profile(s) loaded.
2672
2699
  */
2673
- requestProfileSchema(profileUrl: string): Promise<void>;
2700
+ requestProfileSchema(profileUrl: string, options?: RequestProfileSchemaOptions): Promise<string[]>;
2674
2701
  /**
2675
2702
  * Reads resource history by resource type and ID.
2676
2703
  *
@@ -2709,7 +2736,7 @@ export declare class MedplumClient extends EventTarget_2 {
2709
2736
  * @param id - The resource ID.
2710
2737
  * @param vid - The version ID.
2711
2738
  * @param options - Optional fetch options.
2712
- * @returns The resource if available; undefined otherwise.
2739
+ * @returns The resource if available.
2713
2740
  */
2714
2741
  readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
2715
2742
  /**
@@ -3152,7 +3179,7 @@ export declare class MedplumClient extends EventTarget_2 {
3152
3179
  * @param options - Optional fetch options.
3153
3180
  * @returns Promise to the result. If waiting for response, the result is the response body. Otherwise, it is an operation outcome.
3154
3181
  */
3155
- pushToAgent(agent: Agent | Reference<Agent>, destination: Device | Reference<Device>, body: any, contentType?: string, waitForResponse?: boolean, options?: RequestInit): Promise<any>;
3182
+ pushToAgent(agent: Agent | Reference<Agent>, destination: Device | Reference<Device> | string, body: any, contentType?: string, waitForResponse?: boolean, options?: RequestInit): Promise<any>;
3156
3183
  /**
3157
3184
  * @category Authentication
3158
3185
  * @returns The Login State
@@ -3728,6 +3755,8 @@ export declare interface MedplumInfraConfig {
3728
3755
  rdsInstanceType: string;
3729
3756
  rdsInstanceVersion?: string;
3730
3757
  rdsSecretsArn?: string;
3758
+ rdsReaderInstanceType?: string;
3759
+ rdsProxyEnabled?: boolean;
3731
3760
  cacheNodeType?: string;
3732
3761
  desiredServerCount: number;
3733
3762
  serverImage: string;
@@ -3787,8 +3816,10 @@ export declare interface MedplumSourceInfraConfig {
3787
3816
  maxAzs: ValueOrExternalSecret<number>;
3788
3817
  rdsInstances: ValueOrExternalSecret<number>;
3789
3818
  rdsInstanceType: ValueOrExternalSecret<string>;
3790
- rdsInstanceVersion: ValueOrExternalSecret<string>;
3819
+ rdsInstanceVersion?: ValueOrExternalSecret<string>;
3791
3820
  rdsSecretsArn?: ValueOrExternalSecret<string>;
3821
+ rdsReaderInstanceType?: ValueOrExternalSecret<string>;
3822
+ rdsProxyEnabled?: ValueOrExternalSecret<boolean>;
3792
3823
  cacheNodeType?: ValueOrExternalSecret<string>;
3793
3824
  desiredServerCount: ValueOrExternalSecret<number>;
3794
3825
  serverImage: ValueOrExternalSecret<string>;
@@ -4454,6 +4485,11 @@ export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
4454
4485
  */
4455
4486
  export declare function reorderBundle(bundle: Bundle): Bundle;
4456
4487
 
4488
+ export declare interface RequestProfileSchemaOptions {
4489
+ /** (optional) Whether to include nested profiles, e.g. from extensions. Defaults to false. */
4490
+ expandProfile?: boolean;
4491
+ }
4492
+
4457
4493
  /**
4458
4494
  * Returns the ID portion of a reference.
4459
4495
  * @param input - A FHIR reference or resource.
@@ -4579,6 +4615,7 @@ export declare interface SliceDefinition {
4579
4615
  elements: Record<string, InternalSchemaElement>;
4580
4616
  min: number;
4581
4617
  max: number;
4618
+ binding?: ElementDefinitionBinding;
4582
4619
  }
4583
4620
 
4584
4621
  export declare interface SliceDiscriminator {
@@ -4600,6 +4637,15 @@ export declare interface SortRule {
4600
4637
  descending?: boolean;
4601
4638
  }
4602
4639
 
4640
+ /**
4641
+ * Splits a string into an array of strings using the specified delimiter.
4642
+ * Unlike the built-in split function, this function will split the string into a maximum of exactly n parts.
4643
+ * Trailing empty strings are included in the result.
4644
+ * @param str - The string to split.
4645
+ * @param delim - The delimiter.
4646
+ * @param n - The maximum number of parts to split the string into.
4647
+ * @returns The resulting array of strings.
4648
+ */
4603
4649
  export declare function splitN(str: string, delim: string, n: number): string[];
4604
4650
 
4605
4651
  /**
@@ -4738,6 +4784,13 @@ export declare interface TokenResponse {
4738
4784
 
4739
4785
  export declare const tooManyRequests: OperationOutcome;
4740
4786
 
4787
+ /**
4788
+ * Tries to convert an unknown input value to a Period object.
4789
+ * @param input - Unknown input value.
4790
+ * @returns A Period object or undefined.
4791
+ */
4792
+ export declare function toPeriod(input: unknown): Period | undefined;
4793
+
4741
4794
  /**
4742
4795
  * Returns a "best guess" TypedValue for a given value.
4743
4796
  * @param value - The unknown value to check.
@@ -4851,6 +4904,8 @@ export declare function validateResourceType(resourceType: string): void;
4851
4904
 
4852
4905
  export declare function validationError(details: string): OperationOutcome;
4853
4906
 
4907
+ export declare const validationRegexes: Record<string, RegExp>;
4908
+
4854
4909
  export declare type ValueOrExternalSecret<T extends ExternalSecretPrimitive> = T | ExternalSecret<T>;
4855
4910
 
4856
4911
  /**
@@ -395,6 +395,7 @@ export declare const ContentType: {
395
395
  readonly SVG: "image/svg+xml";
396
396
  readonly TEXT: "text/plain";
397
397
  readonly TYPESCRIPT: "text/typescript";
398
+ readonly PING: "x-application/ping";
398
399
  };
399
400
 
400
401
  /**
@@ -1197,9 +1198,10 @@ export declare function getDisplayString(resource: Resource): string;
1197
1198
  * Returns an element definition by type and property name.
1198
1199
  * @param typeName - The type name.
1199
1200
  * @param propertyName - The property name.
1201
+ * @param profileUrl - (optional) The URL of the current resource profile
1200
1202
  * @returns The element definition if found.
1201
1203
  */
1202
- export declare function getElementDefinition(typeName: string, propertyName: string): InternalSchemaElement | undefined;
1204
+ export declare function getElementDefinition(typeName: string, propertyName: string, profileUrl?: string): InternalSchemaElement | undefined;
1203
1205
 
1204
1206
  /**
1205
1207
  * Returns an element definition from mapping of elements by property name.
@@ -1255,7 +1257,9 @@ export declare function getIdentifier(resource: Resource, system: string): strin
1255
1257
  */
1256
1258
  export declare function getImageSrc(resource: Resource): string | undefined;
1257
1259
 
1258
- export declare function getNestedProperty(value: TypedValue, key: string): (TypedValue | TypedValue[] | undefined)[];
1260
+ export declare function getNestedProperty(value: TypedValue, key: string, options?: {
1261
+ profileUrl?: string;
1262
+ }): (TypedValue | TypedValue[] | undefined)[];
1259
1263
 
1260
1264
  /**
1261
1265
  * Returns a human friendly display name for a FHIR element definition path.
@@ -1338,18 +1342,24 @@ export declare function getStatus(outcome: OperationOutcome): number;
1338
1342
  * This function returns the value and the type.
1339
1343
  * @param input - The base context (FHIR resource or backbone element).
1340
1344
  * @param path - The property path.
1345
+ * @param options - (optional) Additional options
1341
1346
  * @returns The value of the property and the property type.
1342
1347
  */
1343
- export declare function getTypedPropertyValue(input: TypedValue, path: string): TypedValue[] | TypedValue | undefined;
1348
+ export declare function getTypedPropertyValue(input: TypedValue, path: string, options?: GetTypedPropertyValueOptions): TypedValue[] | TypedValue | undefined;
1349
+
1350
+ export declare interface GetTypedPropertyValueOptions {
1351
+ /** (optional) URL of a resource profile for type resolution */
1352
+ profileUrl?: string;
1353
+ }
1344
1354
 
1345
1355
  /**
1346
1356
  * Returns the value of the property and the property type using a type schema.
1347
- * @param value - The base context (FHIR resource or backbone element).
1357
+ * @param typedValue - The base context (FHIR resource or backbone element).
1348
1358
  * @param path - The property path.
1349
1359
  * @param element - The property element definition.
1350
1360
  * @returns The value of the property and the property type.
1351
1361
  */
1352
- export declare function getTypedPropertyValueWithSchema(value: TypedValue['value'], path: string, element: InternalSchemaElement): TypedValue[] | TypedValue | undefined;
1362
+ export declare function getTypedPropertyValueWithSchema(typedValue: TypedValue, path: string, element: InternalSchemaElement): TypedValue[] | TypedValue | undefined;
1353
1363
 
1354
1364
  /**
1355
1365
  * Global schema singleton.
@@ -1778,6 +1788,20 @@ export declare function isCreated(outcome: OperationOutcome): boolean;
1778
1788
 
1779
1789
  export declare function isDataTypeLoaded(type: string): boolean;
1780
1790
 
1791
+ /**
1792
+ * Returns true if the input value is a YYYY-MM-DD date string.
1793
+ * @param input - Unknown input value.
1794
+ * @returns True if the input is a date string.
1795
+ */
1796
+ export declare function isDateString(input: unknown): input is string;
1797
+
1798
+ /**
1799
+ * Returns true if the input value is a YYYY-MM-DDThh:mm:ss.sssZ date/time string.
1800
+ * @param input - Unknown input value.
1801
+ * @returns True if the input is a date/time string.
1802
+ */
1803
+ export declare function isDateTimeString(input: unknown): input is string;
1804
+
1781
1805
  /**
1782
1806
  * Returns true if the value is empty (null, undefined, empty string, or empty object).
1783
1807
  * @param v - Any value.
@@ -2130,6 +2154,8 @@ export declare const MEDPLUM_VERSION: any;
2130
2154
  * 6. Searching
2131
2155
  * 7. Making GraphQL queries
2132
2156
  *
2157
+ * The client can also be used to integrate with other FHIR servers. For an example, see the Epic Connection Demo Bot [here](https://github.com/medplum/medplum/tree/main/examples/medplum-demo-bots/src/epic).
2158
+ *
2133
2159
  * @example
2134
2160
  * Here is a quick example of how to use the client:
2135
2161
  *
@@ -2631,7 +2657,7 @@ export declare class MedplumClient extends EventTarget_2 {
2631
2657
  * @param resourceType - The FHIR resource type.
2632
2658
  * @param id - The resource ID.
2633
2659
  * @param options - Optional fetch options.
2634
- * @returns The resource if available; undefined otherwise.
2660
+ * @returns The resource if available.
2635
2661
  */
2636
2662
  readResource<K extends ResourceType>(resourceType: K, id: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
2637
2663
  /**
@@ -2652,7 +2678,7 @@ export declare class MedplumClient extends EventTarget_2 {
2652
2678
  * @category Read
2653
2679
  * @param reference - The FHIR reference object.
2654
2680
  * @param options - Optional fetch options.
2655
- * @returns The resource if available; undefined otherwise.
2681
+ * @returns The resource if available.
2656
2682
  */
2657
2683
  readReference<T extends Resource>(reference: Reference<T>, options?: RequestInit): ReadablePromise<T>;
2658
2684
  /**
@@ -2668,9 +2694,10 @@ export declare class MedplumClient extends EventTarget_2 {
2668
2694
  * If the schema is already cached, the promise is resolved immediately.
2669
2695
  * @category Schema
2670
2696
  * @param profileUrl - The FHIR URL of the profile
2671
- * @returns Promise to a schema with the requested profile.
2697
+ * @param options - (optional) Additional options
2698
+ * @returns Promise with an array of URLs of the profile(s) loaded.
2672
2699
  */
2673
- requestProfileSchema(profileUrl: string): Promise<void>;
2700
+ requestProfileSchema(profileUrl: string, options?: RequestProfileSchemaOptions): Promise<string[]>;
2674
2701
  /**
2675
2702
  * Reads resource history by resource type and ID.
2676
2703
  *
@@ -2709,7 +2736,7 @@ export declare class MedplumClient extends EventTarget_2 {
2709
2736
  * @param id - The resource ID.
2710
2737
  * @param vid - The version ID.
2711
2738
  * @param options - Optional fetch options.
2712
- * @returns The resource if available; undefined otherwise.
2739
+ * @returns The resource if available.
2713
2740
  */
2714
2741
  readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
2715
2742
  /**
@@ -3152,7 +3179,7 @@ export declare class MedplumClient extends EventTarget_2 {
3152
3179
  * @param options - Optional fetch options.
3153
3180
  * @returns Promise to the result. If waiting for response, the result is the response body. Otherwise, it is an operation outcome.
3154
3181
  */
3155
- pushToAgent(agent: Agent | Reference<Agent>, destination: Device | Reference<Device>, body: any, contentType?: string, waitForResponse?: boolean, options?: RequestInit): Promise<any>;
3182
+ pushToAgent(agent: Agent | Reference<Agent>, destination: Device | Reference<Device> | string, body: any, contentType?: string, waitForResponse?: boolean, options?: RequestInit): Promise<any>;
3156
3183
  /**
3157
3184
  * @category Authentication
3158
3185
  * @returns The Login State
@@ -3728,6 +3755,8 @@ export declare interface MedplumInfraConfig {
3728
3755
  rdsInstanceType: string;
3729
3756
  rdsInstanceVersion?: string;
3730
3757
  rdsSecretsArn?: string;
3758
+ rdsReaderInstanceType?: string;
3759
+ rdsProxyEnabled?: boolean;
3731
3760
  cacheNodeType?: string;
3732
3761
  desiredServerCount: number;
3733
3762
  serverImage: string;
@@ -3787,8 +3816,10 @@ export declare interface MedplumSourceInfraConfig {
3787
3816
  maxAzs: ValueOrExternalSecret<number>;
3788
3817
  rdsInstances: ValueOrExternalSecret<number>;
3789
3818
  rdsInstanceType: ValueOrExternalSecret<string>;
3790
- rdsInstanceVersion: ValueOrExternalSecret<string>;
3819
+ rdsInstanceVersion?: ValueOrExternalSecret<string>;
3791
3820
  rdsSecretsArn?: ValueOrExternalSecret<string>;
3821
+ rdsReaderInstanceType?: ValueOrExternalSecret<string>;
3822
+ rdsProxyEnabled?: ValueOrExternalSecret<boolean>;
3792
3823
  cacheNodeType?: ValueOrExternalSecret<string>;
3793
3824
  desiredServerCount: ValueOrExternalSecret<number>;
3794
3825
  serverImage: ValueOrExternalSecret<string>;
@@ -4454,6 +4485,11 @@ export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
4454
4485
  */
4455
4486
  export declare function reorderBundle(bundle: Bundle): Bundle;
4456
4487
 
4488
+ export declare interface RequestProfileSchemaOptions {
4489
+ /** (optional) Whether to include nested profiles, e.g. from extensions. Defaults to false. */
4490
+ expandProfile?: boolean;
4491
+ }
4492
+
4457
4493
  /**
4458
4494
  * Returns the ID portion of a reference.
4459
4495
  * @param input - A FHIR reference or resource.
@@ -4579,6 +4615,7 @@ export declare interface SliceDefinition {
4579
4615
  elements: Record<string, InternalSchemaElement>;
4580
4616
  min: number;
4581
4617
  max: number;
4618
+ binding?: ElementDefinitionBinding;
4582
4619
  }
4583
4620
 
4584
4621
  export declare interface SliceDiscriminator {
@@ -4600,6 +4637,15 @@ export declare interface SortRule {
4600
4637
  descending?: boolean;
4601
4638
  }
4602
4639
 
4640
+ /**
4641
+ * Splits a string into an array of strings using the specified delimiter.
4642
+ * Unlike the built-in split function, this function will split the string into a maximum of exactly n parts.
4643
+ * Trailing empty strings are included in the result.
4644
+ * @param str - The string to split.
4645
+ * @param delim - The delimiter.
4646
+ * @param n - The maximum number of parts to split the string into.
4647
+ * @returns The resulting array of strings.
4648
+ */
4603
4649
  export declare function splitN(str: string, delim: string, n: number): string[];
4604
4650
 
4605
4651
  /**
@@ -4738,6 +4784,13 @@ export declare interface TokenResponse {
4738
4784
 
4739
4785
  export declare const tooManyRequests: OperationOutcome;
4740
4786
 
4787
+ /**
4788
+ * Tries to convert an unknown input value to a Period object.
4789
+ * @param input - Unknown input value.
4790
+ * @returns A Period object or undefined.
4791
+ */
4792
+ export declare function toPeriod(input: unknown): Period | undefined;
4793
+
4741
4794
  /**
4742
4795
  * Returns a "best guess" TypedValue for a given value.
4743
4796
  * @param value - The unknown value to check.
@@ -4851,6 +4904,8 @@ export declare function validateResourceType(resourceType: string): void;
4851
4904
 
4852
4905
  export declare function validationError(details: string): OperationOutcome;
4853
4906
 
4907
+ export declare const validationRegexes: Record<string, RegExp>;
4908
+
4854
4909
  export declare type ValueOrExternalSecret<T extends ExternalSecretPrimitive> = T | ExternalSecret<T>;
4855
4910
 
4856
4911
  /**