@medplum/core 5.1.9 → 5.1.10

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.
@@ -2368,6 +2368,9 @@ export declare interface Hl7DateParseOptions {
2368
2368
  export declare class Hl7Field {
2369
2369
  readonly context: Hl7Context;
2370
2370
  readonly components: string[][];
2371
+ /** @internal */
2372
+ onModified?: () => void;
2373
+ private cachedString;
2371
2374
  /**
2372
2375
  * Creates a new HL7 field.
2373
2376
  * @param components - The HL7 components.
@@ -2420,6 +2423,7 @@ export declare class Hl7Field {
2420
2423
  * @returns true if the component was set, false otherwise
2421
2424
  */
2422
2425
  setComponent(component: number, value: string, subcomponent?: number, repetition?: number): boolean;
2426
+ private invalidateCache;
2423
2427
  }
2424
2428
 
2425
2429
  /**
@@ -2428,13 +2432,42 @@ export declare class Hl7Field {
2428
2432
  */
2429
2433
  export declare class Hl7Message {
2430
2434
  readonly context: Hl7Context;
2431
- readonly segments: Hl7Segment[];
2435
+ /**
2436
+ * Internal lazy-parsed segment storage. Entries are `string` until they
2437
+ * are accessed (via {@link getSegment}, {@link getAllSegments}, {@link header},
2438
+ * or the public {@link segments} getter), at which point they are parsed in
2439
+ * place and replaced with their {@link Hl7Segment} form.
2440
+ */
2441
+ private readonly _segments;
2442
+ /**
2443
+ * Maps segment name → indices into {@link _segments}. Storing indices (rather
2444
+ * than references to the segments themselves) keeps this map in sync with
2445
+ * {@link _segments} without needing a per-parse update step, and is immune to
2446
+ * collisions when two segments have identical raw text.
2447
+ */
2448
+ private segmentsByName;
2449
+ private cachedString;
2450
+ /** Becomes true once every entry in `_segments` has been parsed. */
2451
+ private allSegmentsParsed;
2432
2452
  /**
2433
2453
  * Creates a new HL7 message.
2454
+ *
2455
+ * Segment strings are not parsed until they are accessed via {@link getSegment},
2456
+ * {@link getAllSegments}, {@link header}, or the {@link segments} getter.
2457
+ *
2434
2458
  * @param segments - The HL7 segments.
2435
2459
  * @param context - Optional HL7 parsing context.
2436
2460
  */
2437
- constructor(segments: Hl7Segment[], context?: Hl7Context);
2461
+ constructor(segments: (Hl7Segment | string)[], context?: Hl7Context);
2462
+ /**
2463
+ * Returns all HL7 segments, parsing any unparsed segment strings on first access.
2464
+ *
2465
+ * Prefer {@link getSegment} or {@link getAllSegments} when you only need a subset
2466
+ * of segments; those methods avoid parsing unrelated segments.
2467
+ *
2468
+ * @returns The HL7 segments array.
2469
+ */
2470
+ get segments(): Hl7Segment[];
2438
2471
  /**
2439
2472
  * Returns the HL7 message header.
2440
2473
  * @returns The HL7 message header.
@@ -2461,18 +2494,35 @@ export declare class Hl7Message {
2461
2494
  *
2462
2495
  * When using a string index, this method returns the first segment with the specified name.
2463
2496
  *
2497
+ * Segments are lazily parsed; the requested segment is parsed and cached on demand.
2498
+ *
2464
2499
  * @param index - The HL7 segment index or name.
2465
2500
  * @returns The HL7 segment if found; otherwise, undefined.
2466
2501
  */
2467
2502
  getSegment(index: number | string): Hl7Segment | undefined;
2468
2503
  /**
2469
2504
  * Returns all HL7 segments of a given name.
2505
+ *
2506
+ * Only the segments that match the requested name are parsed, which avoids parsing
2507
+ * unrelated segments when scanning a message.
2508
+ *
2470
2509
  * @param name - The HL7 segment name.
2471
2510
  * @returns An array of HL7 segments with the specified name.
2472
2511
  */
2473
2512
  getAllSegments(name: string): Hl7Segment[];
2513
+ /**
2514
+ * Parses the segment at the given index (if not already parsed), caches it back into
2515
+ * the segments array, and wires up the onModified callback.
2516
+ * @param index - The HL7 segment index.
2517
+ * @returns The parsed HL7 segment, or undefined if the index is out of range.
2518
+ */
2519
+ private parseSegment;
2474
2520
  /**
2475
2521
  * Returns the HL7 message as a string.
2522
+ *
2523
+ * Unparsed segments are emitted directly from their original string form, which
2524
+ * preserves the source text without forcing a parse.
2525
+ *
2476
2526
  * @returns The HL7 message as a string.
2477
2527
  */
2478
2528
  toString(): string;
@@ -2499,6 +2549,9 @@ export declare class Hl7Message {
2499
2549
  * @returns true if the segment was set, false otherwise
2500
2550
  */
2501
2551
  setSegment(index: number | string, segment: Hl7Segment): boolean;
2552
+ private findSegmentIndexByName;
2553
+ private invalidateCache;
2554
+ private bindSegments;
2502
2555
  }
2503
2556
 
2504
2557
  /**
@@ -2509,13 +2562,37 @@ export declare class Hl7Message {
2509
2562
  export declare class Hl7Segment {
2510
2563
  readonly context: Hl7Context;
2511
2564
  readonly name: string;
2512
- readonly fields: Hl7Field[];
2565
+ /**
2566
+ * Internal lazy-parsed field storage. Entries are `string` until they are
2567
+ * accessed (via {@link getField} or the public {@link fields} getter), at
2568
+ * which point they are parsed in place and replaced with their
2569
+ * {@link Hl7Field} form.
2570
+ */
2571
+ private readonly _fields;
2572
+ /** Becomes true once every entry in `_fields` has been parsed. */
2573
+ private allFieldsParsed;
2574
+ private cachedString;
2575
+ /** @internal */
2576
+ onModified?: () => void;
2513
2577
  /**
2514
2578
  * Creates a new HL7 segment.
2579
+ *
2580
+ * Field strings are not parsed until they are accessed via {@link getField}
2581
+ * or via the {@link fields} getter.
2582
+ *
2515
2583
  * @param fields - The HL7 fields. The first field is the segment name.
2516
2584
  * @param context - Optional HL7 parsing context.
2517
2585
  */
2518
- constructor(fields: Hl7Field[] | string[], context?: Hl7Context);
2586
+ constructor(fields: (Hl7Field | string)[], context?: Hl7Context);
2587
+ /**
2588
+ * Returns all HL7 fields, parsing any unparsed field strings on first access.
2589
+ *
2590
+ * Prefer {@link getField} when you only need a subset of fields; that method
2591
+ * avoids parsing unrelated fields.
2592
+ *
2593
+ * @returns The HL7 fields array.
2594
+ */
2595
+ get fields(): Hl7Field[];
2519
2596
  /**
2520
2597
  * Returns an HL7 field by index.
2521
2598
  * @param index - The HL7 field index.
@@ -2534,10 +2611,19 @@ export declare class Hl7Segment {
2534
2611
  *
2535
2612
  * Field zero is the segment name.
2536
2613
  *
2614
+ * Fields are lazily parsed; the requested field is parsed and cached on demand.
2615
+ *
2537
2616
  * @param index - The HL7 field index.
2538
2617
  * @returns The HL7 field.
2539
2618
  */
2540
2619
  getField(index: number): Hl7Field;
2620
+ /**
2621
+ * Parses the field at the given index (if not already parsed), caches it back into
2622
+ * the fields array, and wires up the onModified callback.
2623
+ * @param index - The HL7 field index.
2624
+ * @returns The parsed HL7 field, or undefined if the index is out of range.
2625
+ */
2626
+ private parseField;
2541
2627
  /**
2542
2628
  * Returns an HL7 component by field index and component index.
2543
2629
  *
@@ -2558,6 +2644,10 @@ export declare class Hl7Segment {
2558
2644
  getComponent(fieldIndex: number, component: number, subcomponent?: number, repetition?: number): string;
2559
2645
  /**
2560
2646
  * Returns the HL7 segment as a string.
2647
+ *
2648
+ * Unparsed fields are emitted directly from their original string form, which
2649
+ * preserves the source text without forcing a parse.
2650
+ *
2561
2651
  * @returns The HL7 segment as a string.
2562
2652
  */
2563
2653
  toString(): string;
@@ -2588,6 +2678,8 @@ export declare class Hl7Segment {
2588
2678
  * @returns true if the component was set, false otherwise
2589
2679
  */
2590
2680
  setComponent(fieldIndex: number, component: number, value: string, subcomponent?: number, repetition?: number): boolean;
2681
+ private invalidateCache;
2682
+ private bindFields;
2591
2683
  }
2592
2684
 
2593
2685
  export declare const HTTP_HL7_ORG = "http://hl7.org";
@@ -5533,6 +5625,7 @@ export declare interface MedplumInfraConfig {
5533
5625
  loadBalancerSecurityGroupId?: string;
5534
5626
  loadBalancerLoggingBucket?: string;
5535
5627
  loadBalancerLoggingPrefix?: string;
5628
+ loadBalancerAlgorithm?: 'round_robin' | 'least_outstanding_requests' | 'weighted_random';
5536
5629
  clamscanEnabled: boolean;
5537
5630
  clamscanLoggingBucket: string;
5538
5631
  clamscanLoggingPrefix: string;
@@ -5758,6 +5851,7 @@ export declare interface MedplumSourceInfraConfig {
5758
5851
  loadBalancerSecurityGroupId?: ValueOrExternalSecret<string>;
5759
5852
  loadBalancerLoggingBucket?: ValueOrExternalSecret<string>;
5760
5853
  loadBalancerLoggingPrefix?: ValueOrExternalSecret<string>;
5854
+ loadBalancerAlgorithm?: ValueOrExternalSecret<'round_robin' | 'least_outstanding_requests' | 'weighted_random'>;
5761
5855
  clamscanEnabled: ValueOrExternalSecret<boolean>;
5762
5856
  clamscanLoggingBucket: ValueOrExternalSecret<string>;
5763
5857
  clamscanLoggingPrefix: ValueOrExternalSecret<string>;
@@ -2368,6 +2368,9 @@ export declare interface Hl7DateParseOptions {
2368
2368
  export declare class Hl7Field {
2369
2369
  readonly context: Hl7Context;
2370
2370
  readonly components: string[][];
2371
+ /** @internal */
2372
+ onModified?: () => void;
2373
+ private cachedString;
2371
2374
  /**
2372
2375
  * Creates a new HL7 field.
2373
2376
  * @param components - The HL7 components.
@@ -2420,6 +2423,7 @@ export declare class Hl7Field {
2420
2423
  * @returns true if the component was set, false otherwise
2421
2424
  */
2422
2425
  setComponent(component: number, value: string, subcomponent?: number, repetition?: number): boolean;
2426
+ private invalidateCache;
2423
2427
  }
2424
2428
 
2425
2429
  /**
@@ -2428,13 +2432,42 @@ export declare class Hl7Field {
2428
2432
  */
2429
2433
  export declare class Hl7Message {
2430
2434
  readonly context: Hl7Context;
2431
- readonly segments: Hl7Segment[];
2435
+ /**
2436
+ * Internal lazy-parsed segment storage. Entries are `string` until they
2437
+ * are accessed (via {@link getSegment}, {@link getAllSegments}, {@link header},
2438
+ * or the public {@link segments} getter), at which point they are parsed in
2439
+ * place and replaced with their {@link Hl7Segment} form.
2440
+ */
2441
+ private readonly _segments;
2442
+ /**
2443
+ * Maps segment name → indices into {@link _segments}. Storing indices (rather
2444
+ * than references to the segments themselves) keeps this map in sync with
2445
+ * {@link _segments} without needing a per-parse update step, and is immune to
2446
+ * collisions when two segments have identical raw text.
2447
+ */
2448
+ private segmentsByName;
2449
+ private cachedString;
2450
+ /** Becomes true once every entry in `_segments` has been parsed. */
2451
+ private allSegmentsParsed;
2432
2452
  /**
2433
2453
  * Creates a new HL7 message.
2454
+ *
2455
+ * Segment strings are not parsed until they are accessed via {@link getSegment},
2456
+ * {@link getAllSegments}, {@link header}, or the {@link segments} getter.
2457
+ *
2434
2458
  * @param segments - The HL7 segments.
2435
2459
  * @param context - Optional HL7 parsing context.
2436
2460
  */
2437
- constructor(segments: Hl7Segment[], context?: Hl7Context);
2461
+ constructor(segments: (Hl7Segment | string)[], context?: Hl7Context);
2462
+ /**
2463
+ * Returns all HL7 segments, parsing any unparsed segment strings on first access.
2464
+ *
2465
+ * Prefer {@link getSegment} or {@link getAllSegments} when you only need a subset
2466
+ * of segments; those methods avoid parsing unrelated segments.
2467
+ *
2468
+ * @returns The HL7 segments array.
2469
+ */
2470
+ get segments(): Hl7Segment[];
2438
2471
  /**
2439
2472
  * Returns the HL7 message header.
2440
2473
  * @returns The HL7 message header.
@@ -2461,18 +2494,35 @@ export declare class Hl7Message {
2461
2494
  *
2462
2495
  * When using a string index, this method returns the first segment with the specified name.
2463
2496
  *
2497
+ * Segments are lazily parsed; the requested segment is parsed and cached on demand.
2498
+ *
2464
2499
  * @param index - The HL7 segment index or name.
2465
2500
  * @returns The HL7 segment if found; otherwise, undefined.
2466
2501
  */
2467
2502
  getSegment(index: number | string): Hl7Segment | undefined;
2468
2503
  /**
2469
2504
  * Returns all HL7 segments of a given name.
2505
+ *
2506
+ * Only the segments that match the requested name are parsed, which avoids parsing
2507
+ * unrelated segments when scanning a message.
2508
+ *
2470
2509
  * @param name - The HL7 segment name.
2471
2510
  * @returns An array of HL7 segments with the specified name.
2472
2511
  */
2473
2512
  getAllSegments(name: string): Hl7Segment[];
2513
+ /**
2514
+ * Parses the segment at the given index (if not already parsed), caches it back into
2515
+ * the segments array, and wires up the onModified callback.
2516
+ * @param index - The HL7 segment index.
2517
+ * @returns The parsed HL7 segment, or undefined if the index is out of range.
2518
+ */
2519
+ private parseSegment;
2474
2520
  /**
2475
2521
  * Returns the HL7 message as a string.
2522
+ *
2523
+ * Unparsed segments are emitted directly from their original string form, which
2524
+ * preserves the source text without forcing a parse.
2525
+ *
2476
2526
  * @returns The HL7 message as a string.
2477
2527
  */
2478
2528
  toString(): string;
@@ -2499,6 +2549,9 @@ export declare class Hl7Message {
2499
2549
  * @returns true if the segment was set, false otherwise
2500
2550
  */
2501
2551
  setSegment(index: number | string, segment: Hl7Segment): boolean;
2552
+ private findSegmentIndexByName;
2553
+ private invalidateCache;
2554
+ private bindSegments;
2502
2555
  }
2503
2556
 
2504
2557
  /**
@@ -2509,13 +2562,37 @@ export declare class Hl7Message {
2509
2562
  export declare class Hl7Segment {
2510
2563
  readonly context: Hl7Context;
2511
2564
  readonly name: string;
2512
- readonly fields: Hl7Field[];
2565
+ /**
2566
+ * Internal lazy-parsed field storage. Entries are `string` until they are
2567
+ * accessed (via {@link getField} or the public {@link fields} getter), at
2568
+ * which point they are parsed in place and replaced with their
2569
+ * {@link Hl7Field} form.
2570
+ */
2571
+ private readonly _fields;
2572
+ /** Becomes true once every entry in `_fields` has been parsed. */
2573
+ private allFieldsParsed;
2574
+ private cachedString;
2575
+ /** @internal */
2576
+ onModified?: () => void;
2513
2577
  /**
2514
2578
  * Creates a new HL7 segment.
2579
+ *
2580
+ * Field strings are not parsed until they are accessed via {@link getField}
2581
+ * or via the {@link fields} getter.
2582
+ *
2515
2583
  * @param fields - The HL7 fields. The first field is the segment name.
2516
2584
  * @param context - Optional HL7 parsing context.
2517
2585
  */
2518
- constructor(fields: Hl7Field[] | string[], context?: Hl7Context);
2586
+ constructor(fields: (Hl7Field | string)[], context?: Hl7Context);
2587
+ /**
2588
+ * Returns all HL7 fields, parsing any unparsed field strings on first access.
2589
+ *
2590
+ * Prefer {@link getField} when you only need a subset of fields; that method
2591
+ * avoids parsing unrelated fields.
2592
+ *
2593
+ * @returns The HL7 fields array.
2594
+ */
2595
+ get fields(): Hl7Field[];
2519
2596
  /**
2520
2597
  * Returns an HL7 field by index.
2521
2598
  * @param index - The HL7 field index.
@@ -2534,10 +2611,19 @@ export declare class Hl7Segment {
2534
2611
  *
2535
2612
  * Field zero is the segment name.
2536
2613
  *
2614
+ * Fields are lazily parsed; the requested field is parsed and cached on demand.
2615
+ *
2537
2616
  * @param index - The HL7 field index.
2538
2617
  * @returns The HL7 field.
2539
2618
  */
2540
2619
  getField(index: number): Hl7Field;
2620
+ /**
2621
+ * Parses the field at the given index (if not already parsed), caches it back into
2622
+ * the fields array, and wires up the onModified callback.
2623
+ * @param index - The HL7 field index.
2624
+ * @returns The parsed HL7 field, or undefined if the index is out of range.
2625
+ */
2626
+ private parseField;
2541
2627
  /**
2542
2628
  * Returns an HL7 component by field index and component index.
2543
2629
  *
@@ -2558,6 +2644,10 @@ export declare class Hl7Segment {
2558
2644
  getComponent(fieldIndex: number, component: number, subcomponent?: number, repetition?: number): string;
2559
2645
  /**
2560
2646
  * Returns the HL7 segment as a string.
2647
+ *
2648
+ * Unparsed fields are emitted directly from their original string form, which
2649
+ * preserves the source text without forcing a parse.
2650
+ *
2561
2651
  * @returns The HL7 segment as a string.
2562
2652
  */
2563
2653
  toString(): string;
@@ -2588,6 +2678,8 @@ export declare class Hl7Segment {
2588
2678
  * @returns true if the component was set, false otherwise
2589
2679
  */
2590
2680
  setComponent(fieldIndex: number, component: number, value: string, subcomponent?: number, repetition?: number): boolean;
2681
+ private invalidateCache;
2682
+ private bindFields;
2591
2683
  }
2592
2684
 
2593
2685
  export declare const HTTP_HL7_ORG = "http://hl7.org";
@@ -5533,6 +5625,7 @@ export declare interface MedplumInfraConfig {
5533
5625
  loadBalancerSecurityGroupId?: string;
5534
5626
  loadBalancerLoggingBucket?: string;
5535
5627
  loadBalancerLoggingPrefix?: string;
5628
+ loadBalancerAlgorithm?: 'round_robin' | 'least_outstanding_requests' | 'weighted_random';
5536
5629
  clamscanEnabled: boolean;
5537
5630
  clamscanLoggingBucket: string;
5538
5631
  clamscanLoggingPrefix: string;
@@ -5758,6 +5851,7 @@ export declare interface MedplumSourceInfraConfig {
5758
5851
  loadBalancerSecurityGroupId?: ValueOrExternalSecret<string>;
5759
5852
  loadBalancerLoggingBucket?: ValueOrExternalSecret<string>;
5760
5853
  loadBalancerLoggingPrefix?: ValueOrExternalSecret<string>;
5854
+ loadBalancerAlgorithm?: ValueOrExternalSecret<'round_robin' | 'least_outstanding_requests' | 'weighted_random'>;
5761
5855
  clamscanEnabled: ValueOrExternalSecret<boolean>;
5762
5856
  clamscanLoggingBucket: ValueOrExternalSecret<string>;
5763
5857
  clamscanLoggingPrefix: ValueOrExternalSecret<string>;