diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index df8ad84b4af..d4b5053a328 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -22,6 +22,7 @@ import static org.apache.commons.lang3.StringUtils.defaultIfBlank; */ import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.trim; import java.io.UnsupportedEncodingException; import java.text.Normalizer; @@ -311,6 +312,29 @@ public abstract class BaseHapiFhirDao implements IDao { } } + Set treatReferencesAsLogical = myConfig.getTreatReferencesAsLogical(); + if (treatReferencesAsLogical != null) { + boolean isLogical = false; + for (String nextLogicalRef : treatReferencesAsLogical) { + nextLogicalRef = trim(nextLogicalRef); + if (nextLogicalRef.charAt(nextLogicalRef.length() - 1) == '*') { + if (nextId.getValue().startsWith(nextLogicalRef.substring(0, nextLogicalRef.length() -1))) { + isLogical = true; + break; + } + } else { + if (nextId.getValue().equals(nextLogicalRef)) { + isLogical = true; + break; + } + } + } + + if (isLogical) { + continue; + } + } + String baseUrl = nextId.getBaseUrl(); String typeString = nextId.getResourceType(); if (isBlank(typeString)) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java index 470105ea099..675cae7cb5c 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java @@ -42,6 +42,8 @@ public class DaoConfig { * */ public static final Set DEFAULT_LOGICAL_BASE_URLS = Collections.unmodifiableSet(new HashSet(Arrays.asList( + "http://hl7.org/fhir/ValueSet/*", + "http://hl7.org/fhir/CodeSystem/*", "http://hl7.org/fhir/valueset-*", "http://hl7.org/fhir/codesystem-*", "http://hl7.org/fhir/StructureDefinition/*"))); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java index 89cb786d40b..d066eb2b729 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java @@ -75,6 +75,12 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { */ @Test public void testBuiltInLogicalReferences() throws IOException { + myDaoConfig.getTreatReferencesAsLogical().add("http://phr.kanta.fi/fiphr-vs-*"); + + ValueSet vsBodySite = loadResourceFromClasspath(ValueSet.class, "/issue534/fiphr-vs-bodysite.xml"); + myValueSetDao.create(vsBodySite, mySrd); + ValueSet vsObsMethod = loadResourceFromClasspath(ValueSet.class, "/issue534/fiphr-vs-observationmethod.xml"); + myValueSetDao.create(vsObsMethod, mySrd); StructureDefinition sd = loadResourceFromClasspath(StructureDefinition.class, "/issue534/bw_profile_snapshot.xml"); myStructureDefinitionDao.create(sd, mySrd); @@ -93,6 +99,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { @After public final void after() { myDaoConfig.setAllowExternalReferences(new DaoConfig().isAllowExternalReferences()); + myDaoConfig.setTreatReferencesAsLogical(new DaoConfig().getTreatReferencesAsLogical()); } diff --git a/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-bodysite.xml b/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-bodysite.xml index 5b31d4f503e..391c002e3f1 100644 --- a/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-bodysite.xml +++ b/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-bodysite.xml @@ -1,5 +1,4 @@ - diff --git a/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-observationmethod.xml b/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-observationmethod.xml index 577d16d45e0..44926aecfb8 100644 --- a/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-observationmethod.xml +++ b/hapi-fhir-jpaserver-base/src/test/resources/issue534/fiphr-vs-observationmethod.xml @@ -1,5 +1,4 @@ -