001package org.hl7.fhir.common.hapi.validation.validator;
002
003import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
004import ca.uhn.fhir.context.FhirContext;
005import ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition;
006import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition;
007import ca.uhn.fhir.context.RuntimeResourceDefinition;
008import ca.uhn.fhir.i18n.Msg;
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)
028                                || (def instanceof RuntimeCompositeDatatypeDefinition);
029        }
030
031        @Override
032        public boolean isPrimitiveType(String typeSimple) {
033                BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
034                Validate.notNull(typeSimple);
035                return (def instanceof RuntimePrimitiveDatatypeDefinition);
036        }
037
038        @Override
039        public boolean isResource(String typeSimple) {
040                BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
041                Validate.notNull(typeSimple);
042                return def instanceof RuntimeResourceDefinition;
043        }
044
045        @Override
046        public boolean hasLinkFor(String typeSimple) {
047                return false;
048        }
049
050        @Override
051        public String getLinkFor(String corePath, String typeSimple) {
052                return null;
053        }
054
055        @Override
056        public BindingResolution resolveBinding(
057                        StructureDefinition theStructureDefinition,
058                        ElementDefinition.ElementDefinitionBindingComponent theElementDefinitionBindingComponent,
059                        String theS)
060                        throws FHIRException {
061                return null;
062        }
063
064        @Override
065        public BindingResolution resolveBinding(StructureDefinition theStructureDefinition, String theS, String theS1)
066                        throws FHIRException {
067                return null;
068        }
069
070        @Override
071        public String getLinkForProfile(StructureDefinition theStructureDefinition, String theS) {
072                return null;
073        }
074
075        @Override
076        public boolean prependLinks() {
077                return false;
078        }
079
080        @Override
081        public String getLinkForUrl(String corePath, String url) {
082                throw new UnsupportedOperationException(Msg.code(693));
083        }
084}