use of ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition in project bunsen by cerner.
the class LeafExtensionConverter method toHapiConverter.
@Override
public HapiFieldSetter toHapiConverter(BaseRuntimeElementDefinition... elementDefinitions) {
// Get the structure definition of the value.
String fieldName = "value" + valueConverter.getElementType();
RuntimeCompositeDatatypeDefinition definition = (RuntimeCompositeDatatypeDefinition) elementDefinitions[0];
BaseRuntimeElementDefinition valueDefinition = definition.getChildByName(fieldName).getChildByName(fieldName);
HapiObjectConverter sparkToHapi = (HapiObjectConverter) valueConverter.toHapiConverter(valueDefinition);
return new LeafExensionFieldSetter(definition, sparkToHapi);
}
use of ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition in project pathling by aehrc.
the class R4DatatypeMappingsTest method testCorrectChoicesOnOpenElementType.
@Test
public void testCorrectChoicesOnOpenElementType() {
ElementCtx<Object, Object> ex = ElementCtx.forExtension(fhirContext);
RuntimeChildExtension extension = (RuntimeChildExtension) ex.childDefinition();
RuntimeCompositeDatatypeDefinition extensionChild = (RuntimeCompositeDatatypeDefinition) extension.getChildByName("extension");
// This is how we can access the 'value' child od RuntimeChildExtension.
RuntimeChildChoiceDefinition openTypeElement = (RuntimeChildChoiceDefinition) extensionChild.getChildByName("value[x]");
final Set<String> actualOpenElementUniqueChildNames = JavaConverters.seqAsJavaList(dataTypeMappings.getValidChoiceTypes(openTypeElement)).stream().map(openTypeElement::getChildNameByDatatype).collect(Collectors.toUnmodifiableSet());
final Set<String> expectedOpenElementTypes = ALLOWED_R4_OPEN_ELEMENT_TYPES.stream().map(typeName -> "value" + StringUtils.capitalize(typeName)).collect(Collectors.toUnmodifiableSet());
assertEquals(expectedOpenElementTypes, actualOpenElementUniqueChildNames);
}
Aggregations