@medplum/fhir-router 5.1.27 → 5.1.28
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.
- package/dist/cjs/index.cjs +40 -40
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/cjs/index.d.ts +71 -3
- package/dist/esm/index.d.ts +71 -3
- package/dist/esm/index.mjs +35 -35
- package/dist/esm/index.mjs.map +4 -4
- package/package.json +4 -4
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CapabilityStatementRestInteraction } from '@medplum/fhirtypes';
|
|
|
4
4
|
import type { CapabilityStatementRestResourceInteraction } from '@medplum/fhirtypes';
|
|
5
5
|
import type { Event as Event_2 } from '@medplum/core';
|
|
6
6
|
import { EventTarget as EventTarget_2 } from '@medplum/core';
|
|
7
|
+
import type { IncludeTarget } from '@medplum/core';
|
|
7
8
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
8
9
|
import type { Operation } from '@medplum/core';
|
|
9
10
|
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
@@ -349,7 +350,7 @@ export declare abstract class FhirRepository {
|
|
|
349
350
|
* @param patch - The JSONPatch operations.
|
|
350
351
|
* @returns The patched resource.
|
|
351
352
|
*/
|
|
352
|
-
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
353
|
+
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
353
354
|
/**
|
|
354
355
|
* Searches for FHIR resources.
|
|
355
356
|
*
|
|
@@ -457,7 +458,7 @@ export declare abstract class FhirRepository {
|
|
|
457
458
|
* @returns A promise that resolves when the operation is complete.
|
|
458
459
|
*/
|
|
459
460
|
conditionalDelete(search: SearchRequest): Promise<void>;
|
|
460
|
-
conditionalPatch(search: SearchRequest, patch: Operation[]): Promise<WithId<Resource>>;
|
|
461
|
+
conditionalPatch(search: SearchRequest, patch: Operation[], options?: UpdateResourceOptions): Promise<WithId<Resource>>;
|
|
461
462
|
}
|
|
462
463
|
|
|
463
464
|
export declare type FhirRequest = {
|
|
@@ -508,8 +509,75 @@ export declare class FhirRouter extends EventTarget_2 {
|
|
|
508
509
|
log(level: string, message: string, data?: Record<string, any>): void;
|
|
509
510
|
}
|
|
510
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Gets the extra search entries for the _include and _revinclude parameters.
|
|
514
|
+
*
|
|
515
|
+
* The `entries` array is appended to in place.
|
|
516
|
+
*
|
|
517
|
+
* @param repo - The FHIR repository.
|
|
518
|
+
* @param searchRequest - The original search request.
|
|
519
|
+
* @param resources - The resources returned by the original search.
|
|
520
|
+
* @param entries - The output bundle entries.
|
|
521
|
+
* @param options - Optional repository-specific behavior.
|
|
522
|
+
*/
|
|
523
|
+
export declare function getExtraEntries<T extends Resource>(repo: FhirRepository, searchRequest: SearchRequest<T>, resources: T[], entries: BundleEntry[], options?: IncludeOptions): Promise<void>;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Returns bundle entries for the resources that are included in the search result.
|
|
527
|
+
*
|
|
528
|
+
* See documentation on _include: https://hl7.org/fhir/R4/search.html#include
|
|
529
|
+
* @param repo - The repository.
|
|
530
|
+
* @param include - The include parameter.
|
|
531
|
+
* @param resources - The base search result resources.
|
|
532
|
+
* @param options - Optional repository-specific behavior.
|
|
533
|
+
* @returns The bundle entries for the included resources.
|
|
534
|
+
*/
|
|
535
|
+
export declare function getSearchIncludeEntries(repo: FhirRepository, include: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns bundle entries for the resources that are reverse included in the search result.
|
|
539
|
+
*
|
|
540
|
+
* See documentation on _revinclude: https://hl7.org/fhir/R4/search.html#revinclude
|
|
541
|
+
* @param repo - The repository.
|
|
542
|
+
* @param revInclude - The revInclude parameter.
|
|
543
|
+
* @param resources - The base search result resources.
|
|
544
|
+
* @param options - Optional repository-specific behavior.
|
|
545
|
+
* @returns The bundle entries for the reverse included resources.
|
|
546
|
+
*/
|
|
547
|
+
export declare function getSearchRevIncludeEntries(repo: FhirRepository, revInclude: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
548
|
+
|
|
511
549
|
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
512
550
|
|
|
551
|
+
export declare interface IncludeOptions {
|
|
552
|
+
/**
|
|
553
|
+
* Builds the `Bundle.entry.fullUrl` for an included resource.
|
|
554
|
+
* When omitted, `fullUrl` is not set on the resulting entries.
|
|
555
|
+
*/
|
|
556
|
+
readonly fullUrl?: (resourceType: string, id: string) => string;
|
|
557
|
+
/**
|
|
558
|
+
* The maximum number of `:iterate` rounds before the search is rejected. Defaults to 5.
|
|
559
|
+
*/
|
|
560
|
+
readonly maxDepth?: number;
|
|
561
|
+
/**
|
|
562
|
+
* The maximum total number of bundle entries before the search is rejected.
|
|
563
|
+
* Defaults to `DEFAULT_MAX_SEARCH_COUNT`.
|
|
564
|
+
*/
|
|
565
|
+
readonly maxResults?: number;
|
|
566
|
+
/**
|
|
567
|
+
* Executes the sub-searches needed for canonical `_include` and for all `_revinclude` targets.
|
|
568
|
+
* Defaults to `repo.searchResources()`.
|
|
569
|
+
*/
|
|
570
|
+
readonly executeSearch?: IncludeSearchFn;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Executes a search on behalf of the include logic.
|
|
575
|
+
*
|
|
576
|
+
* The default implementation uses {@link FhirRepository.searchResources}. The server overrides this
|
|
577
|
+
* to reuse its already-built query pipeline rather than re-entering the public `search()` entry point.
|
|
578
|
+
*/
|
|
579
|
+
export declare type IncludeSearchFn = (searchRequest: SearchRequest) => Promise<WithId<Resource>[]>;
|
|
580
|
+
|
|
513
581
|
export declare interface LogEvent extends Event_2 {
|
|
514
582
|
message: string;
|
|
515
583
|
data?: Record<string, any>;
|
|
@@ -529,7 +597,7 @@ export declare class MemoryRepository extends FhirRepository {
|
|
|
529
597
|
createResource<T extends Resource>(resource: T, options?: CreateResourceOptions, update?: boolean): Promise<WithId<T>>;
|
|
530
598
|
generateId(): string;
|
|
531
599
|
updateResource<T extends Resource>(resource: T, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
532
|
-
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
600
|
+
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
533
601
|
readResource<T extends Resource>(resourceType: string, id: string): Promise<T>;
|
|
534
602
|
readReference<T extends Resource>(reference: Reference<T>): Promise<WithId<T>>;
|
|
535
603
|
readReferences<T extends Resource>(references: readonly Reference<T>[]): Promise<(T | OperationOutcomeError)[]>;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CapabilityStatementRestInteraction } from '@medplum/fhirtypes';
|
|
|
4
4
|
import type { CapabilityStatementRestResourceInteraction } from '@medplum/fhirtypes';
|
|
5
5
|
import type { Event as Event_2 } from '@medplum/core';
|
|
6
6
|
import { EventTarget as EventTarget_2 } from '@medplum/core';
|
|
7
|
+
import type { IncludeTarget } from '@medplum/core';
|
|
7
8
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
8
9
|
import type { Operation } from '@medplum/core';
|
|
9
10
|
import type { OperationOutcome } from '@medplum/fhirtypes';
|
|
@@ -349,7 +350,7 @@ export declare abstract class FhirRepository {
|
|
|
349
350
|
* @param patch - The JSONPatch operations.
|
|
350
351
|
* @returns The patched resource.
|
|
351
352
|
*/
|
|
352
|
-
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
353
|
+
abstract patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
353
354
|
/**
|
|
354
355
|
* Searches for FHIR resources.
|
|
355
356
|
*
|
|
@@ -457,7 +458,7 @@ export declare abstract class FhirRepository {
|
|
|
457
458
|
* @returns A promise that resolves when the operation is complete.
|
|
458
459
|
*/
|
|
459
460
|
conditionalDelete(search: SearchRequest): Promise<void>;
|
|
460
|
-
conditionalPatch(search: SearchRequest, patch: Operation[]): Promise<WithId<Resource>>;
|
|
461
|
+
conditionalPatch(search: SearchRequest, patch: Operation[], options?: UpdateResourceOptions): Promise<WithId<Resource>>;
|
|
461
462
|
}
|
|
462
463
|
|
|
463
464
|
export declare type FhirRequest = {
|
|
@@ -508,8 +509,75 @@ export declare class FhirRouter extends EventTarget_2 {
|
|
|
508
509
|
log(level: string, message: string, data?: Record<string, any>): void;
|
|
509
510
|
}
|
|
510
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Gets the extra search entries for the _include and _revinclude parameters.
|
|
514
|
+
*
|
|
515
|
+
* The `entries` array is appended to in place.
|
|
516
|
+
*
|
|
517
|
+
* @param repo - The FHIR repository.
|
|
518
|
+
* @param searchRequest - The original search request.
|
|
519
|
+
* @param resources - The resources returned by the original search.
|
|
520
|
+
* @param entries - The output bundle entries.
|
|
521
|
+
* @param options - Optional repository-specific behavior.
|
|
522
|
+
*/
|
|
523
|
+
export declare function getExtraEntries<T extends Resource>(repo: FhirRepository, searchRequest: SearchRequest<T>, resources: T[], entries: BundleEntry[], options?: IncludeOptions): Promise<void>;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Returns bundle entries for the resources that are included in the search result.
|
|
527
|
+
*
|
|
528
|
+
* See documentation on _include: https://hl7.org/fhir/R4/search.html#include
|
|
529
|
+
* @param repo - The repository.
|
|
530
|
+
* @param include - The include parameter.
|
|
531
|
+
* @param resources - The base search result resources.
|
|
532
|
+
* @param options - Optional repository-specific behavior.
|
|
533
|
+
* @returns The bundle entries for the included resources.
|
|
534
|
+
*/
|
|
535
|
+
export declare function getSearchIncludeEntries(repo: FhirRepository, include: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns bundle entries for the resources that are reverse included in the search result.
|
|
539
|
+
*
|
|
540
|
+
* See documentation on _revinclude: https://hl7.org/fhir/R4/search.html#revinclude
|
|
541
|
+
* @param repo - The repository.
|
|
542
|
+
* @param revInclude - The revInclude parameter.
|
|
543
|
+
* @param resources - The base search result resources.
|
|
544
|
+
* @param options - Optional repository-specific behavior.
|
|
545
|
+
* @returns The bundle entries for the reverse included resources.
|
|
546
|
+
*/
|
|
547
|
+
export declare function getSearchRevIncludeEntries(repo: FhirRepository, revInclude: IncludeTarget, resources: Resource[], options?: IncludeOptions): Promise<BundleEntry[]>;
|
|
548
|
+
|
|
511
549
|
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
512
550
|
|
|
551
|
+
export declare interface IncludeOptions {
|
|
552
|
+
/**
|
|
553
|
+
* Builds the `Bundle.entry.fullUrl` for an included resource.
|
|
554
|
+
* When omitted, `fullUrl` is not set on the resulting entries.
|
|
555
|
+
*/
|
|
556
|
+
readonly fullUrl?: (resourceType: string, id: string) => string;
|
|
557
|
+
/**
|
|
558
|
+
* The maximum number of `:iterate` rounds before the search is rejected. Defaults to 5.
|
|
559
|
+
*/
|
|
560
|
+
readonly maxDepth?: number;
|
|
561
|
+
/**
|
|
562
|
+
* The maximum total number of bundle entries before the search is rejected.
|
|
563
|
+
* Defaults to `DEFAULT_MAX_SEARCH_COUNT`.
|
|
564
|
+
*/
|
|
565
|
+
readonly maxResults?: number;
|
|
566
|
+
/**
|
|
567
|
+
* Executes the sub-searches needed for canonical `_include` and for all `_revinclude` targets.
|
|
568
|
+
* Defaults to `repo.searchResources()`.
|
|
569
|
+
*/
|
|
570
|
+
readonly executeSearch?: IncludeSearchFn;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Executes a search on behalf of the include logic.
|
|
575
|
+
*
|
|
576
|
+
* The default implementation uses {@link FhirRepository.searchResources}. The server overrides this
|
|
577
|
+
* to reuse its already-built query pipeline rather than re-entering the public `search()` entry point.
|
|
578
|
+
*/
|
|
579
|
+
export declare type IncludeSearchFn = (searchRequest: SearchRequest) => Promise<WithId<Resource>[]>;
|
|
580
|
+
|
|
513
581
|
export declare interface LogEvent extends Event_2 {
|
|
514
582
|
message: string;
|
|
515
583
|
data?: Record<string, any>;
|
|
@@ -529,7 +597,7 @@ export declare class MemoryRepository extends FhirRepository {
|
|
|
529
597
|
createResource<T extends Resource>(resource: T, options?: CreateResourceOptions, update?: boolean): Promise<WithId<T>>;
|
|
530
598
|
generateId(): string;
|
|
531
599
|
updateResource<T extends Resource>(resource: T, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
532
|
-
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2): Promise<WithId<T>>;
|
|
600
|
+
patchResource<T extends Resource>(resourceType: T['resourceType'], id: string, patch: Operation[] | Parameters_2, options?: UpdateResourceOptions): Promise<WithId<T>>;
|
|
533
601
|
readResource<T extends Resource>(resourceType: string, id: string): Promise<T>;
|
|
534
602
|
readReference<T extends Resource>(reference: Reference<T>): Promise<WithId<T>>;
|
|
535
603
|
readReferences<T extends Resource>(references: readonly Reference<T>[]): Promise<(T | OperationOutcomeError)[]>;
|