Skip to content

Commit

Permalink
update exclusion criteria for cohort flow chart
Browse files Browse the repository at this point in the history
  • Loading branch information
emprestige committed Mar 21, 2024
1 parent 1047109 commit 9592be1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
28 changes: 11 additions & 17 deletions analysis/cohort_criteria.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----
Expand Down
13 changes: 6 additions & 7 deletions analysis/dataset_definition_flow_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 9592be1

Please sign in to comment.