Draft Website - For Review Purposes Only

12 Appendix A: Predicate Definition Language

Elements assigned with a declared conditional usage require an associated predicate that is computable and based on other elements in the message. The conformance methodology specification does not prescribe a language to define the predicate. A recommended pseudo language that provides the mechanisms to construct predicate statements is given in this section. The language is HL7 v2-specific and is grounded on predicate definitions that have emerged over time in the specification of HL7 v2 implementation guides. The goal is to provide specifiers with a simple language that affords consistency within and across HL7 v2 implementation guides, the readability of a natural language, and be machine computable. The language is not comprehensive (nor formal) and is intended for use in HL7 v2 for convenience.

Examples of Condition Predicates:

IF CWE.1 (Identifier) is valued.

IF RXA-20 (Completion Status) contains one of the values in the list: {'CP', 'PA'}.

The pseudo language for describing predicate definition is composed of building blocks that are linked together to create the predicates. The building blocks include:

An example template for the condition predicate builder follows this general pattern:

Condition Predicate Example using a template pattern:

IF LOCATION (DESCRIPTION) VERB one of the values in the list: {‘VALUE 1’, ‘VALUE 2’, ‘VALUE N’}.

Example:

IF RXA-20 (Completion Status) contains one of the values in the list: {'CP', 'PA'}.

Table 12.1 shows the template pattern broken up into its building-block parts. Additionally, a usage is given for each building block. Some building blocks are a part of all condition predicates (required), and others may be part of the condition predicates (optional). Subsequent sections explains the details for each of the building blocks.

Table 12.1: Condition Predicate Template

Example Template Pattern

Template Example

Example

Usage

IF

IF

IF

Required

Occurrence Declarative Statement

N/A

N/A

Optional

Location

LOCATION (DESCRIPTION)

RXA-20 (Completion Status)

Required

Context

N/A

N/A

Optional

Verb

VERB

contains

Required

Content Declarative Statement OR Content Comparison Declarative Statement

contains the value one of the values in the list: {‘VALUE 1 ‘VALUE 2’, ‘VALUE N’}.

one of the values in the list: {'CP', 'PA'}.

Required

12.1 IF Statement

Every condition predicate starts with an “IF” statement.

12.2 Occurrence-Declarative Statement

A condition predicate may refer to a specific instance of an element or to a group of element instances. Identifying an instance or instances is accomplished with the occurrence-declarative statement. Table 12.2 shows the list of pre-defined occurrence-declarative statement patterns and their meanings.

Table 12.2: Occurrence-Declarative Statement

Occurrence-Declarative Statement

Description

at least one occurrence of

One or more occurrence(s) of a repeating element can satisfy the predicate.

the 'INSTANCE' occurrence of

The occurrence indicated by the INSTANCE of a repeating element must satisfy the predicate. Other instances may also satisfy the predicate.

no occurrence of

No occurrence of a repeating element can satisfy the predicate.

exactly one occurrence of

One and only one occurrence of a repeating element can satisfy the predicate.

'COUNT' occurrences of

Exactly COUNT occurrences of a repeating element can satisfy the predicate.

All occurrences of

All occurrences of a repeating element must satisfy the predicate.

12.3 Element Location

The Element Location indicates the location in the message that is being addressed. The location can reference a group, segment, field, component, or sub-component and includes a description. For details of how an element location is represented, see Section 1.2.3.

12.4 Context

The meaning of a condition predicate can be different depending on the context or scope to which it applies. Table 12.3 shows the list of pre-defined context patterns and their meanings. Note that the context of “LOCATION” indicates the location at any level. To indicate a specific context, the condition predicate may be enhanced with the context provided in Table 12.3.

Table 12.3: Condition Predicate Context

Context (Scope/Location)

 Description

in the same GROUP group

"same group", e.g., “in the same ORDER group”

12.5 Verbs

Table 12.4 indicates the set of verbs that can be used to construct predicate inquires. The verbs are paired with certain Proposition Content Declarative Statements or Content Comparison Declarative Statements.

Table 12.4: Condition Predicate Verbs

Verbs

is

is not

contains

does not contain

matches

does not match

12.6 Content-Declarative Statements

Proposition content-declarative statements ask whether an element contains certain content. The values can be arbitrary values, coded values, or restricted values based on a format. The values may or may not contain an associated description. Table 12.5 lists each of the statements along with the verbs they can be paired with.

Table 12.5: Content-Declarative Statement

Declarative Statement

 Verb Pairs

valued

is/is not

the value ‘VALUE’.

contains/does not contain

the value ‘VALUE’ (DESCRIPTION).

contains/does not contain

the value ‘VALUE’ drawn from the code system 'CODE SYSTEM'.

contains/does not contain

the value ‘VALUE’ (DESCRIPTION) drawn from the code system 'CODE SYSTEM'.

contains/does not contain

one of the values in the list: { ‘VALUE 1’, 'VALUE 2', 'VALUE N' }.

contains/does not contain

one of the values in the list: { ‘VALUE 1’ (DESCRIPTION), 'VALUE 2' (DESCRIPTION), 'VALUE N' (DESCRIPTION) }.

contains/does not contain

