Skip to content

Commit

Permalink
Move import codelists into separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
milanwiedemann committed Oct 3, 2024
1 parent b4c294d commit 01af9cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
15 changes: 15 additions & 0 deletions analysis/codelists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ehrql import codelist_from_csv

# Import pharmacy first conditions codelist
pharmacy_first_conditions_codelist = codelist_from_csv(
"codelists/user-chriswood-pharmacy-first-clinical-pathway-conditions.csv",
column="code",
category_column="term",
)

# Import ethnicity codelist
ethnicity_codelist = codelist_from_csv(
"codelists/opensafely-ethnicity-snomed-0removed.csv",
column="snomedcode",
category_column="Grouping_6",
)
18 changes: 2 additions & 16 deletions analysis/measures_definition_pf_codes_conditions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ehrql import INTERVAL, create_measures, months, codelist_from_csv, case, when
from ehrql import INTERVAL, create_measures, months, case, when
from ehrql.tables.tpp import clinical_events, practice_registrations, patients, addresses, ethnicity_from_sus
from codelists import pharmacy_first_conditions_codelist, ethnicity_codelist

measures = create_measures()
measures.configure_dummy_data(population_size=1000)
Expand All @@ -19,21 +20,6 @@
"pharmacy_first_service": ["983341000000102"],
}

# Import pharmacy first conditions codelist
pharmacy_first_conditions_codelist = codelist_from_csv(
"codelists/user-chriswood-pharmacy-first-clinical-pathway-conditions.csv",
column="code",
category_column="term",
)

# Import ethnicity codelist
ethnicity_codelist = codelist_from_csv(
"codelists/opensafely-ethnicity-snomed-0removed.csv",
column="snomedcode",
category_column="Grouping_6",
)


# # Get the latest ethnicity data for each patient
# ethnicity = (
# clinical_events.where(
Expand Down

0 comments on commit 01af9cf

Please sign in to comment.