"E": """
              most_recent_smoking_code = 'E' OR (
                most_recent_smoking_code = 'N' AND ever_smoked
              )
         """,
         "N": "most_recent_smoking_code = 'N' AND NOT ever_smoked",
         "M": "DEFAULT"
     },
     most_recent_smoking_code=patients.with_these_clinical_events(
         clear_smoking_codes,
         find_last_match_in_period=True,
         on_or_before='2020-02-01',
         returning="category",
     ),
     ever_smoked=patients.with_these_clinical_events(
         filter_codes_by_category(clear_smoking_codes, include=['S', 'E']),
         on_or_before='2020-02-01'
     ),
 ),
 smoking_status_date=patients.with_these_clinical_events(
     clear_smoking_codes,
     on_or_before='2020-02-01',
     return_last_date_in_period=True,
     include_month=True,
 ),
 most_recent_unclear_smoking_cat=patients.with_these_clinical_events(
     unclear_smoking_codes,
     find_last_match_in_period=True,
     on_or_before='2020-02-01',
     returning="category",
 ),
Exemple #2
0
             "ratios": {
                 "S": 0.6,
                 "E": 0.1,
                 "N": 0.2,
                 "M": 0.1
             }
         }
     },
     most_recent_smoking_code=patients.with_these_clinical_events(
         clear_smoking_codes,
         find_last_match_in_period=True,
         on_or_before="2020-02-29",
         returning="category",
     ),
     ever_smoked=patients.with_these_clinical_events(
         filter_codes_by_category(clear_smoking_codes, include=["S", "E"]),
         on_or_before="2020-02-29",
     ),
 ),
 smoking_status_date=patients.with_these_clinical_events(
     clear_smoking_codes,
     on_or_before="2020-02-29",
     return_last_date_in_period=True,
     include_month=True,
     return_expectations={"date": {
         "latest": "2020-02-29"
     }},
 ),
 #### HIGH DOSE ICS
 high_dose_ics=patients.with_these_medications(
     high_dose_ics_med_codes,
def test_filter_codes_by_category():
    codes = codelist([("1", "A"), ("2", "B"), ("3", "A"), ("4", "C")], "ctv3")
    filtered = filter_codes_by_category(codes, include=["B", "C"])
    assert filtered.system == codes.system
    assert filtered == [("2", "B"), ("4", "C")]