How to use the hl7apy.exceptions.ChildNotFound function in hl7apy

To help you get started, we’ve selected a few hl7apy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crs4 / hl7apy / hl7apy / v2_5_1 / __init__.py View on Github external
def get(name, element_type):
    try:
        return ELEMENTS[element_type][name]
    except KeyError:
        raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_6 / __init__.py View on Github external
def find(name, where):
    """
    >>> from hl7apy.core import Segment
    >>> from hl7apy import find_reference
    >>> find_reference('UNKNOWN', (Segment, ), '2.6')  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ChildNotFound: No child named UNKNOWN
    """
    for cls in where:
        try:
            return {'ref': get(name, cls.__name__), 'name': name, 'cls': cls}
        except ChildNotFound:
            pass
    raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_2 / __init__.py View on Github external
def find(name, where):
    """
    >>> from hl7apy.core import Segment
    >>> from hl7apy import find_reference
    >>> find_reference('UNKNOWN', (Segment, ), '2.2')  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ChildNotFound: No child named UNKNOWN
    """
    for cls in where:
        try:
            return {'ref': get(name, cls.__name__), 'name': name, 'cls': cls}
        except ChildNotFound:
            pass
    raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_2 / __init__.py View on Github external
def find(name, where):
    """
    >>> from hl7apy.core import Segment
    >>> from hl7apy import find_reference
    >>> find_reference('UNKNOWN', (Segment, ), '2.2')  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ChildNotFound: No child named UNKNOWN
    """
    for cls in where:
        try:
            return {'ref': get(name, cls.__name__), 'name': name, 'cls': cls}
        except ChildNotFound:
            pass
    raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_7 / __init__.py View on Github external
def find(name, where):
    """
    >>> from hl7apy.core import Segment
    >>> from hl7apy import find_reference
    >>> find_reference('UNKNOWN', (Segment, ), '2.7')  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ChildNotFound: No child named UNKNOWN
    """
    for cls in where:
        try:
            return {'ref': get(name, cls.__name__), 'name': name, 'cls': cls}
        except ChildNotFound:
            pass
    raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / core.py View on Github external
def _do_traversal(self, mode, name, value=None):
        try:
            if mode == 'get':
                return super(Field, self).__getattr__(name)
            elif mode == 'set':
                super(Field, self).__setattr__(name, value)
            else:
                super(Field, self).__delattr__(name)
        except ChildNotFound as e:
            component, subcomponent = self._get_traversal_children(name)
            if component is None:
                raise ChildNotFound(name)

            if is_base_datatype(self.datatype, self.version):
                if subcomponent is not None or component != 1:
                    raise ChildNotFound(name)
                component_name = self.datatype
            else:
                component_name = '{0}_{1}'.format(self.datatype, component)
            if subcomponent is None:
                if mode == 'get':
                    return getattr(self, component_name)
                elif mode == 'set':
                    setattr(self, component_name, value)
                else:
                    delattr(self, component_name)
            else:
                component = getattr(self, component_name)
                component_ref = self.structure_by_name[component_name]['ref']
                component_datatype = component_ref[2]
                subcomponent_name = '{0}_{1}'.format(component_datatype, subcomponent)
                try:
github crs4 / hl7apy / hl7apy / v2_1 / __init__.py View on Github external
def get(name, element_type):
    try:
        return ELEMENTS[element_type][name]
    except KeyError:
        raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_8_1 / __init__.py View on Github external
def get(name, element_type):
    try:
        return ELEMENTS[element_type][name]
    except KeyError:
        raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_1 / __init__.py View on Github external
def find(name, where):
    """
    >>> from hl7apy.core import Segment
    >>> from hl7apy import find_reference
    >>> find_reference('UNKNOWN', (Segment, ), '2.1')  # doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    ...
    ChildNotFound: No child named UNKNOWN
    """
    for cls in where:
        try:
            return {'ref': get(name, cls.__name__), 'name': name, 'cls': cls}
        except ChildNotFound:
            pass
    raise ChildNotFound(name)
github crs4 / hl7apy / hl7apy / v2_7 / __init__.py View on Github external
def get(name, element_type):
    try:
        return ELEMENTS[element_type][name]
    except KeyError:
        raise ChildNotFound(name)