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;
if (isSource(vs, cm.getSourceScope())) {
ConceptMapRenderInstructions re = findByTarget(cm.getTargetScope());
if (re == null) {
re = new ConceptMapRenderInstructions(cm.present(), cm.getUrl(), false);
}
if (re != 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));
@ -346,12 +349,14 @@ public class ValueSetRenderer extends TerminologyRenderer {
return null;
}
String src = source.primitiveValue();
if (src != null)
for (ConceptMapRenderInstructions t : renderingMaps) {
if (src.equals(t.getUrl()))
return t;
}
return null;
if (src == null) {
return null;
}
for (ConceptMapRenderInstructions t : renderingMaps) {
if (src.equals(t.getUrl()))
return t;
}
return null;
}

View File

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