On this page:

6.7Java Repository Validation Bean


More granular validation support can be provided by adding your own implementation(s) of IValidationSupport to the Repository Validation Chain.

For example, if you needed to add custom code handling for a specific code system, you could write a class like the following.

package com.example.fhir;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import org.springframework.beans.factory.annotation.Autowired;

public class CustomValidator implements IValidationSupport {
	public static FhirContext ourFhirContext = FhirContext.forCached(FhirVersionEnum.R4);
	public static String SYSTEM = "http://example.com/system";
	public static String GOOD_CODE = "123";
	public static String GOOD_DISPLAY = "code display";
	public static String WARNING_CODE = "456";
	public static String WARNING_MESSAGE = "this code should not be used";
	public static String FATAL_CODE = "789";

   private FhirContext myFhirContext;

   public FhirContext getFhirContext() {
      return myFhirContext;

   public boolean isCodeSystemSupported(ValidationSupportContext theValidationSupportContext, String theSystem) {
      return SYSTEM.equals(theSystem);

   public CodeValidationResult validateCode(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, String theValueSetUrl) {
      if (SYSTEM.equals(theCodeSystem)) {
         if (GOOD_CODE.equals(theCode)) {
            return new IValidationSupport.CodeValidationResult()
         } else if (WARNING_CODE.equals(theCode)) {
            return new IValidationSupport.CodeValidationResult()
         } else if (FATAL_CODE.equals(theCode)) {
            return new IValidationSupport.CodeValidationResult()
      return null;

You may register these validator beans with the Storage Module in the same way as Storage Interceptors are registered: Compile the validator classes into a jar file and copy that jar file into the customerlib folder. See the "Registering An Interceptor" section on the Interceptors page for more details.

The only difference between registering a custom interceptor and registering a custom validator is the custom validator is registered using the "validator_bean_types" config key in the properties file


More than one validator can be specified in a comma-separated list.

This config can also be managed in the Web Admin Console in the "Repository Validation" section of a Relational Storage Module.