001package org.hl7.fhir.r4.hapi.ctx;
002
003import ca.uhn.fhir.context.FhirContext;
004import org.hl7.fhir.instance.model.api.IBaseResource;
005import org.hl7.fhir.r4.model.CodeSystem;
006import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
007import org.hl7.fhir.r4.model.StructureDefinition;
008import org.hl7.fhir.r4.model.ValueSet;
009import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
010import org.hl7.fhir.r4.terminologies.ValueSetExpander;
011import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
012
013import java.util.List;
014
015public interface IValidationSupport
016  extends ca.uhn.fhir.context.support.IContextValidationSupport<ConceptSetComponent, ValueSetExpander.ValueSetExpansionOutcome, StructureDefinition, CodeSystem, ConceptDefinitionComponent, IssueSeverity> {
017
018  /**
019   * Expands the given portion of a ValueSet
020   *
021   * @param theInclude The portion to include
022   * @return The expansion
023   */
024  @Override
025  ValueSetExpander.ValueSetExpansionOutcome expandValueSet(FhirContext theContext, ConceptSetComponent theInclude);
026
027  /**
028   * Load and return all possible structure definitions
029   */
030  @Override
031  List<StructureDefinition> fetchAllStructureDefinitions(FhirContext theContext);
032
033  /**
034   * Fetch a code system by Uri
035   *
036   * @param uri Canonical Uri of the code system
037   * @return The valueset (must not be null, but can be an empty ValueSet)
038   */
039  @Override
040  CodeSystem fetchCodeSystem(FhirContext theContext, String uri);
041
042  /**
043   * Fetch a valueset by Uri
044   *
045   * @param uri Canonical Uri of the ValueSet
046   * @return The valueset (must not be null, but can be an empty ValueSet)
047   */
048  @Override
049  ValueSet fetchValueSet(FhirContext theContext, String uri);
050
051  /**
052   * Loads a resource needed by the validation (a StructureDefinition, or a
053   * ValueSet)
054   *
055   * @param theContext The HAPI FHIR Context object current in use by the validator
056   * @param theClass   The type of the resource to load
057   * @param theUri     The resource URI
058   * @return Returns the resource, or <code>null</code> if no resource with the
059   * given URI can be found
060   */
061  @Override
062  <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri);
063
064  @Override
065  StructureDefinition fetchStructureDefinition(FhirContext theCtx, String theUrl);
066
067  /**
068   * Returns <code>true</code> if codes in the given code system can be expanded
069   * or validated
070   *
071   * @param theSystem The URI for the code system, e.g. <code>"http://loinc.org"</code>
072   * @return Returns <code>true</code> if codes in the given code system can be
073   * validated
074   */
075  @Override
076  boolean isCodeSystemSupported(FhirContext theContext, String theSystem);
077
078  /**
079   * Returns <code>true</code> if the given valueset can be validated by the given
080   * validation support module
081   *
082   * @param theContext The FHIR context
083   * @param theValueSetUrl The URL
084   */
085  default boolean isValueSetSupported(FhirContext theContext, String theValueSetUrl) {
086    return false;
087  }
088
089  /**
090   * Generate a snapshot from the given differential profile.
091   *
092   * @return Returns null if this module does not know how to handle this request
093   */
094  StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theProfileName);
095
096}