001package org.hl7.fhir.common.hapi.validation.support;
002
003import ca.uhn.fhir.context.FhirContext;
004import ca.uhn.fhir.context.support.ConceptValidationOptions;
005import ca.uhn.fhir.context.support.IValidationSupport;
006import ca.uhn.fhir.context.support.ValidationSupportContext;
007import ca.uhn.fhir.context.support.ValueSetExpansionOptions;
008import org.apache.commons.lang3.Validate;
009import org.hl7.fhir.instance.model.api.IBaseResource;
010
011import javax.annotation.Nonnull;
012import java.util.List;
013
014/**
015 * This class is a wrapper for an existing {@link @IContextValidationSupport} object, intended to be
016 * subclassed in order to layer functionality on top of the existing validation support object.
017 *
018 * @since 5.0.0
019 */
020public class BaseValidationSupportWrapper extends BaseValidationSupport {
021        private final IValidationSupport myWrap;
022
023        /**
024         * Constructor
025         *
026         * @param theFhirContext The FhirContext object (must be initialized for the appropriate FHIR version)
027         * @param theWrap The validation support object to wrap
028         */
029        public BaseValidationSupportWrapper(FhirContext theFhirContext, IValidationSupport theWrap) {
030                super(theFhirContext);
031                Validate.notNull(theWrap, "theWrap must not be null");
032
033                myWrap = theWrap;
034        }
035
036        @Override
037        public List<IBaseResource> fetchAllConformanceResources() {
038                return myWrap.fetchAllConformanceResources();
039        }
040
041        @Override
042        public <T extends IBaseResource> List<T> fetchAllStructureDefinitions() {
043                return myWrap.fetchAllStructureDefinitions();
044        }
045
046        @Override
047        public <T extends IBaseResource> T fetchResource(Class<T> theClass, String theUri) {
048                return myWrap.fetchResource(theClass, theUri);
049        }
050
051        @Override
052        public boolean isCodeSystemSupported(ValidationSupportContext theValidationSupportContext, String theSystem) {
053                return myWrap.isCodeSystemSupported(theValidationSupportContext, theSystem);
054        }
055
056        @Override
057        public CodeValidationResult validateCode(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, String theValueSetUrl) {
058                return myWrap.validateCode(theValidationSupportContext, theOptions, theCodeSystem, theCode, theDisplay, theValueSetUrl);
059        }
060
061        @Override
062        public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) {
063                return myWrap.lookupCode(theValidationSupportContext, theSystem, theCode);
064        }
065
066        @Override
067        public boolean isValueSetSupported(ValidationSupportContext theValidationSupportContext, String theValueSetUrl) {
068                return myWrap.isValueSetSupported(theValidationSupportContext, theValueSetUrl);
069        }
070
071        @Override
072        public IValidationSupport.ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, IBaseResource theValueSetToExpand) {
073                return myWrap.expandValueSet(theValidationSupportContext, theExpansionOptions, theValueSetToExpand);
074        }
075
076        @Override
077        public IBaseResource fetchCodeSystem(String theSystem) {
078                return myWrap.fetchCodeSystem(theSystem);
079        }
080
081        @Override
082        public IBaseResource fetchValueSet(String theUri) {
083                return myWrap.fetchValueSet(theUri);
084        }
085
086
087        @Override
088        public IBaseResource fetchStructureDefinition(String theUrl) {
089                return myWrap.fetchStructureDefinition(theUrl);
090        }
091
092        @Override
093        public IBaseResource generateSnapshot(ValidationSupportContext theValidationSupportContext, IBaseResource theInput, String theUrl, String theWebUrl, String theProfileName) {
094                return myWrap.generateSnapshot(theValidationSupportContext, theInput, theUrl, theWebUrl, theProfileName);
095        }
096
097        @Override
098        public IValidationSupport.CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theValidationOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) {
099                return myWrap.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet);
100        }
101
102
103}