def test_make_df_from_expectations_with_deregistration_date():
    study = StudyDefinition(
        population=patients.all(),
        dereg_date=patients.date_deregistered_from_all_supported_practices(
            on_or_before="2018-02-01",
            date_format="YYYY-MM",
            return_expectations={
                "incidence": 0.1,
                "date": {
                    "earliest": "1980-01-01",
                    "latest": "2018-02-01"
                },
            },
        ),
    )
    population_size = 1000
    result = study.make_df_from_expectations(population_size)
    dates = result.dereg_date.dropna()
    assert dates.max() <= "2018-02"
    assert dates.min() >= "1980-01"
study = StudyDefinition(
    default_expectations={
        "date": {
            "earliest": "1970-01-01",
            "latest": "today"
        },
        "rate": "uniform",
        "incidence": 0.2,
    },

    # STUDY POPULATION
    # This line defines the study population
    population=patients.registered_with_one_practice_between(
        "2018-11-01", "2019-02-01"),
    dereg_date=patients.date_deregistered_from_all_supported_practices(
        on_or_after="2020-02-01",
        date_format="YYYY-MM",
    ),

    # OUTCOMES
    worms=patients.with_these_clinical_events(
        worms_codes,
        return_first_date_in_period=True,
        include_month=True,
        return_expectations={"date": {
            "earliest": "2019-02-01"
        }},
    ),
    died_date_ons=patients.died_from_any_cause(
        on_or_before="2020-08-01",
        returning="date_of_death",
        include_month=True,
Пример #3
0
study = StudyDefinition(

  default_expectations = {
    "date": {"earliest": "1970-01-01", "latest": "today"}, # date range for simulation
    "rate": "uniform",
    "incidence": 0.2
  },

  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"}},
    ),

  # DEMOGRAPHIC COVARIATES
  # AGE
  age = patients.age_as_of(
    "today",
    return_expectations = {
      "rate": "universal",
      "int": {"distribution": "population_ages"},
    }
  ),

  # SEX
  sex = patients.sex(return_expectations={