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