Interface IValidationSupport

All Known Implementing Classes:
DefaultProfileValidationSupport

public interface IValidationSupport
This interface is a version-independent representation of the various functions that can be provided by validation and terminology services.

This interface is invoked directly by internal parts of the HAPI FHIR API, including the Validator and the FHIRPath evaluator. It is used to supply artifacts required for validation (e.g. StructureDefinition resources, ValueSet resources, etc.) and also to provide terminology functions such as code validation, ValueSet expansion, etc.

Implementations are not required to implement all of the functions in this interface; in fact it is expected that most won't. Any methods which are not implemented may simply return null and calling code is expected to be able to handle this. Generally, a series of implementations of this interface will be joined together using the ValidationSupportChain class.

See Validation Support Modules for information on how to assemble and configure implementations of this interface. See also the org.hl7.fhir.common.hapi.validation.support package summary in the hapi-fhir-validation module for many implementations of this interface.

Since:
5.0.0
  • Field Details

  • Method Details

    • expandValueSet

      @Nullable default IValidationSupport.ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, @Nullable ValueSetExpansionOptions theExpansionOptions, @Nonnull IBaseResource theValueSetToExpand)
      Expands the given portion of a ValueSet
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theExpansionOptions - If provided (can be null), contains options controlling the expansion
      theValueSetToExpand - The valueset that should be expanded
      Returns:
      The expansion, or null
    • expandValueSet

      @Nullable default IValidationSupport.ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, @Nullable ValueSetExpansionOptions theExpansionOptions, @Nonnull String theValueSetUrlToExpand) throws ResourceNotFoundException
      Expands the given portion of a ValueSet by canonical URL.
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theExpansionOptions - If provided (can be null), contains options controlling the expansion
      theValueSetUrlToExpand - The valueset that should be expanded
      Returns:
      The expansion, or null
      Throws:
      ResourceNotFoundException - If no ValueSet can be found with the given URL
      Since:
      6.0.0
    • fetchAllConformanceResources

      Load and return all conformance resources associated with this validation support module. This method may return null if it doesn't make sense for a given module.
    • fetchAllStructureDefinitions

      @Nullable default <T extends IBaseResource> List<T> fetchAllStructureDefinitions()
      Load and return all possible structure definitions
    • fetchAllNonBaseStructureDefinitions

      @Nullable default <T extends IBaseResource> List<T> fetchAllNonBaseStructureDefinitions()
      Load and return all possible structure definitions aside from resource definitions themselves
    • fetchCodeSystem

      @Nullable default IBaseResource fetchCodeSystem(String theSystem)
      Fetch a code system by ID
      Parameters:
      theSystem - The code system
      Returns:
      The valueset (must not be null, but can be an empty ValueSet)
    • fetchResource

      @Nullable default <T extends IBaseResource> T fetchResource(@Nullable Class<T> theClass, String theUri)
      Loads a resource needed by the validation (a StructureDefinition, or a ValueSet)

      Note: Since 5.3.0, theClass can be null

      Parameters:
      theClass - The type of the resource to load, or null to return any resource with the given canonical URI
      theUri - The resource URI
      Returns:
      Returns the resource, or null if no resource with the given URI can be found
    • fetchStructureDefinition

      @Nullable default IBaseResource fetchStructureDefinition(String theUrl)
    • isCodeSystemSupported

      default boolean isCodeSystemSupported(ValidationSupportContext theValidationSupportContext, String theSystem)
      Returns true if codes in the given code system can be expanded or validated
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theSystem - The URI for the code system, e.g. "http://loinc.org"
      Returns:
      Returns true if codes in the given code system can be validated
    • isRemoteTerminologyServiceConfigured

      Returns true if a Remote Terminology Service is currently configured
      Returns:
      Returns true if a Remote Terminology Service is currently configured
    • fetchValueSet

      @Nullable default IBaseResource fetchValueSet(String theValueSetUrl)
      Fetch the given ValueSet by URL, or returns null if one can't be found for the given URL
    • fetchBinary

      default byte[] fetchBinary(String binaryKey)
      Fetch the given binary data by key.
      Parameters:
      binaryKey -
      Returns:
    • validateCode

      @Nullable default IValidationSupport.CodeValidationResult validateCode(@Nonnull ValidationSupportContext theValidationSupportContext, @Nonnull ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, String theValueSetUrl)
      Validates that the given code exists and if possible returns a display name. This method is called to check codes which are found in "example" binding fields (e.g. Observation.code) in the default profile.
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theOptions - Provides options controlling the validation
      theCodeSystem - The code system, e.g. "http://loinc.org"
      theCode - The code, e.g. "1234-5"
      theDisplay - The display name, if it should also be validated
      Returns:
      Returns a validation result object
    • validateCodeInValueSet

      @Nullable default IValidationSupport.CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet)
      Validates that the given code exists and if possible returns a display name. This method is called to check codes which are found in "example" binding fields (e.g. Observation.code) in the default profile.
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theCodeSystem - The code system, e.g. "http://loinc.org"
      theCode - The code, e.g. "1234-5"
      theDisplay - The display name, if it should also be validated
      theValueSet - The ValueSet to validate against. Must not be null, and must be a ValueSet resource.
      Returns:
      Returns a validation result object, or null if this validation support module can not handle this kind of request
    • lookupCode

      @Nullable default IValidationSupport.LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage)
      Look up a code using the system and code value
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theSystem - The CodeSystem URL
      theCode - The code
      theDisplayLanguage - to filter out the designation by the display language. To return all designation, set this value to null.
    • lookupCode

      @Nullable default IValidationSupport.LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode)
      Look up a code using the system and code value
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theSystem - The CodeSystem URL
      theCode - The code
    • isValueSetSupported

      default boolean isValueSetSupported(ValidationSupportContext theValidationSupportContext, String theValueSetUrl)
      Returns true if the given valueset can be validated by the given validation support module
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      theValueSetUrl - The ValueSet canonical URL
    • generateSnapshot

      @Nullable default IBaseResource generateSnapshot(ValidationSupportContext theValidationSupportContext, IBaseResource theInput, String theUrl, String theWebUrl, String theProfileName)
      Generate a snapshot from the given differential profile.
      Parameters:
      theValidationSupportContext - The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter.
      Returns:
      Returns null if this module does not know how to handle this request
    • getFhirContext

      Returns the FHIR Context associated with this module
    • invalidateCaches

      default void invalidateCaches()
      This method clears any temporary caches within the validation support. It is mainly intended for unit tests, but could be used in non-test scenarios as well.
    • translateConcept

      Attempt to translate the given concept from one code system to another