# Path: pyehr/ehr/services/dbmanager/errors.py
# class InvalidFieldError(Exception):
#     pass


from pyehr.ehr.services.dbmanager.errors import InvalidFieldError
        raise KeyError('Can\'t map key %s' % key)

    def __str__(self):
        return str(self.to_json())

    def extend(self, result_set):
        self.total_results += result_set.total_results
        self.rows += result_set.rows
        for c in result_set.columns:
            if c not in self.columns:
                self.columns.append(c)

    def add_column_definition(self, colum_def):
        if colum_def not in self.columns:
            self.columns.append(colum_def)

    def add_row(self, row):
        self.rows.append(row)
        self.total_results += 1

    @property
    def results(self):
        for r in self.rows:
            yield {self._get_alias(k): v for k, v in r.record.iteritems()}

    def get_distinct_results(self, field):
        try:
            for x in set([r[field] for r in self.results]):
                yield x
        except KeyError:

# Path: pyehr/ehr/services/dbmanager/errors.py
# class InvalidFieldError(Exception):
#     pass


# Path: pyehr/ehr/services/dbmanager/querymanager/results_wrappers.py
from pyehr.ehr.services.dbmanager.errors import InvalidFieldError

        raise KeyError('Can\'t map key %s' % key)

    def __str__(self):
        return str(self.to_json())

    def extend(self, result_set):
        self.total_results += result_set.total_results
        self.rows += result_set.rows
        for c in result_set.columns:
            if c not in self.columns:
                self.columns.append(c)

    def add_column_definition(self, colum_def):
        if colum_def not in self.columns:
            self.columns.append(colum_def)

    def add_row(self, row):
        self.rows.append(row)
        self.total_results += 1

    @property
    def results(self):
        for r in self.rows:
            yield {self._get_alias(k): v for k, v in r.record.iteritems()}

    def get_distinct_results(self, field):
        try:
            for x in set([r[field] for r in self.results]):
                yield x
        except KeyError:

            raise InvalidFieldError('There is no field "%s" in this results set' % field)