def numeric_factory(value, datatype_cls, validation_level=None):
    """
    Creates a :class:`NM <hl7apy.base_datatypes.NM>` object

    The value in input can be a string representing a decimal number or a ``float``.
    (i.e. a string valid for :class:`decimal.Decimal()`).
    If it's not, a :exc:`ValueError` is raised
    Also an empty string or ``None`` are allowed

    :type value: ``str`` or ``None``
    :param value: the value to assign the numeric object

    :type datatype_cls: :class:`class`
    :param value: the :class:`NM <hl7apy.base_datatypes.NM>` class to use. It has to be one implementation
        of the different version modules

    :type validation_level: ``int``
    :param validation_level: It must be a value from class
        :class:`VALIDATION_LEVEL hl7apy.consts.VALIDATION_LEVEL` or ``None`` to use the default value

    :rtype: :class:`NM <hl7apy.base_datatypes.NM>`
    """
    if not value:
        return datatype_cls(validation_level=validation_level)
    try:
        return datatype_cls(Decimal(value), validation_level=validation_level)
    except InvalidOperation:
        raise ValueError('{0} is not an HL7 valid NM value'.format(value))
Creates a :class:`NM <hl7apy.base_datatypes.NM>` object

    The value in input can be a string representing a decimal number or a ``float``.
    (i.e. a string valid for :class:`decimal.Decimal()`).
    If it's not, a :exc:`ValueError` is raised
    Also an empty string or ``None`` are allowed

    :type value: ``str`` or ``None``
    :param value: the value to assign the numeric object

    :type datatype_cls: :class:`class`
    :param value: the :class:`NM <hl7apy.base_datatypes.NM>` class to use. It has to be one implementation
        of the different version modules

    :type validation_level: ``int``
    :param validation_level: It must be a value from class
        :class:`VALIDATION_LEVEL hl7apy.consts.VALIDATION_LEVEL` or ``None`` to use the default value

    :rtype: :class:`NM <hl7apy.base_datatypes.NM>`