Ejemplo n.º 1
0
		# retrieve from our database
		if not _force_update:
			existing = Study.retrieve(ncts)
			for ex in existing:
				trials[ex.nct] = ex
		
		# loop trials
		for nct in ncts:
			if not nct:
				continue
			
			# get the trial fresh via web
			if nct in trials:
				trial = trials[nct]
			else:
				trial = lilly.get_trial(nct)
				if trial is None:
					raise Exception("No trial for %s" % nct)
				trial.store()
			
			# skip if not in the US
			countries = getattr(trial, 'location_countries')
			if countries is None or 0 == len(countries) or u'United States' not in countries.get('country', []):
				# print '-->  Skipping %s (%s)' % (nct, countries)
				continue
			# print '==>  Using %s' % nct
			
			first_y = trial.entered
			last_y = trial.last_updated
			
			# collect trial attributes
Ejemplo n.º 2
0
        # retrieve from our database
        if not _force_update:
            existing = Study.retrieve(ncts)
            for ex in existing:
                trials[ex.nct] = ex

        # loop trials
        for nct in ncts:
            if not nct:
                continue

            # get the trial fresh via web
            if nct in trials:
                trial = trials[nct]
            else:
                trial = lilly.get_trial(nct)
                if trial is None:
                    raise Exception("No trial for %s" % nct)
                trial.store()

            # skip if not in the US
            countries = getattr(trial, 'location_countries')
            if countries is None or 0 == len(
                    countries) or u'United States' not in countries.get(
                        'country', []):
                # print '-->  Skipping %s (%s)' % (nct, countries)
                continue
            # print '==>  Using %s' % nct

            first_y = trial.entered
            last_y = trial.last_updated
Ejemplo n.º 3
0
        # open output file
        csv_new = "%s-auto-updated.csv" % os.path.splitext(
            csv_path)[0].replace('-manual', '')
        with codecs.open(csv_new, 'w') as w_handle:
            lilly = LillyCOI()
            # ref_date = datetime.datetime(2013, 7, 30)		# this can NOT be used against date last updated, of course
            ref_date = datetime.datetime.now()

            writer = csv.writer(w_handle)
            header.pop(idx_drop)
            writer.writerow(header)

            # loop trials
            for row in reader:
                trial = lilly.get_trial(row[idx_nct])

                # date calculations
                first = trial.date('firstreceived_date')
                first_y = round((ref_date - first[1]).days / 365.25 *
                                10) / 10 if first[1] else 99
                last = trial.date('lastchanged_date')
                last_y = round((ref_date - last[1]).days / 365.25 *
                               10) / 10 if last[1] else 99
                comp = trial.date('primary_completion_date')
                comp_y = round((ref_date - comp[1]).days / 365.25 *
                               10) / 10 if comp[1] else 99
                veri = trial.date('verification_date')
                veri_y = round((ref_date - veri[1]).days / 365.25 *
                               10) / 10 if veri[1] else 99
Ejemplo n.º 4
0
		idx_last = header.index('last update yrs ago')
		
		# open output file
		csv_new = "%s-auto-updated.csv" % os.path.splitext(csv_path)[0].replace('-manual', '')
		with codecs.open(csv_new, 'w') as w_handle:
			lilly = LillyCOI()
			# ref_date = datetime.datetime(2013, 7, 30)		# this can NOT be used against date last updated, of course
			ref_date = datetime.datetime.now()
			
			writer = csv.writer(w_handle)
			header.pop(idx_drop)
			writer.writerow(header)
			
			# loop trials
			for row in reader:
				trial = lilly.get_trial(row[idx_nct])
				
				# date calculations
				first = trial.date('firstreceived_date')
				first_y = round((ref_date - first[1]).days / 365.25 * 10) / 10 if first[1] else 99
				last = trial.date('lastchanged_date')
				last_y = round((ref_date - last[1]).days / 365.25 * 10) / 10 if last[1] else 99
				comp = trial.date('primary_completion_date')
				comp_y = round((ref_date - comp[1]).days / 365.25 * 10) / 10 if comp[1] else 99
				veri = trial.date('verification_date')
				veri_y = round((ref_date - veri[1]).days / 365.25 * 10) / 10 if veri[1] else 99
				
				# write updated row
				row[idx_first] = first_y
				row[idx_last] = last_y
				row.pop(idx_drop)