Skip to content

Commit

Permalink
Add ehrQL placeholders to research template
Browse files Browse the repository at this point in the history
  • Loading branch information
milanwiedemann authored Oct 13, 2023
2 parents 2863504 + 84206c8 commit fe9f7ef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions analysis/dataset_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Note: If you are using ehrQL to define your study population you need to:
# (1) uncomment the ehrQL action in the project.yaml file (lines 14-18),
# (2) delete the cohort-extractor action from the project.yaml file (lines 8-12), and
# (3) delete the study_definition.py file.

from ehrql import Dataset
from ehrql.tables.beta.tpp import patients, practice_registrations

dataset = Dataset()

index_date = "2020-03-31"

has_registration = practice_registrations.for_patient_on(
index_date
).exists_for_patient()

dataset.age = patients.age_on(index_date)

dataset.define_population(has_registration & (dataset.age > 17))
4 changes: 4 additions & 0 deletions analysis/study_definition.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Note: If you are using cohortextrator to define your study population you need to
# (1) delete the ehrQL action in the project.yaml file (lines 14-18) and
# (2) delete the dataset_definition.py file.

from cohortextractor import StudyDefinition, patients, codelist, codelist_from_csv # NOQA


Expand Down
6 changes: 6 additions & 0 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ actions:
outputs:
highly_sensitive:
cohort: output/input.csv.gz

# generate_dataset:
# run: ehrql:v0 generate-dataset analysis/dataset_definition.py --output output/dataset.csv.gz
# outputs:
# highly_sensitive:
# cohort: output/dataset.csv.gz

0 comments on commit fe9f7ef

Please sign in to comment.