got uspdc displaying
parent
3e65b9fbdd
commit
dd90715400
@ -1,47 +0,0 @@
|
||||
import functools
|
||||
from flask import (Blueprint, flash, g, redirect, render_template, request, session, url_for)
|
||||
from datetime import datetime
|
||||
|
||||
from FormulariesMatching.db_interface import (
|
||||
get_db,
|
||||
get_connection_details,
|
||||
get_trial_summary,
|
||||
)
|
||||
|
||||
|
||||
|
||||
#setup blueprint
|
||||
bp = Blueprint("formularies validation", __name__, url_prefix='/link/formularies')
|
||||
|
||||
@bp.route("/", methods=['GET'])
|
||||
def get_remaining():
|
||||
#get db connection
|
||||
#db_conn = get_db()
|
||||
|
||||
#get required data
|
||||
connection_valid = get_connection_details()
|
||||
|
||||
#return html
|
||||
return connection_valid
|
||||
|
||||
|
||||
@bp.route("/<nct_id>", methods=['GET',"POST"])
|
||||
def match_trial_to_formulary_groups(nct_id):
|
||||
#get db connection
|
||||
db_conn = get_db()
|
||||
|
||||
if request.method == "GET":
|
||||
pass
|
||||
#get list of potential matches for each of the formularies
|
||||
#get trial summary
|
||||
summary = get_trial_summary(db_conn,nct_id)
|
||||
|
||||
#render template
|
||||
return summary
|
||||
|
||||
elif request.method == "POST":
|
||||
pass
|
||||
#build array of data to insert
|
||||
|
||||
else:
|
||||
pass
|
||||
@ -0,0 +1,70 @@
|
||||
import functools
|
||||
from flask import (Blueprint, flash, g, redirect, render_template, request, session, url_for)
|
||||
from datetime import datetime
|
||||
|
||||
from FormulariesMatching.db_interface import (
|
||||
get_db,
|
||||
get_connection_details,
|
||||
get_trial_summary,
|
||||
)
|
||||
import FormulariesMatching.uspdc_db as uspdc
|
||||
import FormulariesMatching.uspmmg_db as uspmmg
|
||||
import FormulariesMatching.vaform_db as vaform
|
||||
|
||||
FORMULARIES = {
|
||||
"USP DC":uspdc,
|
||||
# "USP MMG":uspmmg,
|
||||
# "VA Formulary":vaform,
|
||||
}
|
||||
|
||||
|
||||
#setup blueprint
|
||||
bp = Blueprint("formularies", __name__, url_prefix='/link/formularies')
|
||||
|
||||
@bp.route("/", methods=['GET'])
|
||||
def get_remaining_trials():
|
||||
#get db connection
|
||||
#db_conn = get_db()
|
||||
|
||||
#get required data
|
||||
connection_valid = get_connection_details()
|
||||
|
||||
#return html
|
||||
return connection_valid
|
||||
|
||||
|
||||
@bp.route("/<nct_id>", methods=['GET',"POST"])
|
||||
def match_trial_to_formulary_groups(nct_id):
|
||||
#get db connection
|
||||
db_conn = get_db()
|
||||
|
||||
if request.method == "GET":
|
||||
|
||||
#get list of potential matches for each of the formularies
|
||||
potential_matches = {}
|
||||
class_lists = {}
|
||||
|
||||
for formulary in FORMULARIES:
|
||||
potential_matches[formulary] = FORMULARIES[formulary].get_groups_per_nctid(db_conn,nct_id)
|
||||
class_lists[formulary] = FORMULARIES[formulary].get_all_formulary_groups(db_conn)
|
||||
|
||||
#get trial summary
|
||||
summary = get_trial_summary(db_conn,nct_id)
|
||||
|
||||
#render template
|
||||
# return [potential_matches,class_lists,summary]
|
||||
return render_template('trial_formularies.html',
|
||||
nct_id=nct_id,
|
||||
potential_matches=potential_matches,
|
||||
class_lists=class_lists,
|
||||
summary=summary,
|
||||
)
|
||||
|
||||
elif request.method == "POST":
|
||||
pass
|
||||
#build array of data to insert
|
||||
|
||||
else:
|
||||
raise Exception("HTTP method <{}> not implemented".format(request.method))
|
||||
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid;
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,76 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block header %}
|
||||
<h1>
|
||||
{% block title %}
|
||||
Match Trial {{nct_id}} to Formularies
|
||||
{% endblock %}
|
||||
</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
Based on the drugs associated with a trial,
|
||||
the following are the formulary group suggestions.
|
||||
|
||||
<form>
|
||||
{% for formulary in potential_matches %}
|
||||
<div class=formulary_matches>
|
||||
<h2>
|
||||
{{ formulary }}
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
{% for formulary in potential_matches %}
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th>Class</th>
|
||||
<th>Select</th>
|
||||
</tr>
|
||||
{% for row in potential_matches[formulary] %}
|
||||
<tr>
|
||||
<td> {{ row[1] }} </td>
|
||||
<td> {{ row[2] }} </td>
|
||||
<td> <input
|
||||
type="checkbox"
|
||||
id="{{ formulary,row }}"
|
||||
name={{ formulary,row }}
|
||||
value="selected">
|
||||
</td>
|
||||
<!-- add checkbox here -->
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
</p>
|
||||
<p>
|
||||
If you've determined it belongs to another class
|
||||
<select name="{{ formulary }}-select_box" id="{{ formularay }}-select_box">
|
||||
<option disabled selected value> -- select an option -- </option>
|
||||
<option value="difficult">
|
||||
Difficult to choose
|
||||
</option>
|
||||
|
||||
{% for option in class_lists[formulary] %}
|
||||
<option value={{ (option[0],option[1]) }}>
|
||||
Category:{{ option[0] }} Class:{{ option[1] }}
|
||||
<!-- FIX this is really hard to read -->
|
||||
<!-- FIX try to add opgroups? -->
|
||||
</option>
|
||||
{% endfor %}
|
||||
|
||||
</select>
|
||||
{% endfor %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Submit">
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
@ -0,0 +1,47 @@
|
||||
import psycopg as psyco
|
||||
from datetime import datetime
|
||||
|
||||
from flask import current_app, g
|
||||
|
||||
|
||||
|
||||
|
||||
def get_all_formulary_groups(db_conn):
|
||||
'''
|
||||
Get the list of active formulary groups
|
||||
TODO: IMplement for the given formulary
|
||||
'''
|
||||
sql = '''\
|
||||
select distinct "USP Category", "USP Class"
|
||||
from "Formularies".usp_dc ud
|
||||
order by "USP Category", "USP Class"
|
||||
;
|
||||
'''
|
||||
#query
|
||||
with db_conn.cursor() as curse:
|
||||
curse.execute(sql)
|
||||
return curse.fetchall()
|
||||
|
||||
|
||||
|
||||
|
||||
def get_groups_per_nctid(db_conn, nct_id):
|
||||
'''
|
||||
Get the list of formulary groups associated with
|
||||
the drugs found in a trial identified by NCTID
|
||||
'''
|
||||
pass
|
||||
sql = '''\
|
||||
select * from "Formularies".trial_to_uspdc_category_class ttucc
|
||||
where nct_id = %(nctid)s
|
||||
;
|
||||
'''
|
||||
|
||||
#query
|
||||
with db_conn.cursor() as curse:
|
||||
curse.execute(sql, {"nctid":nct_id})
|
||||
return curse.fetchall()
|
||||
|
||||
|
||||
def store_trial_to_formulary_group_matches():
|
||||
pass
|
||||
@ -0,0 +1,35 @@
|
||||
import psycopg as psyco
|
||||
from datetime import datetime
|
||||
|
||||
from flask import current_app, g
|
||||
|
||||
|
||||
|
||||
|
||||
def get_all_formulary_groups(db_conn):
|
||||
'''
|
||||
Get the list of active formulary groups
|
||||
TODO: IMplement for the given formulary
|
||||
'''
|
||||
sql = '''\
|
||||
select distinct "USP Category", "USP Class"
|
||||
from "Formularies".usp_dc ud
|
||||
order by "USP Category", "USP Class"
|
||||
;
|
||||
'''
|
||||
|
||||
#query
|
||||
with db_conn.cursor() as curse:
|
||||
curse.execute(sql)
|
||||
return curse.fetchall()
|
||||
|
||||
def get_formulary_groups_per_NCTID(db_conn, nct_id):
|
||||
'''
|
||||
Get the list of formulary groups associated with
|
||||
the drugs found in a trial identified by NCTID
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
def store_trial_to_formulary_group_matches():
|
||||
pass
|
||||
@ -0,0 +1,35 @@
|
||||
import psycopg as psyco
|
||||
from datetime import datetime
|
||||
|
||||
from flask import current_app, g
|
||||
|
||||
|
||||
|
||||
|
||||
def get_all_formulary_groups(db_conn):
|
||||
'''
|
||||
Get the list of active formulary groups
|
||||
TODO: IMplement for the given formulary
|
||||
'''
|
||||
sql = '''\
|
||||
select distinct "USP Category", "USP Class"
|
||||
from "Formularies".usp_dc ud
|
||||
order by "USP Category", "USP Class"
|
||||
;
|
||||
'''
|
||||
|
||||
#query
|
||||
with db_conn.cursor() as curse:
|
||||
curse.execute(sql)
|
||||
return curse.fetchall()
|
||||
|
||||
def get_formulary_groups_per_NCTID(db_conn, nct_id):
|
||||
'''
|
||||
Get the list of formulary groups associated with
|
||||
the drugs found in a trial identified by NCTID
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
def store_trial_to_formulary_group_matches():
|
||||
pass
|
||||
Loading…
Reference in New Issue