opensafely / vaccine-neuro-cohort

COVID vaccine neuro analyses - methodological extension using a cohort design
MIT License
0 stars 0 forks source link

Notes for first PR #3

Closed annaschultze closed 11 months ago

annaschultze commented 2 years ago

Need to double check with Caroline that current method of indicating a non missing value is acceptable, i.e,

image

in above code, does first_known_vaccine_date need to be a boolean, or can it be a date? what is the most efficient way of specifying this?

annaschultze commented 2 years ago

@CarolineMorton sorry I forgot to tag you in this and coming back to it now, but was wondering if I could ask your advice on the above question. Essentially, I'm extracting a vaccine date and I want to restrict the study population to only those vaccinated. The vaccine date is created like below, and then I attempted to create a binary yes no variable like this:

    # first ever vaccine date 
    first_known_vaccine_date=patients.minimum_of("first_moderna_date", "first_az_date", "first_pfizer_date"), 

    # ever vaccinated yes or no
    has_first_known_vaccine=patients.satisfying(
        """first_known_vaccine_date""",
        return_expectations={"incidence": 0.99},
    ),

I then specified the study population as attached:

     # select the study population
    population=patients.satisfying(
        """
        (age >= 18 AND age < 105) 
        AND (sex = "M" OR sex = "F") 
        AND known_care_home 
        AND imd > 0 
        AND has_baseline_time 
        AND has_first_known_vaccine 
        AND NOT has_died 
        AND NOT pregnancy 
        """,
    ),

I can't tell whether this will do what I expect or not - it seems to in dummy data, but would you be able to advice? Thank you in advance!!

CarolineMorton commented 2 years ago

This looks right to me. I am expecting if there is a date from the vaccine date query to produce a boolean when passed to the .satisying() arg.

I totally missed your first comment as not tagged so apologies in the long delay in getting back to you on this.

annaschultze commented 2 years ago

Hi @CarolineMorton - thank you so much! I'll include some "sense checks" in the code to double check this, but was worried about it taking way longer to run during the matching if not.

And it was definitely me forgetting this not you - I initially made this as a note to myself but had to move to other projects for a while, and only came back to it now. So no delay at all. Thank you so much!!!