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 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 boolean isCodeSystemSupported(ValidationSupportContext theValidationSupportContext, String theSystem) {
061                return myWrap.isCodeSystemSupported(theValidationSupportContext, theSystem);
062        }
063
064        @Override
065        public CodeValidationResult validateCode(@Nonnull ValidationSupportContext theValidationSupportContext, @Nonnull ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, String theValueSetUrl) {
066                return myWrap.validateCode(theValidationSupportContext, theOptions, theCodeSystem, theCode, theDisplay, theValueSetUrl);
067        }
068
069        @Override
070        public IValidationSupport.CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theValidationOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) {
071                return myWrap.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet);
072        }
073
074        @Override
075        public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) {
076                return myWrap.lookupCode(theValidationSupportContext, theSystem, theCode, theDisplayLanguage);
077        }
078
079        @Override
080        public boolean isValueSetSupported(ValidationSupportContext theValidationSupportContext, String theValueSetUrl) {
081                return myWrap.isValueSetSupported(theValidationSupportContext, theValueSetUrl);
082        }
083
084        @Override
085        public IValidationSupport.ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, @Nonnull IBaseResource theValueSetToExpand) {
086                return myWrap.expandValueSet(theValidationSupportContext, theExpansionOptions, theValueSetToExpand);
087        }
088
089        @Override
090        public IBaseResource fetchCodeSystem(String theSystem) {
091                return myWrap.fetchCodeSystem(theSystem);
092        }
093
094        @Override
095        public IBaseResource fetchValueSet(String theUri) {
096                return myWrap.fetchValueSet(theUri);
097        }
098
099
100        @Override
101        public IBaseResource fetchStructureDefinition(String theUrl) {
102                return myWrap.fetchStructureDefinition(theUrl);
103        }
104
105        @Override
106        public IBaseResource generateSnapshot(ValidationSupportContext theValidationSupportContext, IBaseResource theInput, String theUrl, String theWebUrl, String theProfileName) {
107                return myWrap.generateSnapshot(theValidationSupportContext, theInput, theUrl, theWebUrl, theProfileName);
108        }
109
110        @Override
111        public TranslateConceptResults translateConcept(TranslateCodeRequest theRequest) {
112                return myWrap.translateConcept(theRequest);
113        }
114}