Validate Field length

How to build a Segment/Field rule validating that a field’s value has the expected length

In this example, we’ll validate that:

  • PID.2 length >= 10
  • PID.3.1 length = 7

 

In the inbound HL7 task, select the Validation tab

  1. Select the Segment/Field Validation tab
  2. Add a first rule:  PID.2 is matching regex .{10,}
  3. Add a second rule: PID.3.1 is matching regex .{7}

 

This illustrates the power of regular expressions.

  • . (dot) refers to a character
  • {n,m} refers to the number of characters where n is the minimum and m is the maximum expected

 

Other quantifiers can be used

  • * : 0 or more
  • + : 1 or more
  • ? : 0 or 1

 

You can download the rule file for use in Caristix Workgroup or Test software.

Download the rule file (Field length.cxf)

Learn more about how to import validation rules into an inbound HL7 task.