Skip to content

Commit

Permalink
adding basic logic or rules for dates
Browse files Browse the repository at this point in the history
  • Loading branch information
quan14 committed Jan 23, 2025
1 parent 7e36b0d commit 839f8d7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions analysis/dataset_definition_dx_to_med_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def last_matching_event(events, codelist, where=True):
)

dataset = create_dataset()
dataset.configure_dummy_data(population_size=1000)
dataset.configure_dummy_data(population_size=10)

# Date range
start_date = "2016-01-01"
Expand All @@ -52,22 +52,19 @@ def last_matching_event(events, codelist, where=True):
clinical_events.snomedct_code.is_in(adhd_codelist)
).exists_for_patient()

# dataset.has_mph_med = selected_medications.where(
# medications.dmd_code.is_in(methylphenidate_codelist)
# ).exists_for_patient()

dataset.adhd_cod_date = last_matching_event(selected_events, adhd_codelist).date

dataset.mph_med_date = selected_medications.where(True)\
.where(selected_medications.dmd_code.is_in(methylphenidate_codelist))\
.sort_by(selected_medications.date)\
.last_for_patient().date
.first_for_patient().date

dataset.define_population(
has_registration
& dataset.sex.is_in(["male", "female"])
& (dataset.age >= 18)
& (dataset.age <= 120)
& patients.is_alive_on(start_date)
& dataset.mph_med_date.is_not_null(),
& dataset.adhd_cod_date.is_not_null()
& dataset.mph_med_date.is_not_null()
& (dataset.adhd_cod_date <= dataset.mph_med_date)
)

0 comments on commit 839f8d7

Please sign in to comment.