improve rendering of multiple filters on value set

This commit is contained in:
Grahame Grieve 2019-09-02 07:18:59 +10:00
parent c7499882a0
commit d63a8f7be3
1 changed files with 38 additions and 26 deletions

View File

@ -3747,34 +3747,46 @@ public class NarrativeGenerator implements INarrativeGenerator {
} }
} }
} }
boolean first = true; li.addText(type+" codes from ");
for (ConceptSetFilterComponent f : inc.getFilter()) { addCsRef(inc, li, e);
if (first) { li.tx(" where ");
li.addText(type+" codes from "); for (int i = 0; i < inc.getFilter().size(); i++) {
first = false; ConceptSetFilterComponent f = inc.getFilter().get(i);
} else if (i > 0) {
li.tx(" and "); if (i == inc.getFilter().size()-1) {
addCsRef(inc, li, e); li.tx(" and ");
li.tx(" where "+f.getProperty()+" "+describe(f.getOp())+" "); } else {
if (e != null && codeExistsInValueSet(e, f.getValue())) { li.tx(", ");
String href = prefix+getCsRef(e);
if (href.contains("#"))
href = href + "-"+Utilities.nmtokenize(f.getValue());
else
href = href + "#"+e.getId()+"-"+Utilities.nmtokenize(f.getValue());
li.ah(href).addText(f.getValue());
} else if ("concept".equals(f.getProperty()) && inc.hasSystem()) {
li.addText(f.getValue());
ValidationResult vr = context.validateCode(terminologyServiceOptions, inc.getSystem(), f.getValue(), null);
if (vr.isOk()) {
li.tx(" ("+vr.getDisplay()+")");
} }
} }
else if (f.getOp() == FilterOperator.EXISTS) {
li.addText(f.getValue()); if (f.getValue().equals("true")) {
String disp = ToolingExtensions.getDisplayHint(f); li.tx(f.getProperty()+" exists");
if (disp != null) } else {
li.tx(" ("+disp+")"); li.tx(f.getProperty()+" doesn't exist");
}
} else {
li.tx(f.getProperty()+" "+describe(f.getOp())+" ");
if (e != null && codeExistsInValueSet(e, f.getValue())) {
String href = prefix+getCsRef(e);
if (href.contains("#"))
href = href + "-"+Utilities.nmtokenize(f.getValue());
else
href = href + "#"+e.getId()+"-"+Utilities.nmtokenize(f.getValue());
li.ah(href).addText(f.getValue());
} else if ("concept".equals(f.getProperty()) && inc.hasSystem()) {
li.addText(f.getValue());
ValidationResult vr = context.validateCode(terminologyServiceOptions, inc.getSystem(), f.getValue(), null);
if (vr.isOk()) {
li.tx(" ("+vr.getDisplay()+")");
}
}
else
li.addText(f.getValue());
String disp = ToolingExtensions.getDisplayHint(f);
if (disp != null)
li.tx(" ("+disp+")");
}
} }
} }
if (inc.hasValueSet()) { if (inc.hasValueSet()) {