def update_panel(adapter, panel_name, panel_version, new_version=None, new_date=None):
panel_obj = adapter.gene_panel(panel_name, panel_version)<EOL>if not panel_obj:<EOL><INDENT>raise IntegrityError("<STR_LIT>" % (panel_name, panel_version))<EOL><DEDENT>updated_panel = adapter.update_panel(panel_obj, new_version, new_date)<EOL>panel_id = updated_panel['<STR_LIT>']<EOL>update = {'<STR_LIT>': {}}<EOL>if new_version:<EOL><INDENT>update['<STR_LIT>']['<STR_LIT>'] = updated_panel['<STR_LIT:version>']<EOL><DEDENT>if new_date:<EOL><INDENT>update['<STR_LIT>']['<STR_LIT>'] = updated_panel['<STR_LIT:date>']<EOL><DEDENT>LOG.info('<STR_LIT>'.format(update))<EOL>query = {'<STR_LIT>': { '<STR_LIT>': {'<STR_LIT>': panel_name}}}<EOL>adapter.case_collection.update_many(query, update)<EOL>return updated_panel<EOL>
Update a gene panel in the database

    We need to update the actual gene panel and then all cases that refers to the panel.

    Args:
        adapter(scout.adapter.MongoAdapter)
        panel_name(str): Unique name for a gene panel
        panel_version(float)
        new_version(float)
        new_date(datetime.datetime)

    Returns:
        updated_panel(scout.models.GenePanel): The updated gene panel object