Merge pull request #1402 from hapifhir/do-2023-08-14-update-ucum
Update ucum to version 1.0.8
This commit is contained in:
commit
2ab5919e2e
|
@ -78,10 +78,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>xpp3</groupId>
|
||||||
|
<artifactId>xpp3</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>xpp3</groupId>
|
||||||
|
<artifactId>xpp3_xpath</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<!-- HTTP Client -->
|
<!-- HTTP Client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -32,22 +32,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>xpp3</groupId>
|
|
||||||
<artifactId>xpp3</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>xpp3</groupId>
|
|
||||||
<artifactId>xpp3_xpath</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>xpp3</groupId>
|
|
||||||
<artifactId>xpp3_min</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- XML Parsers -->
|
<!-- XML Parsers -->
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -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<String> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,7 +38,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -1499,7 +1499,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
boolean cache = false;
|
boolean cache = false;
|
||||||
for (CanonicalType c : inc.getValueSet()) {
|
for (CanonicalType c : inc.getValueSet()) {
|
||||||
ValueSet vs = fetchResource(ValueSet.class, c.getValue(), src);
|
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);
|
pin.addParameter().setName("tx-resource").setResource(vs);
|
||||||
if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(vs.getVUrl())) {
|
if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(vs.getVUrl())) {
|
||||||
tcc.getCached().add(vs.getVUrl());
|
tcc.getCached().add(vs.getVUrl());
|
||||||
|
@ -1509,7 +1509,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CodeSystem cs = fetchResource(CodeSystem.class, inc.getSystem(), src);
|
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);
|
pin.addParameter().setName("tx-resource").setResource(cs);
|
||||||
if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(cs.getVUrl())) {
|
if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(cs.getVUrl())) {
|
||||||
tcc.getCached().add(cs.getVUrl());
|
tcc.getCached().add(cs.getVUrl());
|
||||||
|
@ -1520,6 +1520,16 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
return cache;
|
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) {
|
public ValidationResult processValidationResult(Parameters pOut, String vs) {
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
String message = "No Message returned";
|
String message = "No Message returned";
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class PathBuilder {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPathRoot(args[0])) {
|
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 @@ public class PathBuilder {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args[0] == null || Utilities.noString(args[0].trim())) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,7 @@ class UtilitiesTest {
|
||||||
RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> {
|
RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> {
|
||||||
Utilities.path(pathStrings);
|
Utilities.path(pathStrings);
|
||||||
});
|
});
|
||||||
assertTrue(thrown.getMessage().endsWith(pathStrings[0]));
|
assertTrue(thrown.getMessage().endsWith(pathStrings[0]+", full path = "+String.join(", ", pathStrings)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Arguments> macAndLinuxNonFirstElementStartPaths() {
|
public static Stream<Arguments> macAndLinuxNonFirstElementStartPaths() {
|
||||||
|
@ -384,7 +384,7 @@ class UtilitiesTest {
|
||||||
RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> {
|
RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> {
|
||||||
Utilities.path(pathsStrings);
|
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
|
@Test
|
||||||
|
|
|
@ -286,7 +286,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xpp3</groupId>
|
<groupId>xpp3</groupId>
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.fhir</groupId>
|
<groupId>org.fhir</groupId>
|
||||||
<artifactId>ucum</artifactId>
|
<artifactId>ucum</artifactId>
|
||||||
<version>1.0.3</version>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- CQL-to-ELM -->
|
<!-- CQL-to-ELM -->
|
||||||
|
|
5
pom.xml
5
pom.xml
|
@ -164,6 +164,11 @@
|
||||||
<artifactId>Saxon-HE</artifactId>
|
<artifactId>Saxon-HE</artifactId>
|
||||||
<version>${saxon_he_version}</version>
|
<version>${saxon_he_version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.fhir</groupId>
|
||||||
|
<artifactId>ucum</artifactId>
|
||||||
|
<version>1.0.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
|
|
Loading…
Reference in New Issue