File size: 9,962 Bytes
629d596 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
from utils.summarize_utils.summ_utils import *
from utils.summarize_utils.ctwrap import ClinicalTrials
import pandas as pd
# get data
def get_data(study_id_list):
# print(study_id_list)
ct = ClinicalTrials()
fields=['NCTId','OfficialTitle','BriefSummary','DetailedDescription','LocationCountry',
'OrgStudyId','SecondaryId','Condition','InterventionName',
'DesignInterventionModel','BriefTitle','Phase', 'DesignAllocation',
'DesignMasking','OverallStatus', 'WhyStopped','EnrollmentCount', 'LastUpdatePostDate',
'InterventionDescription']
column_names = ['Rank','NCTId','OfficialTitle','BriefSummary','DetailedDescription',
'LocationCountry' ,'OrgStudyId','SecondaryId','Condition','InterventionName',
'DesignInterventionModel', 'BriefTitle','Phase','DesignAllocation',
'DesignMasking', 'OverallStatus', 'WhyStopped','EnrollmentCount',
'LastUpdatePostDate','InterventionDescription']
my_list =[]
for ncid in study_id_list:
nct_fields = ct.get_study_fields(
search_expr= ncid,
fields=fields,
fmt="csv",
)
my_list.append(nct_fields[1:])
flat_list = [item for sublist in my_list for item in sublist]
d= [dict(zip(column_names, l)) for l in flat_list ]
data = pd.DataFrame(d).fillna('')
print('Data reading complete..')
return data
def get_summ(status, alloc, masking, phase, imodel, osid, sid, locations,pcount,otitle, bsumm,ddesc,ystop,nctid,lupd):
locs = get_locs(locations)
print(status)
if alloc.lower()!='n/a'and ystop =='' and pcount !='0' and status =='':
print('first if - im inside alloc is not na & ystop is none')
ostmt = get_first_word(alloc,masking,status) + \
alloc.lower() + ', ' + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
' in ' + pcount + ' subjects '+ \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
return ostmt
if alloc.lower()!='n/a'and ystop =='' and pcount !='0' and status =='Active, not recruiting' :
print('second if - im inside alloc is not na & ystop is none')
ostmt = get_first_word(alloc,masking,status) + \
alloc.lower() + ', ' + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
get_status(status) + \
' in ' + pcount + ' subjects '+ \
get_obj(otitle,bsumm,ddesc) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
# ostmt = unique_list(ostmt)
return ostmt
if alloc.lower()!='n/a'and ystop =='' and pcount !='0' and status !='':
print('third if - im inside alloc is not na & ystop is none')
ostmt = get_first_word(alloc,masking,status) + \
alloc.lower() + ', ' + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
' in ' + pcount + ' subjects '+ \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))) )
# ostmt = unique_list(ostmt)
return ostmt
if alloc.lower()=='n/a' and ystop =='' and pcount !='0':
print('fourth if - im alloc is na and ystop is none')
ostmt = get_first_word(alloc,masking,status) + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
' in ' + pcount + ' subjects '+ \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_url(nctid,lupd)
print(ostmt)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
# ostmt = unique_list(ostmt)
return ostmt
if alloc.lower()=='n/a' and ystop !='' and pcount !='0':
print('fifth if - im in alloc na; ystop not none; pcount not 0')
ostmt = get_first_word(alloc,masking,status) + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
' in ' + pcount + ' subjects '+ \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_ystop(ystop) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
# ostmt = unique_list(ostmt)
return ostmt
if alloc.lower()!='n/a' and ystop !='' and pcount !='0':
print('sixth if - im alloc not na and ystop is not none')
ostmt = get_first_word(alloc,masking,status) + \
alloc.lower() + ', ' + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
' in ' + pcount + ' subjects '+ \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_ystop(ystop) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
# ostmt = unique_list(ostmt)
return ostmt
if alloc.lower()!='n/a' and ystop !='' and pcount =='0':
print('seventh if - im alloc not na and ystop is not none')
print(ystop)
ostmt = get_first_word(alloc,masking,status) + \
alloc.lower() + ', ' + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_ystop(ystop) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
# ostmt = unique_list(ostmt)
return ostmt
if alloc.lower()=='n/a' and ystop !='' and pcount =='0':
print('eigth if - im alloc not na and ystop is not none')
ostmt = get_first_word(alloc,masking,status) + \
get_mask(masking) + \
get_imodel(imodel) + \
'/'.join(phase.lower().split('|')) + ' '+ \
get_osid(osid,sid)+ \
'study ' + \
get_locs(locations) + \
get_obj(otitle,bsumm,ddesc) + \
get_status(status) + \
get_ystop(ystop) + \
get_url(nctid,lupd)
ostmt = repos_study_design(remove_period_spaces(map_terms(map_week_num(ostmt))))
# ostmt = unique_list(ostmt)
return ostmt
|