began work to get list of unmatched trials

main^2
will king 3 years ago
parent dd90715400
commit 692559ee5a

@ -81,3 +81,45 @@ where k.nct_id = %s
return {"summary":summary, "keywords":keywords, "conditions":conditions}
def get_trials_unmatched_to_formularies(db_conn):
"""
Get the NCT_IDs of trials not yet matchec to formularies
For each formulary
get list
add to dsp
"""
#setup sql for each formulary
uspdc_sql = '''\
/*
Get the trials that have not been proceesed.
First: get most recent matched status
Second: only include those who have non-null status
Third: check list of trials against this and remove any of them.
This leaves unmatched trials.
*/
select distinct(nct_id)
from "DiseaseBurden".trial_to_icd10 tti
where nct_id not in (
select nct_id from "Formularies".uspdc_most_recent_matched_status umrms
where status is not null
)
; '''
uspmmg_sql = ''' Null; '''
vaform_sql = ''' Null; '''
#query each formulary, adding data to dict
formulary_list = dict()
with db_conn.cursor as curse:
# uspdc
curse.execute(uspdc_sql)
formulary_list["uspdc"] = curse.fetchall()
# uspmm
# vaform
return formulary_list

@ -6,6 +6,7 @@ from FormulariesMatching.db_interface import (
get_db,
get_connection_details,
get_trial_summary,
get_trials_unmatched_to_formularies,
)
import FormulariesMatching.uspdc_db as uspdc
import FormulariesMatching.uspmmg_db as uspmmg
@ -24,10 +25,10 @@ bp = Blueprint("formularies", __name__, url_prefix='/link/formularies')
@bp.route("/", methods=['GET'])
def get_remaining_trials():
#get db connection
#db_conn = get_db()
db_conn = get_db()
#get required data
connection_valid = get_connection_details()
#get list of trials
connection_valid = get_trials_unmatched_to_formularies(db_conn)
#return html
return connection_valid

Loading…
Cancel
Save