@cases_bp.route('<STR_LIT>', methods=['<STR_LIT:POST>'])<EOL>@cases_bp.route('<STR_LIT>',<EOL>methods=['<STR_LIT:POST>'])<EOL>def phenotypes(institute_id, case_name, phenotype_id=None):
institute_obj, case_obj = institute_and_case(store, institute_id, case_name)<EOL>case_url = url_for('<STR_LIT>', institute_id=institute_id, case_name=case_name)<EOL>is_group = request.args.get('<STR_LIT>') == '<STR_LIT:yes>'<EOL>user_obj = store.user(current_user.email)<EOL>if phenotype_id:<EOL><INDENT>store.remove_phenotype(institute_obj, case_obj, user_obj, case_url,<EOL>phenotype_id, is_group=is_group)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>phenotype_term = request.form['<STR_LIT>']<EOL>if phenotype_term.startswith('<STR_LIT>') or len(phenotype_term) == <NUM_LIT:7>:<EOL><INDENT>hpo_term = phenotype_term.split('<STR_LIT>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>store.add_phenotype(institute_obj, case_obj, user_obj, case_url,<EOL>hpo_term=hpo_term, is_group=is_group)<EOL><DEDENT>else:<EOL><INDENT>store.add_phenotype(institute_obj, case_obj, user_obj, case_url,<EOL>omim_term=phenotype_term)<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>return abort(<NUM_LIT>, ("<STR_LIT>".format(phenotype_term)))<EOL><DEDENT><DEDENT>return redirect(case_url)<EOL>
Handle phenotypes.