HIPAA compliance and custom validation

Out of the box ediFabric allows you to validate transaction objects against their corresponding specs.

There are situations however, when this might not be sufficient. Examples are cross segment validation, also known as relational conditions in X12, or the seven HIPAA SNIP levels.

There are two options for extending the existing validation which allow you to embed custom code or components - by inheriting from either ValidationAttribute or IValidator. The inbuilt validation process will always invoke the validation of any attribute inheriting from ValidationAttribute whilst iterating through the items of EdiMessage. It will then invoke any custom validation if the item implements IValidator.

Create a custom validation attribute for simple data elements

public class ExtraValidation : ValidationAttribute
    public ExtraValidation(int priority) : base(priority)
    public override List<SegmentErrorContext> Validate(InstanceContext instanceContext, int segmentIndex,
    int inSegmentIndex, int inCompositeIndex, int repetitionIndex)
        // Custom validation goes here

Inherit from the base ValidationAttribute attribute and add your validation logic in the Validate method. InstanceContext class contains the current instance, the PropertyInfo for the instance according to the spec and its parent. All of the indexes are relative to the instance in InstanceContext.

The custom attribute can be used directly in the spec by using it together with DataElementAttribute where needed. Attribute only those data elements that need the extra validation.

The Priority parameter orders the execution of the validation attributes. Priority 1 to 4 is reserved for the built in attributes. You can use any priority greater than 4.

Favor this option instead of inheriting from DataElementAttribute for avoiding any clashed with future releases.

Implement IValidator for any EDI item (loop, segment or complex element)

public partial class Loop_2000A : IValidator
    public List<SegmentErrorContext> Validate(InstanceContext instanceContext, int segmentIndex, 
                                        int inSegmentIndex, int inComponentIndex, int repetitionIndex)
        // Custom validation goes here, example below
        var result = new List<SegmentErrorContext>();
        if (All_NM1_2 != null && All_NM1_2.Loop_2010AA != null && All_NM1_2.Loop_2010AB == null)
            result.Add(new SegmentErrorContext("NM1", segmentIndex + 2, SegmentErrorCode.RequiredSegmentMissing,
                "This is custom validation for NM1 2010AB."));
        return result;

Inherit from IValidator. Every EDI composite item (loop, segment or complex data element) can be marked for custom validation. This allows you to implement typed validation across multiple segments or data elements and to comply with HIPAA levels 3, 4, 5 and 6.

It is a good practice to move all custom validation code to separate files to ensure that any updates to the spec will not overwrite the validation logic.

The seven HIPAA SNIP levels (types) are:

  • Type 1 EDI Standard Integrity Testing: Validate basic syntactical integrity of the EDI submission.
  • Type 2 HIPAA Implementation Guide Requirement Testing: Validate HIPAA requirement-guide-specific syntax requirement by checking limits on repeat counts, used or not used qualifiers, code, elements, and segments.
  • Type 3 HIPAA Balance Testing: Validate that claim line items amounts are equal to total claim amount.
  • Type 4 HIPAA Inter-Segment Situation Testing: Validate inter-segment relationship. For example, if element A exists, then element B must be populated.
  • Type 5 HIPAA External Code Set Testing: Validate specific code set values for HIPAA standards.
  • Type 6 Product Type/Type of Service Testing: Validate that segments that differ based on certain Health-care services are properly created and processed.
  • Type 7 Trading Partner-Specific Testing: Compliance with payer specific requirement. However, this is not implemented in the Oracle Health-care/B2B set up.

ediFabric supports HIPAA validation level types 1 and 2 out of the box. You can achieve levels 5 and 7 by creating partner specific specs. To create a partner spec for a transaction set, copy the original spec and apply the changes to the new spec. The changes can vary but are usually one of the following: additional segments or data elements, different data element types, extra EDI codes, segments in different positions, etc. Whatever the requirements you can adhere to any partner custom format by tweaking the spec accordingly.

HIPAA validation level types 3, 4 and 6 can be achieved by using IValidator and to manually check for balanced total amounts or do any cross-field/segment validation. All extra validation logic should be moved to separate files by marking the validated class as partial.