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
    • Method Detail

      • expandValueSet

        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 (may be null), contains options controlling the expansion
        theValueSetToExpand - The valueset that should be expanded
        Returns:
        The expansion, or null
      • fetchAllConformanceResources

        default List<IBaseResourcefetchAllConformanceResources()
        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.
      • fetchCodeSystem

        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

        default <T extends IBaseResource> T fetchResource​(Class<T> theClass,
                                                          String theUri)
        Loads a resource needed by the validation (a StructureDefinition, or a ValueSet)
        Parameters:
        theClass - The type of the resource to load
        theUri - The resource URI
        Returns:
        Returns the resource, or null if no resource with the given URI can be found
      • 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
      • validateCode

        default IValidationSupport.CodeValidationResult validateCode​(ValidationSupportContext theValidationSupportContext,
                                                                     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

        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

        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

        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
      • 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.