Skip to content

Commit

Permalink
Further tidying and setup for prevax_extf
Browse files Browse the repository at this point in the history
  • Loading branch information
venexia committed Feb 3, 2023
1 parent d530fe6 commit 52c56af
Show file tree
Hide file tree
Showing 15 changed files with 2,305 additions and 2,385 deletions.
2 changes: 1 addition & 1 deletion analysis/active_analyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ tmp <- df[df$cohort=="prevax" &
"sub_covid_nonhospitalised") |
df$outcome %in% outcomes_runall),]

tmp$outcome <- paste0(tmp$outcome,"_extf")
tmp$cohort <- paste0(tmp$cohort,"_extf")
tmp$study_stop <- "2021-12-14"
tmp$cut_points <- "28;197;365;714"

Expand Down
7 changes: 7 additions & 0 deletions analysis/codelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,13 @@
self_harm_15plus_snomed_clinical
)

# OCD ICD10
ocd_icd10 = codelist_from_csv(
"codelists/user-kurttaylor-ocd_icd10.csv",
system="icd10",
column="code",
)

# Suicide
suicide_icd10 = codelist_from_csv(
"codelists/user-hjforbes-suicide-icd-10.csv",
Expand Down
48 changes: 24 additions & 24 deletions analysis/common_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_depression_snomed=patients.with_these_clinical_events(
depression_snomed_clinical,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -208,7 +208,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_depression_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=depression_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -222,7 +222,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_depression_death=patients.with_these_codes_on_death_certificate(
depression_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -243,7 +243,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_anxiety_general_snomed=patients.with_these_clinical_events(
anxiety_general_snomed_clinical,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -257,7 +257,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_anxiety_general_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=anxiety_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -271,7 +271,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_anxiety_general_death=patients.with_these_codes_on_death_certificate(
anxiety_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -292,7 +292,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_anxiety_ptsd_snomed=patients.with_these_clinical_events(
anxiety_ptsd_snomed_clinical,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -306,7 +306,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_anxiety_ptsd_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=ptsd_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -320,7 +320,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_anxiety_ptsd_death=patients.with_these_codes_on_death_certificate(
ptsd_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -341,7 +341,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_eating_disorders_snomed=patients.with_these_clinical_events(
eating_disorders_snomed_clinical,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -355,7 +355,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_eating_disorders_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=eating_disorder_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -369,7 +369,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_eating_disorders_death=patients.with_these_codes_on_death_certificate(
eating_disorder_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -390,7 +390,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_serious_mental_illness_snomed=patients.with_these_clinical_events(
serious_mental_illness_snomed_clinical,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -404,7 +404,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_serious_mental_illness_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=serious_mental_illness_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -418,7 +418,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_serious_mental_illness_death=patients.with_these_codes_on_death_certificate(
serious_mental_illness_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -439,7 +439,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_self_harm_snomed=patients.with_these_clinical_events(
self_harm_15_10_combined_snomed,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -453,7 +453,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_self_harm_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=self_harm_15_10_combined_icd,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -467,7 +467,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_self_harm_death=patients.with_these_codes_on_death_certificate(
self_harm_15_10_combined_icd,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -488,7 +488,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_suicide_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=suicide_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -502,7 +502,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_suicide_death=patients.with_these_codes_on_death_certificate(
suicide_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand All @@ -523,7 +523,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_addiction_snomed=patients.with_these_clinical_events(
addiction_snomed_clinical,
returning="date",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -537,7 +537,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_addiction_hes=patients.admitted_to_hospital(
returning="date_admitted",
with_these_diagnoses=opioid_misuse_icd10,
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
date_format="YYYY-MM-DD",
find_first_match_in_period=True,
return_expectations={
Expand All @@ -551,7 +551,7 @@ def generate_common_variables(index_date_variable,end_date_variable):
tmp_out_date_addiction_death=patients.with_these_codes_on_death_certificate(
opioid_misuse_icd10,
returning="date_of_death",
on_or_after=f"{index_date_variable}",
between=[f"{index_date_variable}",f"{end_date_variable}"],
match_only_underlying_cause=True,
date_format="YYYY-MM-DD",
return_expectations={
Expand Down Expand Up @@ -1309,4 +1309,4 @@ def generate_common_variables(index_date_variable,end_date_variable):

)

return dynamic_variables
return dynamic_variables
Loading

0 comments on commit 52c56af

Please sign in to comment.