fhir-snapshot-generator
Version:
Generate snapshots for FHIR Profiles
92 lines • 3.01 kB
TypeScript
/**
* © Copyright Outburn Ltd. 2022-2025 All Rights Reserved
* Project name: fhir-snapshot-generator
*/
import { ExplorerConfig } from 'fhir-package-explorer';
export interface ILogger {
info: (msg: any) => void;
warn: (msg: any) => void;
error: (msg: any) => void;
}
export type Prethrower = (msg: Error | any) => Error;
export interface ElementDefinition {
id: string;
path: string;
extension?: FhirExtensionInstance[];
min?: number;
max?: string;
type?: ElementDefinitionType[];
slicing?: ElementDefinitionSlicing;
sliceName?: string;
fixedUri?: string;
binding?: ElementDefinitionBinding;
short?: string;
definition?: string;
comment?: string;
requirements?: string;
meaningWhenMissing?: string;
[key: string]: any;
}
export type FhirExtensionInstance = {
url: string;
[key: string]: any;
};
export type ElementConstraint = {
source?: string;
[key: string]: any;
};
export interface ElementDefinitionType {
code: string;
profile?: string[];
targetProfile?: string[];
extension?: any;
}
export interface ElementDefinitionSlicing {
discriminator: SlicingDiscriminator[];
rules: 'closed' | 'open' | 'openAtEnd';
description?: string;
ordered?: boolean;
}
export interface SlicingDiscriminator {
type: 'value' | 'exists' | 'pattern' | 'type' | 'profile';
path: string;
}
export interface ElementDefinitionBinding {
strength: 'required' | 'extensible' | 'preferred' | 'example';
valueSet?: string;
}
export interface FhirTreeNode {
id: string;
path: string;
definition?: ElementDefinition;
children: FhirTreeNode[];
idSegments: string[];
pathSegments: string[];
nodeType: 'element' | 'array' | 'poly' | 'slice' | 'resliced' | 'headslice';
sliceName?: string;
}
/**
* Snapshot caching strategy.
*
* - `'lazy'`: Default. Generate each snapshot on demand and cache it afterward.
* - `'ensure'`: Proactively generate and cache all **missing** snapshots.
* - `'rebuild'`: Regenerate **all** snapshots and overwrite existing cache entries.
* - `'none'`: Fully bypass the cache. Always regenerate snapshots and do not write to cache.
*/
export type SnapshotCacheMode = 'lazy' | 'ensure' | 'rebuild' | 'none';
export type BaseFhirVersion = '3.0.2' | '4.0.1' | '4.3.0' | '5.0.0' | '3.0' | '4.0' | '4.3' | '5.0' | 'R3' | 'STU3' | 'R4' | 'R4B' | 'R5';
export type SnapshotGeneratorConfig = Omit<ExplorerConfig, 'skipExamples'> & {
/**
* Determines how snapshot caching is handled.
* Defaults to `'lazy'` if not specified.
*/
cacheMode?: SnapshotCacheMode;
/**
* The FHIR version to use for the snapshot generation.
* This is used to determine the FHIR core package to use when fetching base FHIR types.
* Defaults to 4.0.1 if not specified.
*/
fhirVersion?: BaseFhirVersion;
};
export type SnapshotFetcher = (url: string) => Promise<ElementDefinition[]>;
//# sourceMappingURL=index.d.ts.map