@synanetics/fhir-fml-convert
Version:
Converts StructureMaps written in FML to JSON ($convert operation)
61 lines • 4.61 kB
TypeScript
import { ParseTree } from 'antlr4ts/tree/ParseTree';
import { ErrorNode } from 'antlr4ts/tree/ErrorNode';
import { StructureDefinition as StructureDefinitionSTU3, StructureMap as StructureMapSTU3, StructureMapGroup as StructureMapGroupSTU3, StructureMapGroupRule as StructureMapGroupRuleSTU3, StructureMapGroupRuleSource as StructureMapGroupRuleSourceSTU3, StructureMapGroupRuleTarget as StructureMapGroupRuleTargetSTU3, StructureMapStructure as StructureMapStructureSTU3 } from 'fhir/r3';
import { StructureDefinition as StructureDefinitionR4, StructureMap as StructureMapR4, StructureMapGroup as StructureMapGroupR4, StructureMapGroupRule as StructureMapGroupRuleR4, StructureMapGroupRuleSource as StructureMapGroupRuleSourceR4, StructureMapGroupRuleTarget as StructureMapGroupRuleTargetR4, StructureMapStructure as StructureMapStructureR4 } from 'fhir/r4';
import { StructureDefinition as StructureDefinitionR5, StructureMap as StructureMapR5, StructureMapGroup as StructureMapGroupR5, StructureMapGroupRule as StructureMapGroupRuleR5, StructureMapGroupRuleSource as StructureMapGroupRuleSourceR5, StructureMapGroupRuleTarget as StructureMapGroupRuleTargetR5, StructureMapStructure as StructureMapStructureR5 } from 'fhir/r5';
import { StructureMapContext, GroupContext, RuleDefinitionContext, MapIdContext, StructureContext, RuleSourcesContext, RuleTargetsContext, MetadataContext, LiteralContext, RuleNameContext, SourceDefaultContext } from './generated/FhirMapperParser';
import { FhirMapperVisitor } from './generated/FhirMapperVisitor';
import { FhirPrimitiveValue, FhirVersion } from './types';
type StructureDefinition = StructureDefinitionSTU3 | StructureDefinitionR4 | StructureDefinitionR5;
type StructureMap = StructureMapSTU3 | StructureMapR4 | StructureMapR5;
type StructureMapGroup = StructureMapGroupSTU3 | StructureMapGroupR4 | StructureMapGroupR5;
type StructureMapGroupRule = StructureMapGroupRuleSTU3 | StructureMapGroupRuleR4 | StructureMapGroupRuleR5;
type StructureMapGroupRuleSource = StructureMapGroupRuleSourceSTU3 | StructureMapGroupRuleSourceR4 | StructureMapGroupRuleSourceR5;
type StructureMapGroupRuleTarget = StructureMapGroupRuleTargetSTU3 | StructureMapGroupRuleTargetR4 | StructureMapGroupRuleTargetR5;
type StructureMapStructure = StructureMapStructureSTU3 | StructureMapStructureR4 | StructureMapStructureR5;
/**
* The `StructureMapVisitor` class iterates over the token parsed from the FML and returns the
* fragment of the StructureMap object to which the token pertains. It is an extension of the
* automatically-generated FhirMapperVisitor.
*/
export declare abstract class StructureMapVisitor implements FhirMapperVisitor<any> {
readonly METADATA_KEYS: Array<keyof StructureMap>;
protected structureMapDefinition: StructureDefinition;
protected fhirTypes: Partial<StructureDefinition>[];
protected fhirVersion: FhirVersion;
visit(tree: ParseTree): any;
visitTerminal(): void;
visitErrorNode(node: ErrorNode): void;
visitStructureMap(ctx: StructureMapContext): StructureMap;
/**
* Returns a typed value from the inbound metadata field, according to the type expected by the
* StructureMap FHIR profile
* @param type The primitive type from the FHIR profile that this field is allowed to be.
* @param parsedValue The value from the metadata field.
* @returns
*/
private getPrimitiveValue;
visitMetadata(ctx: MetadataContext): Partial<StructureDefinition>;
visitMapId(ctx: MapIdContext): Pick<StructureMap, 'url' | 'name'>;
visitStructure(ctx: StructureContext): StructureMapStructure;
visitGroup(ctx: GroupContext): StructureMapGroup;
protected getRuleName(ctx?: RuleNameContext, ruleSource?: StructureMapGroupRuleSource): string;
abstract visitRuleDefinition(ctx: RuleDefinitionContext): StructureMapGroupRule;
abstract getDefaultValue(ctx: SourceDefaultContext): {
key: string;
value: string;
};
visitRuleSources(ctx: RuleSourcesContext): StructureMapGroupRuleSource[];
private sanitiseString;
/**
* Converts the "literal" value from the FML to a JavaScript type and its accompanying named FHIR
* Type
* @param literal The parsed "literal" token from the FML
* @returns The FHIR primitive type and the actual value from the token.
*/
protected getValueFromLiteral(literal: LiteralContext): FhirPrimitiveValue | undefined;
abstract visitRuleTargets(ctx: RuleTargetsContext): StructureMapGroupRuleTarget[];
visitChildren(): any;
}
export {};
//# sourceMappingURL=StructureMapVisitor.d.ts.map