Merge pull request #1255 from jamesagnew/addFetchValueSet

added fetchValueSet to IValidationSupport and made it public
This commit is contained in:
James Agnew 2019-04-15 17:03:56 -04:00 committed by GitHub
commit 311246e5f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 188 additions and 44 deletions

View File

@ -234,6 +234,12 @@ public class ValidatorExamples {
return null;
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
// TODO: implement
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
// TODO: implement

View File

@ -27,6 +27,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import org.hl7.fhir.dstu3.hapi.ctx.IValidationSupport;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -56,6 +57,11 @@ public class LoadingValidationSupportDstu3 implements IValidationSupport {
return null;
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
String resName = myCtx.getResourceDefinition(theClass).getName();

View File

@ -27,6 +27,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r4.terminologies.ValueSetExpander;
@ -58,6 +59,11 @@ public class LoadingValidationSupportR4 implements org.hl7.fhir.r4.hapi.ctx.IVal
return null;
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
String resName = myCtx.getResourceDefinition(theClass).getName();

View File

@ -67,6 +67,11 @@ public class IgPackValidationSupportDstu3 implements IValidationSupport {
return fetchResource(theContext, CodeSystem.class, theSystem);
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return fetchResource(theContext, ValueSet.class, theSystem);
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
for (Map.Entry<IIdType, IBaseResource> next : myIgResources.entrySet()) {

View File

@ -89,6 +89,14 @@ public class JpaValidationSupportDstu3 implements IJpaValidationSupportDstu3, Ap
return fetchResource(theCtx, CodeSystem.class, theSystem);
}
@Override
public ValueSet fetchValueSet(FhirContext theCtx, String theSystem) {
if (isBlank(theSystem)) {
return null;
}
return fetchResource(theCtx, ValueSet.class, theSystem);
}
@SuppressWarnings("unchecked")
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {

View File

@ -86,6 +86,11 @@ public class JpaValidationSupportR4 implements IJpaValidationSupportR4, Applicat
return fetchResource(theCtx, CodeSystem.class, theSystem);
}
@Override
public ValueSet fetchValueSet(FhirContext theCtx, String theSystem) {
return fetchResource(theCtx, ValueSet.class, theSystem);
}
@SuppressWarnings("unchecked")
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {

View File

@ -204,6 +204,12 @@ public class HapiTerminologySvcDstu3 extends BaseHapiTerminologySvcImpl implemen
return null;
}
@CoverageIgnore
@Override
public ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
return null;

View File

@ -155,6 +155,12 @@ public class HapiTerminologySvcR4 extends BaseHapiTerminologySvcImpl implements
return null;
}
@CoverageIgnore
@Override
public ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
return null;

View File

@ -139,8 +139,9 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
return provideStructureDefinitionMap(theContext).get(theUrl);
}
ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return (ValueSet) fetchCodeSystemOrValueSet(theContext, theSystem, false);
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return (ValueSet) fetchCodeSystemOrValueSet(theContext, uri, false);
}
public void flush() {

View File

@ -4,6 +4,7 @@ import java.util.List;
import org.hl7.fhir.dstu2016may.model.CodeSystem;
import org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu2016may.model.ValueSet;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.dstu2016may.model.StructureDefinition;
import org.hl7.fhir.dstu2016may.model.ValueSet.ConceptSetComponent;
@ -33,14 +34,23 @@ public interface IValidationSupport
List<StructureDefinition> fetchAllStructureDefinitions(FhirContext theContext);
/**
* Fetch a code system by ID
*
* @param theSystem
* The code system
* Fetch a code system by Uri
*
* @param uri
* Canonical Uri of the code system
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
@Override
CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem);
CodeSystem fetchCodeSystem(FhirContext theContext, String uri);
/**
* Fetch a valueset by Uri
*
* @param uri
* Canonical Uri of the ValueSet
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
ValueSet fetchValueSet(FhirContext theContext, String uri);
/**
* Loads a resource needed by the validation (a StructureDefinition, or a

View File

@ -99,8 +99,13 @@ public class PrePopulatedValidationSupport implements IValidationSupport {
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) {
return myCodeSystems.get(theSystem);
public CodeSystem fetchCodeSystem(FhirContext theContext, String uri) {
return myCodeSystems.get(uri);
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return myValueSets.get(uri);
}
@SuppressWarnings("unchecked")

View File

@ -3,6 +3,7 @@ package org.hl7.fhir.dstu2016may.hapi.validation;
import ca.uhn.fhir.context.FhirContext;
import org.hl7.fhir.dstu2016may.model.CodeSystem;
import org.hl7.fhir.dstu2016may.model.StructureDefinition;
import org.hl7.fhir.dstu2016may.model.ValueSet;
import org.hl7.fhir.dstu2016may.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -78,9 +79,9 @@ public class ValidationSupportChain implements IValidationSupport {
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theCtx, String theSystem) {
public CodeSystem fetchCodeSystem(FhirContext theCtx, String uri) {
for (IValidationSupport next : myChain) {
CodeSystem retVal = next.fetchCodeSystem(theCtx, theSystem);
CodeSystem retVal = next.fetchCodeSystem(theCtx, uri);
if (retVal != null) {
return retVal;
}
@ -88,6 +89,18 @@ public class ValidationSupportChain implements IValidationSupport {
return null;
}
@Override
public ValueSet fetchValueSet(FhirContext theCtx, String uri) {
for (IValidationSupport next : myChain) {
ValueSet retVal = next.fetchValueSet(theCtx, uri);
if (retVal != null) {
return retVal;
}
}
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
for (IValidationSupport next : myChain) {

View File

@ -155,8 +155,9 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
return retVal;
}
ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return (ValueSet) fetchCodeSystemOrValueSet(theContext, theSystem, false);
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return (ValueSet) fetchCodeSystemOrValueSet(theContext, uri, false);
}
public void flush() {

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -32,15 +33,24 @@ public interface IValidationSupport
@Override
List<StructureDefinition> fetchAllStructureDefinitions(FhirContext theContext);
/**
* Fetch a code system by ID
*
* @param theSystem
* The code system
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
@Override
CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem);
/**
* Fetch a code system by Uri
*
* @param uri
* Canonical Uri of the code system
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
@Override
CodeSystem fetchCodeSystem(FhirContext theContext, String uri);
/**
* Fetch a valueset by Uri
*
* @param uri
* Canonical Uri of the ValueSet
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
ValueSet fetchValueSet(FhirContext theContext, String uri);
/**
* Loads a resource needed by the validation (a StructureDefinition, or a

View File

@ -158,8 +158,9 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
return provideStructureDefinitionMap(theContext).get(url);
}
ValueSet fetchValueSet(FhirContext theContext, String theSystem) {
return (ValueSet) fetchCodeSystemOrValueSet(theContext, theSystem, false);
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return (ValueSet) fetchCodeSystemOrValueSet(theContext, uri, false);
}
public void flush() {

View File

@ -6,6 +6,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r4.terminologies.ValueSetExpander;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
@ -32,14 +33,23 @@ public interface IValidationSupport
List<StructureDefinition> fetchAllStructureDefinitions(FhirContext theContext);
/**
* Fetch a code system by ID
* Fetch a code system by Uri
*
* @param theSystem
* The code system
* @return The valueset (must not be null, but can be an empty ValueSet)
* @param uri
* Canonical Uri of the code system
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
@Override
CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem);
CodeSystem fetchCodeSystem(FhirContext theContext, String uri);
/**
* Fetch a valueset by Uri
*
* @param uri
* Canonical Uri of the ValueSet
* @return The valueset (must not be null, but can be an empty ValueSet)
*/
ValueSet fetchValueSet(FhirContext theContext, String uri);
/**
* Loads a resource needed by the validation (a StructureDefinition, or a

View File

@ -41,8 +41,13 @@ public class CachingValidationSupport implements IValidationSupport {
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) {
return myWrap.fetchCodeSystem(theContext, theSystem);
public CodeSystem fetchCodeSystem(FhirContext theContext, String uri) {
return myWrap.fetchCodeSystem(theContext, uri);
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return myWrap.fetchValueSet(theContext, uri);
}
@Override

View File

@ -146,11 +146,16 @@ public class PrePopulatedValidationSupport implements IValidationSupport {
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) {
return myCodeSystems.get(theSystem);
}
public CodeSystem fetchCodeSystem(FhirContext theContext, String uri) {
return myCodeSystems.get(uri);
}
@SuppressWarnings("unchecked")
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return myValueSets.get(uri);
}
@SuppressWarnings("unchecked")
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
if (theClass.equals(StructureDefinition.class)) {

View File

@ -5,6 +5,7 @@ import org.hl7.fhir.dstu3.hapi.ctx.IValidationSupport;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.StructureDefinition;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -101,6 +102,17 @@ public class ValidationSupportChain implements IValidationSupport {
return null;
}
@Override
public ValueSet fetchValueSet(FhirContext theCtx, String uri) {
for (IValidationSupport next : myChain) {
ValueSet retVal = next.fetchValueSet(theCtx, uri);
if (retVal != null) {
return retVal;
}
}
return null;
}
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
for (IValidationSupport next : myChain) {

View File

@ -42,8 +42,13 @@ public class CachingValidationSupport implements IValidationSupport {
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) {
return myWrap.fetchCodeSystem(theContext, theSystem);
public CodeSystem fetchCodeSystem(FhirContext theContext, String uri) {
return myWrap.fetchCodeSystem(theContext, uri);
}
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return myWrap.fetchValueSet(theContext, uri);
}
@Override

View File

@ -146,12 +146,18 @@ public class PrePopulatedValidationSupport implements IValidationSupport {
return new ArrayList<StructureDefinition>(myStructureDefinitions.values());
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String theSystem) {
return myCodeSystems.get(theSystem);
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theContext, String uri) {
return myCodeSystems.get(uri);
}
@SuppressWarnings("unchecked")
@Override
public ValueSet fetchValueSet(FhirContext theContext, String uri) {
return myValueSets.get(uri);
}
@SuppressWarnings("unchecked")
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
if (theClass.equals(StructureDefinition.class)) {

View File

@ -7,6 +7,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.hapi.ctx.IValidationSupport;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r4.terminologies.ValueSetExpander;
@ -70,9 +71,20 @@ public class ValidationSupportChain implements IValidationSupport {
}
@Override
public CodeSystem fetchCodeSystem(FhirContext theCtx, String theSystem) {
public CodeSystem fetchCodeSystem(FhirContext theCtx, String uri) {
for (IValidationSupport next : myChain) {
CodeSystem retVal = next.fetchCodeSystem(theCtx, theSystem);
CodeSystem retVal = next.fetchCodeSystem(theCtx, uri);
if (retVal != null) {
return retVal;
}
}
return null;
}
@Override
public ValueSet fetchValueSet(FhirContext theCtx, String uri) {
for (IValidationSupport next : myChain) {
ValueSet retVal = next.fetchValueSet(theCtx, uri);
if (retVal != null) {
return retVal;
}