@medplum/core 3.1.6 → 3.1.7

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.
@@ -18,6 +18,7 @@ import { Device } from '@medplum/fhirtypes';
18
18
  import { ElementDefinition } from '@medplum/fhirtypes';
19
19
  import { ElementDefinitionBinding } from '@medplum/fhirtypes';
20
20
  import { Extension } from '@medplum/fhirtypes';
21
+ import { ExtensionValue } from '@medplum/fhirtypes';
21
22
  import { ExtractResource } from '@medplum/fhirtypes';
22
23
  import { HumanName } from '@medplum/fhirtypes';
23
24
  import { Identifier } from '@medplum/fhirtypes';
@@ -48,6 +49,7 @@ import { ResourceType } from '@medplum/fhirtypes';
48
49
  import { SearchParameter } from '@medplum/fhirtypes';
49
50
  import { StructureDefinition } from '@medplum/fhirtypes';
50
51
  import { StructureMap } from '@medplum/fhirtypes';
52
+ import { Subscription } from '@medplum/fhirtypes';
51
53
  import type { TDocumentDefinitions } from 'pdfmake/interfaces';
52
54
  import type { TFontDictionary } from 'pdfmake/interfaces';
53
55
  import { Timing } from '@medplum/fhirtypes';
@@ -241,6 +243,12 @@ export declare interface AtomContext {
241
243
  variables: Record<string, TypedValue>;
242
244
  }
243
245
 
246
+ export declare interface BackgroundJobContext {
247
+ interaction: BackgroundJobInteraction;
248
+ }
249
+
250
+ export declare type BackgroundJobInteraction = 'create' | 'update' | 'delete';
251
+
244
252
  export declare function badRequest(details: string, expression?: string): OperationOutcome;
245
253
 
246
254
  export declare interface BaseAgentMessage {
@@ -293,7 +301,7 @@ export declare interface BotEvent<T = Resource | Hl7Message | string | Record<st
293
301
  readonly traceId?: string;
294
302
  }
295
303
 
