fix version return + profile support in testing

This commit is contained in:
Grahame Grieve 2023-05-04 10:01:35 +10:00
parent 94fd0ae795
commit 806c065fcb
3 changed files with 39 additions and 7 deletions

View File

@ -325,11 +325,21 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
String disp = lookupDisplay(foundCoding);
ConceptDefinitionComponent cd = new ConceptDefinitionComponent(foundCoding.getCode());
cd.setDisplay(disp);
return new ValidationResult(IssueSeverity.WARNING, info.summary(), foundCoding.getSystem(), foundCoding.hasVersion() ? foundCoding.getVersion() : ((CodeSystem) foundCoding.getUserData("cs")).getVersion(), cd, disp, info.getIssues());
return new ValidationResult(IssueSeverity.WARNING, info.summary(), foundCoding.getSystem(), getVersion(foundCoding), cd, disp, info.getIssues());
} else {
ConceptDefinitionComponent cd = new ConceptDefinitionComponent(foundCoding.getCode());
cd.setDisplay(lookupDisplay(foundCoding));
return new ValidationResult(foundCoding.getSystem(), foundCoding.hasVersion() ? foundCoding.getVersion() : ((CodeSystem) foundCoding.getUserData("cs")).getVersion(), cd, getPreferredDisplay(cd, null));
return new ValidationResult(foundCoding.getSystem(), getVersion(foundCoding), cd, getPreferredDisplay(cd, null));
}
}
private String getVersion(Coding c) {
if (c.hasVersion()) {
return c.getVersion();
} else if (c.hasUserData("cs")) {
return ((CodeSystem) c.getUserData("cs")).getVersion();
} else {
return null;
}
}

View File

@ -522,6 +522,7 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
private boolean criticalSignpost;
private Date ruleDate;
public static final String NO_RULE_DATE = null;
private boolean matched; // internal use counting matching filters
/**
@ -841,4 +842,14 @@ public class ValidationMessage implements Comparator<ValidationMessage>, Compara
public boolean isError() {
return level == IssueSeverity.ERROR || level == IssueSeverity.FATAL;
}
public boolean isMatched() {
return matched;
}
public void setMatched(boolean matched) {
this.matched = matched;
}
}

View File

@ -165,11 +165,12 @@ public class TxTester {
return ok;
}
private boolean runTest(JsonObject test, TerminologyClient tx, List<Resource> setup, String filter, JsonArray output) {
private boolean runTest(JsonObject test, TerminologyClient tx, List<Resource> setup, String filter, JsonArray output) throws FHIRFormatError, DefinitionException, FileNotFoundException, FHIRException, IOException {
JsonObject outputT = new JsonObject();
if (output != null) {
output.add(outputT);
}
Parameters profile = loadProfile(test);
outputT.add("name", test.asString("name"));
if (Utilities.noString(filter) || filter.equals("*") || test.asString("name").contains(filter)) {
System.out.print(" Test "+test.asString("name")+": ");
@ -186,9 +187,9 @@ public class TxTester {
String msg = null;
if (test.asString("operation").equals("expand")) {
msg = expand(tx, setup, req, resp, fp);
msg = expand(tx, setup, req, resp, fp, profile);
} else if (test.asString("operation").equals("validate-code")) {
msg = validate(tx, setup, req, resp, fp);
msg = validate(tx, setup, req, resp, fp, profile);
} else {
throw new Exception("Unknown Operation "+test.asString("operation"));
}
@ -216,14 +217,23 @@ public class TxTester {
}
}
private Parameters loadProfile(JsonObject test) throws FHIRFormatError, DefinitionException, FileNotFoundException, FHIRException, IOException {
if (test.has("profile")) {
return (Parameters) loader.loadResource(test.asString("profile"));
} else {
return (Parameters) loader.loadResource("parameters-default.json");
}
}
private String serverId() throws URISyntaxException {
return new URI(server).getHost();
}
private String expand(TerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp) throws IOException {
private String expand(TerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, Parameters profile) throws IOException {
for (Resource r : setup) {
p.addParameter().setName("tx-resource").setResource(r);
}
p.getParameter().addAll(profile.getParameter());
String vsj;
try {
ValueSet vs = tx.expandValueset(null, p, null);
@ -243,10 +253,11 @@ public class TxTester {
return diff;
}
private String validate(TerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp) throws IOException {
private String validate(TerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, Parameters profile) throws IOException {
for (Resource r : setup) {
p.addParameter().setName("tx-resource").setResource(r);
}
p.getParameter().addAll(profile.getParameter());
String pj;
try {
Parameters po = tx.validateVS(p);