# STUDY POPULATION
    population=patients.registered_with_one_practice_between(
        "2019-02-01", "2020-02-01"),
    dereg_date=patients.date_deregistered_from_all_supported_practices(
        on_or_before="2020-12-01",
        date_format="YYYY-MM",
        return_expectations={"date": {
            "earliest": "2020-02-01"
        }},
    ),

    # OUTCOMES,
    primary_care_case=patients.with_these_clinical_events(
        combine_codelists(
            covid_primary_care_code,
            covid_primary_care_positive_test,
            covid_primary_care_sequalae,
        ),
        returning="date",
        find_first_match_in_period=True,
        date_format="YYYY-MM-DD",
        return_expectations={"rate": "exponential_increase"},
    ),
    primary_care_historic_case=patients.with_these_clinical_events(
        combine_codelists(
            covid_primary_care_historic_case,
            covid_primary_care_potential_historic_case,
        ),
        returning="date",
        date_format="YYYY-MM-DD",
        find_first_match_in_period=True,
            },
            "incidence": 0.95,
        },
    ),

    # CANCER - 3 TYPES
    cancer_haem=patients.with_these_clinical_events(
        haem_cancer_codes,
        return_first_date_in_period=True,
        include_month=True,
        return_expectations={"date": {
            "latest": "2019-01-31"
        }},
    ),
    cancer_nonhaem=patients.with_these_clinical_events(
        combine_codelists(lung_cancer_codes, other_cancer_codes),
        return_first_date_in_period=True,
        include_month=True,
        return_expectations={"date": {
            "latest": "2019-01-31"
        }},
    ),

    #### PERMANENT
    permanent_immunodeficiency=patients.with_these_clinical_events(
        combine_codelists(hiv_codes, permanent_immune_codes,
                          sickle_cell_codes),
        on_or_before="2019-01-31",
        return_last_date_in_period=True,
        include_month=True,
        return_expectations={"date": {
Exemplo n.º 3
0
 ),
 covid_icu_date=patients.admitted_to_icu(
     on_or_after="2020-02-01",
     include_day=True,
     returning="date_admitted",
     find_first_match_in_period=True,
     return_expectations={
         "date": {
             "earliest": "2020-02-01"
         },
         "incidence": 0.8
     },
 ),
 covid_tpp_probable=patients.with_these_clinical_events(
     combine_codelists(
         covid_identification_in_primary_care_case_codes_clinical,
         covid_identification_in_primary_care_case_codes_test,
         covid_identification_in_primary_care_case_codes_seq),
     return_first_date_in_period=True,
     include_day=True,
     return_expectations={
         "date": {
             "earliest": "2020-02-01"
         },
         "incidence": 0.6
     },
 ),
 covid_admission_date=patients.admitted_to_hospital(
     returning="date_admitted",  # defaults to "binary_flag"
     with_these_diagnoses=covid_codelist,  # optional
     on_or_after="2020-02-01",
     find_first_match_in_period=True,
Exemplo n.º 4
0
         "latest": "2020-02-29"
     }},
 ),
 # CURRENT ASTHMA
 asthma=patients.with_these_clinical_events(
     current_asthma_codes,
     on_or_before="2020-02-29",
     return_first_date_in_period=True,
     include_month=True,
     return_expectations={"date": {
         "latest": "2020-02-29"
     }},
 ),
 # CANCER - 3 TYPES
 cancer=patients.with_these_clinical_events(
     combine_codelists(lung_cancer_codes, haem_cancer_codes,
                       other_cancer_codes),
     on_or_before="2020-02-29",
     return_first_date_in_period=True,
     include_month=True,
     return_expectations={"date": {
         "latest": "2020-02-29"
     }},
 ),
 # IMMUNOSUPPRESSION
 #### PERMANENT
 permanent_immunodeficiency=patients.with_these_clinical_events(
     combine_codelists(
         hiv_codes,
         permanent_immune_codes,
         sickle_cell_codes,
         organ_transplant_codes,
Exemplo n.º 5
0
 ),
 pneumococcal_vaccine=patients.satisfying(
     """
     pneumococcal_vaccine_tpp_table OR
     pneumococcal_vaccine_med OR
     pneumococcal_vaccine_clinical
     """, ),
 ### EXACERBATION
 # count
 exacerbation_count=patients.with_these_medications(
     oral_steroid_med_codes,
     between=["2019-03-01", "2020-02-29"],
     ignore_days_where_these_clinical_codes_occur=combine_codelists(
         sle_codes,
         interstital_lung_codes,
         ra_codes,
         ms_codes,
         temporal_arteritis_codes,
     ),
     returning="number_of_episodes",
     episode_defined_as="series of events each <= 14 days apart",
     return_expectations={
         "int": {
             "distribution": "normal",
             "mean": 2,
             "stddev": 1
         },
         "incidence": 0.2,
     },
 ),
 # # binary flag
Exemplo n.º 6
0
     },
 ),
 ### STATIN USE
 statin=patients.with_these_medications(
     statin_med_codes,
     between=["2019-11-01", "2020-02-29"],
     return_last_date_in_period=True,
     include_month=True,
     return_expectations={
         "date": {"earliest": "2019-11-01", "latest": "2020-02-29"}
     },
 ),
 ### EXACERBATIONS
 ## count
 exacerbation_count=patients.with_these_clinical_events(
     combine_codelists(copd_infection_codes, lrti_codes),
     between=["2019-03-01", "2020-02-29"],
     ignore_days_where_these_codes_occur=copd_review_rescue_codes,
     returning="number_of_episodes",
     episode_defined_as="series of events each <= 14 days apart",
     return_expectations={
         "int": {"distribution": "normal", "mean": 4, "stddev": 2},
         "incidence": 0.2,
     },
 ),
 # binary flag
 exacerbations=patients.satisfying(
     """
     exacerbation_count > 0
     """,
 ),
Exemplo n.º 7
0
        on_or_after="2020-02-01",
        returning="date_of_death",
        include_month=True,
        include_day=True,
        return_expectations={
            "date": {
                "earliest": "2020-08-01"
            },
            "incidence": 0.5
        },
    ),

    ### Primary care COVID cases
    covid_tpp_probable=patients.with_these_clinical_events(
        combine_codelists(
            covid_identification_in_primary_care_case_codes_clinical,
            covid_identification_in_primary_care_case_codes_test,
            covid_identification_in_primary_care_case_codes_seq),
        return_first_date_in_period=True,
        include_day=True,
        return_expectations={
            "date": {
                "earliest": "2020-10-20"
            },
            "incidence": 0.2
        },
    ),

    # Any COVID vaccination (first dose)
    covid_vacc_date=patients.with_tpp_vaccination_record(
        target_disease_matches="SARS-2 CORONAVIRUS",
        on_or_after="2020-12-01",  # check all december to date