class R4VitalSignFhirToDhisTransformerUtils extends AbstractVitalSignFhirToDhisTransformerUtils {

    @Nullable
    @Override
    public Double getWeight( @Nullable ICompositeType value, @Nullable Object weightUnit, boolean round ) throws TransformerDataException
    {
        if ( value == null )
        {
            return null;
        }

        if ( weightUnit == null )
        {
            throw new TransformerMappingException( "Weight unit has not been specified." );
        }
        final WeightUnit resultingWeightUnit;
        try
        {
            resultingWeightUnit = NameUtils.toEnumValue( WeightUnit.class, weightUnit );
        }
        catch ( IllegalArgumentException e )
        {
            throw new TransformerMappingException( "Specified weight unit is invalid: " + weightUnit );
        }

        if ( !(value instanceof Quantity) )
        {
            throw new TransformerDataException( "Weight must be included as quantity, but element is " + value.getClass().getSimpleName() + "." );
        }
        final Quantity quantity = (Quantity) value;

        if ( !UNIT_SYSTEM.equals( quantity.getSystem() ) )
        {
            throw new TransformerDataException( UNIT_SYSTEM + " is expected as unit system: " + quantity.getSystem() );
        }
        final WeightUnit actualWeightUnit = WeightUnit.getByUcumCode( quantity.getCode() );
        if ( actualWeightUnit == null )
        {
            throw new TransformerDataException( "Unknown UCUM weight unit code: " + quantity.getCode() );
        }

        final BigDecimal actualValue = quantity.getValue();
        if ( actualValue == null )
        {
            return null;
        }
        final double convertedValue = actualWeightUnit.convertTo( actualValue.doubleValue(), resultingWeightUnit );
        return round ? Math.round( convertedValue ) : convertedValue;
    }

    public  R4VitalSignFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext );

}