From 3d1676170a3a3f1649c71b48df9ac063cb591067 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 27 Aug 2021 10:41:43 +1000 Subject: [PATCH] fixes for processing code validation outcomes --- .../main/java/org/hl7/fhir/r5/context/IWorkerContext.java | 8 +++++++- .../org/hl7/fhir/r5/terminologies/ValueSetExpander.java | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index e135c99a1..2d1c648af 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -626,7 +626,13 @@ public interface IWorkerContext { return message != null; } - + public Coding asCoding() { + if (isOk() && definition != null && definition.getCode() != null) { + return new Coding(system, definition.getCode(), definition.getDisplay()); + } else { + return null; + } + } } /** diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpander.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpander.java index 8b4f98c2f..5582c30b4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpander.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpander.java @@ -123,7 +123,10 @@ public interface ValueSetExpander { public List getAllErrors() { return allErrors; } - + + public boolean isOk() { + return (allErrors.isEmpty() || (allErrors.size() == 1 && allErrors.get(0) == null)) && error == null; + } } /** *