From 09c2c8f81bbcef5186df5fa71eafddfbd2c0513f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 15 Dec 2023 04:21:50 -0500 Subject: [PATCH] Improve handling of terminology error and warning messages + handling of example and fragment code systems --- .../fhir/r5/context/BaseWorkerContext.java | 3 ++- .../validation/ValueSetValidator.java | 19 ++++++++++++++++++- .../src/main/resources/Messages.properties | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) 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 b4bb3762c..7f02237e8 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 @@ -1348,7 +1348,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } else if (!res.isOk() && res.getUnknownSystems() != null && res.getUnknownSystems().contains(codeKey) && localWarning != null) { // we had some problem evaluating locally, but the server doesn't know the code system, so we'll just go with the local error res.setMessage(localWarning); - res.setDiagnostics("Local Error: "+localWarning.trim()+". Server Error: "+res.getMessage()); + res.setSeverity(IssueSeverity.WARNING); + res.setDiagnostics("Local Warning: "+localWarning.trim()+". Server Error: "+res.getMessage()); } updateUnsupportedCodeSystems(res, code, codeKey); if (cachingAllowed && txCache != null) { // we never cache unsupported code systems - we always keep trying (but only once per run) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/validation/ValueSetValidator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/validation/ValueSetValidator.java index 7159c8d72..6c0842bb4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/validation/ValueSetValidator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/validation/ValueSetValidator.java @@ -448,7 +448,24 @@ public class ValueSetValidator extends ValueSetProcessBase { return new ValidationResult(IssueSeverity.ERROR, msg, makeIssue(IssueSeverity.ERROR, IssueType.NOTFOUND, path, msg)); } if (cs!=null && cs.getContent() != CodeSystemContentMode.COMPLETE) { - warningMessage = "Resolved system "+system+(cs.hasVersion() ? " (v"+cs.getVersion()+")" : "")+", but the definition is not complete"; + warningMessage = "Resolved system "+system+(cs.hasVersion() ? " (v"+cs.getVersion()+")" : "")+", but the definition "; + switch (cs.getContent()) { + case EXAMPLE: + warningMessage = warningMessage +"only has example content"; + break; + case FRAGMENT: + warningMessage = warningMessage + "is only a fragment"; + break; + case NOTPRESENT: + warningMessage = warningMessage + "doesn't include any codes"; + break; + case SUPPLEMENT: + warningMessage = warningMessage + " is for a supplement to "+cs.getSupplements(); + break; + default: + break; + } + warningMessage = warningMessage + ", so the code has not been validated"; if (!inExpansion && cs.getContent() != CodeSystemContentMode.FRAGMENT) { // we're going to give it a go if it's a fragment throw new VSCheckerException(warningMessage, null, true); } diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index d4dd6e758..1c4899cf8 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -140,7 +140,7 @@ Resource_RES_ID_Malformed_Length = Invalid Resource id: Too long ({0} chars) Resource_RES_ID_Malformed_Chars = Invalid Resource id: Invalid Characters (''{0}'') Resource_RES_ID_Missing = Resource requires an id, but none is present Resource_RES_ID_Prohibited = Resource has an id, but none is allowed -Terminology_PassThrough_TX_Message = {0} for ''{1}#{2}'' +Terminology_PassThrough_TX_Message = {0} (for ''{1}#{2}'') Terminology_TX_Binding_CantCheck = Binding by URI reference cannot be checked Terminology_TX_Binding_Missing = Binding for CodeableConcept {0} missing Terminology_TX_Binding_Missing2 = Binding for Coding {0} missing