diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 3e1a0e387..3062c0734 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -75,6 +75,7 @@ import org.hl7.fhir.r5.model.NamingSystem; import org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType; import org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent; import org.hl7.fhir.r5.model.OperationDefinition; +import org.hl7.fhir.r5.model.OperationOutcome; import org.hl7.fhir.r5.model.Parameters; import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent; import org.hl7.fhir.r5.model.PlanDefinition; @@ -91,8 +92,10 @@ import org.hl7.fhir.r5.model.TerminologyCapabilities.TerminologyCapabilitiesCode import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleType; +import org.hl7.fhir.r5.model.Bundle.HTTPVerb; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent; +import org.hl7.fhir.r5.renderers.OperationOutcomeRenderer; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.TerminologyClient; import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple; @@ -751,6 +754,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte setTerminologyOptions(options, pIn); BundleEntryComponent be = batch.addEntry(); be.setResource(pIn); + be.getRequest().setMethod(HTTPVerb.POST); be.getRequest().setUrl("ValueSet/$validate-code"); be.setUserData("source", t); systems.add(t.getCoding().getSystem()); @@ -768,16 +772,19 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte for (int i = 0; i < batch.getEntry().size(); i++) { CodingValidationRequest t = (CodingValidationRequest) batch.getEntry().get(i).getUserData("source"); BundleEntryComponent r = resp.getEntry().get(i); - if (r.getResponse().getStatus().startsWith("2")) { - t.setResult(new ValidationResult(IssueSeverity.ERROR, getResponseText(r.getResource())).setTxLink(txLog == null ? null : txLog.getLastId())); - } else { + if (r.getResource() instanceof Parameters) { t.setResult(processValidationResult((Parameters) r.getResource())); + } else { + t.setResult(new ValidationResult(IssueSeverity.ERROR, getResponseText(r.getResource())).setTxLink(txLog == null ? null : txLog.getLastId())); } } } } private String getResponseText(Resource resource) { + if (resource instanceof OperationOutcome) { + return OperationOutcomeRenderer.toString((OperationOutcome) resource); + } return "Todo"; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationOutcomeRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationOutcomeRenderer.java index d67c8f8f4..6139cbb97 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationOutcomeRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationOutcomeRenderer.java @@ -16,6 +16,7 @@ import org.hl7.fhir.r5.model.StringType; import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext; import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.xhtml.XhtmlNode; public class OperationOutcomeRenderer extends ResourceRenderer { @@ -89,4 +90,11 @@ public class OperationOutcomeRenderer extends ResourceRenderer { return display((OperationOutcome) r); } + public static String toString(OperationOutcome oo) { + CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); + for (OperationOutcomeIssueComponent issue : oo.getIssue()) { + b.append(issue.getSeverity().toCode()+": "+issue.getDetails().getText()); + } + return b.toString(); + } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java index 0411ff817..56698605c 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java @@ -513,7 +513,6 @@ public class FHIRToolingClient { } @SuppressWarnings("unchecked") - public OperationOutcome validate(Class resourceClass, T resource, String id) { ResourceRequest result = null; try { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java index 4f143c22d..e1bd5dece 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTestSuite.java @@ -98,7 +98,8 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour private String version; private String name; - private static final String DEF_TX = "http://tx.fhir.org"; + private static final String DEF_TX = "http://tx.fhir.org"; +// private static final String DEF_TX = "http://local.fhir.org:960"; private static Map ve = new HashMap<>(); private static ValidationEngine vCurr;