Skip to content

Commit

Permalink
Removed primis_variables() and fixed related bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
marrpesce committed Dec 19, 2024
1 parent 8f16473 commit 74f747e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 58 deletions.
2 changes: 1 addition & 1 deletion analysis/dataset_definition_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@

demographic_variables(dataset = dataset, index_date = snapshot_date)
primis_variables(dataset = dataset, index_date = snapshot_date)
other_cx_variables(dataset = dataset, index_date = snapshot_date)
# other_cx_variables(dataset = dataset, index_date = snapshot_date)
7 changes: 4 additions & 3 deletions analysis/dataset_definition_varying.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@
demographic_variables(dataset = dataset, index_date = current_vax.date, var_name_suffix = suffix)

# primis variables
primis_variables(dataset = dataset, index_date = current_vax.date, var_name_suffix = suffix)
# primis_variables(dataset = dataset, index_date = current_vax.date, var_name_suffix = suffix)
dataset.add_column(f"primis_atrisk_{i}", primis_atrisk(current_vax.date)) # at risk

# primis variables
other_cx_variables(dataset = dataset, index_date = current_vax.date, var_name_suffix = suffix)
# other clinical variables
# other_cx_variables(dataset = dataset, index_date = current_vax.date, var_name_suffix = suffix)

previous_vax_date = current_vax.date

