diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 7e073a55a..38fe4ab43 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -312,64 +312,66 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte map = new HashMap(); allResourcesById.put(r.getType(), map); } - map.put(r.getId(), new ResourceProxy(r)); + if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) { + map.put(r.getId(), new ResourceProxy(r)); + } - String url = r.getUrl(); - if (!allowLoadingDuplicates && hasResource(r.getType(), url)) { - // spcial workaround for known problems with existing packages - if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) { - return; - } - throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url)); + String url = r.getUrl(); + if (!allowLoadingDuplicates && hasResource(r.getType(), url)) { + // spcial workaround for known problems with existing packages + if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) { + return; } - switch(r.getType()) { - case "StructureDefinition": - if ("1.4.0".equals(version)) { - StructureDefinition sd = (StructureDefinition) r.getResource(); - fixOldSD(sd); - } - structures.register(r, packageInfo); - break; - case "ValueSet": - valueSets.register(r, packageInfo); - break; - case "CodeSystem": - codeSystems.register(r, packageInfo); - break; - case "ImplementationGuide": - guides.register(r, packageInfo); - break; - case "CapabilityStatement": - capstmts.register(r, packageInfo); - break; - case "Measure": - measures.register(r, packageInfo); - break; - case "Library": - libraries.register(r, packageInfo); - break; - case "SearchParameter": - searchParameters.register(r, packageInfo); - break; - case "PlanDefinition": - plans.register(r, packageInfo); - break; - case "OperationDefinition": - operations.register(r, packageInfo); - break; - case "Questionnaire": - questionnaires.register(r, packageInfo); - break; - case "ConceptMap": - maps.register(r, packageInfo); - break; - case "StructureMap": - transforms.register(r, packageInfo); - break; - case "NamingSystem": - systems.register(r, packageInfo); - break; + throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url)); + } + switch(r.getType()) { + case "StructureDefinition": + if ("1.4.0".equals(version)) { + StructureDefinition sd = (StructureDefinition) r.getResource(); + fixOldSD(sd); } + structures.register(r, packageInfo); + break; + case "ValueSet": + valueSets.register(r, packageInfo); + break; + case "CodeSystem": + codeSystems.register(r, packageInfo); + break; + case "ImplementationGuide": + guides.register(r, packageInfo); + break; + case "CapabilityStatement": + capstmts.register(r, packageInfo); + break; + case "Measure": + measures.register(r, packageInfo); + break; + case "Library": + libraries.register(r, packageInfo); + break; + case "SearchParameter": + searchParameters.register(r, packageInfo); + break; + case "PlanDefinition": + plans.register(r, packageInfo); + break; + case "OperationDefinition": + operations.register(r, packageInfo); + break; + case "Questionnaire": + questionnaires.register(r, packageInfo); + break; + case "ConceptMap": + maps.register(r, packageInfo); + break; + case "StructureMap": + transforms.register(r, packageInfo); + break; + case "NamingSystem": + systems.register(r, packageInfo); + break; + } } } @@ -382,12 +384,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) { map.put(r.getId(), new ResourceProxy(r)); + } else { + System.out.println("Ingore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString()); } if (r instanceof CodeSystem || r instanceof NamingSystem) { oidCache.clear(); } - + if (r instanceof CanonicalResource) { CanonicalResource m = (CanonicalResource) r; String url = m.getUrl(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java index 34bfc6099..a781cc776 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java @@ -218,7 +218,7 @@ public class CanonicalResourceManager { if (cr.getPackageInfo() != null && cr.getPackageInfo().getId() != null && cr.getPackageInfo().getId().startsWith("hl7.terminology") && "http://nucc.org/provider-taxonomy".equals(cr.getUrl())) { return; } - + if (enforceUniqueId && map.containsKey(cr.getId())) { drop(cr.getId()); } @@ -236,7 +236,7 @@ public class CanonicalResourceManager { } } CachedCanonicalResource existing = cr.hasVersion() ? map.get(cr.getUrl()+"|"+cr.getVersion()) : map.get(cr.getUrl()+"|#0"); - if (existing != null && (cr.getPackageInfo() != null && cr.getPackageInfo().isExamplesPackage())) { + if (map.get(cr.getUrl()) != null && (cr.getPackageInfo() != null && cr.getPackageInfo().isExamplesPackage())) { return; } if (existing != null) { @@ -245,6 +245,7 @@ public class CanonicalResourceManager { list.add(cr); map.put(cr.getId(), cr); // we do this so we can drop by id + map.put(cr.getUrl(), cr); if (cr.getUrl() != null) { // first, this is the correct reosurce for this version (if it has a version) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index ed0afccfc..ae95c7b40 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -171,8 +171,14 @@ public interface IWorkerContext { return version; } public boolean isExamplesPackage() { - return !(id.startsWith("hl7.fhir.") && id.endsWith(".example")); + boolean b = id.startsWith("hl7.fhir.") && id.endsWith(".examples"); + return b; } + @Override + public String toString() { + return id+"#"+version; + } + } public class PackageDetails extends PackageVersion {