From c6edf285e32548328103af7599b51a93b0c2951a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 17 Jan 2025 06:41:00 +1100 Subject: [PATCH] Correctly handle supplements when validating based on expansions --- .../utilities/ValueSetProcessBase.java | 9 +++++++++ .../terminologies/validation/ValueSetValidator.java | 13 ++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/ValueSetProcessBase.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/ValueSetProcessBase.java index 6f4bca562..b31ef5492 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/ValueSetProcessBase.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/utilities/ValueSetProcessBase.java @@ -264,6 +264,15 @@ public class ValueSetProcessBase { } + public String removeSupplement(String s) { + requiredSupplements.remove(s); + if (s.contains("|")) { + s = s.substring(0, s.indexOf("|")); + requiredSupplements.remove(s); + } + return s; + } + protected AlternateCodesProcessingRules altCodeParams = new AlternateCodesProcessingRules(false); protected AlternateCodesProcessingRules allAltCodes = new AlternateCodesProcessingRules(true); } 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 9d87baafb..08e79173b 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 @@ -77,6 +77,7 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; +import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.client.TerminologyClientManager; import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome; @@ -518,17 +519,14 @@ public class ValueSetValidator extends ValueSetProcessBase { if (cs != null) { if (cs.hasUserData("supplements.installed")) { for (String s : cs.getUserString("supplements.installed").split("\\,")) { - requiredSupplements.remove(s); - if (s.contains("|")) { - s = s.substring(0, s.indexOf("|")); - requiredSupplements.remove(s); - } + s = removeSupplement(s); } } } return cs; } + public List resolveCodeSystemVersions(String system) { List res = new ArrayList<>(); for (CodeSystem t : localSystems) { @@ -696,6 +694,11 @@ public class ValueSetValidator extends ValueSetProcessBase { res = validateCode(path, code, cs, null, info); res.setIssues(issues); } else if (cs == null && valueset.hasExpansion() && inExpansion) { + for (ValueSetExpansionParameterComponent p : valueset.getExpansion().getParameter()) { + if ("used-supplement".equals(p.getName())) { + removeSupplement(p.getValue().primitiveValue()); + } + } // we just take the value set as face value then res = new ValidationResult(system, wv, new ConceptDefinitionComponent().setCode(code.getCode()).setDisplay(code.getDisplay()), code.getDisplay()); if (!preferServerSide(system)) {