001package org.hl7.fhir.convertors.loaders.loaderR3;
002
003import javax.annotation.Nonnull;
004
005import org.hl7.fhir.dstu3.context.SimpleWorkerContext.IContextResourceLoader;
006import org.hl7.fhir.dstu3.model.Resource;
007
008import lombok.Getter;
009import lombok.Setter;
010import lombok.experimental.Accessors;
011
012@Accessors(chain = true)
013public abstract class BaseLoaderR3 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 ILoaderKnowledgeProviderR3 lkp;
023
024  @Getter @Setter protected boolean patchUrls;
025  @Getter @Setter protected boolean killPrimitives;
026
027  public BaseLoaderR3(@Nonnull String[] types, @Nonnull ILoaderKnowledgeProviderR3 lkp) {
028    super();
029    this.types = types;
030    this.lkp = lkp;
031  }
032
033  public String getResourcePath(Resource resource) {
034    return lkp.getResourcePath(resource);
035  }
036
037  public void setPath(Resource r) {
038    String path = lkp.getResourcePath(r);
039    if (path != null) {
040      r.setUserData("path", path);
041    }
042  }
043
044}