Search in sources :

Example 1 with RuntimeCompositeDatatypeDefinition

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);
}
Also used : BaseRuntimeElementDefinition(ca.uhn.fhir.context.BaseRuntimeElementDefinition) RuntimeCompositeDatatypeDefinition(ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition)

Example 2 with RuntimeCompositeDatatypeDefinition

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);
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) RuntimeChildChoiceDefinition(ca.uhn.fhir.context.RuntimeChildChoiceDefinition) Set(java.util.Set) Test(org.junit.Test) Collectors(java.util.stream.Collectors) FhirContext(ca.uhn.fhir.context.FhirContext) RuntimeCompositeDatatypeDefinition(ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition) List(java.util.List) FhirEncoders(au.csiro.pathling.encoders.FhirEncoders) ElementCtx(au.csiro.pathling.schema.ElementCtx) JavaConverters(scala.collection.JavaConverters) RuntimeChildExtension(ca.uhn.fhir.context.RuntimeChildExtension) Assert.assertEquals(org.junit.Assert.assertEquals) RuntimeChildChoiceDefinition(ca.uhn.fhir.context.RuntimeChildChoiceDefinition) RuntimeChildExtension(ca.uhn.fhir.context.RuntimeChildExtension) RuntimeCompositeDatatypeDefinition(ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition) Test(org.junit.Test)

Aggregations

RuntimeCompositeDatatypeDefinition (ca.uhn.fhir.context.RuntimeCompositeDatatypeDefinition)2 FhirEncoders (au.csiro.pathling.encoders.FhirEncoders)1 ElementCtx (au.csiro.pathling.schema.ElementCtx)1 BaseRuntimeElementDefinition (ca.uhn.fhir.context.BaseRuntimeElementDefinition)1 FhirContext (ca.uhn.fhir.context.FhirContext)1 RuntimeChildChoiceDefinition (ca.uhn.fhir.context.RuntimeChildChoiceDefinition)1 RuntimeChildExtension (ca.uhn.fhir.context.RuntimeChildExtension)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang.StringUtils)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Test (org.junit.Test)1 JavaConverters (scala.collection.JavaConverters)1