How to build a Segment/Field rule validating that a field contains a valid date. This one is sophisticated – take a look at the logic below.
We’ll validate that MSH.7 (Date/Time of message) contains a date.
- In the inbound HL7 task, select the Validation tab
- Select the Segment/Field Validation tab
- Add the rule: MSH.7 is matching regex ^20dd(0[1-9]|1[012])(0[1-9]|[12]d|3[01])([01]d|2[0-3])([0-5]d)([0-5]d)$
This rule means that:
- Year (^20dd): The first 2 characters must be 20 and the next 2 must be numbers
- Month (0[1-9]|1[012]): Number between 01 and 12
- Day (0[1-9]|[12]d|3[01]): Number between 01 and 31
- Hour ([01]d|2[0-3]): Number between 00 and 23
- Minute ([0-5]d): Number between 00 and 59
- Second ([0-5]d): Number between 00 and 59
We think this is a nice one…
You can download the rule file for use in Caristix Workgroup or Test software.
Download the rules file (Field is a valid date.cxf)
Learn more about how to import validation rules into an inbound HL7 task.