Class HuskyFhirValidatorImpl
java.lang.Object
org.projecthusky.fhir.validation.impl.HuskyFhirValidatorImpl
- All Implemented Interfaces:
HuskyFhirValidator
- Direct Known Subclasses:
ChEmedEprHapiValidator,ChVacdValidator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.hl7.fhir.common.hapi.validation.support.ValidationSupportChainValidation support chain.protected booleanWhether the validation outcome should be logged with logger when calling a validation method.protected final org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupportprotected @Nullable ValidationResultLoggerThe logger to use in case validation result logger is enabled.protected final ca.uhn.fhir.validation.FhirValidator -
Constructor Summary
ConstructorsConstructorDescriptionHuskyFhirValidatorImpl(ca.uhn.fhir.context.FhirContext context, List<String> resourcePackages, @Nullable String txServer) Creates an instance of aHuskyFhirValidatorImpl, that is, a validator that will not try to use external terminology services, and that uses HAPI's validation engine. -
Method Summary
Modifier and TypeMethodDescriptionaddValidationMessagePostProcessingInterceptor(ca.uhn.fhir.rest.server.interceptor.validation.ValidationMessagePostProcessingInterceptor interceptor) Adds an interceptor to the list of validation message post-processing interceptors.Gets a default validation result logger.List<@NonNull ca.uhn.fhir.rest.server.interceptor.validation.ValidationMessagePostProcessingInterceptor> Gets the list of validation message post-processing interceptors to be processed after validation.org.slf4j.LoggergetLog()Gets the class logger.protected voidhandleValidationResult(ca.uhn.fhir.validation.ValidationResult result) Handles the HAPI FHIR validation result by having all registered post-processors handle it.protected voidlogValidationResult(ValidationResult validationResult) Logs the validation result if enabled in the validator config.voidsetInterceptors(List<@NonNull ca.uhn.fhir.rest.server.interceptor.validation.ValidationMessagePostProcessingInterceptor> interceptors) voidsetLogValidationOutcome(boolean logValidationOutcome) voidsetValidationResultLogger(ValidationResultLogger validationResultLogger) validateDocumentBundle(org.hl7.fhir.r4.model.Bundle bundle, String profile) Validates a document Bundle.validateResource(org.hl7.fhir.instance.model.api.IBaseResource resource, String profile)
-
Field Details
-
validator
protected final ca.uhn.fhir.validation.FhirValidator validator -
chain
protected final org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain chainValidation support chain. -
prepopulatedValidationSupport
protected final org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupport prepopulatedValidationSupport -
logValidationOutcome
protected boolean logValidationOutcomeWhether the validation outcome should be logged with logger when calling a validation method. -
validationResultLogger
The logger to use in case validation result logger is enabled.
-
-
Constructor Details
-
HuskyFhirValidatorImpl
public HuskyFhirValidatorImpl(ca.uhn.fhir.context.FhirContext context, List<String> resourcePackages, @Nullable String txServer) throws IOException Creates an instance of aHuskyFhirValidatorImpl, that is, a validator that will not try to use external terminology services, and that uses HAPI's validation engine.- Parameters:
context- The FHIR context to be used.resourcePackages- The list of resource packages to load for validation.txServer- The terminology server to use for validation. If null or blank, an in-memory terminology server will be used.- Throws:
IOException- if the NPM packages can't be found in the classpath.
-
-
Method Details
-
getLog
public org.slf4j.Logger getLog()Description copied from interface:HuskyFhirValidatorGets the class logger.- Specified by:
getLogin interfaceHuskyFhirValidator
-
getInterceptors
public List<@NonNull ca.uhn.fhir.rest.server.interceptor.validation.ValidationMessagePostProcessingInterceptor> getInterceptors()Gets the list of validation message post-processing interceptors to be processed after validation. -
setInterceptors
public void setInterceptors(List<@NonNull ca.uhn.fhir.rest.server.interceptor.validation.ValidationMessagePostProcessingInterceptor> interceptors) -
addValidationMessagePostProcessingInterceptor
public HuskyFhirValidatorImpl addValidationMessagePostProcessingInterceptor(ca.uhn.fhir.rest.server.interceptor.validation.ValidationMessagePostProcessingInterceptor interceptor) Adds an interceptor to the list of validation message post-processing interceptors. -
handleValidationResult
protected void handleValidationResult(ca.uhn.fhir.validation.ValidationResult result) Handles the HAPI FHIR validation result by having all registered post-processors handle it. The result is expected to be potentially modified by the handling. No new instance will be kept, results must be modified. -
validateDocumentBundle
Description copied from interface:HuskyFhirValidatorValidates a document Bundle. No logic validation is performed on the content.- Specified by:
validateDocumentBundlein interfaceHuskyFhirValidator- Parameters:
bundle- The document Bundle to be validated.profile- The profile to match the bundle against.- Returns:
- the validation result.
-
validateResource
public ValidationResult validateResource(org.hl7.fhir.instance.model.api.IBaseResource resource, String profile) throws IOException - Specified by:
validateResourcein interfaceHuskyFhirValidator- Throws:
IOException
-
logValidationResult
Logs the validation result if enabled in the validator config. If enabled and no explicitValidationResultLoggerhas been set, a default one will be automatically set and used.- Parameters:
validationResult- The validation result to be logged.
-
getDefaultValidationResultLogger
Gets a default validation result logger. -
setLogValidationOutcome
public void setLogValidationOutcome(boolean logValidationOutcome) -
setValidationResultLogger
-