scout/adapter/mongo/query.py
def clinsig_query(self, query, mongo_query):
        """ Add clinsig filter values to the mongo query object

            Args:
                query(dict): a dictionary of query filters specified by the users
                mongo_query(dict): the query that is going to be submitted to the database

            Returns:
                clinsig_query(dict): a dictionary with clinsig key-values

        """
        LOG.debug('clinsig is a query parameter')
        trusted_revision_level = ['mult', 'single', 'exp', 'guideline']
        rank = []
        str_rank = []
        clnsig_query = {}

        for item in query['clinsig']:
            rank.append(int(item))
            # search for human readable clinsig values in newer cases
            rank.append(CLINSIG_MAP[int(item)])
            str_rank.append(CLINSIG_MAP[int(item)])

        if query.get('clinsig_confident_always_returned') == True:
            LOG.debug("add CLINSIG filter with trusted_revision_level")

            clnsig_query = { "clnsig":
                        {
                            '$elemMatch': {
                                '$or' : [
                                    {
                                        '$and' : [
                                             {'value' : { '$in': rank }},
                                             {'revstat': { '$in': trusted_revision_level }}
                                        ]
                                    },
                                    {
                                        '$and': [
                                            {'value' : re.compile('|'.join(str_rank))},
                                            {'revstat' : re.compile('|'.join(trusted_revision_level))}
                                        ]
                                    }
                                ]
                            }
                         }
                    }
        else:
            LOG.debug("add CLINSIG filter for rank: %s" %
                             ', '.join(str(query['clinsig'])))

            clnsig_query = {
                    "clnsig":
                        {
                            '$elemMatch': {
                                '$or' : [
                                    { 'value' : { '$in': rank }},
                                    { 'value' : re.compile('|'.join(str_rank)) }
                                ]
                            }
                        }
                }

        return clnsig_query
def clinsig_query(self, query, mongo_query):
        """ Add clinsig filter values to the mongo query object

            Args:
                query(dict): a dictionary of query filters specified by the users
                mongo_query(dict): the query that is going to be submitted to the database

            Returns:
                clinsig_query(dict): a dictionary with clinsig key-values

        """
        LOG.debug('clinsig is a query parameter')
        trusted_revision_level = ['mult', 'single', 'exp', 'guideline']
        rank = []
        str_rank = []
        clnsig_query = {}

        for item in query['clinsig']:
            rank.append(int(item))
            # search for human readable clinsig values in newer cases
            rank.append(CLINSIG_MAP[int(item)])
            str_rank.append(CLINSIG_MAP[int(item)])

        if query.get('clinsig_confident_always_returned') == True:
            LOG.debug("add CLINSIG filter with trusted_revision_level")

            clnsig_query = { "clnsig":
                        {
                            '$elemMatch': {
                                '$or' : [
                                    {
                                        '$and' : [
                                             {'value' : { '$in': rank }},
                                             {'revstat': { '$in': trusted_revision_level }}
                                        ]
                                    },
                                    {
                                        '$and': [
                                            {'value' : re.compile('|'.join(str_rank))},
                                            {'revstat' : re.compile('|'.join(trusted_revision_level))}
                                        ]
                                    }
                                ]
                            }
                         }
                    }
        else:
            LOG.debug("add CLINSIG filter for rank: %s" %
                             ', '.join(str(query['clinsig'])))

            clnsig_query = {
                    "clnsig":
                        {
                            '$elemMatch': {
                                '$or' : [
                                    { 'value' : { '$in': rank }},
                                    { 'value' : re.compile('|'.join(str_rank)) }
                                ]
                            }
                        }
                }

        return clnsig_query
Add clinsig filter values to the mongo query object

            Args:
                query(dict): a dictionary of query filters specified by the users
                mongo_query(dict): the query that is going to be submitted to the database

            Returns:
                clinsig_query(dict): a dictionary with clinsig key-values