def start_question_detail(): # get parameters cond = request.args.get('cond') locn = request.args.get('locn') age = request.args.get('age') gender = request.args.get('gender') domain = request.args.get('domain') user_picked_time = request.args.get('user_picked_time') exposure = request.args.get('exposure') stat = request.args.get('stat') preg = request.args.get('preg') pre_quest_answers = [ age, gender, domain, user_picked_time, exposure, stat, preg ] # save the query in session session.clear() session['query'] = cond session.modified = True # get trials and tags rnct = ctgov.get_initial_nct_patient(cond, locn) working_nct_id_list = qst.init_working_nct_id_list(rnct, pre_quest_answers) question_answer_list = [] if len(working_nct_id_list) > 0: question_answer_list = qst.find_new_question(question_answer_list, working_nct_id_list) log.info('%s -- first question' % (request.remote_addr)) return jsonify(question_answer_list=question_answer_list, working_nct_id_list=working_nct_id_list)
def check_homepage_parameters(): # get parameters locn = request.args.get('locn') miles = request.args.get('miles') trial_type = request.args.get('trial_type') active_restriction = request.args.get('active_restriction') keyword_search = request.args.get('keyword') if keyword_search is None: keyword_search = '' print('keyword in views: ' + keyword_search) # trying zipcode search try: nearby_nct = ctgov.get_nct_list_from_zip(locn, miles) print('length of nearby nct: ' + str(len(nearby_nct))) # session['nearby_nct_list'] = nearby_nct valid_zip = True print('assigned new variable') except: nearby_nct = [] valid_zip = False return jsonify(valid_zip=valid_zip, nearby_length=0, keyword_length=0, type_length=0, working_nct_length=0) print('passing try piece') # testing keyword search klist = ctgov.get_nct_list_from_keywords(keyword_search) # session['keyword_trial_list'] = klist # testing additional trial information pull using active restriction and trial type tlist = qst.find_active_nct_id_list(trial_type, active_restriction) # session['trial_type_list'] = tlist # building working nct_id list from search parameters zanct = [] nearby_nct_list = [x.split(';')[0] for x in nearby_nct] keyword_nct_list = [x.split(';')[0] for x in klist] for item in tlist: split_item = item.split(';') if split_item[1] in nearby_nct_list and split_item[1] in keyword_nct_list: zanct.append([split_item[0], split_item[1], int(split_item[2])]) working_nct_id_list = qst.init_working_nct_id_list(zanct) session['working_nct_list_pre_process'] = zanct session.modified = True # session['working_nct_id_list'] = working_nct_id_list print(valid_zip) print(len(klist)) print(len(tlist)) print(len(zanct)) return jsonify(valid_zip=valid_zip, nearby_length=len(nearby_nct), keyword_length=len(klist), type_length=len(tlist), working_nct_length=len(zanct))
def start_question(): # get parameters stxt = request.args.get ('stxt') # save the query in session # session['query'] = stxt # get trials and tags rnct = ctgov.get_initial_nct(stxt) working_nct_id_list = qst.init_working_nct_id_list(rnct) question_answer_list = [] question_answer_list = qst.find_new_question(question_answer_list, working_nct_id_list) log.info('%s -- first question' % (request.remote_addr)) return jsonify(question_answer_list=question_answer_list, working_nct_id_list=working_nct_id_list)
def get_to_pre_questions(): # get parameters cond = request.args.get('cond') locn = request.args.get('locn') # save the query in session session.clear() session['query'] = cond session.modified = True # get trials and tags rnct = ctgov.get_initial_nct_patient(cond, locn) working_nct_id_list = qst.init_working_nct_id_list(rnct) return jsonify(working_nct_id_list=working_nct_id_list)
def advs_start_question(): qlabel = request.args.get('qlabel') # save the query in session session.clear() session['query'] = qlabel session.modified = True # get trials url = ctgov.form_advanced_search_url (request.args) rnct = ctgov.get_initial_nct_from_url (url) working_nct_id_list = qst.init_working_nct_id_list(rnct) question_answer_list = [] if len(working_nct_id_list) > 0: question_answer_list = qst.find_new_question(question_answer_list,working_nct_id_list) log.info ('%s -- first question' % (request.remote_addr)) return jsonify (question_answer_list = question_answer_list, working_nct_id_list = working_nct_id_list)
def start_question_detail(): age = request.args.get('age') # gender = request.args.get('gender') exposure = request.args.get('exposure') domain = request.args.get('domain') user_picked_time = request.args.get('user_picked_time') stat = request.args.get('stat') preg = request.args.get('preg') miles = request.args.get('miles') pre_quest_answers = [age, exposure, domain, user_picked_time, stat, preg] locn = request.args.get('locn') trial_type = request.args.get('trial_type') #Save user access info into the database rnd = ''.join(str(random.choice(range(6))) for _ in range(6)) tim = time.strftime('%Y%m%d%H%M%S') session_id = rnd + tim age = int(age.encode('ascii', 'ignore')) if 0 <= age < 10: age = 10 else: age = int(age / 10) * 10 conn = general_pool_criteria.connection() cur = conn.cursor() sql = "insert into dbo.access_stat values ('%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s')" % ( session_id, str(locn), str(miles), trial_type, str(age), exposure, domain, user_picked_time or '', stat, preg) #print sql cur.execute(sql) conn.commit() conn.close() cur.close() # get trials and tags rnct = session.get('working_nct_list_pre_process') working_nct_id_list = qst.init_working_nct_id_list(rnct, pre_quest_answers) question_answer_list = [] if len(working_nct_id_list) > 0: question_answer_list = qst.find_new_question(question_answer_list, working_nct_id_list) log.info('%s -- first question' % (request.remote_addr)) return jsonify(question_answer_list=question_answer_list, working_nct_id_list=working_nct_id_list)
def start_question_detail(): # get parameters cond = request.args.get('cond') locn = request.args.get('locn') # save the query in session session.clear() session['query'] = cond session.modified = True # get trials and tags rnct = ctgov.get_initial_nct_patient(cond,locn) working_nct_id_list = qst.init_working_nct_id_list(rnct) question_answer_list = [] if len(working_nct_id_list) > 0: question_answer_list = qst.find_new_question(question_answer_list,working_nct_id_list) log.info ('%s -- first question' % (request.remote_addr)) return jsonify (question_answer_list = question_answer_list, working_nct_id_list = working_nct_id_list)
def get_to_pre_questions(): # # get parameters # locn = request.args.get('locn') # miles = request.args.get('miles') # trial_type = request.args.get('trial_type') # active_restriction = request.args.get('active_restriction') # keyword_search = request.args.get('keyword_search') # retrieve trials within set mile range of given zip code # znct = ctgov.get_nct_list_from_zip(locn, miles) # znct = session.get('nearby_nct_list') # print('rnct: ' + str(znct)) # retrieve trials based on keyword search provided by user # knct = ctgov.get_nct_list_from_keywords(keyword_search) # knct = session.get('keyword_trial_list') # print('knct: ' + str(knct)) # retrieve trials which are of a given trial type and status (based on active restriction checkbox) # anct = qst.find_active_nct_id_list(trial_type, active_restriction) # anct = session.get('trial_type_list') # print('anct: ' + str(anct)) # compare nearby nct list with active list # zanct = [] # nearby_nct_list = [x.split(';')[0] for x in znct] # keyword_nct_list = [x.split(';')[0] for x in knct] # for item in anct: # split_item = item.split(';') # if split_item[1] in nearby_nct_list and split_item[1] in keyword_nct_list: # zanct.append([split_item[0], split_item[1], int(split_item[2])]) # # working_nct_id_list = qst.init_working_nct_id_list(zanct) # session['nearby_active_nct_list'] = zanct working_nct_list_pre_process = session.get('working_nct_list_pre_process') working_nct_id_list = qst.init_working_nct_id_list( working_nct_list_pre_process) unique_nct_ct = qst.find_size_of_active_trials(working_nct_id_list) return jsonify(working_nct_id_list=working_nct_id_list, unique_nct_ct=unique_nct_ct)
def start_question_detail(): age = request.args.get('age') # gender = request.args.get('gender') exposure = request.args.get('exposure') domain = request.args.get('domain') user_picked_time = request.args.get('user_picked_time') stat = request.args.get('stat') preg = request.args.get('preg') miles = request.args.get('miles') pre_quest_answers = [age, exposure, domain, user_picked_time, stat, preg] # get trials and tags rnct = session.get('working_nct_list_pre_process') working_nct_id_list = qst.init_working_nct_id_list(rnct, pre_quest_answers) question_answer_list = [] if len(working_nct_id_list) > 0: question_answer_list = qst.find_new_question(question_answer_list, working_nct_id_list) log.info('%s -- first question' % (request.remote_addr)) return jsonify(question_answer_list=question_answer_list, working_nct_id_list=working_nct_id_list)