IF-MATCH Function

This function matches a data element's value to a regular expression pattern, and returns one of the two specified values depending on the pattern-matching result.

Purpose

This function uses the result of a boolean operation (if-else) to drive HL7 and CSV data transformation. The function first tests a data element’s string value against a regular expression (a powerful industry-standard ‘pattern matching’ method), it then returns one specified value if the match returns true, and another specified value if the match returns false.

Combined with Foldda Expression, which is a novel and effective way to address HL7 or CSV data elements in a given context, IF-MATCH

Hint: IF-MATCH function is inspired by Excel’s “IF function”, which has the following syntax: IF(A1>70,”Pass”,”Fail”)

Format

IF-MATCH(source-data-element, matching-pattern, value-if-true, value-if-false)

Example 1

A HL7DataTransformer handler with the following config entry assigns IN1-16 (“name of insured”) with the value from PID-5 (“patient name”), if IN1-17 (“insured’s relationship to patient”) has the value “SELF”, otherwise, keeps value in IN1-16 unchanged.

<Parameter>
  <!-- IF-MATCH Example -->
  <Name>transformation-rule</Name>
  <Value>$PID~IN1-16=>IF-MATCH($IN1-17,"SELF", $PID-5, $$)</Value>
</Parameter>
InputOutcome
PID|||||Robert||
IN1||||||||||||||||Roby|SELF|
PID|||||Robert||
IN1||||||||||||||||Robert|SELF|
Pattern matched.
InputOutcome
PID|||||Robert||
IN1||||||||||||||||Smith|FATHER|
PID|||||Robert||
IN1||||||||||||||||Smith|FATHER|
Pattern un-matched.

Example 2

A HL7DataTransformer handler with the following config checks if PID-8 (“patient sex”) has the expected value “M” or “F”, if yes, keeps the original value, otherwise set it to value “U”.

<Parameter>
  <!-- IF-MATCH Example -->
  <Name>transformation-rule</Name>
  <Value>$PID-8=>IF-MATCH($$,"M|F", $$, "U")</Value>
</Parameter>
InputOutcome
PID||||||||M|PID||||||||M|
Pattern matched.
InputOutcome
PID||||||||F|PID||||||||F|
Pattern matched.
InputOutcome
PID||||||||X|PID||||||||U|
Pattern un-matched.

Related

Nil.