001package org.hl7.fhir.common.hapi.validation.validator;
002
003import ca.uhn.fhir.i18n.Msg;
004import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
005import ca.uhn.fhir.context.FhirContext;
006import ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition;
007import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition;
008import ca.uhn.fhir.context.RuntimeResourceDefinition;
009import org.apache.commons.lang3.Validate;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r5.conformance.profile.BindingResolution;
012import org.hl7.fhir.r5.conformance.profile.ProfileKnowledgeProvider;
013import org.hl7.fhir.r5.model.ElementDefinition;
014import org.hl7.fhir.r5.model.StructureDefinition;
015
016public class ProfileKnowledgeWorkerR5 implements ProfileKnowledgeProvider {
017    private final FhirContext myCtx;
018
019    public ProfileKnowledgeWorkerR5(FhirContext theCtx) {
020        myCtx = theCtx;
021    }
022
023    @Override
024    public boolean isDatatype(String typeSimple) {
025        BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
026        Validate.notNull(typeSimple);
027        return (def instanceof RuntimePrimitiveDatatypeDefinition) || (def instanceof RuntimeCompositeDatatypeDefinition);
028    }
029
030        @Override
031        public boolean isPrimitiveType(String typeSimple) {
032                BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
033                Validate.notNull(typeSimple);
034                return (def instanceof RuntimePrimitiveDatatypeDefinition);
035        }
036
037        @Override
038    public boolean isResource(String typeSimple) {
039        BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
040        Validate.notNull(typeSimple);
041        return def instanceof RuntimeResourceDefinition;
042    }
043
044    @Override
045    public boolean hasLinkFor(String typeSimple) {
046        return false;
047    }
048
049    @Override
050    public String getLinkFor(String corePath, String typeSimple) {
051        return null;
052    }
053
054    @Override
055    public BindingResolution resolveBinding(StructureDefinition theStructureDefinition, ElementDefinition.ElementDefinitionBindingComponent theElementDefinitionBindingComponent, String theS) throws FHIRException {
056        return null;
057    }
058
059    @Override
060    public BindingResolution resolveBinding(StructureDefinition theStructureDefinition, String theS, String theS1) throws FHIRException {
061        return null;
062    }
063
064    @Override
065    public String getLinkForProfile(StructureDefinition theStructureDefinition, String theS) {
066        return null;
067    }
068
069    @Override
070    public boolean prependLinks() {
071        return false;
072    }
073
074    @Override
075    public String getLinkForUrl(String corePath, String url) {
076        throw new UnsupportedOperationException(Msg.code(693));
077    }
078
079}