From 9ba4e00254a77780b66d57faaf706fd86748957b Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 26 Jul 2022 06:09:00 +1000 Subject: [PATCH] fix evaluation of ValueSets that have only one value set import --- .../terminologies/ValueSetCheckerSimple.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java index 3472559a6..ec314cc15 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java @@ -676,23 +676,29 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe } private Boolean inComponent(ConceptSetComponent vsi, int vsiIndex, String system, String code, boolean only, List warnings) throws FHIRException { - if (isValueSetUnionImports()) { - for (UriType uri : vsi.getValueSet()) { - if (inImport(uri.getValue(), system, code)) { - return true; + boolean ok = true; + + if (vsi.hasValueSet()) { + if (isValueSetUnionImports()) { + ok = false; + for (UriType uri : vsi.getValueSet()) { + if (inImport(uri.getValue(), system, code)) { + return true; + } } - } - } else { - for (UriType uri : vsi.getValueSet()) { - if (!inImport(uri.getValue(), system, code)) { - return false; + } else { + ok = inImport(vsi.getValueSet().get(0).getValue(), system, code); + for (int i = 1; i < vsi.getValueSet().size(); i++) { + UriType uri = vsi.getValueSet().get(i); + ok = ok && inImport(uri.getValue(), system, code); } } } - if (!vsi.hasSystem()) { - return false; + if (!vsi.hasSystem() || !ok) { + return ok; } + if (only && system == null) { // whether we know the system or not, we'll accept the stated codes at face value for (ConceptReferenceComponent cc : vsi.getConcept()) { @@ -726,18 +732,16 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe return res.isOk(); } else { if (vsi.hasFilter()) { - boolean ok = true; + ok = true; for (ConceptSetFilterComponent f : vsi.getFilter()) { if (!codeInFilter(cs, system, f, code)) { - ok = false; - break; + return false; } } - return ok; } List list = cs.getConcept(); - boolean ok = validateCodeInConceptList(code, cs, list); + ok = validateCodeInConceptList(code, cs, list); if (ok && vsi.hasConcept()) { for (ConceptReferenceComponent cc : vsi.getConcept()) { if (cc.getCode().equals(code)) {