Fix issue with unknown element rendering fixed value for Attachment

This commit is contained in:
Grahame Grieve 2024-05-10 08:09:03 +10:00
parent ba3dc45863
commit e57ef59ee9
1 changed files with 113 additions and 101 deletions

View File

@ -2237,8 +2237,9 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(value.fhirType());
for (org.hl7.fhir.r5.model.Property t : value.children()) {
ElementDefinition ed = findElementDefinitionOrNull(sd, t.getName());
if (ed != null) { // might be null because of added properties across versions
if (t.getValues().size() > 0 || snapshot) {
ElementDefinition ed = findElementDefinition(sd, t.getName());
if (t.getValues().size() == 0 || (t.getValues().size() == 1 && t.getValues().get(0).isEmpty())) {
if (!skipnoValue) {
Row row = gen.new Row();
@ -2349,6 +2350,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
}
}
}
}
private ElementDefinition findElementDefinition(StructureDefinition sd, String name) {
@ -2361,6 +2363,16 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
}
private ElementDefinition findElementDefinitionOrNull(StructureDefinition sd, String name) {
String path = sd.getTypeName()+"."+name;
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().equals(path))
return ed;
}
return null;
}
private String getFixedUrl(StructureDefinition sd) {
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().equals("Extension.url")) {