From 9592be12666880a24b4c4dcff5cbb196c9700e06 Mon Sep 17 00:00:00 2001 From: Em Prestige Date: Thu, 21 Mar 2024 14:57:22 +0000 Subject: [PATCH] update exclusion criteria for cohort flow chart --- analysis/cohort_criteria.R | 28 +++++++++-------------- analysis/dataset_definition_flow_chart.py | 13 +++++------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/analysis/cohort_criteria.R b/analysis/cohort_criteria.R index 3957f68..6bb073d 100644 --- a/analysis/cohort_criteria.R +++ b/analysis/cohort_criteria.R @@ -56,27 +56,21 @@ not_age_count <- if (cohort == "infants" | cohort == "infants_subgroup") { registered_count - age_count } -if (cohort == "older_adults") { - included_count <- sum(patients_df$registered & patients_df$is_female_or_male - & patients_df$is_appropriate_age & patients_df$has_imd - & !patients_df$care_home, na.rm = TRUE) - excluded_count <- sum(!patients_df$is_female_or_male |!patients_df$has_imd - | patients_df$care_home, na.rm = TRUE) - not_age_count -} else if (cohort == "infants" | cohort == "infants_subgroup") { - included_count <- sum(patients_df$is_female_or_male +if (cohort == "infants" | cohort == "infants_subgroup") { + included_count <- sum(!patients_df$severe_immunodeficiency & patients_df$is_appropriate_age & patients_df$has_imd - & !patients_df$risk_group_infants - & !patients_df$severe_immunodeficiency, na.rm = TRUE) - excluded_count <- sum(!patients_df$is_female_or_male |!patients_df$has_imd - | patients_df$risk_group_infants - | patients_df$severe_immunodeficiency, na.rm = TRUE) - + & patients_df$is_female_or_male & !patients_df$care_home + & !patients_df$risk_group_infants, na.rm = TRUE) + excluded_count <- sum(!patients_df$is_female_or_male|!patients_df$has_imd + |patients_df$risk_group_infants|patients_df$care_home + |patients_df$severe_immunodeficiency, na.rm = TRUE) - not_age_count } else { included_count <- sum(patients_df$registered & patients_df$is_female_or_male - & patients_df$is_appropriate_age & patients_df$has_imd, - na.rm = TRUE) - excluded_count <- sum(!patients_df$is_female_or_male - |!patients_df$has_imd, na.rm = TRUE) - not_age_count + & patients_df$is_appropriate_age & patients_df$has_imd + & !patients_df$care_home, na.rm = TRUE) + excluded_count <- sum(!patients_df$is_female_or_male|!patients_df$has_imd + |patients_df$care_home, na.rm = TRUE) - not_age_count } ## create output directories ---- diff --git a/analysis/dataset_definition_flow_chart.py b/analysis/dataset_definition_flow_chart.py index 457c5da..73aa45b 100644 --- a/analysis/dataset_definition_flow_chart.py +++ b/analysis/dataset_definition_flow_chart.py @@ -193,13 +193,12 @@ def first_infection_event(codelist, where = True): ) #care home resident -if cohort == "older_adults" : - care_home_tpp = ( - addresses.for_patient_on(index_date) - .care_home_is_potential_match.when_null_then(False) - ) - care_home_code = (has_prior_event(codelists.carehome_codelist)) - dataset.care_home = care_home_tpp | care_home_code +care_home_tpp = ( + addresses.for_patient_on(index_date) + .care_home_is_potential_match.when_null_then(False) +) +care_home_code = (has_prior_event(codelists.carehome_codelist)) +dataset.care_home = care_home_tpp | care_home_code #define population dataset.define_population(practice_registrations.exists_for_patient())