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>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<optional>true</optional>
|
||||
</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 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
<dependency>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -32,22 +32,7 @@
|
|||
<dependency>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<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>
|
||||
|
||||
<!-- XML Parsers -->
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
<dependency>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
<dependency>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<optional>true</optional>
|
||||
</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>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -1499,7 +1499,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
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 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
}
|
||||
}
|
||||
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 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
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";
|
||||
|
|
|
@ -150,7 +150,7 @@ public class PathBuilder {
|
|||
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 @@ public class PathBuilder {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ class UtilitiesTest {
|
|||
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<Arguments> macAndLinuxNonFirstElementStartPaths() {
|
||||
|
@ -384,7 +384,7 @@ class UtilitiesTest {
|
|||
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
|
||||
|
|
|
@ -286,7 +286,6 @@
|
|||
<dependency>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xpp3</groupId>
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
<dependency>
|
||||
<groupId>org.fhir</groupId>
|
||||
<artifactId>ucum</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- CQL-to-ELM -->
|
||||
|
|
Loading…
Reference in New Issue