The TabularData Transformer handler provides a way of assigning new values to one or many data elements in tabular data (aka. “CSV data”). The new values can be a constant string, or a value from another data element, or a transformed value of the original from the same data element.
The Transformer handler uses a notion called “Foldda Expression” for identifying target data elements, for the data value transformation. Foldda Expression allows specifying a context when identifying data elements, kinda like a “conditional search”. Because multiple data elements can be qualified by an expression, it means one transformation rule can be applied to multiple data elements in a single operation.
For deriving or generating new values for being assigned to the data elements in a transformation, a number of string-manipulating functions are provided. These functions are –
- CONCAT – concatenates multiple strings into one.
- PRINT – prints a data element’s value, or a variable in the log
- FORMAT-DATETIME – converts a date-time string to another format
- IF-MATCH – produces a different value depending on a RegEx pattern-match result.
- FORMAT-NUMBER – formats a number, e.g. as currency or with padding 0’s.
- KEEP-LEFT – truncates or pads a string to a specified length, counting from the left.
- KEEP-RIGHT – truncates or pads a string to a specified length, counting from the right.
- CUT-LEFT – cuts a specified number of chars from a string, counting from the left.
- CUT-RIGHT – cuts a specified number of chars from a string, counting from the right.
- TRIM – trims leading and trailing spaces.
- REPLACE – replaces a part of a string to a new value.
- TIMESTAMP – produces a string of the current date and time, in the specified format.
- ID – produces various record identifiers.
Multiple “transformation rule” parameters can be specified in a transformer handler’s config setting, allowing a kind of multi-steps “batch” data processing by the transformer, as these rules are executed sequentially in the supplied order and the modified data elements and variables from the previous steps are kept in the context when executing the later steps.
There is only one type of parameter can be configured through the handler’s config file, although it can be specified multiple times.
|transformation-rule||Includes a Foldda Expression for identifying data elements under the transformation, also values to be assigned to these identified data elements.|
In the following example, the handler’s config specified one transformation rule: concatenate cell $2 and cell $3 from a tabular row, with a hyphen in between, and assign the concatenated string to cell $1 of the same row.
<Handler>TabularDataTransformer</Handler> <Parameters> <!-- set the 1st column as the concatination of column 2 and 3. --> <Parameter> <Name>transformation-rule</Name> <Value>$1=>CONCAT($2,"-",$3)</Value> </Parameter> </Parameters>
The HL7 Data Transformer handler is the equivalent handler for transforming HL7 records.