From f9ed8dc3485ff8d78eb79cddd2baadfa19583da9 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sun, 28 Jul 2024 20:03:44 +0800 Subject: [PATCH] Add support for unknown code system version validating concept maps --- .../hl7/fhir/r5/context/BaseWorkerContext.java | 17 +++++++++++++++-- .../utilities/TerminologyServiceErrorClass.java | 2 +- .../instance/type/ConceptMapValidator.java | 2 ++ 3 files changed, 18 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 540c50261..f05f4ca3e 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 @@ -1885,8 +1885,15 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } else if (p.getName().equals("status")) { status = ((PrimitiveType) p.getValue()).asStringValue(); } else if (p.getName().equals("x-caused-by-unknown-system")) { - err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED; - unknownSystems.add(((PrimitiveType) p.getValue()).asStringValue()); + String unkSystem = ((PrimitiveType) p.getValue()).asStringValue(); + if (unkSystem != null && unkSystem.contains("|")) { + err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED_VERSION; + system = unkSystem.substring(0, unkSystem.indexOf("|")); + version = unkSystem.substring(unkSystem.indexOf("|")+1); + } else { + err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED; + unknownSystems.add(unkSystem); + } } else if (p.getName().equals("x-unknown-system")) { unknownSystems.add(((PrimitiveType) p.getValue()).asStringValue()); } else if (p.getName().equals("warning-withdrawn")) { @@ -1948,6 +1955,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte res.setDefinition(new ConceptDefinitionComponent().setDisplay(display).setCode(code)); res.setDisplay(display); } + if (system != null) { + res.setSystem(system); + } + if (version != null) { + res.setVersion(version); + } } else if (message != null && !message.equals("No Message returned")) { res = new ValidationResult(IssueSeverity.WARNING, message, system, version, new ConceptDefinitionComponent().setDisplay(display).setCode(code), display, null).setTxLink(txLog.getLastId()); } else if (display != null) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/TerminologyServiceErrorClass.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/TerminologyServiceErrorClass.java index d88fd4171..5aeb0fff5 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/TerminologyServiceErrorClass.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/TerminologyServiceErrorClass.java @@ -1,7 +1,7 @@ package org.hl7.fhir.r5.terminologies.utilities; public enum TerminologyServiceErrorClass { - UNKNOWN, NOSERVICE, SERVER_ERROR, VALUESET_UNSUPPORTED, CODESYSTEM_UNSUPPORTED, BLOCKED_BY_OPTIONS, INTERNAL_ERROR, BUSINESS_RULE, TOO_COSTLY, PROCESSING; + UNKNOWN, NOSERVICE, SERVER_ERROR, VALUESET_UNSUPPORTED, CODESYSTEM_UNSUPPORTED, CODESYSTEM_UNSUPPORTED_VERSION, BLOCKED_BY_OPTIONS, INTERNAL_ERROR, BUSINESS_RULE, TOO_COSTLY, PROCESSING; public boolean isInfrastructure() { return this == NOSERVICE || this == SERVER_ERROR || this == VALUESET_UNSUPPORTED; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ConceptMapValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ConceptMapValidator.java index 912cc98b3..0d6892c17 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ConceptMapValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ConceptMapValidator.java @@ -171,6 +171,8 @@ public class ConceptMapValidator extends BaseValidator { for (CMCodingValidationRequest cv : batch) { if (cv.getResult().getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED) { warning(errors, "2023-09-06", IssueType.BUSINESSRULE, cv.getStack(), cv.getResult().isOk(), I18nConstants.CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM, cv.getCoding().getSystem(), cv.getCoding().getCode(), cv.getVsObj().getUrl()); + } else if (cv.getResult().getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED_VERSION) { + warning(errors, "2023-09-06", IssueType.BUSINESSRULE, cv.getStack(), cv.getResult().isOk(), I18nConstants.CONCEPTMAP_VS_CONCEPT_CODE_UNKNOWN_SYSTEM_VERSION, cv.getCoding().getSystem(), cv.getCoding().getCode(), cv.getVsObj().getUrl(), cv.getResult().getVersion()); } else if (cv.getCoding().getVersion() == null) { ok = rule(errors, "2023-09-06", IssueType.BUSINESSRULE, cv.getStack(), cv.getResult().isOk(), I18nConstants.CONCEPTMAP_VS_INVALID_CONCEPT_CODE, cv.getCoding().getSystem(), cv.getCoding().getCode(), cv.getVsObj().getUrl()) && ok; } else {