fix for renderer on ElementDefinition rendering - follow contentReference

This commit is contained in:
Grahame Grieve 2020-12-09 10:08:01 +11:00
parent d432cff826
commit 752918a80a

View File

@ -6,8 +6,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.conformance.ProfileUtilities.ElementDefinitionResolution;
import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.XmlParser; import org.hl7.fhir.r5.elementmodel.XmlParser;
import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.IParser.OutputStyle;
@ -83,7 +85,15 @@ public class ElementWrappers {
element.getNamedChildrenWithWildcard(name, elements); element.getNamedChildrenWithWildcard(name, elements);
else else
element.getNamedChildren(name, elements); element.getNamedChildren(name, elements);
list.add(new PropertyWrapperMetaElement(context, structure, child, elements)); if (child.hasContentReference()) {
ElementDefinitionResolution nchild = context.getProfileUtilities().resolveContentRef(structure, child);
if (nchild == null) {
throw new DefinitionException("Unable to resolve content reference "+child.getContentReference());
}
list.add(new PropertyWrapperMetaElement(context, nchild.getSource(), nchild.getElement(), elements));
} else {
list.add(new PropertyWrapperMetaElement(context, structure, child, elements));
}
} }
} }
return list; return list;
@ -285,8 +295,9 @@ public class ElementWrappers {
public List<BaseWrapper> getValues() { public List<BaseWrapper> getValues() {
if (list == null) { if (list == null) {
list = new ArrayList<BaseWrapper>(); list = new ArrayList<BaseWrapper>();
for (Element e : values) for (Element e : values) {
list.add(new BaseWrapperMetaElement(context, e, e.fhirType(), structure, definition)); list.add(new BaseWrapperMetaElement(context, e, e.fhirType(), structure, definition));
}
} }
return list; return list;
} }