diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 934701ca5f..1f928bdacf 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -78,10 +78,19 @@ org.fhir ucum - 1.0.3 true + + xpp3 + xpp3 + true + + + xpp3 + xpp3_xpath + true + org.apache.httpcomponents diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 9829794008..5e154e7d2b 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -32,7 +32,6 @@ org.fhir ucum - 1.0.3 true diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 14b6af817d..4b7771c225 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -32,22 +32,7 @@ org.fhir ucum - 1.0.3 true - - - xpp3 - xpp3 - - - xpp3 - xpp3_xpath - - - xpp3 - xpp3_min - - diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index d998ac341e..fb4607ab25 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -32,7 +32,6 @@ org.fhir ucum - 1.0.3 true diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 3a30dd2598..7c4e8014f9 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -39,7 +39,6 @@ org.fhir ucum - 1.0.3 true diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ParametersBuilder.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ParametersBuilder.java new file mode 100644 index 0000000000..c209391ee8 --- /dev/null +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ParametersBuilder.java @@ -0,0 +1,68 @@ +package org.hl7.fhir.r4.utils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Arrays; +import java.util.Set; +import java.util.HashSet; + +import org.hl7.fhir.r4.formats.IParser.OutputStyle; +import org.hl7.fhir.r4.formats.JsonParser; +import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.r4.model.MetadataResource; +import org.hl7.fhir.r4.model.Parameters; +import org.hl7.fhir.utilities.TextFile; + +/** + * Used to take an overload dump from tx.fhir.org and turn it into a parameters resource + * + * @author grahamegrieve + * + */ +public class ParametersBuilder { + + public static void main(String[] args) throws FileNotFoundException, IOException { + new ParametersBuilder(args[0], args[1]).process(args[2]); + } + + + + private String folder; + private String baseId; + + protected ParametersBuilder(String folder, String baseId) { + super(); + this.folder = folder; + this.baseId = baseId; + } + + private void process(String output) throws FileNotFoundException, IOException { + Parameters p = new Parameters(); + Set ids = new HashSet<>(); + for (File f : new File(folder).listFiles()) { + if (f.getName().startsWith(baseId)) { + if (f.getName().startsWith(baseId)) { + byte[] cnt = TextFile.fileToBytes(f); + cnt = shaveZeros(cnt); // bug in tx.fhir.org + MetadataResource r = (MetadataResource) new JsonParser().parse(cnt); + if (!ids.contains(r.getUrl()+"|"+r.getVersion())) { + ids.add(r.getUrl()+"|"+r.getVersion()); + p.addParameter().setName("tx-resource").setResource(r); + } + } + } + } + new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(output), p); + } + + private byte[] shaveZeros(byte[] cnt) { + for (int i = 0; i < cnt.length; i++) { + if (cnt[i] == 0) { + return Arrays.copyOf(cnt, i-1); + } + } + return cnt; + } +} diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index 83af6a56c8..a0d87e6d62 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -38,7 +38,6 @@ org.fhir ucum - 1.0.3 true 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 4e21702d96..74a596b0bf 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 @@ -1499,7 +1499,7 @@ private boolean addDependentResources(Parameters pin, ConceptSetComponent inc, R boolean cache = false; for (CanonicalType c : inc.getValueSet()) { ValueSet vs = fetchResource(ValueSet.class, c.getValue(), src); - if (vs != null) { + if (vs != null && !hasCanonicalResource(pin, "tx-resource", vs.getVUrl())) { pin.addParameter().setName("tx-resource").setResource(vs); if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(vs.getVUrl())) { tcc.getCached().add(vs.getVUrl()); @@ -1509,7 +1509,7 @@ private boolean addDependentResources(Parameters pin, ConceptSetComponent inc, R } } CodeSystem cs = fetchResource(CodeSystem.class, inc.getSystem(), src); - if (cs != null && (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == CodeSystemContentMode.FRAGMENT)) { + if (cs != null && !hasCanonicalResource(pin, "tx-resource", cs.getVUrl()) && (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == CodeSystemContentMode.FRAGMENT)) { pin.addParameter().setName("tx-resource").setResource(cs); if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(cs.getVUrl())) { tcc.getCached().add(cs.getVUrl()); @@ -1520,6 +1520,16 @@ private boolean addDependentResources(Parameters pin, ConceptSetComponent inc, R return cache; } + private boolean hasCanonicalResource(Parameters pin, String name, String vUrl) { + for (ParametersParameterComponent p : pin.getParameter()) { + if (name.equals(p.getName()) && p.hasResource() && + p.getResource() instanceof CanonicalResource && vUrl.equals(((CanonicalResource) p.getResource()).getVUrl())) { + return true; + } + } + return false; + } + public ValidationResult processValidationResult(Parameters pOut, String vs) { boolean ok = false; String message = "No Message returned"; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/PathBuilder.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/PathBuilder.java index 7f3d3cd809..b546b1a377 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/PathBuilder.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/PathBuilder.java @@ -150,7 +150,7 @@ private void checkNonRootFirstEntry(String[] args) { return; } if (isPathRoot(args[0])) { - throw new RuntimeException("First entry cannot be root: " + args[0]); + throw new RuntimeException("First entry in file path cannot be root: " + args[0]+", full path = "+String.join(", ", args)); } } @@ -159,7 +159,7 @@ private void checkNonNullNonEmptyFirstEntry(String[] args) { return; } if (args[0] == null || Utilities.noString(args[0].trim())) { - throw new RuntimeException("First path entry cannot be null or empty"); + throw new RuntimeException("First entry in file path cannot be null or empty, full path = "+String.join(", ", args)); } } diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java index fd00f34497..c91f1508e5 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java @@ -293,7 +293,7 @@ private static void testCantStartWithRoot(String[] pathStrings) { RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> { Utilities.path(pathStrings); }); - assertTrue(thrown.getMessage().endsWith(pathStrings[0])); + assertTrue(thrown.getMessage().endsWith(pathStrings[0]+", full path = "+String.join(", ", pathStrings))); } public static Stream macAndLinuxNonFirstElementStartPaths() { @@ -384,7 +384,7 @@ public void testNullOrEmptyFirstPathEntryFails(String[] pathsStrings) { RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> { Utilities.path(pathsStrings); }); - assertEquals("First path entry cannot be null or empty",thrown.getMessage()); + assertEquals("First entry in file path cannot be null or empty, full path = "+String.join(", ", pathsStrings),thrown.getMessage()); } @Test diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index c63ba2d96c..86a2a89eba 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -286,7 +286,6 @@ org.fhir ucum - 1.0.3 xpp3 diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 4a7d6c8255..51904be864 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -120,7 +120,7 @@ org.fhir ucum - 1.0.3 + true diff --git a/pom.xml b/pom.xml index 649202ea91..5c87ffa821 100644 --- a/pom.xml +++ b/pom.xml @@ -164,6 +164,11 @@ Saxon-HE ${saxon_he_version} + + org.fhir + ucum + 1.0.8 + mysql