Merge pull request #1228 from hapifhir/gg-202304-tx-updates

Gg 202304 tx updates
This commit is contained in:
Grahame Grieve 2023-04-21 18:49:54 +08:00 committed by GitHub
commit 41fc99a8f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 65 additions and 1736 deletions

View File

@ -10,6 +10,6 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Users/grahamegrieve/.m2/repository/ca/uhn/hapi/fhir/hapi-fhir-base/5.4.0/hapi-fhir-base-5.4.0.jar"/>
<classpathentry kind="lib" path="/Users/grahamegrieve/.m2/repository/ca/uhn/hapi/fhir/hapi-fhir-base/6.2.1/hapi-fhir-base-6.2.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

File diff suppressed because it is too large Load Diff

View File

@ -128,7 +128,7 @@ public class Property {
String tn = definition.getType().get(0).getWorkingCode();
for (int i = 1; i < definition.getType().size(); i++) {
if (!tn.equals(definition.getType().get(i).getWorkingCode()))
throw new Error("logic error, gettype when types > 1");
return null; // though really, we shouldn't get here - type != null when definition.getType.size() > 1, or it should be
}
return tn;
} else

View File

@ -36,11 +36,13 @@ public class ConceptMapRenderer extends TerminologyRenderer {
}
public boolean render(XhtmlNode x, Resource dr) throws FHIRFormatError, DefinitionException, IOException {
return render(x, (ConceptMap) dr);
return render(x, (ConceptMap) dr, false);
}
public boolean render(XhtmlNode x, ConceptMap cm) throws FHIRFormatError, DefinitionException, IOException {
x.h2().addText(cm.getName()+" ("+cm.getUrl()+")");
public boolean render(XhtmlNode x, ConceptMap cm, boolean header) throws FHIRFormatError, DefinitionException, IOException {
if (header) {
x.h2().addText(cm.getName()+" ("+cm.getUrl()+")");
}
XhtmlNode p = x.para();
p.tx("Mapping from ");

View File

@ -406,7 +406,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), vsSrc.getLanguage(), parent,
convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), focus.getExtensionString(ToolingExtensions.EXT_DEFINITION), filters, noInactive, false, vsProps, null, focus.getProperty(), null, focus.getExtension());
for (ValueSetExpansionContainsComponent c : focus.getContains())
addCodeAndDescendents(focus, np, expParams, filters, noInactive, vsProps, vsSrc);
addCodeAndDescendents(c, np, expParams, filters, noInactive, vsProps, vsSrc);
}
private List<ConceptDefinitionDesignationComponent> convert(List<ConceptReferenceDesignationComponent> designations) {
@ -542,6 +542,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
expParams = makeDefaultExpansion();
source.checkNoModifiers("ValueSet", "expanding");
focus = source.copy();
focus.setIdBase(null);
focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
focus.getExpansion().setTimestampElement(DateTimeType.now());
focus.getExpansion().setIdentifier(Factory.createUUID());

View File

@ -44,7 +44,7 @@ public class CompareUtilities extends BaseTestingUtilities {
public static String checkXMLIsSame(String expected, String actual) throws Exception {
String result = compareXml(expected, actual);
if (result != null && SHOW_DIFF) {
String diff = FhirSettings.hasDiffToolPath() ? FhirSettings.getDiffToolPath() : Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
String diff = getDiffTool();
if (new File(diff).exists() || Utilities.isToken(diff)) {
Runtime.getRuntime().exec(new String[]{diff, expected, actual});
}
@ -52,6 +52,16 @@ public class CompareUtilities extends BaseTestingUtilities {
return result;
}
private static String getDiffTool() throws IOException {
if (FhirSettings.hasDiffToolPath()) {
return FhirSettings.getDiffToolPath();
} else if (System.getenv("ProgramFiles") != null) {
return Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
} else {
return null;
}
}
private static String compareXml(InputStream expected, InputStream actual) throws Exception {
return compareElements("", loadXml(expected).getDocumentElement(), loadXml(actual).getDocumentElement());
}

View File

@ -16,6 +16,7 @@ public class FhirSettings {
public static final String FHIR_SETTINGS_PATH = "fhir.settings.path";
private static String explicitFilePath = null;
private static Boolean prohibitNetworkAccess;
public static void setExplicitFilePath(String explicitFilePath) {
if (instance != null) {
@ -114,14 +115,27 @@ public class FhirSettings {
}
public static boolean hasProhibitNetworkAccess() {
if (prohibitNetworkAccess != null) {
return true;
}
getInstance();
return instance.fhirSettings.getProhibitNetworkAccess() != null; }
return instance.fhirSettings.getProhibitNetworkAccess() != null;
}
public static boolean isProhibitNetworkAccess() {
if (prohibitNetworkAccess != null) {
return prohibitNetworkAccess;
}
getInstance();
return instance.fhirSettings.getProhibitNetworkAccess() == null
? false
: instance.fhirSettings.getProhibitNetworkAccess(); }
: instance.fhirSettings.getProhibitNetworkAccess();
}
public static void setProhibitNetworkAccess(boolean value) {
prohibitNetworkAccess = value;
}
private static FhirSettings instance = null;
private static FhirSettings getInstance() {

View File

@ -227,12 +227,12 @@ public class TxTester {
String vsj;
try {
ValueSet vs = tx.expandValueset(null, p, null);
vs.setText(null);
TxTesterScrubbers.scrub(vs);
TxTesterSorters.sortValueSet(vs);
vsj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(vs);
} catch (EFhirClientException e) {
OperationOutcome oo = e.getServerErrors().get(0);
oo.setText(null);
TxTesterScrubbers.scrub(oo);
vsj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(oo);
}
String diff = CompareUtilities.checkJsonSrcIsSame(resp, vsj);
@ -250,6 +250,7 @@ public class TxTester {
String pj;
try {
Parameters po = tx.validateVS(p);
TxTesterScrubbers.scrub(po);
TxTesterSorters.sortParameters(po);
pj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(po);
} catch (EFhirClientException e) {

View File

@ -0,0 +1,20 @@
package org.hl7.fhir.validation.special;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.model.ValueSet;
public class TxTesterScrubbers {
public static void scrub(DomainResource dr) {
dr.setText(null);
dr.setMeta(null);
}
public static void scrub(Parameters po) {
po.setMeta(null);
}
}

View File

@ -44,6 +44,7 @@ import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.json.model.JsonObject;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.hl7.fhir.validation.ValidationEngine;
import org.hl7.fhir.validation.special.TxTesterScrubbers;
import org.hl7.fhir.validation.special.TxTesterSorters;
import org.hl7.fhir.validation.tests.ValidationEngineTests;
import org.hl7.fhir.validation.tests.utilities.TestUtilities;
@ -154,6 +155,7 @@ public class TerminologyServiceTests {
removeParameter(vse.getValueset(), "excludeNested");
}
TxTesterSorters.sortValueSet(vse.getValueset());
TxTesterScrubbers.scrub(vse.getValueset());
String vsj = new JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(vse.getValueset());
String diff = CompareUtilities.checkJsonSrcIsSame(resp, vsj);
if (diff != null) {
@ -197,6 +199,7 @@ public class TerminologyServiceTests {
}
e.getDetails().setText(vse.getError());
oo.addIssue(e);
TxTesterScrubbers.scrub(oo);
String ooj = new JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(oo);
String diff = CompareUtilities.checkJsonSrcIsSame(resp, ooj);
@ -263,7 +266,8 @@ public class TerminologyServiceTests {
res.addParameter().setName("issues").setResource(oo);
}
TxTesterSorters.sortParameters(res);
TxTesterScrubbers.scrub(res);
String pj = new JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(res);
String diff = CompareUtilities.checkJsonSrcIsSame(resp, pj);
if (diff != null) {

View File

@ -85,7 +85,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.6</version>
<version>1.2.3</version>
<scope>test</scope>
</dependency>