"date": { "earliest": "2020-01-01", "latest": "today" }, "rate": "universal", }, # define the study index date index_date=index_date, # This line defines the study population population=patients.satisfying( "(NOT died) AND (registered) AND (pregnant) AND age >= 16", died=patients.died_from_any_cause(on_or_before=index_date, returning="binary_flag"), registered=patients.registered_as_of(index_date), pregnant=patients.with_these_clinical_events( pregnant_code, between=["index_date", "index_date + 1 month"], returning="binary_flag", return_expectations={"incidence": 0.6}, ), ), age=patients.age_as_of(index_date, return_expectations={ "rate": "universal", "int": { "distribution": "population_ages" } }), clinical_riskgroup=patients.with_these_clinical_events(
## LIBRARIES - simple study definitions # cohort extractor from cohortextractor import (StudyDefinition, patients) # dictionaries of STP codes (for dummy data) from dictionaries import dict_stp # set the index date index_date = "2020-01-01" ## STUDY POPULATION study = StudyDefinition( default_expectations={ "date": { "earliest": index_date, "latest": "today" }, # date range for simulation "rate": "uniform", "incidence": 1 }, population=patients.registered_as_of(index_date), stp=patients.registered_practice_as_of(index_date, returning="stp_code", return_expectations={ "category": { "ratios": dict_stp }, }))
from datetime import date from cohortextractor import StudyDefinition, patients today = str(date.today()) study = StudyDefinition( default_expectations={ "date": { "earliest": "1900-01-01", "latest": "today" }, "rate": "exponential_increase", }, population=patients.registered_as_of(today), imd=patients.address_as_of( today, returning="index_of_multiple_deprivation", round_to_nearest=100, return_expectations={ "incidence": 0.8, "category": { "ratios": {100 * (n + 1): 1 / 330 for n in range(330)} }, }, ), )
"date": { "earliest": start_date, "latest": end_date }, "rate": "exponential_increase", "incidence": 0.1, }, population=patients.satisfying( """ registered AND (NOT died) AND (sex = 'F' OR sex='M') AND (age != 'missing') """, registered=patients.registered_as_of( "index_date", return_expectations={"incidence": 0.9}, ), died=patients.died_from_any_cause( on_or_before="index_date", returning="binary_flag", return_expectations={"incidence": 0.1}), ), age=patients.age_as_of( "index_date", return_expectations={ "rate": "universal", "int": { "distribution": "population_ages" }, }, ),
"incidence": 0.2, }, # set an index date (as starting point) index_date="2020-02-01", # This line defines the study population that the below varaibles will be defined for # currently registered patients restricts to those alive # the age restriction is applied as current TPP linkage only includes linkages to old age care population=patients.satisfying( """ (age >= 65 AND age < 120) AND is_registered_with_tpp """, is_registered_with_tpp=patients.registered_as_of( "index_date" ), ), # TPP ADDRESS LINKAGE # tpp defined care home as of date tpp_care_home_type=patients.care_home_status_as_of( "index_date", categorised_as={ "PC": """ IsPotentialCareHome AND LocationDoesNotRequireNursing='Y' AND LocationRequiresNursing='N' """, "PN": """ IsPotentialCareHome
(covid_vacc_date OR (age >=70 AND age <= 110) OR (care_home_type)) AND NOT has_died """), has_follow_up=patients.registered_with_one_practice_between( start_date="2019-12-01", end_date=campaign_start, return_expectations={"incidence": 0.90}, ), registered=patients.registered_as_of( campaign_start, # day before vaccination campaign starts - discuss with team if this should be "today" return_expectations={"incidence": 0.98}, ), has_died=patients.died_from_any_cause( on_or_before=campaign_start, returning="binary_flag", return_expectations={"incidence": 0.05}, ), # Demographic information # CAREHOME STATUS care_home_type=patients.care_home_status_as_of( campaign_start, categorised_as={ "PC": """ IsPotentialCareHome
# Import codelists from codelists import * from datetime import date start_date = "2020-12-07" end_date = "2021-02-01" # Specifiy study definition study = StudyDefinition( default_expectations={ "date": {"earliest": start_date, "latest": end_date}, "rate": "exponential_increase", "incidence": 0.1, }, population=patients.registered_as_of(start_date), practice=patients.registered_practice_as_of( start_date, returning="pseudo_id", return_expectations={ "int": {"distribution": "normal", "mean": 25, "stddev": 5}, "incidence": 0.5} ), )