24 changes: 12 additions & 12 deletions analysis/process.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ data_vax <-
matches("imd_\\d+"),
matches("imd_quintile_\\d+"),
# ... more clinical (PRIMIS) characteristics here
matches("primis_atrisk_\\d+"), # Clinically vulnerable
matches("crd_\\d+"), #chronic respiratory disease
matches("chd_\\d+"), #chronic heart disease
matches("ckd_\\d+"), #chronic kidney disease
matches("cld_\\d+"), # chronic liver disease
matches("cns_\\d+"), # chronic neurological disease
matches("learndis_\\d+"), # learning Disability
matches("diabetes_\\d+"), #diabetes
matches("immunosuppressed_\\d+"), #immunosuppress grouped
matches("asplenia_\\d+"), # asplenia or dysfunction of the spleen
matches("severe_obesity_\\d+"), #immunosuppress grouped
matches("smi_\\d+"), #severe mental illness
matches("primis_atrisk_\\d+") #, # Clinically vulnerable
# matches("crd_\\d+"), #chronic respiratory disease
# matches("chd_\\d+"), #chronic heart disease
# matches("ckd_\\d+"), #chronic kidney disease
# matches("cld_\\d+"), # chronic liver disease
# matches("cns_\\d+"), # chronic neurological disease
# matches("learndis_\\d+"), # learning Disability
# matches("diabetes_\\d+"), #diabetes
# matches("immunosuppressed_\\d+"), #immunosuppress grouped
# matches("asplenia_\\d+"), # asplenia or dysfunction of the spleen
# matches("severe_obesity_\\d+"), #immunosuppress grouped
# matches("smi_\\d+"), #severe mental illness
) %>%
pivot_longer(
cols = -patient_id,
Expand Down
69 changes: 35 additions & 34 deletions analysis/report_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ summary_stratified <-
vax_dosenumber, vax_type8, vax_campaign,
sex, ageband, ethnicity5, region, imd_quintile,
# PRIMIS
crd, chd, ckd, cld, cns, learndis, diabetes, immunosuppressed, asplenia, severe_obesity, smi, primis_atrisk
# crd, chd, ckd, cld, cns, learndis, diabetes, immunosuppressed, asplenia, severe_obesity, smi,
primis_atrisk
) %>%
summarise(
n = ceiling_any(n(), 100)
Expand Down Expand Up @@ -265,17 +266,17 @@ plot_vax_dates(vax_campaign, all)
plot_vax_dates(vax_dosenumber, all)

#PRIMIS
plot_vax_dates(crd, all) # chronic respiratory disease
plot_vax_dates(chd, all) # chronic heart disease
plot_vax_dates(ckd, all) # chronic kidney disease
plot_vax_dates(cld, all) # chronic liver disease
plot_vax_dates(cns, all) #chronic neurological
plot_vax_dates(learndis, all) # learning disability
plot_vax_dates(diabetes, all) # diabetes
plot_vax_dates(immunosuppressed, all) # immunosuppressed
plot_vax_dates(asplenia, all) # asplenia or dysfunction of the spleen
plot_vax_dates(severe_obesity, all) # obesity
plot_vax_dates(smi, all) # severe mental illness
#plot_vax_dates(crd, all) # chronic respiratory disease
#plot_vax_dates(chd, all) # chronic heart disease
#plot_vax_dates(ckd, all) # chronic kidney disease
#plot_vax_dates(cld, all) # chronic liver disease
# plot_vax_dates(cns, all) #chronic neurological
# plot_vax_dates(learndis, all) # learning disability
# plot_vax_dates(diabetes, all) # diabetes
# plot_vax_dates(immunosuppressed, all) # immunosuppressed
# plot_vax_dates(asplenia, all) # asplenia or dysfunction of the spleen
# plot_vax_dates(severe_obesity, all) # obesity
# plot_vax_dates(smi, all) # severe mental illness
plot_vax_dates(primis_atrisk, all) # clinically vulnerable


Expand All @@ -286,17 +287,17 @@ plot_vax_dates(region, vax_dosenumber)
plot_vax_dates(imd_quintile, vax_dosenumber)
plot_vax_dates(vax_campaign, vax_dosenumber)
#PRIMIS
plot_vax_dates(crd, vax_dosenumber) # chronic respiratory disease
plot_vax_dates(chd, vax_dosenumber) # chronic heart disease
plot_vax_dates(ckd, vax_dosenumber) # chronic kidney disease
plot_vax_dates(cld, vax_dosenumber) # chronic liver disease
plot_vax_dates(cns, vax_dosenumber) # chronic neurological disease
plot_vax_dates(learndis, vax_dosenumber) # learning Disability
plot_vax_dates(diabetes, vax_dosenumber) # diabetes
plot_vax_dates(immunosuppressed, vax_dosenumber) # immunosuppressed
plot_vax_dates(asplenia, vax_dosenumber) # asplenia or dysfunction of the spleen
plot_vax_dates(severe_obesity, vax_dosenumber) # obesity
plot_vax_dates(smi, vax_dosenumber) # severe mental illness
#plot_vax_dates(crd, vax_dosenumber) # chronic respiratory disease
#plot_vax_dates(chd, vax_dosenumber) # chronic heart disease
# plot_vax_dates(ckd, vax_dosenumber) # chronic kidney disease
# plot_vax_dates(cld, vax_dosenumber) # chronic liver disease
# plot_vax_dates(cns, vax_dosenumber) # chronic neurological disease
# plot_vax_dates(learndis, vax_dosenumber) # learning Disability
# plot_vax_dates(diabetes, vax_dosenumber) # diabetes
# plot_vax_dates(immunosuppressed, vax_dosenumber) # immunosuppressed
# plot_vax_dates(asplenia, vax_dosenumber) # asplenia or dysfunction of the spleen
# plot_vax_dates(severe_obesity, vax_dosenumber) # obesity
# plot_vax_dates(smi, vax_dosenumber) # severe mental illness
plot_vax_dates(primis_atrisk, vax_dosenumber) # Clinically vulnerable

## output plots of time since previous vaccination by type, dose number, and other characteristics ----
Expand Down Expand Up @@ -379,15 +380,15 @@ plot_vax_intervals(vax_dosenumber, all)

#PRIMIS

plot_vax_intervals(crd, vax_dosenumber) # chronic respiratory disease
plot_vax_intervals(chd, vax_dosenumber) # chronic heart disease
plot_vax_intervals(ckd, vax_dosenumber) # chronic kidney disease
plot_vax_intervals(cld, vax_dosenumber) # chronic liver disease
plot_vax_intervals(cns, vax_dosenumber) # chronic neurological
plot_vax_intervals(learndis, vax_dosenumber) # learning disability
plot_vax_intervals(diabetes, vax_dosenumber) # diabetes
plot_vax_intervals(immunosuppressed, vax_dosenumber) # immunosuppressed
plot_vax_intervals(asplenia, vax_dosenumber) # asplenia or dysfunction of the spleen
plot_vax_intervals(severe_obesity, vax_dosenumber) # obesity
plot_vax_intervals(smi, vax_dosenumber) # severe mental illness
# plot_vax_intervals(crd, vax_dosenumber) # chronic respiratory disease
# plot_vax_intervals(chd, vax_dosenumber) # chronic heart disease
# plot_vax_intervals(ckd, vax_dosenumber) # chronic kidney disease
# plot_vax_intervals(cld, vax_dosenumber) # chronic liver disease
# plot_vax_intervals(cns, vax_dosenumber) # chronic neurological
# plot_vax_intervals(learndis, vax_dosenumber) # learning disability
# plot_vax_intervals(diabetes, vax_dosenumber) # diabetes
# plot_vax_intervals(immunosuppressed, vax_dosenumber) # immunosuppressed
# plot_vax_intervals(asplenia, vax_dosenumber) # asplenia or dysfunction of the spleen
# plot_vax_intervals(severe_obesity, vax_dosenumber) # obesity
# plot_vax_intervals(smi, vax_dosenumber) # severe mental illness
plot_vax_intervals(primis_atrisk, vax_dosenumber) # Clinically vulnerable
20 changes: 12 additions & 8 deletions analysis/variables_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ def has_severe_obesity(index_date):
event_bmi = last_prior_event(
bmi,
index_date,
where=(clinical_events.numeric_value.is_not_null())
where=(
clinical_events.numeric_value.is_not_null() &
(clinical_events.numeric_value > 4) &
(clinical_events.numeric_value < 200)
)
)
# Severe obesity
severe_obesity = case(
Expand Down Expand Up @@ -308,14 +312,14 @@ def primis_variables(dataset, index_date, var_name_suffix=""):
##################################################################


def other_cx_variables(dataset, index_date, var_name_suffix=""):
# def other_cx_variables(dataset, index_date, var_name_suffix=""):
## others of interest
dataset.add_column(f"sol_org_trans{var_name_suffix}", has_prior_event(solid_organ_transplant, index_date)) # Organs transplant
dataset.add_column(f"hiv{var_name_suffix}", has_prior_event(hiv_aids, index_date)) #HIV/AIDS
dataset.add_column(f"cancer{var_name_suffix}",
has_prior_event(cancer_nonhaem_snomed, index_date, where=clinical_events.date.is_after(index_date - days(int(3 * 365.25))))|
has_prior_event(cancer_haem_snomed, index_date, where=clinical_events.date.is_after(index_date - days(int(3 * 365.25))))
) #cancer
# dataset.add_column(f"sol_org_trans{var_name_suffix}", has_prior_event(solid_organ_transplant, index_date)) # Organs transplant
# dataset.add_column(f"hiv{var_name_suffix}", has_prior_event(hiv_aids, index_date)) #HIV/AIDS
# dataset.add_column(f"cancer{var_name_suffix}",
# has_prior_event(cancer_nonhaem_snomed, index_date, where=clinical_events.date.is_after(index_date - days(int(3 * 365.25))))|
# has_prior_event(cancer_haem_snomed, index_date, where=clinical_events.date.is_after(index_date - days(int(3 * 365.25))))
# ) #cancer



Expand Down

0 comments on commit 74f747e

Please sign in to comment.