From 01af9cfc0663c3f24cbe4fa96ce4e074777018b2 Mon Sep 17 00:00:00 2001 From: Milan Wiedemann Date: Thu, 3 Oct 2024 17:03:06 +0100 Subject: [PATCH] Move import codelists into separate module --- analysis/codelists.py | 15 +++++++++++++++ .../measures_definition_pf_codes_conditions.py | 18 ++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 analysis/codelists.py diff --git a/analysis/codelists.py b/analysis/codelists.py new file mode 100644 index 0000000..ce8b5c8 --- /dev/null +++ b/analysis/codelists.py @@ -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", +) diff --git a/analysis/measures_definition_pf_codes_conditions.py b/analysis/measures_definition_pf_codes_conditions.py index 7cb4acd..a34ceed 100644 --- a/analysis/measures_definition_pf_codes_conditions.py +++ b/analysis/measures_definition_pf_codes_conditions.py @@ -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) @@ -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(