between=[index_date, end_date], returning="date_of_death", date_format="YYYY-MM-DD", return_expectations={ "incidence": 0.2, }, ), death_category=patients.categorised_as( { "covid-death": "died_covid", "non-covid-death": "(NOT died_covid) AND died_any", "alive": "DEFAULT" }, died_covid=patients.with_these_codes_on_death_certificate( codes_ICD10_covid, returning="binary_flag", match_only_underlying_cause=False, between=[index_date, end_date], ), died_any=patients.died_from_any_cause( between=[index_date, end_date], returning="binary_flag", ), return_expectations={ "category": { "ratios": { "alive": 0.8, "covid-death": 0.1, "non-covid-death": 0.1 } }, "incidence": 1
include_day=True, returning="date_admitted", find_first_match_in_period=True, return_expectations={ "date": { "earliest": "2020-03-01" }, "incidence": 0.1 }, ), died_ons_covid_flag_any=patients.with_these_codes_on_death_certificate( covid_identification, on_or_after="2020-03-01", match_only_underlying_cause=False, return_expectations={ "date": { "earliest": "2020-03-01" }, "incidence": 0.1 }, ), died_ons_covid_flag_underlying=patients. with_these_codes_on_death_certificate( covid_identification, on_or_after="2020-03-01", match_only_underlying_cause=True, return_expectations={ "date": { "earliest": "2020-03-01" }, "incidence": 0.1
include_day=True, return_expectations={ "date": { "earliest": "2020-02-01" }, "rate": "exponential_increase" }, ), # ons died_ons_covid_flag_any=patients.with_these_codes_on_death_certificate( covid_codelist, on_or_after="2020-02-01", match_only_underlying_cause=False, return_expectations={ "date": { "earliest": "2020-02-01" }, "rate": "exponential_increase" }, ), died_ons_confirmedcovid_flag_any=patients. with_these_codes_on_death_certificate( confirmed_covid_codelist, on_or_after="2020-02-01", match_only_underlying_cause=False, return_expectations={ "date": { "earliest": "2020-02-01" }, "rate": "exponential_increase"
**date_X("codes_probable_covid_pos_test", n=n), **date_X("codes_probable_covid_sequelae", n=n), **date_X("codes_suspected_covid_advice", n=m), **date_X("codes_suspected_covid_had_test", n=m), **date_X("codes_suspected_covid_isolation", n=n), **date_X("codes_suspected_covid_nonspecific", n=n), **date_X("codes_suspected_covid", n=m), **date_X("codes_covid_unrelated_to_case_status", n=m), **date_X("codes_suspected_covid_had_antigen_test", n=n), **sgss_X(n=n), # Outcomes died_ons_covid=patients.with_these_codes_on_death_certificate( codes_covid_death, returning="binary_flag", on_or_after=from_date, match_only_underlying_cause=False, return_expectations={"date": { "earliest": from_date }}, ), died_ons_covid_underlying=patients.with_these_codes_on_death_certificate( codes_covid_death, returning="binary_flag", on_or_after=from_date, match_only_underlying_cause=True, return_expectations={"date": { "earliest": "2020-03-01" }}, ), died_ons=patients.died_from_any_cause( returning="binary_flag",
), stroke=patients.satisfying( "stroke_gp OR stroke_hospital OR stroke_ons", stroke_gp=patients.with_these_clinical_events( stroke, between=["index_date", "last_day_of_month(index_date)"], return_expectations={"incidence": 0.05}, ), stroke_hospital=patients.admitted_to_hospital( with_these_diagnoses=stroke_hospital, between=["index_date", "last_day_of_month(index_date)"], return_expectations={"incidence": 0.05}, ), stroke_ons=patients.with_these_codes_on_death_certificate( stroke_hospital, between=["index_date", "last_day_of_month(index_date)"], return_expectations={"incidence": 0.05}, ), ), DVT=patients.satisfying( "dvt_gp OR dvt_hospital OR dvt_ons", dvt_gp=patients.with_these_clinical_events( filter_codes_by_category(vte_codes_gp, include=["dvt"]), between=["index_date", "last_day_of_month(index_date)"], return_expectations={"incidence": 0.05}, ), dvt_hospital=patients.admitted_to_hospital( with_these_diagnoses=filter_codes_by_category(vte_codes_hospital, include=["dvt"]), between=["index_date", "last_day_of_month(index_date)"], return_expectations={"incidence": 0.05},
return_expectations={ "rate": "universal", "int": { "distribution": "population_ages" }, }, ), sex=patients.sex(return_expectations={ "rate": "universal", "category": { "ratios": { "M": 0.49, "F": 0.51 } }, }), cardiac_disease=patients.with_these_clinical_events( cardiac_disease_codes, returning="binary_flag", return_expectations={"incidence": 0.2}, ), # } # Define output variable covid_on_death_certificate=patients.with_these_codes_on_death_certificate( covid_codes, match_only_underlying_cause=False, return_expectations={"incidence": 0.001}, ), )