Fix problem rendering ConceptMaps in value sets

This commit is contained in:
Grahame Grieve 2022-08-18 09:39:01 +10:00
parent 7c5782689a
commit cd820bdf3f
2 changed files with 39 additions and 11 deletions

View File

@ -108,6 +108,9 @@ public class ValueSetRenderer extends TerminologyRenderer {
ConceptMap cm = (ConceptMap) md; ConceptMap cm = (ConceptMap) md;
if (isSource(vs, cm.getSourceScope())) { if (isSource(vs, cm.getSourceScope())) {
ConceptMapRenderInstructions re = findByTarget(cm.getTargetScope()); ConceptMapRenderInstructions re = findByTarget(cm.getTargetScope());
if (re == null) {
re = new ConceptMapRenderInstructions(cm.present(), cm.getUrl(), false);
}
if (re != null) { if (re != null) {
ValueSet vst = cm.hasTargetScope() ? getContext().getWorker().fetchResource(ValueSet.class, cm.hasTargetScopeCanonicalType() ? cm.getTargetScopeCanonicalType().getValue() : cm.getTargetScopeUriType().asStringValue()) : null; ValueSet vst = cm.hasTargetScope() ? getContext().getWorker().fetchResource(ValueSet.class, cm.hasTargetScopeCanonicalType() ? cm.getTargetScopeCanonicalType().getValue() : cm.getTargetScopeUriType().asStringValue()) : null;
res.add(new UsedConceptMap(re, vst == null ? cm.getUserString("path") : vst.getUserString("path"), cm)); res.add(new UsedConceptMap(re, vst == null ? cm.getUserString("path") : vst.getUserString("path"), cm));
@ -346,12 +349,14 @@ public class ValueSetRenderer extends TerminologyRenderer {
return null; return null;
} }
String src = source.primitiveValue(); String src = source.primitiveValue();
if (src != null) if (src == null) {
for (ConceptMapRenderInstructions t : renderingMaps) { return null;
if (src.equals(t.getUrl())) }
return t; for (ConceptMapRenderInstructions t : renderingMaps) {
} if (src.equals(t.getUrl()))
return null; return t;
}
return null;
} }

View File

@ -44,23 +44,45 @@ public class CommaSeparatedStringBuilder {
String sep = ", "; String sep = ", ";
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
int count = 0; int count = 0;
String pending = null;
private String lastSep;
public CommaSeparatedStringBuilder() { public CommaSeparatedStringBuilder() {
this.sep = ", ";
this.lastSep = ", ";
} }
public CommaSeparatedStringBuilder(String sep) { public CommaSeparatedStringBuilder(String sep) {
this.sep = sep; this.sep = sep;
this.lastSep = sep;
} }
public CommaSeparatedStringBuilder(String sep, String lastSep) {
this.sep = sep;
this.lastSep = lastSep;
}
private void commit(boolean last) {
if (pending != null) {
if (!first) {
if (last) {
b.append(lastSep);
} else {
b.append(sep);
}
}
b.append(pending);
first = false;
}
}
public void append(String value) { public void append(String value) {
if (!first) commit(false);
b.append(sep); pending = value;
b.append(value);
first = false;
count++; count++;
} }
public int length() { public int length() {
commit(false);
return b.length(); return b.length();
} }
@ -70,6 +92,7 @@ public class CommaSeparatedStringBuilder {
@Override @Override
public String toString() { public String toString() {
commit(true);
return b.toString(); return b.toString();
} }
@ -81,7 +104,7 @@ public class CommaSeparatedStringBuilder {
public void addAll(List<String> list) { public void addAll(List<String> list) {
for (String s : list) { for (String s : list) {
append(s); appendIfNotNull(s);
} }
} }