296
- export declare function buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, }: {
304
+ export declare function buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, accessPolicyResource, }: {
297
305
  /** The most recent `ElementsContextType` in which this context is being built. */
298
306
  parentContext: ElementsContextType | undefined;
299
307
  /** The FHIR path from the root resource to which the keys of `elements` are relative. */
@@ -307,6 +315,7 @@ export declare function buildElementsContext({ parentContext, path, elements, pr
307
315
  profileUrl?: string;
308
316
  /** Whether debug logging is enabled */
309
317
  debugMode?: boolean;
318
+ accessPolicyResource?: AccessPolicyResource;
310
319
  }): ElementsContextType | undefined;
311
320
 
312
321
  export declare function buildTypeName(components: string[]): string;
@@ -663,20 +672,39 @@ export declare type ElementsContextType = {
663
672
  /** The FHIR path from the root resource to which the keys of `elements` are relative. */
664
673
  path: string;
665
674
  /**
666
- * The mapping of keys to `InternalSchemaElement` at the current `path` relative to the
675
+ * The mapping of keys to `ExtendedInternalSchemaElement` at the current `path` relative to the
667
676
  * root resource. `elements` originate from either `InternalTypeSchema.elements` or
668
677
  * `SliceDefinition.elements` when the elements context is created within a slice.
669
678
  */
670
- elements: Record<string, InternalSchemaElement>;
679
+ elements: Record<string, ExtendedInternalSchemaElement>;
671
680
  /**
672
681
  * Similar mapping as `elements`, but with keys being the full path from the root resource rather
673
682
  * than relative to `path`, in other words, the keys of the Record are `${path}.${key}`.
674
683
  */
675
- elementsByPath: Record<string, InternalSchemaElement>;
684
+ elementsByPath: Record<string, ExtendedInternalSchemaElement>;
676
685
  /** The URL, if any, of the resource profile or extension from which the `elements` collection originated. */
677
686
  profileUrl: string | undefined;
678
687
  /** Whether debug logging is enabled */
679
688
  debugMode: boolean;
689
+ /** The `AccessPolicyResource` provided, if any, used to determine hidden and readonly elements. */
690
+ accessPolicyResource?: AccessPolicyResource;
691
+ /**
692
+ * Used to get an `ExtendedElementProperties` object for an element at a given path. This
693
+ * is primarily useful when working with elements not included in `InternalTypeSchema.elements`
694
+ * as is the case for nested elements that have not been modified by a profile or extension,
695
+ * e.g. Patient.name.family.
696
+ *
697
+ * This function does not attempt to determine if the input `path` is actually an element in the
698
+ * resource. When a syntactically correct path to a nonexistent element, e.g. Patient.foobar, is provided,
699
+ * a `ExtendedElementProperties` object with default values is returned.
700
+ *
701
+ * @param path - The full path to an element in the resource, e.g. Patient.name.family
702
+ * @returns An `ExtendedElementProperties` object with `readonly` and `hidden` properties for the
703
+ * element at `path`, or `undefined` if the input path is malformed.
704
+ */
705
+ getExtendedProps(path: string): ExtendedElementProperties | undefined;
706
+ /** `true` if this is a default/placeholder `ElementsContextType` */
707
+ isDefaultContext?: boolean;
680
708
  };
681
709
 
682
710
  export declare interface ElementType {
@@ -772,6 +800,15 @@ declare class EventTarget_2 {
772
800
  }
773
801
  export { EventTarget_2 as EventTarget }
774
802
 
803
+ export declare type ExtendedElementProperties = {
804
+ readonly: boolean;
805
+ hidden: boolean;
806
+ };
807
+
808
+ export declare interface ExtendedInternalSchemaElement extends InternalSchemaElement {
809
+ readonly?: boolean;
810
+ }
811
+
775
812
  export declare type ExternalSecret<T extends ExternalSecretPrimitive = ExternalSecretPrimitive> = {
776
813
  system: ExternalSecretSystem;
777
814
  key: string;
@@ -1412,7 +1449,7 @@ export declare function getExtension(resource: any, ...urls: string[]): Extensio
1412
1449
  * @param urls - Array of extension URLs. Each entry represents a nested extension.
1413
1450
  * @returns The extension value if found; undefined otherwise.
1414
1451
  */
1415
- export declare function getExtensionValue(resource: any, ...urls: string[]): string | undefined;
1452
+ export declare function getExtensionValue(resource: any, ...urls: string[]): ExtensionValue | undefined;
1416
1453
 
1417
1454
  /**
1418
1455
  * Returns the resource identifier for the given system.
@@ -1853,7 +1890,7 @@ export declare interface IncludeTarget {
1853
1890
  resourceType: string;
1854
1891
  searchParam: string;
1855
1892
  targetType?: string;
1856
- modifier?: string;
1893
+ modifier?: 'iterate';
1857
1894
  }
1858
1895
 
1859
1896
  /**
@@ -2060,6 +2097,8 @@ export declare function isEmpty(v: unknown): boolean;
2060
2097
  */
2061
2098
  export declare function isFhircastResourceType(resourceType: FhircastResourceType): boolean;
2062
2099
 
2100
+ export declare function isFhirCriteriaMet(subscription: Subscription, currentResource: Resource, getPreviousResource: (currentResource: Resource) => Promise<Resource | undefined>): Promise<boolean>;
2101
+
2063
2102
  export declare function isGone(outcome: OperationOutcome): boolean;
2064
2103
 
2065
2104
  /**
@@ -4195,10 +4234,12 @@ export declare interface MedplumInfraConfig {
4195
4234
  rdsReaderInstanceType?: string;
4196
4235
  rdsProxyEnabled?: boolean;
4197
4236
  cacheNodeType?: string;
4237
+ cacheSecurityGroupId?: string;
4198
4238
  desiredServerCount: number;
4199
4239
  serverImage: string;
4200
4240
  serverMemory: number;
4201
4241
  serverCpu: number;
4242
+ loadBalancerSecurityGroupId?: string;
4202
4243
  loadBalancerLoggingBucket?: string;
4203
4244
  loadBalancerLoggingPrefix?: string;
4204
4245
  clamscanEnabled: boolean;
@@ -4307,10 +4348,12 @@ export declare interface MedplumSourceInfraConfig {
4307
4348
  rdsReaderInstanceType?: ValueOrExternalSecret<string>;
4308
4349
  rdsProxyEnabled?: ValueOrExternalSecret<boolean>;
4309
4350
  cacheNodeType?: ValueOrExternalSecret<string>;
4351
+ cacheSecurityGroupId?: ValueOrExternalSecret<string>;
4310
4352
  desiredServerCount: ValueOrExternalSecret<number>;
4311
4353
  serverImage: ValueOrExternalSecret<string>;
4312
4354
  serverMemory: ValueOrExternalSecret<number>;
4313
4355
  serverCpu: ValueOrExternalSecret<number>;
4356
+ loadBalancerSecurityGroupId?: ValueOrExternalSecret<string>;
4314
4357
  loadBalancerLoggingBucket?: ValueOrExternalSecret<string>;
4315
4358
  loadBalancerLoggingPrefix?: ValueOrExternalSecret<string>;
4316
4359
  clamscanEnabled: ValueOrExternalSecret<boolean>;
@@ -5019,6 +5062,16 @@ export declare type ResourceArray<T extends Resource = Resource> = T[] & {
5019
5062
  bundle: Bundle<T>;
5020
5063
  };
5021
5064
 
5065
+ export declare type ResourceMatchesSubscriptionCriteria = {
5066
+ resource: Resource;
5067
+ subscription: Subscription;
5068
+ context: BackgroundJobContext;
5069
+ logger?: Logger;
5070
+ getPreviousResource: (currentResource: Resource) => Promise<Resource | undefined>;
5071
+ };
5072
+
5073
+ export declare function resourceMatchesSubscriptionCriteria({ resource, subscription, context, getPreviousResource, logger, }: ResourceMatchesSubscriptionCriteria): Promise<boolean>;
5074
+
5022
5075
  export declare interface ResourceVisitor {
5023
5076
  onEnterObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void;
5024
5077
  onExitObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void;
@@ -5194,6 +5247,17 @@ export declare function sortStringArray(array: string[]): string[];
5194
5247
  */
5195
5248
  export declare function splitN(str: string, delim: string, n: number): string[];
5196
5249
 
5250
+ /**
5251
+ * Splits a FHIR search value on commas.
5252
+ * Respects backslash escape.
5253
+ *
5254
+ * See: https://hl7.org/fhir/r4/search.html#escaping
5255
+ *
5256
+ * @param input - The FHIR search value to split.
5257
+ * @returns The individual search values.
5258
+ */
5259
+ export declare function splitSearchOnComma(input: string): string[];
5260
+
5197
5261
  /**
5198
5262
  * Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data.
5199
5263
  * @param stream - The Readable stream to read from.
@@ -18,6 +18,7 @@ import { Device } from '@medplum/fhirtypes';
18
18
  import { ElementDefinition } from '@medplum/fhirtypes';
19
19
  import { ElementDefinitionBinding } from '@medplum/fhirtypes';
20
20
  import { Extension } from '@medplum/fhirtypes';
21
+ import { ExtensionValue } from '@medplum/fhirtypes';
21
22
  import { ExtractResource } from '@medplum/fhirtypes';
22
23
  import { HumanName } from '@medplum/fhirtypes';
23
24
  import { Identifier } from '@medplum/fhirtypes';
@@ -48,6 +49,7 @@ import { ResourceType } from '@medplum/fhirtypes';
48
49
  import { SearchParameter } from '@medplum/fhirtypes';
49
50
  import { StructureDefinition } from '@medplum/fhirtypes';
50
51
  import { StructureMap } from '@medplum/fhirtypes';
52
+ import { Subscription } from '@medplum/fhirtypes';
51
53
  import type { TDocumentDefinitions } from 'pdfmake/interfaces';
52
54
  import type { TFontDictionary } from 'pdfmake/interfaces';
53
55
  import { Timing } from '@medplum/fhirtypes';
@@ -241,6 +243,12 @@ export declare interface AtomContext {
241
243
  variables: Record<string, TypedValue>;
242
244
  }
243
245
 
246
+ export declare interface BackgroundJobContext {
247
+ interaction: BackgroundJobInteraction;
248
+ }
249
+
250
+ export declare type BackgroundJobInteraction = 'create' | 'update' | 'delete';
251
+
244
252
  export declare function badRequest(details: string, expression?: string): OperationOutcome;
245
253
 
246
254
  export declare interface BaseAgentMessage {
@@ -293,7 +301,7 @@ export declare interface BotEvent<T = Resource | Hl7Message | string | Record<st
293
301
  readonly traceId?: string;
294
302
  }
295
303
 
296
- export declare function buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, }: {
304
+ export declare function buildElementsContext({ parentContext, path, elements, profileUrl, debugMode, accessPolicyResource, }: {
297
305
  /** The most recent `ElementsContextType` in which this context is being built. */
298
306
  parentContext: ElementsContextType | undefined;
299
307
  /** The FHIR path from the root resource to which the keys of `elements` are relative. */
@@ -307,6 +315,7 @@ export declare function buildElementsContext({ parentContext, path, elements, pr
307
315
  profileUrl?: string;
308
316
  /** Whether debug logging is enabled */
309
317
  debugMode?: boolean;
318
+ accessPolicyResource?: AccessPolicyResource;
310
319
  }): ElementsContextType | undefined;
311
320
 
312
321
  export declare function buildTypeName(components: string[]): string;
@@ -663,20 +672,39 @@ export declare type ElementsContextType = {
663
672
  /** The FHIR path from the root resource to which the keys of `elements` are relative. */
664
673
  path: string;
665
674
  /**
666
- * The mapping of keys to `InternalSchemaElement` at the current `path` relative to the
675
+ * The mapping of keys to `ExtendedInternalSchemaElement` at the current `path` relative to the
667
676
  * root resource. `elements` originate from either `InternalTypeSchema.elements` or
668
677
  * `SliceDefinition.elements` when the elements context is created within a slice.
669
678
  */
670
- elements: Record<string, InternalSchemaElement>;
679
+ elements: Record<string, ExtendedInternalSchemaElement>;
671
680
  /**
672
681
  * Similar mapping as `elements`, but with keys being the full path from the root resource rather
673
682
  * than relative to `path`, in other words, the keys of the Record are `${path}.${key}`.
674
683
  */
675
- elementsByPath: Record<string, InternalSchemaElement>;
684
+ elementsByPath: Record<string, ExtendedInternalSchemaElement>;
676
685
  /** The URL, if any, of the resource profile or extension from which the `elements` collection originated. */
677
686
  profileUrl: string | undefined;
678
687
  /** Whether debug logging is enabled */
679
688
  debugMode: boolean;
689
+ /** The `AccessPolicyResource` provided, if any, used to determine hidden and readonly elements. */
690
+ accessPolicyResource?: AccessPolicyResource;
691
+ /**
692
+ * Used to get an `ExtendedElementProperties` object for an element at a given path. This
693
+ * is primarily useful when working with elements not included in `InternalTypeSchema.elements`
694
+ * as is the case for nested elements that have not been modified by a profile or extension,
695
+ * e.g. Patient.name.family.
696
+ *
697
+ * This function does not attempt to determine if the input `path` is actually an element in the
698
+ * resource. When a syntactically correct path to a nonexistent element, e.g. Patient.foobar, is provided,
699
+ * a `ExtendedElementProperties` object with default values is returned.
700
+ *
701
+ * @param path - The full path to an element in the resource, e.g. Patient.name.family
702
+ * @returns An `ExtendedElementProperties` object with `readonly` and `hidden` properties for the
703
+ * element at `path`, or `undefined` if the input path is malformed.
704
+ */
705
+ getExtendedProps(path: string): ExtendedElementProperties | undefined;
706
+ /** `true` if this is a default/placeholder `ElementsContextType` */
707
+ isDefaultContext?: boolean;
680
708
  };
681
709
 
682
710
  export declare interface ElementType {
@@ -772,6 +800,15 @@ declare class EventTarget_2 {
772
800
  }
773
801
  export { EventTarget_2 as EventTarget }
774
802
 
803
+ export declare type ExtendedElementProperties = {
804
+ readonly: boolean;
805
+ hidden: boolean;
806
+ };
807
+
808
+ export declare interface ExtendedInternalSchemaElement extends InternalSchemaElement {
809
+ readonly?: boolean;
810
+ }
811
+
775
812
  export declare type ExternalSecret<T extends ExternalSecretPrimitive = ExternalSecretPrimitive> = {
776
813
  system: ExternalSecretSystem;
777
814
  key: string;
@@ -1412,7 +1449,7 @@ export declare function getExtension(resource: any, ...urls: string[]): Extensio
1412
1449
  * @param urls - Array of extension URLs. Each entry represents a nested extension.
1413
1450
  * @returns The extension value if found; undefined otherwise.
1414
1451
  */
1415
- export declare function getExtensionValue(resource: any, ...urls: string[]): string | undefined;
1452
+ export declare function getExtensionValue(resource: any, ...urls: string[]): ExtensionValue | undefined;
1416
1453
 
1417
1454
  /**
1418
1455
  * Returns the resource identifier for the given system.
@@ -1853,7 +1890,7 @@ export declare interface IncludeTarget {
1853
1890
  resourceType: string;
1854
1891
  searchParam: string;
1855
1892
  targetType?: string;
1856
- modifier?: string;
1893
+ modifier?: 'iterate';
1857
1894
  }
1858
1895
 
1859
1896
  /**
@@ -2060,6 +2097,8 @@ export declare function isEmpty(v: unknown): boolean;
2060
2097
  */
2061
2098
  export declare function isFhircastResourceType(resourceType: FhircastResourceType): boolean;
2062
2099
 
2100
+ export declare function isFhirCriteriaMet(subscription: Subscription, currentResource: Resource, getPreviousResource: (currentResource: Resource) => Promise<Resource | undefined>): Promise<boolean>;
2101
+
2063
2102
  export declare function isGone(outcome: OperationOutcome): boolean;
2064
2103
 
2065
2104
  /**
@@ -4195,10 +4234,12 @@ export declare interface MedplumInfraConfig {
4195
4234
  rdsReaderInstanceType?: string;
4196
4235
  rdsProxyEnabled?: boolean;
4197
4236
  cacheNodeType?: string;
4237
+ cacheSecurityGroupId?: string;
4198
4238
  desiredServerCount: number;
4199
4239
  serverImage: string;
4200
4240
  serverMemory: number;
4201
4241
  serverCpu: number;
4242
+ loadBalancerSecurityGroupId?: string;
4202
4243
  loadBalancerLoggingBucket?: string;
4203
4244
  loadBalancerLoggingPrefix?: string;
4204
4245
  clamscanEnabled: boolean;
@@ -4307,10 +4348,12 @@ export declare interface MedplumSourceInfraConfig {
4307
4348
  rdsReaderInstanceType?: ValueOrExternalSecret<string>;
4308
4349
  rdsProxyEnabled?: ValueOrExternalSecret<boolean>;
4309
4350
  cacheNodeType?: ValueOrExternalSecret<string>;
4351
+ cacheSecurityGroupId?: ValueOrExternalSecret<string>;
4310
4352
  desiredServerCount: ValueOrExternalSecret<number>;
4311
4353
  serverImage: ValueOrExternalSecret<string>;
4312
4354
  serverMemory: ValueOrExternalSecret<number>;
4313
4355
  serverCpu: ValueOrExternalSecret<number>;
4356
+ loadBalancerSecurityGroupId?: ValueOrExternalSecret<string>;
4314
4357
  loadBalancerLoggingBucket?: ValueOrExternalSecret<string>;
4315
4358
  loadBalancerLoggingPrefix?: ValueOrExternalSecret<string>;
4316
4359
  clamscanEnabled: ValueOrExternalSecret<boolean>;
@@ -5019,6 +5062,16 @@ export declare type ResourceArray<T extends Resource = Resource> = T[] & {
5019
5062
  bundle: Bundle<T>;
5020
5063
  };
5021
5064
 
5065
+ export declare type ResourceMatchesSubscriptionCriteria = {
5066
+ resource: Resource;
5067
+ subscription: Subscription;
5068
+ context: BackgroundJobContext;
5069
+ logger?: Logger;
5070
+ getPreviousResource: (currentResource: Resource) => Promise<Resource | undefined>;
5071
+ };
5072
+
5073
+ export declare function resourceMatchesSubscriptionCriteria({ resource, subscription, context, getPreviousResource, logger, }: ResourceMatchesSubscriptionCriteria): Promise<boolean>;
5074
+
5022
5075
  export declare interface ResourceVisitor {
5023
5076
  onEnterObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void;
5024
5077
  onExitObject?: (path: string, value: TypedValueWithPath, schema: InternalTypeSchema) => void;
@@ -5194,6 +5247,17 @@ export declare function sortStringArray(array: string[]): string[];
5194
5247
  */
5195
5248
  export declare function splitN(str: string, delim: string, n: number): string[];
5196
5249
 
5250
+ /**
5251
+ * Splits a FHIR search value on commas.
5252
+ * Respects backslash escape.
5253
+ *
5254
+ * See: https://hl7.org/fhir/r4/search.html#escaping
5255
+ *
5256
+ * @param input - The FHIR search value to split.
5257
+ * @returns The individual search values.
5258
+ */
5259
+ export declare function splitSearchOnComma(input: string): string[];
5260
+
5197
5261
  /**
5198
5262
  * Reads data from a Readable stream and returns a Promise that resolves with a Buffer containing all the data.
5199
5263
  * @param stream - The Readable stream to read from.