use of org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method serverValidateCode.
private ValidationResult serverValidateCode(Parameters pin, boolean doCache) throws Exception {
if (noTerminologyServer) {
return new ValidationResult(null, null, TerminologyServiceErrorClass.NOSERVICE);
}
String cacheName = doCache ? generateCacheName(pin) : null;
ValidationResult res = loadFromCache(cacheName);
if (res != null) {
return res;
}
tlog("Terminology Server: $validate-code " + describeValidationParameters(pin));
for (ParametersParameterComponent pp : pin.getParameter()) {
if (pp.getName().equals("profile")) {
throw new Error("Can only specify profile in the context");
}
}
if (expProfile == null) {
throw new Exception("No ExpansionProfile provided");
}
pin.addParameter().setName("profile").setResource(expProfile);
Parameters pout = txServer.operateType(ValueSet.class, "validate-code", pin);
boolean ok = false;
String message = "No Message returned";
String display = null;
TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN;
for (ParametersParameterComponent p : pout.getParameter()) {
if (p.getName().equals("result")) {
ok = ((BooleanType) p.getValue()).getValue().booleanValue();
} else if (p.getName().equals("message")) {
message = ((StringType) p.getValue()).getValue();
} else if (p.getName().equals("display")) {
display = ((StringType) p.getValue()).getValue();
} else if (p.getName().equals("cause")) {
try {
IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
if (it == IssueType.UNKNOWN) {
err = TerminologyServiceErrorClass.UNKNOWN;
} else if (it == IssueType.NOTSUPPORTED) {
err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
}
} catch (FHIRException e) {
}
}
}
if (!ok) {
res = new ValidationResult(IssueSeverity.ERROR, message, err);
} else if (display != null) {
res = new ValidationResult(new ConceptDefinitionComponent().setDisplay(display));
} else {
res = new ValidationResult(new ConceptDefinitionComponent());
}
saveToCache(res, cacheName);
return res;
}
Aggregations