HL7 Data Transformer

HL7 Data Transformer is a versatile and powerful handler for HL7 data transformation.

Purpose

The HL7 Data Transformer handler provides a way of assigning new values to one or many data elements in an HL7 record. 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 identifies the target data elements, for data value transformation, using a notion called “Foldda Expression”, which is a more advanced way than the conventional HL7 data element address syntax for identifying HL7 data elements. Because the expression may also identify multiple “qualified” data elements, it means the transformer handler can transformer multiple data elements in a single operation.

A number of string-manipulating functions are provided for creating new values for being assigned to the data elements under the transformation. 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.

Parameters

There is only one type of parameter can be configured through the handler’s config file, although it can be specified multiple times.

NameRemark
transformation-ruleIncludes a Foldda Expression for identifying data elements under the transformation, also values to be assigned to these identified data elements.

Config Example

In the following example, the handler’s config specified two transformation rules: the first one “copies the value in PID-5 (patient name) to IN1-6 (insurer contact person), if the IN1’s IN1-7 (insurance-type) is ‘self’, but apply to ADT messages only”.

The second rule specifies “if PID-16 (marital status) element value is not one of the valid ones, set it to ‘UNKNOWN'”. No in this rule, the use of self-reference $$, which refers to the target data element PID-16.

<Handler>HL7DataTransformer</Handler>
  <Parameters>
    <Parameter>
      <!-- first transformation -->
      <Name>transformation-rule</Name>
      <Value>MSH-9.1==ADT~PID~IN1-17==SELF~IN1-6=>PID-5</Value>
    </Parameter>
    <Parameter>
      <!-- second transformation -->
      <Name>transformation-rule</Name>
      <Value>PID-16=>IF-MATCH($$,"SINGLE|MARRIED|DIVORCED",$$,"UNKNOWN")</Value>
    </Parameter>
  </Parameters>

See Also

The HL7 Net Sender handler.