scout/adapter/mongo/event.py
def remove_phenotype(self, institute, case, user, link, phenotype_id,
                         is_group=False):
        """Remove an existing phenotype from a case

        Args:
            institute (dict): A Institute object
            case (dict): Case object
            user (dict): A User object
            link (dict): The url to be used in the event
            phenotype_id (str): A phenotype id

        Returns:
            updated_case(dict)
        """
        LOG.info("Removing HPO term from case {0}".format(case['display_name']))

        if is_group:
            updated_case = self.case_collection.find_one_and_update(
                {'_id': case['_id']},
                {
                    '$pull': {
                        'phenotype_terms': {'phenotype_id': phenotype_id},
                        'phenotype_groups': {'phenotype_id': phenotype_id},
                    },
                },
                return_document=pymongo.ReturnDocument.AFTER
            )

        else:
            updated_case = self.case_collection.find_one_and_update(
                {'_id': case['_id']},
                {
                    '$pull': {
                        'phenotype_terms': {'phenotype_id': phenotype_id},
                    },
                },
                return_document=pymongo.ReturnDocument.AFTER
            )

        LOG.info("Creating event for removing phenotype term {0}" \
                    " from case {1}".format(phenotype_id, case['display_name']))

        self.create_event(
            institute=institute,
            case=case,
            user=user,
            link=link,
            category='case',
            verb='remove_phenotype',
            subject=case['display_name']
        )

        LOG.debug("Case updated")
        return updated_case
def remove_phenotype(self, institute, case, user, link, phenotype_id,
                         is_group=False):
        LOG.info("Removing HPO term from case {0}".format(case['display_name']))

        if is_group:
            updated_case = self.case_collection.find_one_and_update(
                {'_id': case['_id']},
                {
                    '$pull': {
                        'phenotype_terms': {'phenotype_id': phenotype_id},
                        'phenotype_groups': {'phenotype_id': phenotype_id},
                    },
                },
                return_document=pymongo.ReturnDocument.AFTER
            )

        else:
            updated_case = self.case_collection.find_one_and_update(
                {'_id': case['_id']},
                {
                    '$pull': {
                        'phenotype_terms': {'phenotype_id': phenotype_id},
                    },
                },
                return_document=pymongo.ReturnDocument.AFTER
            )

        LOG.info("Creating event for removing phenotype term {0}" \
                    " from case {1}".format(phenotype_id, case['display_name']))

        self.create_event(
            institute=institute,
            case=case,
            user=user,
            link=link,
            category='case',
            verb='remove_phenotype',
            subject=case['display_name']
        )

        LOG.debug("Case updated")
        return updated_case
def remove_phenotype ( self , institute , case , user , link , phenotype_id , is_group = False ) : LOG . info ( "Removing HPO term from case {0}" . format ( case [ 'display_name' ] ) ) if is_group : updated_case = self . case_collection . find_one_and_update ( { '_id' : case [ '_id' ] } , { '$pull' : { 'phenotype_terms' : { 'phenotype_id' : phenotype_id } , 'phenotype_groups' : { 'phenotype_id' : phenotype_id } , } , } , return_document = pymongo . ReturnDocument . AFTER ) else : updated_case = self . case_collection . find_one_and_update ( { '_id' : case [ '_id' ] } , { '$pull' : { 'phenotype_terms' : { 'phenotype_id' : phenotype_id } , } , } , return_document = pymongo . ReturnDocument . AFTER ) LOG . info ( "Creating event for removing phenotype term {0}" " from case {1}" . format ( phenotype_id , case [ 'display_name' ] ) ) self . create_event ( institute = institute , case = case , user = user , link = link , category = 'case' , verb = 'remove_phenotype' , subject = case [ 'display_name' ] ) LOG . debug ( "Case updated" ) return updated_case
Remove an existing phenotype from a case

        Args:
            institute (dict): A Institute object
            case (dict): Case object
            user (dict): A User object
            link (dict): The url to be used in the event
            phenotype_id (str): A phenotype id

        Returns:
            updated_case(dict)
Remove an existing phenotype from a case