FHIR Mapping Language
FHIR Mapping Language parser and transformation utilities.
FHIRMappingEngineComponent
Path: fhircraft.fhir.mapper.engine.abstract.FHIRMappingEngineComponent
Bases: ABC
Base class for components of the FHIR Mapper Engine.
Methods:
| Name | Description |
|---|---|
process |
Process the component within the given mapping scope. |
resolve_fhirpath_within_context |
Resolve FHIRPath expressions within the given context. |
process
abstractmethod
process(scope: MappingScope) -> Any
Process the component within the given mapping scope.
resolve_fhirpath_within_context
staticmethod
resolve_fhirpath_within_context(expression: str, scope: MappingScope) -> FHIRPath
Resolve FHIRPath expressions within the given context.
Source code in fhircraft/fhir/mapper/engine/abstract.py
ArbitraryModel
Path: fhircraft.fhir.mapper.engine.core.ArbitraryModel
Bases: BaseModel
A dynamic Pydantic model that accepts arbitrary fields.
This is used for arbitrary target structures in mappings where no specific structure definition is provided. Unlike plain dicts, this model is compatible with the FHIRPath engine's update mechanisms, allowing complex nested path creation and array operations.
FHIRMappingEngine
Path: fhircraft.fhir.mapper.engine.core.FHIRMappingEngine
FHIRMappingEngine(repository: CompositeStructureDefinitionRepository | None = None, factory: ResourceFactory | None = None)
FHIRMappingEngine is responsible for executing FHIR StructureMap-based transformations between FHIR resources.
This engine validates, processes, and applies mapping rules defined in a StructureMap to transform source FHIR resources into target resources, supporting complex mapping logic, rule dependencies, and FHIRPath-based expressions.
Attributes:
| Name | Type | Description |
|---|---|---|
repository |
CompositeStructureDefinitionRepository
|
Repository for FHIR StructureDefinitions. |
factory |
ResourceFactory
|
Factory for constructing FHIR resource models. |
transformer |
MappingTransformer
|
Executes FHIRPath-based transforms. |
Methods:
| Name | Description |
|---|---|
execute |
Executes a FHIR StructureMap transformation using the provided sources and optional targets. |
Source code in fhircraft/fhir/mapper/engine/core.py
execute
execute(structure_map: StructureMap | StructureMap | StructureMap, sources: tuple[BaseModel | dict], targets: tuple[BaseModel | dict] | None = None, group: str | None = None) -> tuple[BaseModel | dict, ...]
Executes a FHIR StructureMap transformation using the provided sources and optional targets.
This method resolves structure definitions, validates input data, sets up the mapping scope, binds source and target instances to group parameters, and processes the entrypoint group to produce the mapped target instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure_map
|
StructureMap | StructureMap | StructureMap
|
The StructureMap resource defining the transformation rules. |
required |
sources
|
tuple[BaseModel | dict]
|
Source data to be mapped, as a tuple of Pydantic models or dictionaries. |
required |
targets
|
tuple[BaseModel | dict] | None
|
Optional target instances to populate. If not provided, new instances are created as needed. |
None
|
group
|
str | None
|
The name of the entrypoint group to execute. If not specified, the first group is used. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[BaseModel | dict, ...]
|
A tuple of resulting target instances after the transformation, which can be a mixture of BaseModel instances and/or dictionaries. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If StructureMap imports are present (not supported). |
ValueError
|
If a constant in the StructureMap is missing a name or conflicts with a model name. |
RuntimeError
|
If the number of provided sources or targets does not match the group parameters, or if required targets are missing. |
TypeError
|
If provided sources or targets do not match the expected types for the group parameters. |
Source code in fhircraft/fhir/mapper/engine/core.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
StructureMapModelMode
Path: fhircraft.fhir.mapper.engine.core.StructureMapModelMode
StructureMapTargetListMode
Path: fhircraft.fhir.mapper.engine.core.StructureMapTargetListMode
MappingDigestionError
Path: fhircraft.fhir.mapper.engine.exceptions.MappingDigestionError
Bases: MappingError
Raised during the digestion of StructureMap definitions.
MappingError
Path: fhircraft.fhir.mapper.engine.exceptions.MappingError
Bases: Exception
Base exception for mapping engine errors.
RuleProcessingError
Path: fhircraft.fhir.mapper.engine.exceptions.RuleProcessingError
Bases: MappingError
Raised when rule processing fails.
SourceAssertionError
Path: fhircraft.fhir.mapper.engine.exceptions.SourceAssertionError
Bases: MappingError
Raised when a source's assertion fails.
SourceConditionError
Path: fhircraft.fhir.mapper.engine.exceptions.SourceConditionError
Bases: MappingError
Raised when a source's condition fails.
SourceProcessingError
Path: fhircraft.fhir.mapper.engine.exceptions.SourceProcessingError
Bases: MappingError
Raised when source processing fails.
SourceTypeError
Path: fhircraft.fhir.mapper.engine.exceptions.SourceTypeError
Bases: MappingError
Raised when a source's type condition fails.
ValidationError
Path: fhircraft.fhir.mapper.engine.exceptions.ValidationError
Bases: MappingError
Raised when input data validation fails.
Group
Path: fhircraft.fhir.mapper.engine.group.Group
Group(definition: StructureMapGroup | StructureMapGroup | StructureMapGroup, parent_group=None)
Bases: FHIRMappingEngineComponent
Represents a StructureMap Group with its own processing logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
The StructureMapGroupRuleTarget to initialize from. |
required |
Raises: SourceProcessingError: If required fields are missing.
Methods:
| Name | Description |
|---|---|
bind_parameters |
Bind input parameters to the group scope. |
process |
Processes a StructureMap group by validating input parameters, constructing a local mapping scope, |
Source code in fhircraft/fhir/mapper/engine/group.py
bind_parameters
bind_parameters(scope: MappingScope, parameters: Sequence[FHIRPath], is_dependent: bool) -> None
Bind input parameters to the group scope.
Source code in fhircraft/fhir/mapper/engine/group.py
process
process(scope: MappingScope, parameters: Sequence[FHIRPath], is_dependent: bool = False)
Processes a StructureMap group by validating input parameters, constructing a local mapping scope, and executing the group's rules in the correct order, handling special list modes ('first' and 'last').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Sequence[FHIRPath]
|
The input parameters to be mapped, corresponding to the group's input definitions. |
required |
scope
|
MappingScope
|
The parent mapping scope to use as the basis for the group's local scope. |
required |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the number of provided parameters does not match the group's input definitions. |
RuntimeError
|
If more than one rule with 'first' or 'last' target list mode is found in the group. |
NotImplementedError
|
If a target list mode other than 'first' or 'last' is encountered. |
Source code in fhircraft/fhir/mapper/engine/group.py
Rule
Path: fhircraft.fhir.mapper.engine.rule.Rule
Rule(definition: StructureMapGroupRule | StructureMapGroupRule | StructureMapGroupRule, parent_group=None)
Bases: FHIRMappingEngineComponent
Represents a StructureMap Rule with iteration and condition logic.
A Rule contains Sources and Targets, manages iteration over source collections, and handles conditions and dependencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
The StructureMapGroupRuleTarget to initialize from. |
required |
Raises: SourceProcessingError: If required fields are missing.
Methods:
| Name | Description |
|---|---|
process |
Processes the rule within the given mapping scope. |
Attributes:
| Name | Type | Description |
|---|---|---|
has_first_target |
bool
|
Check if this rule has a target with 'first' list mode. |
has_last_target |
bool
|
Check if this rule has a target with 'last' list mode. |
Source code in fhircraft/fhir/mapper/engine/rule.py
has_first_target
property
has_first_target: bool
Check if this rule has a target with 'first' list mode.
has_last_target
property
has_last_target: bool
Check if this rule has a target with 'last' list mode.
process
process(scope: MappingScope)
Processes the rule within the given mapping scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope. |
required |
Source code in fhircraft/fhir/mapper/engine/rule.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
MappingScope
Path: fhircraft.fhir.mapper.engine.scope.MappingScope
dataclass
MappingScope(name: str, types: Dict[str, type[BaseModel]] = dict(), source_instances: Dict[str, BaseModel] = dict(), target_instances: Dict[str, BaseModel] = dict(), concept_maps: Dict[str, ConceptMap | ConceptMap | ConceptMap] = dict(), groups: OrderedDict[str, Group] = OrderedDict(), variables: Dict[str, FHIRPath] = dict(), default_groups: Dict[str, Group] = dict(), processing_rules: Set[str] = set(), parent: Optional[MappingScope] = None)
A scope defines the visibility and accessibility of identifiers (variables, types, etc.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the scope |
required |
types
|
Dict[str, type[BaseModel]]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
source_instances
|
Dict[str, BaseModel]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
target_instances
|
Dict[str, BaseModel]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
concept_maps
|
Dict[str, ConceptMap | ConceptMap | ConceptMap]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
groups
|
OrderedDict[str, str]
|
Dictionary that remembers insertion order |
<class 'collections.OrderedDict'>
|
variables
|
Dict[str, FHIRPath]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
default_groups
|
Dict[str, ForwardRef]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
processing_rules
|
Set[str]
|
Build an unordered collection of unique elements. |
<dynamic>
|
parent
|
ForwardRef | None
|
Parent mapping scope |
None
|
Methods:
| Name | Description |
|---|---|
define_variable |
Defines a new variable in the current scope. |
get_instances |
Returns a dictionary containing all instances from the current scope, including those inherited from the parent scope (if any), as well as target and source instances. |
get_concept_map |
Retrieve a ConceptMap by its identifier from the current scope or any parent scopes. |
get_target_instance |
Retrieve a target instance by its identifier from the current scope or any parent scopes. |
get_source_instance |
Retrieve a source instance by its identifier from the current scope or any parent scopes. |
get_type |
Retrieve the type associated with the given identifier from the current scope or its parent scopes. |
resolve_symbol |
Resolves a symbol (variable, type, or group) by its identifier from the current scope or any parent scopes. |
has_symbol |
Checks if a symbol with the given identifier exists in the current scope. |
has_local_symbol |
Checks if a symbol with the given identifier exists in the current scope only. |
resolve_fhirpath |
Resolve a symbol as a FHIRPath expression. |
get_all_visible_symbols |
Retrieves all visible symbols in the current scope, including those inherited from parent scopes. |
get_scope_path |
Returns the hierarchical path of scope names from the root to the current scope as a list of strings. |
get_scope_depth |
Returns the depth of the current scope within the scope hierarchy. |
create_child_scope |
Creates and returns a new child MappingScope with the specified name, setting the current scope as its parent. |
is_processing_rule |
Check if a given rule name is present in the list of processing rules. |
start_processing_rule |
Marks the beginning of processing for a specific rule by adding its name to the set of currently processing rules. |
finish_processing_rule |
Marks the specified rule as finished by removing it from the set of currently processing rules. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the scope |
types |
Dict[str, type[BaseModel]]
|
Registry of available FHIR types by identifier |
source_instances |
Dict[str, BaseModel]
|
The source instances being mapped |
target_instances |
Dict[str, BaseModel]
|
The target instances being mapped |
concept_maps |
Dict[str, ConceptMap | ConceptMap | ConceptMap]
|
Registry of available concept maps for value transformations |
groups |
OrderedDict[str, Group]
|
The groups defined on this scope |
variables |
Dict[str, FHIRPath]
|
Registry of variables mapped to resolved FHIRPath expressions |
default_groups |
Dict[str, Group]
|
Registry of default mapping groups by type signature |
processing_rules |
Set[str]
|
Set of currently processing rules |
parent |
Optional[MappingScope]
|
Parent mapping scope |
types
class-attribute
instance-attribute
Registry of available FHIR types by identifier
source_instances
class-attribute
instance-attribute
The source instances being mapped
target_instances
class-attribute
instance-attribute
The target instances being mapped
concept_maps
class-attribute
instance-attribute
concept_maps: Dict[str, ConceptMap | ConceptMap | ConceptMap] = field(default_factory=dict)
Registry of available concept maps for value transformations
groups
class-attribute
instance-attribute
groups: OrderedDict[str, Group] = field(default_factory=OrderedDict)
The groups defined on this scope
variables
class-attribute
instance-attribute
Registry of variables mapped to resolved FHIRPath expressions
default_groups
class-attribute
instance-attribute
Registry of default mapping groups by type signature
processing_rules
class-attribute
instance-attribute
Set of currently processing rules
parent
class-attribute
instance-attribute
parent: Optional[MappingScope] = None
Parent mapping scope
define_variable
Defines a new variable in the current scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The name of the variable to define. |
required |
value
|
FHIRPath
|
The FHIRPath instance to assign to the variable. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided value is not an instance of FHIRPath. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_instances
Returns a dictionary containing all instances from the current scope, including those inherited from the parent scope (if any), as well as target and source instances.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseModel]
|
Dict[str, BaseModel]: A dictionary mapping instance names to their corresponding BaseModel objects, aggregated from the parent scope, target instances, and source instances. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_concept_map
get_concept_map(identifier: str) -> ConceptMap | ConceptMap | ConceptMap
Retrieve a ConceptMap by its identifier from the current scope or any parent scopes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The unique identifier of the ConceptMap to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ConceptMap |
ConceptMap | ConceptMap | ConceptMap
|
The ConceptMap instance associated with the given identifier. |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the ConceptMap with the specified identifier is not found in the current or any parent scopes. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_target_instance
Retrieve a target instance by its identifier from the current scope or any parent scopes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The unique identifier of the target instance to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseModel |
BaseModel
|
The target instance associated with the given identifier. |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the target instance is not found in the current or any parent scopes. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_source_instance
Retrieve a source instance by its identifier from the current scope or any parent scopes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The unique identifier of the source instance to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseModel |
BaseModel
|
The source instance associated with the given identifier. |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the source instance is not found in the current or any parent scopes. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_type
Retrieve the type associated with the given identifier from the current scope or its parent scopes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The identifier for which to retrieve the associated type. |
required |
Returns:
| Type | Description |
|---|---|
type[BaseModel]
|
type[BaseModel]: The type associated with the identifier. |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the identifier is not found in the current or any parent scope. |
Source code in fhircraft/fhir/mapper/engine/scope.py
resolve_symbol
Resolves a symbol (variable, type, or group) by its identifier from the current scope or any parent scopes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The name of the symbol to resolve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
value |
Union[FHIRPath, type[BaseModel], Group]
|
The resolved symbol, which can be a variable, a type, or a group. |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the symbol cannot be found in the current or any parent scopes. |
Source code in fhircraft/fhir/mapper/engine/scope.py
has_symbol
Checks if a symbol with the given identifier exists in the current scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The name of the symbol to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the symbol exists, False otherwise. |
Source code in fhircraft/fhir/mapper/engine/scope.py
has_local_symbol
Checks if a symbol with the given identifier exists in the current scope only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The name of the symbol to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the symbol exists, False otherwise. |
Source code in fhircraft/fhir/mapper/engine/scope.py
resolve_fhirpath
Resolve a symbol as a FHIRPath expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The symbol identifier to resolve |
required |
Returns: The resolved FHIRPath expression Raises: MappingError: If the symbol is not found or is not a FHIRPath
Source code in fhircraft/fhir/mapper/engine/scope.py
get_all_visible_symbols
get_all_visible_symbols() -> Dict[str, Union[FHIRPath, type[BaseModel], StructureMapGroup | StructureMapGroup | StructureMapGroup]]
Retrieves all visible symbols in the current scope, including those inherited from parent scopes.
This method aggregates symbols from the parent scope (if present) and then overrides them with symbols defined in the current scope. The symbols include variables, types, and groups.
Returns:
| Type | Description |
|---|---|
Dict[str, Union[FHIRPath, type[BaseModel], StructureMapGroup | StructureMapGroup | StructureMapGroup]]
|
Dict[str, Union[FHIRPath, type[BaseModel], StructureMapGroup]]: A dictionary mapping symbol names to their corresponding objects, representing all symbols visible in the current scope. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_scope_path
Returns the hierarchical path of scope names from the root to the current scope as a list of strings.
If the current scope has a parent, the method recursively retrieves the parent's scope path and appends the current scope's name. If there is no parent, returns a list containing only the current scope's name.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: The list of scope names representing the path from the root to the current scope. |
Source code in fhircraft/fhir/mapper/engine/scope.py
get_scope_depth
get_scope_depth() -> int
Returns the depth of the current scope within the scope hierarchy.
Traverses up the parent scopes recursively, incrementing the depth count for each parent until the root scope is reached.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The depth of the current scope, where the root scope has a depth of 0. |
Source code in fhircraft/fhir/mapper/engine/scope.py
create_child_scope
create_child_scope(name: str) -> MappingScope
Creates and returns a new child MappingScope with the specified name, setting the current scope as its parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the child scope to be created. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MappingScope |
MappingScope
|
A new instance of MappingScope with the given name and the current scope as its parent. |
Source code in fhircraft/fhir/mapper/engine/scope.py
is_processing_rule
Check if a given rule name is present in the list of processing rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule_name
|
str
|
The name of the rule to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the rule is in the processing rules, False otherwise. |
Source code in fhircraft/fhir/mapper/engine/scope.py
start_processing_rule
start_processing_rule(rule_name: str) -> None
Marks the beginning of processing for a specific rule by adding its name to the set of currently processing rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule_name
|
str
|
The name of the rule to start processing. |
required |
Source code in fhircraft/fhir/mapper/engine/scope.py
finish_processing_rule
finish_processing_rule(rule_name: str) -> None
Marks the specified rule as finished by removing it from the set of currently processing rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule_name
|
str
|
The name of the rule to mark as finished. |
required |
Source code in fhircraft/fhir/mapper/engine/scope.py
RuleSource
Path: fhircraft.fhir.mapper.engine.source.RuleSource
RuleSource(source: StructureMapGroupRuleSource | StructureMapGroupRuleSource | StructureMapGroupRuleSource, parent_rule: Rule)
Bases: FHIRMappingEngineComponent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
StructureMapGroupRuleSource | StructureMapGroupRuleSource | StructureMapGroupRuleSource
|
The StructureMapGroupRuleSource to initialize from. |
required |
Raises: MappingDigestionError: If required fields are missing.
Methods:
| Name | Description |
|---|---|
process |
Processes the source within the given mapping scope. |
Source code in fhircraft/fhir/mapper/engine/source.py
process
process(scope: MappingScope) -> None
Processes the source within the given mapping scope.
Source code in fhircraft/fhir/mapper/engine/source.py
RuleTarget
Path: fhircraft.fhir.mapper.engine.target.RuleTarget
RuleTarget(source: StructureMapGroupRuleTarget | StructureMapGroupRuleTarget | StructureMapGroupRuleTarget, parent_rule: Rule)
Bases: FHIRMappingEngineComponent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
StructureMapGroupRuleTarget | StructureMapGroupRuleTarget | StructureMapGroupRuleTarget
|
The StructureMapGroupRuleTarget to initialize from. |
required |
Raises: SourceProcessingError: If required fields are missing.
Methods:
| Name | Description |
|---|---|
process |
Process the target, creating path and executing transforms. |
has_list_mode |
Check if this target has a specific list mode. |
Source code in fhircraft/fhir/mapper/engine/target.py
process
process(scope: MappingScope) -> None
Process the target, creating path and executing transforms.
Source code in fhircraft/fhir/mapper/engine/target.py
has_list_mode
Check if this target has a specific list mode.
Source code in fhircraft/fhir/mapper/engine/target.py
Append
Path: fhircraft.fhir.mapper.engine.transforms.Append
Append(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'append' transform, which appends string representations of parameters.
- If
valueIdis present, it resolves the FHIRPath and appends its string value. - If
valueStringis present, it appends the string directly. - If neither is present, it raises a
RuleProcessingError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter]
|
A sequence of StructureMapParameter objects to process. |
required |
Raises:
| Type | Description |
|---|---|
RuleProcessingError
|
If no parameters are provided, or if a parameter does not have a valid type ( |
Methods:
| Name | Description |
|---|---|
process |
Appends the string representations of the provided parameters. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Appends the string representations of the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope used to resolve FHIRPath expressions. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Any
|
The concatenated string of all parameter values. |
Raises:
| Type | Description |
|---|---|
RuleProcessingError
|
If no parameters are provided, or if a parameter does not have a valid type ( |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Cast
Path: fhircraft.fhir.mapper.engine.transforms.Cast
Cast(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'cast' transform, which casts a value to a specified type.
Methods:
| Name | Description |
|---|---|
process |
Casts the value of a FHIRPath expression to a specified target type. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Casts the value of a FHIRPath expression to a specified target type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope containing context and instance data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The value of the source FHIRPath expression cast to the specified type. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
CodeableConcept
Path: fhircraft.fhir.mapper.engine.transforms.CodeableConcept
CodeableConcept(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'cc' transform, which creates a CodeableConcept from parameters.
Methods:
| Name | Description |
|---|---|
process |
Creates a CodeableConcept instance from the provided Coding parameters. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Creates a CodeableConcept instance from the provided Coding parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope (unused in this function). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CodeableConcept |
Any
|
A codeableConcept dictionary containing the specified Codings. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Coding
Path: fhircraft.fhir.mapper.engine.transforms.Coding
Coding(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'c' transform, which creates a Coding from parameters.
Methods:
| Name | Description |
|---|---|
process |
Creates a CodeableConcept instance from the provided Coding parameters. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Creates a CodeableConcept instance from the provided Coding parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope (unused in this function). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Coding |
Any
|
A coding dictionary containing the specified Codings. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
ContactPoint
Path: fhircraft.fhir.mapper.engine.transforms.ContactPoint
ContactPoint(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'cp' transform, which creates a ContactPoint
Methods:
| Name | Description |
|---|---|
process |
Creates an Identifier instance from the provided parameters. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Creates an Identifier instance from the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope (unused in this function). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Identifier |
Any
|
An identifier dictionary containing the specified system, value, and code. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Copy
Path: fhircraft.fhir.mapper.engine.transforms.Copy
Copy(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'copy' transform, which copies the source value to the target.
Methods:
| Name | Description |
|---|---|
process |
Copies a value from the source or uses a provided literal. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Copies a value from the source or uses a provided literal.
This function attempts to copy a value from the specified source using FHIRPath resolution within the given scope.
If source is not provided, it returns the given literal value instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The mapping scope containing context and instances for FHIRPath resolution. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The copied value from the source or the provided literal. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Create
Path: fhircraft.fhir.mapper.engine.transforms.Create
Create(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'create' transform, which creates a new instance of the specified type.
Methods:
| Name | Description |
|---|---|
process |
Creates and returns a new instance of a model of the specified type using the provided mapping scope. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Creates and returns a new instance of a model of the specified type using the provided mapping scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The mapping scope containing type definitions and model constructors. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseModel |
Any
|
A newly constructed instance of the specified model type. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Evaluate
Path: fhircraft.fhir.mapper.engine.transforms.Evaluate
Evaluate(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'evaluate' transform, which evaluates a FHIRPath expression.
Methods:
| Name | Description |
|---|---|
process |
Evaluates a FHIRPath expression against a specified source within the given mapping scope. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Evaluates a FHIRPath expression against a specified source within the given mapping scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope containing context and instances. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result of evaluating the FHIRPath expression against the source context. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Identifier
Path: fhircraft.fhir.mapper.engine.transforms.Identifier
Identifier(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'id' transform, which creates an Identifier
Methods:
| Name | Description |
|---|---|
process |
Creates an Identifier instance from the provided parameters. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Creates an Identifier instance from the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope (unused in this function). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Identifier |
Any
|
An identifier dictionary containing the specified system, value, and code. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
MappingTransform
Path: fhircraft.fhir.mapper.engine.transforms.MappingTransform
Bases: FHIRMappingEngineComponent, ABC
Quantity
Path: fhircraft.fhir.mapper.engine.transforms.Quantity
Quantity(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'qty' transform, which creates a Quantity
Methods:
| Name | Description |
|---|---|
process |
Transforms quantity-related input parameters into a FHIR Quantity object. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Transforms quantity-related input parameters into a FHIR Quantity object.
This function supports two modes of operation:
1. Parsing a single text parameter of the form '[<|<=|>=|>|ad]value and unit parameters (with optional system and code).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The mapping scope context (not used in this function). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Quantity |
Any
|
A FHIR Quantity object constructed from the provided parameters. |
Raises:
| Type | Description |
|---|---|
RuleProcessingError
|
If the |
AssertionError
|
If neither |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Reference
Path: fhircraft.fhir.mapper.engine.transforms.Reference
Reference(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'reference' transform, which creates a FHIR reference from a given source.
Methods:
| Name | Description |
|---|---|
process |
Transforms a FHIR resource reference by extracting its resource type and ID from the given source. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Transforms a FHIR resource reference by extracting its resource type and ID from the given source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope containing context and instances. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Any
|
A string in the format "ResourceType/ResourceId" representing the FHIR reference. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Translate
Path: fhircraft.fhir.mapper.engine.transforms.Translate
Translate(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'translate' transform, which translates a code using a concept map.
Methods:
| Name | Description |
|---|---|
process |
Translates a source code using a specified FHIR ConceptMap. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Translates a source code using a specified FHIR ConceptMap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope, providing access to FHIRPath resolution and ConceptMaps. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Any
|
The translated target code from the ConceptMap. |
Raises:
| Type | Description |
|---|---|
MappingError
|
If the ConceptMap has no groups, if a target code is not defined for the source code, or if the source code cannot be mapped using the ConceptMap. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
Truncate
Path: fhircraft.fhir.mapper.engine.transforms.Truncate
Truncate(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'truncate' transform, which truncates a string to a specified length.
Methods:
| Name | Description |
|---|---|
process |
Truncates the value obtained from a FHIRPath expression to a specified length. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Truncates the value obtained from a FHIRPath expression to a specified length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope containing context and data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Any
|
The truncated string result from the FHIRPath expression. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
UUID
Path: fhircraft.fhir.mapper.engine.transforms.UUID
UUID(parameters: Sequence[StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter | StructureMapGroupRuleTargetParameter])
Bases: MappingTransform
Implements the 'uuid' transform, which generates a UUID string.
Methods:
| Name | Description |
|---|---|
process |
Generates a new UUID string. |
Source code in fhircraft/fhir/mapper/engine/transforms.py
process
process(scope: MappingScope) -> Any
Generates a new UUID string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
MappingScope
|
The current mapping scope (unused in this function). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
Any
|
A newly generated UUID as a string. |