Skip to content

Commit

Permalink
Update ons_deaths table and other ehrQL changes
Browse files Browse the repository at this point in the history
  • Loading branch information
milanwiedemann committed Nov 21, 2023
1 parent cce4f0b commit 2789d41
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions analysis/dataset_definition.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import date, timedelta

from databuilder.ehrql import Dataset, case, when
from databuilder.tables.beta.tpp import (
from ehrql import create_dataset, case, when
from ehrql.tables.beta.tpp import (
clinical_events,
emergency_care_attendances,
hospital_admissions,
Expand Down Expand Up @@ -51,7 +51,7 @@
index_date = date(2022, 9, 25)

# Create dataset
dataset = Dataset()
dataset = create_dataset()

###############################################################################
# Preprocessing data for later use
Expand All @@ -70,7 +70,10 @@
# Demographic variables
dataset.sex = patients.sex
dataset.age = age_as_of(index_date)
dataset.has_died = ons_deaths.where(ons_deaths.date <= index_date).exists_for_patient()
dataset.has_died = case(
when(ons_deaths.date <= index_date).then(True),
default=None,
)

# TPP care home flag
dataset.care_home_tpp = address.care_home_is_potential_match.if_null_then(False)
Expand Down

0 comments on commit 2789d41

Please sign in to comment.