Diff of /docs/index.md [000000] .. [e988c2]

Switch to unified view

a b/docs/index.md
1
*ehrQL* (rhymes with *circle*), the **Electronic Health Records Query Language**,
2
is a query language and software tool designed for working with health data.
3
Researchers write **dataset definitions** with the query language
4
and execute them with the tool to generate **datasets with one row per patient**.
5
6
ehrQL allows researchers to access data sources from primary and secondary care,
7
as well as from organisations such as the Office for National Statistics (ONS).
8
9
ehrQL standardises data management tasks to promote efficiency,
10
reproducibility and transparency while maintaining patient privacy.
11
You can find out more about ehrQL's [philosophy and design goals](https://www.bennett.ox.ac.uk/blog/2023/09/why-ehrql/) on the Bennett Institute blog,
12
or see some [examples of ehrQL](how-to/examples.md) in action in the documentation.
13
14
If you have cumbersome data management tasks which are not currently supported by ehrQL
15
then please email us at <bennett@phc.ox.ac.uk> so we can consider how we might extend ehrQL to meet your needs.
16
17
## ehrQL's documentation
18
19
ehrQL's documentation has four main sections:
20
21
1. The [tutorial](tutorial/index.md) provides practical steps for learning ehrQL.
22
23
1. The [how-to guides](how-to/index.md) provide practical steps for working with ehrQL in your project.
24
25
1. The [reference](reference/index.md) provides background knowledge for working with ehrQL in your project.
26
27
1. The [explanations](explanation/index.md) provide background knowledge for learning ehrQL.
28
29
### Conventions
30
31
* :computer: steps you should follow on the computer you are using for studying or working with ehrQL
32
* :notepad_spiral: explanatory information
33
* :warning: important information
34
* :grey_question: questions for you to think about
35
36
### Navigation
37
38
The four main sections are written to be read in order.
39
You can navigate between them by:
40
41
* pressing the ++n++ or ++period++ keys to go to the next page, and the ++p++ or ++comma++ keys to go to the previous page;
42
* using the *Previous* and *Next* links in the page footer;
43
* referring to the navigation pane to the left of the page and clicking a link.
44
45
## Asking for help
46
47
If you need help with ehrQL or ehrQL's documentation,
48
then please ask for help on the
49
[#opensafely-users](https://bennettoxford.slack.com/archives/C01D7H9LYKB)
50
Slack channel.
51
(If you're unsure how to join, then please ask your co-pilot.)
52
53
## A dataset definition
54
55
The following dataset definition selects the date and the code of each patient's most recent asthma medication,
56
for all patients born on or before 31 December 1999.
57
58
```ehrql
59
from ehrql import create_dataset
60
from ehrql.tables.core import patients, medications
61
62
dataset = create_dataset()
63
64
dataset.define_population(patients.date_of_birth.is_on_or_before("1999-12-31"))
65
66
asthma_codes = ["39113311000001107", "39113611000001102"]
67
latest_asthma_med = (
68
    medications.where(medications.dmd_code.is_in(asthma_codes))
69
    .sort_by(medications.date)
70
    .last_for_patient()
71
)
72
73
dataset.asthma_med_date = latest_asthma_med.date
74
dataset.asthma_med_code = latest_asthma_med.dmd_code
75
```
76
77
When the dataset definition is executed with the command line interface,
78
the command line interface generates a dataset with one row per patient.
79
For example, it may generate the following dummy dataset:
80
81
| patient_id | asthma_med_date |        asthma_med_code |
82
| ---------- | --------------- | ---------------------- |
83
|          1 |      2023-05-14 | 39113611000001102      |
84
|          2 |      2023-05-26 | 39113611000001102      |
85
|          3 |      2018-07-23 | 39113311000001107      |
86
|          5 |      2004-09-25 | 39113611000001102      |
87
|          6 |      2007-04-25 | 39113611000001102      |
88
|          7 |      1949-10-18 | 39113311000001107      |
89
|          9 |      1966-05-15 | 39113311000001107      |
90
|         10 |      1966-03-14 | 39113611000001102      |