-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeasure.py
More file actions
68 lines (59 loc) · 2.14 KB
/
measure.py
File metadata and controls
68 lines (59 loc) · 2.14 KB
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
import csv
import random
from faker import Factory
faker = Factory.create()
# Get data from other CSVs
individuals = []
with open('../deploy/individual.csv', 'rt') as x:
rd = csv.reader(x)
next(rd, None)
for row in rd:
individuals.append(row[0])
studies = []
with open('../deploy/study.csv', 'rt') as y:
rd = csv.reader(y)
next(rd, None)
for row in rd:
studies.append(row[0])
measure_type_revisions = []
with open('../deploy/measure_type.csv', 'rt') as z:
rd = csv.reader(z)
next(rd, None)
for row in rd:
measure_type_revisions.append(row[0])
# Initialize CSVs
with open('../deploy/measure.csv', 'a') as a:
measure_csv = csv.writer(a)
measure_csv.writerow(['individual','measure_type_revision','code','study','json','date_of_evaluation','age_at_evaluation','data_entry_status','last_modified','calculation'])
with open('../deploy/measure_entry.csv', 'a') as b:
measure_entry_csv = csv.writer(b)
measure_entry_csv.writerow(['measure','code','type','status','date_created','created_by','date_modified','modified_by','json','memo'])
# MEASURE DATA
for i in measure_type_revisions:
individual = random.choice(individuals)
measure_type_revision = i
code = '1'
study = random.choice(studies)
json = ''
date_of_evaluation = faker.date_time()
age_at_evaluation = faker.random_int(min=10,max=90)
data_entry_status = random.choice(['in-process','complete'])
last_modified = faker.date_time()
calculation = ''
with open('../deploy/measure.csv', 'a') as a:
measure_csv = csv.writer(a)
measure_csv.writerow([individual,measure_type_revision,code,study,json,date_of_evaluation,age_at_evaluation,data_entry_status,last_modified,calculation])
# MEASURE ENTRY DATA
measure = individual + '.(' + measure_type_revision + ').' + '1'
code = '1'
type = 'preliminary'
status = 'complete'
date_created = faker.date_time()
created_by = faker.name()
date_modified = ''
modified_by = ''
json = '{}'
memo = ''
with open('../deploy/measure_entry.csv', 'a') as b:
measure_entry_csv = csv.writer(b)
measure_entry_csv.writerow([measure,code,type,status,date_created,created_by,date_modified,modified_by,json,memo])