one of the values in the list: { ‘VALUE 1’, 'VALUE 2', 'VALUE N' } drawn from the code system 'CODE SYSTEM'.

contains/does not contain

one of the values in the list: { ‘VALUE 1’ (DESCRIPTION), 'VALUE 2 (DESCRIPTION)', 'VALUE N' (DESCRIPTION) } drawn from the code system 'CODE SYSTEM'.

contains/does not contain

the regular expression ‘REGULAR EXPRESSION’.

matches/does not match

For ‘REGULAR EXPRESSION’, content is required to match the regular expression. Regular expressions of “MR\d{5}” indicate that the content must start with “MR” and be followed with 5 digits. Example is “MR83452”.

12.7 Comparison-Content Declarative Statement

Proposition comparison-content declarative statements ask whether the content of one element matches that of another element based on a comparator. Table 12.6 lists each of the statements along with a description and examples. All Content Comparison Declarative Statement are paired with the verbs is/is not.

Table 12.6: Content Comparison Declarative Statement

Comparative Statement

 Description

Examples

be identical to LOCATION 2 (DESCRIPTION).

Content is the same in meaning and representation (a literal identical to). Applies to general, coded values, and data/time content. This concept can also be applied at the complex element level (e.g., compare ORC-12 and OBX-16).

General: 3 is identical to 3.

Coded Value: The LOINC code of 30963-3 is identical to 30963-3

Date/Time: 201103041023-0400 is identical to 201803041023-0400 (unlikely to be used for time)

Complex element: Each constitute part of the complex element are compared for identical content.

be earlier than LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs before the date/time of the element it is compared to. The comparison is a “meaning” comparison.

Date/Time: 201803041021-0400 is earlier than 201803040823-0600

be earlier than or equivalent to LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs before or at the date/time of the element it is compared to. The comparison is a “meaning” comparison.

Date/Time: 201803041021-0400 is earlier than 201803040823-0600

Date/Time: 201803041023-0400 is equivalent to 201803040823-0600

be truncated earlier than LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs before the date/time of the element it is compared to. The comparison is a “meaning” comparison and is at the coarsest level (i.e., the more detailed element is truncated to the resolution of the less detailed element).

Date/Time: 20180302 is earlier than 201803040823-0600

be truncated earlier than or truncated equivalent to LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs before or at the date/time of the element it is compared to. The comparison is a “meaning” comparison and is at the coarsest level (i.e., the more detailed element is truncated to the resolution of the less detailed element).

Date/Time: 20180304 is equivalent to 201803040823-0600

Date/Time: 20180302 is earlier than 201803040823-0600

be equivalent to LOCATION 2 (DESCRIPTION).

Content is the same in meaning but not representation. Applies to general, coded values, and data/time content. This concept can also be applied at the complex element level (e.g., compare ORC-12 and OBX-16).

General: 3.00 is equivalent to 3.

Coded Value: C38288 (NCIT) is equivalent to PO (HL70162). Oral-administered by mouth. Note: A concept map must be specified.

Date/Time: 201803041023-0400 is equivalent to 201803040823-0600

Complex element: Each constitute part of the complex element are compared for identical content.

be truncated equivalent to LOCATION 2 (DESCRIPTION).

Content is the same in meaning but not represented in the same manner and/or having the same resolution. Applies to general and data/time content. The comparison is at the coarsest level (i.e., the more detailed element is truncated to the resolution of the less detailed element).

General: 3.56 is truncated equivalent to 3.

Date/Time: 20110304 is equivalent to 201803040823-0600

be equivalent to or later than LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs after or at the date/time of the element it is compared to. The comparison is a “meaning” comparison. 

Date/Time: 201803041023-0400 is equivalent to 201803040823-0600 

 

Date/Time: 201803041025-0400 is later than 201803040823-0600 

be later than LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs after the date/time of the element it is compared to. The comparison is a “meaning” comparison.

Date/Time: 201803041025-0400 is later than 201803040823-0600

be truncated equivalent to or truncated later than LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs after or at the date/time of the element it is compared to. The comparison is a “meaning” comparison and is at the coarsest level (i.e., the more detailed element is truncated to the resolution of the less detailed element).

Date/Time: 20180304 is equivalent to 201803040823-0600

Date/Time: 20180305 is later than 201803040823-0600

be truncated later than LOCATION 2 (DESCRIPTION).

Applies to date/time content only and indicates a date/time that occurs after the date/time of the element it is compared to. The comparison is a “meaning” comparison and is at the coarsest level (i.e., the more detailed element is truncated to the resolution of the less detailed element).

Date/Time: 20180305 is later than 201803040823-0600

12.8 Complex Condition Predicates

Condition predicate statements can be combined to make complex condition predicates with a set of connectors (See Table 12.7). Multiple connectors can be used.

Table 12.7: Condition Predicate Connectors

Connectors

 Description

AND

 Both predicates must be satisfied

OR

 One predicate must be satisfied; both may be satisfied

XOR

 Exclusive OR–one predicate must be satisfied; both must not be satisfied

An example of a complex condition predicate is:

Example:

If RXA-9.1 (Identifier) contains the value '00' AND RXA-20 (Completion Status) contains one of the values in the list: {CP, PA}.