Virtual fields¶
Virtual fields are CDM-table fields that only exist inside the engine — they never reach the destination database. They are used as scratch space for normalisation, indexing, or holding intermediate values for joins.
Declaring a virtual field¶
Add a field: line to the Comments field of the CDM table in
Rabbit-in-a-Hat:
The text after field: becomes the name of the virtual field. The field
is then visible to every rule running on that CDM table — both
field-to-field maps and CDM-field rules.
The example above adds a visit_occurrence_source_value field to
visit_occurrence — a common requirement on CDM 5.4, where
visit_occurrence lacks a *_source_value field for its primary key.
Writing to a virtual field from a field-to-field map¶
Use SaveToVirtualField
on a transition that targets an otherwise-unrelated field; the rule
redirects the value into the named virtual field:
This is necessary because Rabbit-in-a-Hat does not visualise virtual fields, so there is no transition arrow you could place a normal rule on.
Writing from rule chain output¶
Any rule chain's Output_Fields_List (the part after the trailing =>)
can declare new fields. New fields declared this way become virtual fields
and remain in scope for subsequent rules in the same chain:
Here :result is a virtual field that lives only for the duration of the
chain.