Skip to content

Allow date exclusion variables within a range #75

@annaschultze

Description

@annaschultze

Two things that might eventually be nice to include (but are currently not hindering any projects, so are really not urgent):

  • Matching on time-updated variables. At the moment, matching on something like STP is imprecise with dynamic index dates because whilst this can be extracted on the index dates for the cases, it can only be extracted at some fixed date for controls. Although you could use the same fixed date for cases and controls, this might lead to discrepancies on the actual index date. It would be really nice to be able to match based on STP derived at the case index date for both cases and controls. Appreciate that's likely very complex to implement. For geographical attributes it's also unlikely to make a large difference, but there may be future use cases where you want to match on something like some lab value at the case index dates. A workaround for something like STP would be to matched based on some fix date, re-extract STP after matching using patients.with_value_from_file, and then exclude all cases + all their controls if case STP is different, and just the individual control if control STP is different (assuming we've matched to more than one control per case).
  • Allow date exclusion variables within a range. date_exclusion_variables currently supports before and after, it would be really nice to add between. An example here is that we want to exclude patients that are pregnant within 274 days of the case index dates from the pool of potential control, but not those that are pregnant ever before. Essentially what would be useful is:
match(
    case_csv="input_covid",
    match_csv="input_pneumonia",
    matches_per_case=1,
    match_variables={
        "sex": "category",
        "age": 1,
    },
    index_date_variable="indexdate",
    date_exclusion_variables={
        "pregnancy": "between["indexdate - 274 days", indexdate"]" 
    },
    output_suffix="_pneumonia",
    output_path="test_data",
)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions