001package org.hl7.fhir.r4.hapi.ctx; 002 003import java.util.List; 004 005import org.hl7.fhir.instance.model.api.IBaseResource; 006import org.hl7.fhir.r4.model.CodeSystem; 007import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent; 008import org.hl7.fhir.r4.model.StructureDefinition; 009import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent; 010import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent; 011import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; 012 013import ca.uhn.fhir.context.FhirContext; 014import ca.uhn.fhir.context.support.IContextValidationSupport; 015 016public interface IValidationSupport 017 extends ca.uhn.fhir.context.support.IContextValidationSupport<ConceptSetComponent, ValueSetExpansionComponent, StructureDefinition, CodeSystem, ConceptDefinitionComponent, IssueSeverity> { 018 019 /** 020 * Expands the given portion of a ValueSet 021 * 022 * @param theInclude 023 * The portion to include 024 * @return The expansion 025 */ 026 @Override 027 ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude); 028 029 /** 030 * Load and return all possible structure definitions 031 */ 032 @Override 033 List<StructureDefinition> fetchAllStructureDefinitions(FhirContext theContext); 034 035 /** 036 * Fetch a code system by ID 037 * 038 * @param theSystem 039 * The code system 040 * @return The valueset (must not be null, but can be an empty ValueSet) 041 */ 042 @Override 043 CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem); 044 045 /** 046 * Loads a resource needed by the validation (a StructureDefinition, or a 047 * ValueSet) 048 * 049 * @param theContext 050 * The HAPI FHIR Context object current in use by the validator 051 * @param theClass 052 * The type of the resource to load 053 * @param theUri 054 * The resource URI 055 * @return Returns the resource, or <code>null</code> if no resource with the 056 * given URI can be found 057 */ 058 @Override 059 <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri); 060 061 @Override 062 StructureDefinition fetchStructureDefinition(FhirContext theCtx, String theUrl); 063 064 /** 065 * Returns <code>true</code> if codes in the given code system can be expanded 066 * or validated 067 * 068 * @param theSystem 069 * The URI for the code system, e.g. <code>"http://loinc.org"</code> 070 * @return Returns <code>true</code> if codes in the given code system can be 071 * validated 072 */ 073 @Override 074 boolean isCodeSystemSupported(FhirContext theContext, String theSystem); 075 076 /** 077 * Validates that the given code exists and if possible returns a display 078 * name. This method is called to check codes which are found in "example" 079 * binding fields (e.g. <code>Observation.code</code> in the default profile. 080 * 081 * @param theCodeSystem 082 * The code system, e.g. "<code>http://loinc.org</code>" 083 * @param theCode 084 * The code, e.g. "<code>1234-5</code>" 085 * @param theDisplay 086 * The display name, if it should also be validated 087 * @return Returns a validation result object 088 */ 089 @Override 090 CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem, String theCode, String theDisplay); 091 092 public class CodeValidationResult extends IContextValidationSupport.CodeValidationResult<ConceptDefinitionComponent, IssueSeverity> { 093 094 public CodeValidationResult(ConceptDefinitionComponent theNext) { 095 super(theNext); 096 } 097 098 public CodeValidationResult(IssueSeverity theSeverity, String theMessage) { 099 super(theSeverity, theMessage); 100 } 101 102 public CodeValidationResult(IssueSeverity severity, String message, ConceptDefinitionComponent definition) { 103 super(severity, message, definition); 104 } 105 106 } 107 108}