fix evaluation of ValueSets that have only one value set import

This commit is contained in:
Grahame Grieve 2022-07-26 06:09:00 +10:00
parent 3fc3109cbc
commit 9ba4e00254
1 changed files with 20 additions and 16 deletions

View File

@ -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<String> warnings) throws FHIRException { private Boolean inComponent(ConceptSetComponent vsi, int vsiIndex, String system, String code, boolean only, List<String> warnings) throws FHIRException {
if (isValueSetUnionImports()) { boolean ok = true;
for (UriType uri : vsi.getValueSet()) {
if (inImport(uri.getValue(), system, code)) { if (vsi.hasValueSet()) {
return true; if (isValueSetUnionImports()) {
ok = false;
for (UriType uri : vsi.getValueSet()) {
if (inImport(uri.getValue(), system, code)) {
return true;
}
} }
} } else {
} else { ok = inImport(vsi.getValueSet().get(0).getValue(), system, code);
for (UriType uri : vsi.getValueSet()) { for (int i = 1; i < vsi.getValueSet().size(); i++) {
if (!inImport(uri.getValue(), system, code)) { UriType uri = vsi.getValueSet().get(i);
return false; ok = ok && inImport(uri.getValue(), system, code);
} }
} }
} }
if (!vsi.hasSystem()) { if (!vsi.hasSystem() || !ok) {
return false; return ok;
} }
if (only && system == null) { if (only && system == null) {
// whether we know the system or not, we'll accept the stated codes at face value // whether we know the system or not, we'll accept the stated codes at face value
for (ConceptReferenceComponent cc : vsi.getConcept()) { for (ConceptReferenceComponent cc : vsi.getConcept()) {
@ -726,18 +732,16 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
return res.isOk(); return res.isOk();
} else { } else {
if (vsi.hasFilter()) { if (vsi.hasFilter()) {
boolean ok = true; ok = true;
for (ConceptSetFilterComponent f : vsi.getFilter()) { for (ConceptSetFilterComponent f : vsi.getFilter()) {
if (!codeInFilter(cs, system, f, code)) { if (!codeInFilter(cs, system, f, code)) {
ok = false; return false;
break;
} }
} }
return ok;
} }
List<ConceptDefinitionComponent> list = cs.getConcept(); List<ConceptDefinitionComponent> list = cs.getConcept();
boolean ok = validateCodeInConceptList(code, cs, list); ok = validateCodeInConceptList(code, cs, list);
if (ok && vsi.hasConcept()) { if (ok && vsi.hasConcept()) {
for (ConceptReferenceComponent cc : vsi.getConcept()) { for (ConceptReferenceComponent cc : vsi.getConcept()) {
if (cc.getCode().equals(code)) { if (cc.getCode().equals(code)) {