got uspdc displaying

main^2
Will King 3 years ago
parent 3e65b9fbdd
commit dd90715400

@ -40,11 +40,8 @@ def create_app(test_config=None):
from . import db_interface
#db_interface.check_connection(app)
from . import formularies_matching
app.register_blueprint(formularies_matching.bp)
from . import matching
app.register_blueprint(matching.bp)
return app

@ -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;
}

@ -1,6 +1,9 @@
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
<title>{% block title %}{% endblock %} - ClinicalTrialsProject</title>
<!--<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">-->
<nav>
<h1>Nav</h1>
@ -9,14 +12,15 @@
<a href="{{ url_for('hello') }}">Linking Home</a>
</li>
<li>
<a href="{{ url_for('formularies validation.get_remaining') }}">Linking Formularies</a>
<a href="{{ url_for('formularies.get_remaining_trials') }}">Linking Formularies</a>
</li>
</ul>
</nav>
</head>
<section class="content">
<header>
<body>
{% block header %}{% endblock %}
</header>
{% block content %}{% endblock %}
</section>
</body>
</html>

@ -1,16 +1,16 @@
{% extends 'base.html' %}
{% block header %}
<h1>{% block title %} ICD-10 to Trial Conditions Validation {% endblock %}</h1>
<h1>{% block title %} Linking Trials to Formularies{% endblock %}</h1>
{% endblock %}
{% block content %}
<h2>Trials to Validate</h2>
<h2>Unlinked Trials</h2>
<table>
<th>Trials</th>
{% for trial in list_to_validate %}
{% for trial in unlinked_trials %}
<tr><td>
<a href="{{ url_for('.validate_trial', nct_id=trial[0] ) }}">
{{ trial [0] }}
@ -19,7 +19,7 @@
{% endfor %}
</table>
<h2>Trials that have been Validated</h2>
<h2>Linked Trials</h2>
<table>
<th>Trials Links</th>
@ -33,7 +33,7 @@
{% endfor %}
</table>
<h2>Trials that don't have a good match</h2>
<h2>Flagged for later Trials</h2>
<table>
<th>Trial Links</th>

@ -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…
Cancel
Save