generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudy_definition.py
82 lines (71 loc) · 2.35 KB
/
study_definition.py
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
from cohortextractor import StudyDefinition, patients, codelist, codelist_from_csv # NOQA
study = StudyDefinition(
default_expectations={
"date": {"earliest": "1900-01-01", "latest": "today"},
"rate": "uniform",
"incidence": 0.5,
},
population=patients.registered_with_one_practice_between(
"2019-02-01", "2020-02-01"
),
age=patients.age_as_of(
"2019-09-01",
return_expectations={
"rate": "universal",
"int": {"distribution": "population_ages"},
},
),
sex=patients.sex(
return_expectations={
"rate": "universal",
"category": {"ratios": {"M": 0.49, "F": 0.51}}}),
region=patients.registered_practice_as_of(
"2020-02-01",
returning="nuts1_region_name",
return_expectations={
"rate": "universal",
"category": {
"ratios": {
"North East": 0.1,
"North West": 0.1,
"Yorkshire and the Humber": 0.1,
"East Midlands": 0.1,
"West Midlands": 0.1,
"East of England": 0.1,
"London": 0.2,
"South East": 0.2,
},
},
}),
admission_method=patients.admitted_to_hospital(
with_admission_method=['21', '22', '23', '28'],
returning='admission_method',
return_expectations={
"rate": "universal",
"category": {
'ratios': {
'21': 0.25,
'22': 0.25,
'23': 0.25,
'28': 0.25
},
},
}),
primary_diagnosis=patients.admitted_to_hospital(
returning='primary_diagnosis',
return_expectations={
"rate": "universal",
"category": {
'ratios': {
'J120': 0.5,
'C910': 0.5
},
},
}),
)
#
# return_expectations={"rate": "universal",
# "category":{'ratios':
# {'J120':0.5,
# 'J120':0.5}}}),
#