mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-03-03 09:59:10 +00:00
variable renaming
This commit is contained in:
parent
69491f1996
commit
890776604d
@ -75,11 +75,11 @@ public class TxServiceTestHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDiffForValidation(IWorkerContext context, String name, Resource req, String resp, String lang, String fp, JsonObject ext, boolean isCS) throws JsonSyntaxException, FileNotFoundException, IOException {
|
public static String getDiffForValidation(IWorkerContext context, String name, Resource requestParameters, String expectedResponse, String lang, String fp, JsonObject externals, boolean isCodeSystem) throws JsonSyntaxException, FileNotFoundException, IOException {
|
||||||
org.hl7.fhir.r5.model.Parameters p = (org.hl7.fhir.r5.model.Parameters) req;
|
org.hl7.fhir.r5.model.Parameters p = (org.hl7.fhir.r5.model.Parameters) requestParameters;
|
||||||
ValueSet vs = null;
|
ValueSet vs = null;
|
||||||
String vsurl = null;
|
String vsurl = null;
|
||||||
if (!isCS) {
|
if (!isCodeSystem) {
|
||||||
if (p.hasParameter("valueSetVersion")) {
|
if (p.hasParameter("valueSetVersion")) {
|
||||||
vsurl = p.getParameterValue("url").primitiveValue()+"|"+p.getParameterValue("valueSetVersion").primitiveValue();
|
vsurl = p.getParameterValue("url").primitiveValue()+"|"+p.getParameterValue("valueSetVersion").primitiveValue();
|
||||||
vs = context.fetchResource(ValueSet.class, p.getParameterValue("url").primitiveValue(), p.getParameterValue("valueSetVersion").primitiveValue());
|
vs = context.fetchResource(ValueSet.class, p.getParameterValue("url").primitiveValue(), p.getParameterValue("valueSetVersion").primitiveValue());
|
||||||
@ -88,21 +88,21 @@ public class TxServiceTestHelper {
|
|||||||
vs = context.fetchResource(ValueSet.class, p.getParameterValue("url").primitiveValue());
|
vs = context.fetchResource(ValueSet.class, p.getParameterValue("url").primitiveValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ValidationResult vm = null;
|
ValidationResult validationResult = null;
|
||||||
String code = null;
|
String code = null;
|
||||||
String system = null;
|
String system = null;
|
||||||
String version = null;
|
String version = null;
|
||||||
String display = null;
|
String display = null;
|
||||||
CodeableConcept cc = null;
|
CodeableConcept cc = null;
|
||||||
org.hl7.fhir.r5.model.Parameters res = null;
|
org.hl7.fhir.r5.model.Parameters res = null;
|
||||||
OperationOutcome oo = null;
|
OperationOutcome operationOutcome = null;
|
||||||
|
|
||||||
if (vs == null && vsurl != null) {
|
if (vs == null && vsurl != null) {
|
||||||
String msg = context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_VALUE_SET_, vsurl);
|
String msg = context.formatMessage(I18nConstants.UNABLE_TO_RESOLVE_VALUE_SET_, vsurl);
|
||||||
oo = new OperationOutcome();
|
operationOutcome = new OperationOutcome();
|
||||||
CodeableConcept cct = oo.addIssue().setSeverity(OperationOutcome.IssueSeverity.ERROR).setCode(OperationOutcome.IssueType.NOTFOUND).getDetails();
|
CodeableConcept codeableConcept = operationOutcome.addIssue().setSeverity(OperationOutcome.IssueSeverity.ERROR).setCode(OperationOutcome.IssueType.NOTFOUND).getDetails();
|
||||||
cct.addCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "not-found", null);
|
codeableConcept.addCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "not-found", null);
|
||||||
cct.setText(msg);
|
codeableConcept.setText(msg);
|
||||||
} else {
|
} else {
|
||||||
ValidationOptions options = new ValidationOptions(FhirPublication.R5);
|
ValidationOptions options = new ValidationOptions(FhirPublication.R5);
|
||||||
if (p.hasParameter("displayLanguage")) {
|
if (p.hasParameter("displayLanguage")) {
|
||||||
@ -127,11 +127,11 @@ public class TxServiceTestHelper {
|
|||||||
}
|
}
|
||||||
if (p.hasParameter("code")) {
|
if (p.hasParameter("code")) {
|
||||||
code = p.getParameterString("code");
|
code = p.getParameterString("code");
|
||||||
system = p.getParameterString(isCS ? "url" : "system");
|
system = p.getParameterString(isCodeSystem ? "url" : "system");
|
||||||
version = p.getParameterString(isCS ? "version" : "systemVersion");
|
version = p.getParameterString(isCodeSystem ? "version" : "systemVersion");
|
||||||
display = p.getParameterString("display");
|
display = p.getParameterString("display");
|
||||||
vm = context.validateCode(options.withGuessSystem(),
|
validationResult = context.validateCode(options.withGuessSystem(),
|
||||||
p.getParameterString(isCS ? "url" : "system"), p.getParameterString(isCS ? "version" : "systemVersion"),
|
p.getParameterString(isCodeSystem ? "url" : "system"), p.getParameterString(isCodeSystem ? "version" : "systemVersion"),
|
||||||
p.getParameterString("code"), p.getParameterString("display"), vs);
|
p.getParameterString("code"), p.getParameterString("display"), vs);
|
||||||
} else if (p.hasParameter("coding")) {
|
} else if (p.hasParameter("coding")) {
|
||||||
Coding coding = (Coding) p.getParameterValue("coding");
|
Coding coding = (Coding) p.getParameterValue("coding");
|
||||||
@ -139,63 +139,63 @@ public class TxServiceTestHelper {
|
|||||||
system = coding.getSystem();
|
system = coding.getSystem();
|
||||||
version = coding.getVersion();
|
version = coding.getVersion();
|
||||||
display = coding.getDisplay();
|
display = coding.getDisplay();
|
||||||
vm = context.validateCode(options, coding, vs);
|
validationResult = context.validateCode(options, coding, vs);
|
||||||
} else if (p.hasParameter("codeableConcept")) {
|
} else if (p.hasParameter("codeableConcept")) {
|
||||||
cc = (CodeableConcept) p.getParameterValue("codeableConcept");
|
cc = (CodeableConcept) p.getParameterValue("codeableConcept");
|
||||||
vm = context.validateCode(options, cc, vs);
|
validationResult = context.validateCode(options, cc, vs);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("validate not done yet for this steup");
|
throw new Error("validate not done yet for this steup");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oo == null && vm != null && vm.getSeverity() == org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity.FATAL) {
|
if (operationOutcome == null && validationResult != null && validationResult.getSeverity() == org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity.FATAL) {
|
||||||
oo = new OperationOutcome();
|
operationOutcome = new OperationOutcome();
|
||||||
oo.getIssue().addAll(vm.getIssues());
|
operationOutcome.getIssue().addAll(validationResult.getIssues());
|
||||||
}
|
}
|
||||||
if (oo != null) {
|
if (operationOutcome != null) {
|
||||||
TxTesterSorters.sortOperationOutcome(oo);
|
TxTesterSorters.sortOperationOutcome(operationOutcome);
|
||||||
TxTesterScrubbers.scrubOO(oo, false);
|
TxTesterScrubbers.scrubOO(operationOutcome, false);
|
||||||
|
|
||||||
String pj = new JsonParser().setOutputStyle(IParser.OutputStyle.PRETTY).composeString(oo);
|
String actualResponse = new JsonParser().setOutputStyle(IParser.OutputStyle.PRETTY).composeString(operationOutcome);
|
||||||
String diff = CompareUtilities.checkJsonSrcIsSame(resp, pj, ext);
|
String diff = CompareUtilities.checkJsonSrcIsSame(expectedResponse, actualResponse, externals);
|
||||||
if (diff != null) {
|
if (diff != null) {
|
||||||
Utilities.createDirectory(Utilities.getDirectoryForFile(fp));
|
Utilities.createDirectory(Utilities.getDirectoryForFile(fp));
|
||||||
TextFile.stringToFile(pj, fp);
|
TextFile.stringToFile(actualResponse, fp);
|
||||||
System.out.println("Test "+name+"failed: "+diff);
|
System.out.println("Test "+name+"failed: "+diff);
|
||||||
}
|
}
|
||||||
return diff;
|
return diff;
|
||||||
} else {
|
} else {
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
res = new org.hl7.fhir.r5.model.Parameters();
|
res = new org.hl7.fhir.r5.model.Parameters();
|
||||||
if (vm.getSystem() != null) {
|
if (validationResult.getSystem() != null) {
|
||||||
res.addParameter("system", new UriType(vm.getSystem()));
|
res.addParameter("system", new UriType(validationResult.getSystem()));
|
||||||
} else if (system != null) {
|
} else if (system != null) {
|
||||||
res.addParameter("system", new UriType(system));
|
res.addParameter("system", new UriType(system));
|
||||||
}
|
}
|
||||||
if (vm.getCode() != null) {
|
if (validationResult.getCode() != null) {
|
||||||
if (code != null && !code.equals(vm.getCode())) {
|
if (code != null && !code.equals(validationResult.getCode())) {
|
||||||
res.addParameter("code", new CodeType(code));
|
res.addParameter("code", new CodeType(code));
|
||||||
res.addParameter("normalized-code", new CodeType(vm.getCode()));
|
res.addParameter("normalized-code", new CodeType(validationResult.getCode()));
|
||||||
} else {
|
} else {
|
||||||
res.addParameter("code", new CodeType(vm.getCode()));
|
res.addParameter("code", new CodeType(validationResult.getCode()));
|
||||||
}
|
}
|
||||||
} else if (code != null) {
|
} else if (code != null) {
|
||||||
res.addParameter("code", new CodeType(code));
|
res.addParameter("code", new CodeType(code));
|
||||||
}
|
}
|
||||||
if (vm.getSeverity() == org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity.ERROR) {
|
if (validationResult.getSeverity() == org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity.ERROR) {
|
||||||
res.addParameter("result", false);
|
res.addParameter("result", false);
|
||||||
} else {
|
} else {
|
||||||
res.addParameter("result", true);
|
res.addParameter("result", true);
|
||||||
}
|
}
|
||||||
if (vm.getMessage() != null) {
|
if (validationResult.getMessage() != null) {
|
||||||
res.addParameter("message", vm.getMessage());
|
res.addParameter("message", validationResult.getMessage());
|
||||||
}
|
}
|
||||||
if (vm.getVersion() != null) {
|
if (validationResult.getVersion() != null) {
|
||||||
res.addParameter("version", vm.getVersion());
|
res.addParameter("version", validationResult.getVersion());
|
||||||
} else if (version != null) {
|
} else if (version != null) {
|
||||||
res.addParameter("version", new StringType(version));
|
res.addParameter("version", new StringType(version));
|
||||||
}
|
}
|
||||||
if (vm.getDisplay() != null) {
|
if (validationResult.getDisplay() != null) {
|
||||||
res.addParameter("display", vm.getDisplay());
|
res.addParameter("display", validationResult.getDisplay());
|
||||||
} else if (display != null) {
|
} else if (display != null) {
|
||||||
res.addParameter("display", new StringType(display));
|
res.addParameter("display", new StringType(display));
|
||||||
}
|
}
|
||||||
@ -205,32 +205,32 @@ public class TxServiceTestHelper {
|
|||||||
if (cc != null) {
|
if (cc != null) {
|
||||||
res.addParameter("codeableConcept", cc);
|
res.addParameter("codeableConcept", cc);
|
||||||
}
|
}
|
||||||
if (vm.isInactive()) {
|
if (validationResult.isInactive()) {
|
||||||
res.addParameter("inactive", true);
|
res.addParameter("inactive", true);
|
||||||
}
|
}
|
||||||
if (vm.getStatus() != null) {
|
if (validationResult.getStatus() != null) {
|
||||||
res.addParameter("status", vm.getStatus());
|
res.addParameter("status", validationResult.getStatus());
|
||||||
}
|
}
|
||||||
if (vm.getUnknownSystems() != null) {
|
if (validationResult.getUnknownSystems() != null) {
|
||||||
for (String s : vm.getUnknownSystems()) {
|
for (String s : validationResult.getUnknownSystems()) {
|
||||||
res.addParameter(vm.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED ? "x-caused-by-unknown-system" : "x-unknown-system", new CanonicalType(s));
|
res.addParameter(validationResult.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED ? "x-caused-by-unknown-system" : "x-unknown-system", new CanonicalType(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vm.getIssues().size() > 0) {
|
if (validationResult.getIssues().size() > 0) {
|
||||||
oo = new OperationOutcome();
|
operationOutcome = new OperationOutcome();
|
||||||
oo.getIssue().addAll(vm.getIssues());
|
operationOutcome.getIssue().addAll(validationResult.getIssues());
|
||||||
res.addParameter().setName("issues").setResource(oo);
|
res.addParameter().setName("issues").setResource(operationOutcome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TxTesterSorters.sortParameters(res);
|
TxTesterSorters.sortParameters(res);
|
||||||
TxTesterScrubbers.scrubParams(res);
|
TxTesterScrubbers.scrubParams(res);
|
||||||
|
|
||||||
String pj = new JsonParser().setOutputStyle(IParser.OutputStyle.PRETTY).composeString(res);
|
String actualResponse = new JsonParser().setOutputStyle(IParser.OutputStyle.PRETTY).composeString(res);
|
||||||
String diff = CompareUtilities.checkJsonSrcIsSame(resp, pj, ext);
|
String diff = CompareUtilities.checkJsonSrcIsSame(expectedResponse, actualResponse, externals);
|
||||||
if (diff != null) {
|
if (diff != null) {
|
||||||
Utilities.createDirectory(Utilities.getDirectoryForFile(fp));
|
Utilities.createDirectory(Utilities.getDirectoryForFile(fp));
|
||||||
TextFile.stringToFile(pj, fp);
|
TextFile.stringToFile(actualResponse, fp);
|
||||||
System.out.println("Test "+name+"failed: "+diff);
|
System.out.println("Test "+name+"failed: "+diff);
|
||||||
}
|
}
|
||||||
return diff;
|
return diff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user