001package org.hl7.fhir.convertors.loaders.loaderR4; 002 003import javax.annotation.Nonnull; 004 005import org.hl7.fhir.r4.context.SimpleWorkerContext.IContextResourceLoader; 006import org.hl7.fhir.r4.model.Resource; 007 008import lombok.Getter; 009import lombok.Setter; 010import lombok.experimental.Accessors; 011 012@Accessors(chain = true) 013public abstract class BaseLoaderR4 implements IContextResourceLoader { 014 015 protected final String URL_BASE = "http://hl7.org/fhir/"; 016 protected final String URL_DSTU2 = "http://hl7.org/fhir/1.0/"; 017 protected final String URL_DSTU2016MAY = "http://hl7.org/fhir/1.4/"; 018 protected final String URL_DSTU3 = "http://hl7.org/fhir/3.0/"; 019 protected final String URL_R4 = "http://hl7.org/fhir/4.0/"; 020 protected final String URL_ELEMENT_DEF_NAMESPACE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"; 021 @Getter private final String[] types; 022 private final ILoaderKnowledgeProviderR4 lkp; 023 @Getter @Setter protected boolean patchUrls; 024 @Getter @Setter protected boolean killPrimitives; 025 026 public BaseLoaderR4(@Nonnull String[] types, @Nonnull ILoaderKnowledgeProviderR4 lkp) { 027 super(); 028 this.types = types; 029 this.lkp = lkp; 030 } 031 032 public String getResourcePath(Resource resource) { 033 return lkp.getResourcePath(resource); 034 } 035 036 public void setPath(Resource r) { 037 String path = lkp.getResourcePath(r); 038 if (path != null) { 039 r.setUserData("path", path); 040 } 041 } 042 043}