-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquiz.py
More file actions
100 lines (83 loc) · 3.66 KB
/
quiz.py
File metadata and controls
100 lines (83 loc) · 3.66 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
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
# Welcome to the ehrQL Quiz!
from quiz_answers import questions
from ehrql import codelist_from_csv, show, months
from ehrql.tables.core import clinical_events
diabetes_codes = codelist_from_csv(
"codelists/nhsd-primary-care-domain-refsets-dm_cod.csv", column="code"
)
referral_codes = codelist_from_csv(
"codelists/nhsd-primary-care-domain-refsets-dsep_cod.csv", column="code"
)
mild_frailty_codes = codelist_from_csv(
"codelists/nhsd-primary-care-domain-refsets-mildfrail_cod.csv", column="code"
)
moderate_frailty_codes = codelist_from_csv(
"codelists/nhsd-primary-care-domain-refsets-modfrail_cod.csv", column="code"
)
severe_frailty_codes = codelist_from_csv(
"codelists/nhsd-primary-care-domain-refsets-sevfrail_cod.csv", column="code"
)
hba1c_codes = codelist_from_csv(
"codelists/nhsd-primary-care-domain-refsets-ifcchbam_cod.csv", column="code"
)
# Question 0
# Create an event frame by filtering clinical_events to find just the records indicating a diabetes
# diagnosis. (Use the diabetes_codes codelist.)
questions[0].check(
clinical_events.where(clinical_events.snomedct_code.is_in(diabetes_codes))
)
# Question 1
# Create a patient series containing the date of each patient's earliest diabetes diagnosis.
questions[1].check(...)
# If you need a hint for this, or any other, question, just uncomment (remove the #) from the following line:
# questions[1].hint()
# Question 2
# Create a patient series containing the date of each patient's earliest structured education
# programme referral. (Use the referral_code codelist.)
questions[2].check(...)
# questions[2].hint()
# Question 3
# Create a boolean patient series indicating whether the date of each patient's earliest diabetes
# diagnosis was between 1st April 2023 and 31st March 2024. If the patient does not have a
# diagnosis, the value for in this series should be False.
questions[3].check(...)
# questions[3].hint()
# Question 4
# Create a patient series indicating the number of months between a patient's earliest diagnosis
# and their earliest referral.
questions[4].check(...)
# questions[4].hint()
# Question 5
# Create a boolean patient series identifying patients who have been diagnosed with diabetes for
# the first time in the year between 1st April 2023 and 31st March 2024, and who have a record of
# being referred to a structured education programme within nine months after their diagnosis.
questions[5].check(...)
# questions[5].hint()
# Question 6
# Create a patient series with the date of the latest record of mild frailty for each patient.
questions[6].check(...)
# questions[6].hint()
# Question 7
# Create a patient series with the date of the latest record of moderate or severe frailty for
# each patient.
questions[7].check(...)
# questions[7].hint()
# Question 8
# A patient may have mild, moderate and severe frailty codes in their record. A patient's frailty
# is considered to be their most recent frailty code. So if their most recent frailty code was for
# mild frailty, then we would say they have mild frailty.
# Create a boolean patient series indicating whether a patient has moderate or severe frailty, i.e
# where the patient's last record of severity is moderate or severe. If the patient does not have
# a record of frailty, the value in this series should be False.
questions[8].check(...)
# questions[8].hint()
# Question 9
# Create a patient series containing the latest HbA1c measurement for each patient.
questions[9].check(...)
# questions[9].hint()
# Question 10
# Create a boolean patient series identifying patients without moderate or severe frailty in whom
# the last IFCC-HbA1c is 58 mmol/mol or less
questions[10].check(...)
# questions[10].hint()
questions.summarise()