HL7 Validation Device
This device is currently marked as [BETA]. Some features have not yet been fully implemented.
The HL7 Validation device is designed to inspect HL7 and report on potential invalid items. It is built on top of the HL7 Transform device, and extends that devices functionality.
Users can add their own validation functions, as well as tweak existing functionality. There is also optional built-in validation based on HL7 schemas.
The Custom Code control in this device allows you to write your own validation functions. Each function must return a collection of ValidationResult objects (in the Connexion.Device.Hl7ValidationDevice namespace) - with an empty collection representing a valid result.
The following contrived example shows a simple validation function:
[FunctionCategory("Tutorial")]
[FunctionDescription("Sample Function")]
public virtual List<ValidationResult> IsNumeric(HL7Path path, ValidationResultLevels level)
{
var currentValue = Message[path];
if(currentValue.Length == 0)
return [ new ValidationResult(path, "Input was empty", level) ];
foreach(var c in currentValue)
{
if(!Char.IsNumber(c) && c != '.')
return [ new ValidationResult(path, "Input non-numeric", level) ];
}
return [];
}This function will return a ValidationResult collection if the HL7 field is empty or non-numeric. You can add a Validation Function transform and reference this C# function. Input the required parameters and view the output in the Out Message viewer.
The result of any user-defined function is displayed at the top of any validation output.
You can also validate based on the existence of specific values within a map table. After defining a map table, use the In Table transform type to check that a field contains a valid value.
You can also use the Custom Code control to override the built-in validation based on the data type of each field (as defined by an HL7 schema). There is a boilerplate code example included with the device (showing validation of date/time types):
public override void OnValidateFieldType(FieldTypeValidateEventArgs args)
{
switch(args.FieldType)
{
case "DTM":
case "DT":
case "TS":
{
if (HL7DateTime.ParseExact(args.FieldValue) == null)
{
args.ViolationType = ViolationType.DataInterpretationError;
args.Handled = true;
}
}
break;
}
}Automatic Validation
In addition to the user-defined validation above, this device also includes some ‘automatic’ validation based on HL7 schemas.
The Settings tab lets you enable/disable Auto Validate, which uses the specified HL7 Version to determine valid values. You can create your own schemas based on an existing one, and edit it using the schema editor.
You can also choose to move messages with validation errors and/or warnings to the error queue.
The Metadata Paths in the above image are used when validation result storage is enabled. You can optionally store validation results externally (file, database), and these fields are used as indexes when searching for specific messages.
If you navigate to the Results Storage tab and set the Retention to a value greater than zero, you can select a target for storage of the validation results.
Validation results can be viewed on the Reporting tab. Use the Query Results tab view a list of errors and warnings, along with a highlighted HL7 message.
The Reporting tab is currently not implemented. In the future, it will have the ability to run reports showing the count and frequency of validation errors.