def case_phenotype(institute_id, case_id, phenotype_id=None): """Add a new HPO term to the case. TODO: validate ID and fetch phenotype description before adding to case. """ institute = validate_user(current_user, institute_id) case_model = store.case(institute_id, case_id) case_url = url_for(".case", institute_id=institute_id, case_id=case_id) if phenotype_id: # DELETE a phenotype from the list store.remove_phenotype(institute, case_model, current_user, case_url, phenotype_id) else: try: # POST a new phenotype to the list phenotype_term = request.form["hpo_term"] if phenotype_term.startswith("HP:") or len(phenotype_term) == 7: store.add_phenotype(institute, case_model, current_user, case_url, hpo_term=phenotype_term) else: # assume omim id store.add_phenotype(institute, case_model, current_user, case_url, omim_term=phenotype_term) except ValueError: return abort(400, ("unable to add phenotype term: {}".format(phenotype_id))) # fetch genes to update dynamic gene list genes = hpo_genes(case_model.phenotype_terms) store.update_dynamic_gene_list(case_model, genes) return redirect(case_url)
def case_phenotype(institute_id, case_id, phenotype_id=None): """Add a new HPO term to the case. TODO: validate ID and fetch phenotype description before adding to case. """ institute = validate_user(current_user, institute_id) case_model = store.case(institute_id, case_id) case_url = url_for('.case', institute_id=institute_id, case_id=case_id) if phenotype_id: # DELETE a phenotype from the list store.remove_phenotype(institute, case_model, current_user, case_url, phenotype_id) else: # POST a new phenotype to the list hpo_term = request.form['hpo_term'] store.add_phenotype(institute, case_model, current_user, case_url, hpo_term) # fetch genes to update dynamic gene list genes = hpo_genes(case_model.phenotype_terms) store.update_dynamic_gene_list(case_model, genes) return redirect(case_url)