Class HuskyFhirValidatorImpl

java.lang.Object
org.projecthusky.fhir.validation.impl.HuskyFhirValidatorImpl
All Implemented Interfaces:
HuskyFhirValidator
Direct Known Subclasses:
ChEmedEprHapiValidator, ChVacdValidator

public class HuskyFhirValidatorImpl extends Object implements HuskyFhirValidator
  • Field Details

    • validator

      protected final ca.uhn.fhir.validation.FhirValidator validator
    • chain

      protected final org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain chain
      Validation support chain.
    • prepopulatedValidationSupport

      protected final org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupport prepopulatedValidationSupport
    • logValidationOutcome

      protected boolean logValidationOutcome
      Whether the validation outcome should be logged with logger when calling a validation method.
    • validationResultLogger

      protected @Nullable ValidationResultLogger 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 a HuskyFhirValidatorImpl, 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: HuskyFhirValidator
      Gets the class logger.
      Specified by:
      getLog in interface HuskyFhirValidator
    • 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

      public ValidationResult validateDocumentBundle(org.hl7.fhir.r4.model.Bundle bundle, String profile)
      Description copied from interface: HuskyFhirValidator
      Validates a document Bundle. No logic validation is performed on the content.
      Specified by:
      validateDocumentBundle in interface HuskyFhirValidator
      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:
      validateResource in interface HuskyFhirValidator
      Throws:
      IOException
    • logValidationResult

      protected void logValidationResult(ValidationResult validationResult)
      Logs the validation result if enabled in the validator config. If enabled and no explicit ValidationResultLogger has been set, a default one will be automatically set and used.
      Parameters:
      validationResult - The validation result to be logged.
    • getDefaultValidationResultLogger

      public ValidationResultLogger getDefaultValidationResultLogger()
      Gets a default validation result logger.
    • setLogValidationOutcome

      public void setLogValidationOutcome(boolean logValidationOutcome)
    • setValidationResultLogger

      public void setValidationResultLogger(ValidationResultLogger validationResultLogger)