|
|
|
|
@ -43,6 +43,7 @@ def check_connection(app):
|
|
|
|
|
|
|
|
|
|
def get_trial_summary(db_conn,nct_id):
|
|
|
|
|
sql_summary ="""
|
|
|
|
|
/*get brief and detailed descriptions*/
|
|
|
|
|
select
|
|
|
|
|
s.nct_id,
|
|
|
|
|
brief_title ,
|
|
|
|
|
@ -64,22 +65,39 @@ where c.nct_id = %s
|
|
|
|
|
;
|
|
|
|
|
"""
|
|
|
|
|
sql_keywords="""
|
|
|
|
|
/*get keywords*/
|
|
|
|
|
select nct_id ,downcase_name
|
|
|
|
|
from ctgov.keywords k
|
|
|
|
|
where k.nct_id = %s
|
|
|
|
|
;
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
sql_indications='''
|
|
|
|
|
select downcase_mesh_term
|
|
|
|
|
from ctgov.browse_interventions bi
|
|
|
|
|
where bi.nct_id = %s and mesh_type = 'mesh-list'
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with db_conn.cursor() as curse:
|
|
|
|
|
curse.execute(sql_summary,[nct_id])
|
|
|
|
|
summary = curse.fetchall()
|
|
|
|
|
|
|
|
|
|
curse.execute(sql_keywords,[nct_id])
|
|
|
|
|
keywords = curse.fetchall()
|
|
|
|
|
keywords = [ x[1] for x in curse.fetchall()]
|
|
|
|
|
|
|
|
|
|
curse.execute(sql_conditions,[nct_id])
|
|
|
|
|
conditions = curse.fetchall()
|
|
|
|
|
conditions = [ x[2] for x in curse.fetchall()]
|
|
|
|
|
|
|
|
|
|
return {"summary":summary, "keywords":keywords, "conditions":conditions}
|
|
|
|
|
curse.execute(sql_indications,[nct_id])
|
|
|
|
|
indications = [ x[0] for x in curse.fetchall()]
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
"summary":summary,
|
|
|
|
|
"keywords":keywords,
|
|
|
|
|
"conditions":conditions,
|
|
|
|
|
"indications":indications
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_trials_unmatched_to_formularies(db_conn):
|
|
|
|
|
@ -106,20 +124,40 @@ where nct_id not in (
|
|
|
|
|
select nct_id from "Formularies".uspdc_most_recent_matched_status umrms
|
|
|
|
|
where status is not null
|
|
|
|
|
)
|
|
|
|
|
; '''
|
|
|
|
|
uspmmg_sql = ''' Null; '''
|
|
|
|
|
and nct_id in (select distinct nct_id from public.formatted_data_mat fd )
|
|
|
|
|
;
|
|
|
|
|
'''
|
|
|
|
|
uspmmg_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".uspmmg_most_recent_matched_status umrms
|
|
|
|
|
where status is not null
|
|
|
|
|
)
|
|
|
|
|
and nct_id in (select distinct nct_id from public.formatted_data_mat fd )
|
|
|
|
|
;
|
|
|
|
|
'''
|
|
|
|
|
vaform_sql = ''' Null; '''
|
|
|
|
|
|
|
|
|
|
#query each formulary, adding data to dict
|
|
|
|
|
formulary_list = dict()
|
|
|
|
|
|
|
|
|
|
with db_conn.cursor as curse:
|
|
|
|
|
with db_conn.cursor() as curse:
|
|
|
|
|
|
|
|
|
|
# uspdc
|
|
|
|
|
curse.execute(uspdc_sql)
|
|
|
|
|
formulary_list["uspdc"] = curse.fetchall()
|
|
|
|
|
|
|
|
|
|
# uspmm
|
|
|
|
|
curse.execute(uspmmg_sql)
|
|
|
|
|
formulary_list["uspmmg"] = curse.fetchall()
|
|
|
|
|
# vaform
|
|
|
|
|
|
|
|
|
|
return formulary_list
|
|
|
|
|
|