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