fix problem with abstract codes not appearing in value set expansions

This commit is contained in:
Grahame Grieve 2020-04-23 17:29:59 +10:00
parent d94b39121f
commit 8d3a0cf18e
1 changed files with 4 additions and 2 deletions

View File

@ -101,6 +101,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander {
private Map<String, ValueSetExpansionContainsComponent> map = new HashMap<String, ValueSet.ValueSetExpansionContainsComponent>(); private Map<String, ValueSetExpansionContainsComponent> map = new HashMap<String, ValueSet.ValueSetExpansionContainsComponent>();
private IWorkerContext context; private IWorkerContext context;
private boolean canBeHeirarchy = true; private boolean canBeHeirarchy = true;
private boolean includeAbstract = true;
private Set<String> excludeKeys = new HashSet<String>(); private Set<String> excludeKeys = new HashSet<String>();
private Set<String> excludeSystems = new HashSet<String>(); private Set<String> excludeSystems = new HashSet<String>();
private ValueSet focus; private ValueSet focus;
@ -213,7 +214,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander {
ValueSetExpansionContainsComponent np = null; ValueSetExpansionContainsComponent np = null;
boolean abs = CodeSystemUtilities.isNotSelectable(cs, def); boolean abs = CodeSystemUtilities.isNotSelectable(cs, def);
boolean inc = CodeSystemUtilities.isInactive(cs, def); boolean inc = CodeSystemUtilities.isInactive(cs, def);
if (canBeHeirarchy || !abs) if (includeAbstract || !abs)
np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters); np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters);
for (ConceptDefinitionComponent c : def.getConcept()) { for (ConceptDefinitionComponent c : def.getConcept()) {
addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion); addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion);
@ -340,7 +341,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander {
} }
} else { } else {
for (ValueSetExpansionContainsComponent c : codes) { for (ValueSetExpansionContainsComponent c : codes) {
if (map.containsKey(key(c)) && !c.getAbstract()) { // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them if (map.containsKey(key(c)) && (includeAbstract || !c.getAbstract())) { // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them
focus.getExpansion().getContains().add(c); focus.getExpansion().getContains().add(c);
c.getContains().clear(); // make sure any heirarchy is wiped c.getContains().clear(); // make sure any heirarchy is wiped
} }
@ -379,6 +380,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander {
for (ConceptSetComponent inc : compose.getExclude()) for (ConceptSetComponent inc : compose.getExclude())
excludeCodes(inc, exp.getParameter(), ctxt); excludeCodes(inc, exp.getParameter(), ctxt);
canBeHeirarchy = !expParams.getParameterBool("excludeNested") && excludeKeys.isEmpty() && excludeSystems.isEmpty(); canBeHeirarchy = !expParams.getParameterBool("excludeNested") && excludeKeys.isEmpty() && excludeSystems.isEmpty();
includeAbstract = !expParams.getParameterBool("excludeNotForUI");
boolean first = true; boolean first = true;
for (ConceptSetComponent inc : compose.getInclude()) { for (ConceptSetComponent inc : compose.getInclude()) {
if (first == true) if (first == true)