diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/interceptors/built_in_server_interceptors.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/interceptors/built_in_server_interceptors.md index 4d2e524b6a5..b1768478819 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/interceptors/built_in_server_interceptors.md +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/interceptors/built_in_server_interceptors.md @@ -227,3 +227,52 @@ The UserRequestRetryVersionConflictsInterceptor allows clients to request that t # JPA Server: Validate Data Being Stored The RepositoryValidatingInterceptor can be used to enforce validation rules on data stored in a HAPI FHIR JPA Repository. See [Repository Validating Interceptor](/docs/validation/repository_validating_interceptor.html) for more information. + + +# Data Standardization + +```StandardizingInterceptor``` handles data standardization (s13n) requirements. This interceptor applies standardization rules on all FHIR primitives as configured in the ```s13n.json``` file that should be made available on the classpath. This file contains FHIRPath definitions together with the standardizers that should be applied to that path. It comes with six per-build standardizers: NAME_FAMILY, NAME_GIVEN, EMAIL, TITLE, PHONE and TEXT. Custom standardizers can be developed by implementing ```ca.uhn.fhir.rest.server.interceptor.s13n.standardizers.IStandardizer``` interface. + +A sample configuration file can be found below: + +```json +{ + "Person" : { + "Person.name.family" : "NAME_FAMILY", + "Person.name.given" : "NAME_GIVEN", + "Person.telecom.where(system='phone').value" : "PHONE" + }, + "Patient" : { + "name.family" : "NAME_FAMILY", + "name.given" : "NAME_GIVEN", + "telecom.where(system='phone').value" : "PHONE" + }, + "*" : { + "telecom.where(system='email').value" : "org.example.s13n.MyCustomStandardizer" + } +} +``` + +Standardization can be disabled for a given request by providing ```HAPI-Standardization-Disabled``` request header. + + +# Validation: Address Validation + +```AddressValidatingInterceptor``` takes care of validation of addresses on all incoming resources through a 3rd party address validation service. Before a resource containing an Address field is stored, this interceptor invokes address validation service and then stores validation results as an extension on the address with ```https://hapifhir.org/AddressValidation/``` URL. + +This interceptor is configured in ```address-validation.properties``` file that should be made available on the classpath. This file must contain ```validator.class``` property, which defines a fully qualified class implementing ```ca.uhn.fhir.rest.server.interceptor.validation.address.IAddressValidator``` interface. The specified implementation must provide service-specific logic for validating an Address instance. An example implementation can be found in ```ca.uhn.fhir.rest.server.interceptor.validation.address.impl.LoquateAddressValidator``` class which validates addresses by using Loquate Data Cleanse service. + +Address validation can be disabled for a given request by providing ```HAPI-Address-Validation-Disabled``` request header. + +# Validation: Field-Level Validation + +```FieldValidatingInterceptor``` allows validating primitive fields on various FHIR resources. It expects validation rules to be provided via ```field-validation-rules.json``` file that should be available on the classpath. JSON in this file defines a mapping of FHIRPath expressions to validators that should be applied to those fields. Custom validators that implement ```ca.uhn.fhir.rest.server.interceptor.validation.fields.IValidator``` interface can be provided. + +```json +{ + "telecom.where(system='email').value" : "EMAIL", + "telecom.where(system='phone').value" : "org.example.validation.MyCustomValidator" +} +``` + +Field validation can be disabled for a given request by providing ```HAPI-Field-Validation-Disabled``` request header. diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/s13n/StandardizingInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/s13n/StandardizingInterceptor.java index 1b796ff4b30..38cc2891086 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/s13n/StandardizingInterceptor.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/s13n/StandardizingInterceptor.java @@ -32,7 +32,7 @@ public class StandardizingInterceptor extends ServerOperationInterceptorAdapter NAME_FAMILY, NAME_GIVEN, EMAIL, TITLE, PHONE, TEXT; } - public static final String STANDARDIZATION_DISABLED_HEADER = "CDR-Standardization-Disabled"; + public static final String STANDARDIZATION_DISABLED_HEADER = "HAPI-Standardization-Disabled"; private static final Logger ourLog = LoggerFactory.getLogger(StandardizingInterceptor.class); diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java index 022029aa0a0..f7a1348d476 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/address/AddressValidatingInterceptor.java @@ -25,7 +25,7 @@ public class AddressValidatingInterceptor extends ServerOperationInterceptorAdap public static final String ADDRESS_TYPE_NAME = "Address"; public static final String PROPERTY_VALIDATOR_CLASS = "validator.class"; - public static final String ADDRESS_VALIDATION_DISABLED_HEADER = "CDR-Address-Validation-Disabled"; + public static final String ADDRESS_VALIDATION_DISABLED_HEADER = "HAPI-Address-Validation-Disabled"; private ExtensionHelper myExtensionHelper = new ExtensionHelper(); diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/fields/FieldValidatingInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/fields/FieldValidatingInterceptor.java index 4e9d74c3701..e611b3143bb 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/fields/FieldValidatingInterceptor.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/validation/fields/FieldValidatingInterceptor.java @@ -22,7 +22,7 @@ public class FieldValidatingInterceptor extends ServerOperationInterceptorAdapte private static final Logger ourLog = LoggerFactory.getLogger(FieldValidatingInterceptor.class); - public static final String VALIDATION_DISABLED_HEADER = "CDR-Field-Validation-Disabled"; + public static final String VALIDATION_DISABLED_HEADER = "HAPI-Field-Validation-Disabled"; private IAddressValidator myAddressValidator;