use of org.hl7.fhir.dstu3.elementmodel.ObjectConverter in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method createExampleElement.
private org.hl7.fhir.r5.elementmodel.Element createExampleElement(StructureDefinition profile, ElementDefinition ed, ExampleValueAccessor accessor) throws FHIRException {
DataType v = accessor.getExampleValue(ed);
if (v != null) {
return new ObjectConverter(context).convert(new Property(context, ed, profile), v);
} else {
org.hl7.fhir.r5.elementmodel.Element res = new org.hl7.fhir.r5.elementmodel.Element(tail(ed.getPath()), new Property(context, ed, profile));
boolean hasValue = false;
List<ElementDefinition> children = getChildMap(profile, ed);
for (ElementDefinition child : children) {
if (!child.hasContentReference()) {
org.hl7.fhir.r5.elementmodel.Element e = createExampleElement(profile, child, accessor);
if (e != null) {
hasValue = true;
res.getChildren().add(e);
}
}
}
if (hasValue)
return res;
else
return null;
}
}
Aggregations