fix problem where profile rendering had spurious 'slices for' nodes everywhere

This commit is contained in:
Grahame Grieve 2024-09-03 21:27:28 +08:00
parent 7e5014c6d7
commit 63ab904401
2 changed files with 17 additions and 7 deletions

View File

@ -897,7 +897,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
Row parent = null;
if (child.hasSliceName()) {
// ok, we're a slice
if (slicer == null || !slicer.getId().equals(child.getPath())) {
if (slicer == null || !noTail(slicer.getId()).equals(child.getPath())) {
parent = gen.new Row();
String anchorE = child.getPath();
anchorE = makeAnchorUnique(anchorE);
@ -906,7 +906,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
parent.setColor(context.getProfileUtilities().getRowColor(child, isConstraintMode));
parent.setLineColor(1);
parent.setIcon("icon_slice.png", context.formatPhrase(RenderingContext.TEXT_ICON_SLICE));
parent.getCells().add(gen.new Cell(null, null, "Slices for "+ child.getName(), "", null));
parent.getCells().add(gen.new Cell(null, null, context.formatPhrase(RenderingContext.STRUC_DEF_SLICE_FOR, child.getName()), "", null));
switch (context.getStructureMode()) {
case BINDINGS:
case OBLIGATIONS:
@ -947,6 +947,16 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
return slicingRow;
}
private String noTail(String id) {
if (id.contains(".")) {
String t = id.substring(id.lastIndexOf(".")+1);
if (Utilities.isInteger(t)) {
return id.substring(0, id.lastIndexOf("."));
}
}
return id;
}
private String makeAnchorUnique(String anchor) {
if (anchors.containsKey(anchor)) {
int c = anchors.get(anchor)+1;

View File

@ -84,12 +84,12 @@ public class NarrativeGenerationTests {
@Override
public String getLinkFor(String corePath, String typeSimple) {
throw new NotImplementedException();
return "http://test/link";
}
@Override
public BindingResolution resolveBinding(StructureDefinition def, ElementDefinitionBindingComponent binding, String path) throws FHIRException {
throw new NotImplementedException();
return new BindingResolution("test", "http://test");
}
@Override
@ -102,7 +102,7 @@ public class NarrativeGenerationTests {
return new BindingResolution(vs.present(), "valueset-"+vs.getIdBase()+".html");
}
}
throw new NotImplementedException();
return new BindingResolution("test", "http://test/ns");
}
@Override
@ -120,7 +120,7 @@ public class NarrativeGenerationTests {
@Override
public String getLinkForUrl(String corePath, String s) {
throw new NotImplementedException();
return "http://test/link/url";
}
@Override