JuliaHealth / OMOPCDMCohortCreator.jl

Create cohorts from databases utilizing the OMOP CDM
https://juliahealth.org/OMOPCDMCohortCreator.jl/stable
Other
8 stars 7 forks source link

[FEATURE] Add Function `GetVisitDate` #44

Closed TheCedarPrince closed 1 year ago

TheCedarPrince commented 1 year ago

I was tinkering with the Mental Health Equity study code today, and realized in creating one of our cohorts, we need a function called GetVisitDate that does the following:

  1. Accepts either a single visit_occurrence_id or a list of visit_occurrence_id's
  2. Contains a kwarg to query either for the visit_start_date or visit_end_date (I would do something like: interval = :start for visit_start_date and interval=:end for visit_end_date)
  3. Queries a given database for each visit_occurrence_id given to the function and finds its associated interval in the visit occurrence.
  4. Returns a dataframe that has two columns for the visit_occurrence_id and the requested date for the second column named eithervisit_start_dateorvisit_end_date`
  5. Add tests for this

Could you get to this asap @VarshC ? Thanks! :smile:

TheCedarPrince commented 1 year ago

Here's a very loose description of the function's docstring:

"""
GetVisitDate(visit_occurrence_id; interval::Symbol = :start, tab = visit_occurrence)

This function queries a database for the start or end date of the visit occurrence associated with the given `visit_occurrence_id` or list of `visit_occurrence_id`'s.

# Arguments:
- `visit_occurrence_id`: A single `visit_occurrence_id` or a vector of `visit_occurrence_id`'s to query for.
- `interval`: A keyword argument that determines whether to query for the visit start date (`interval=:start`) or the visit end date (`interval=:end`). Default value is `interval=:start`.

# Returns:
A dataframe with two columns: `visit_occurrence_id` and either `visit_start_date` or `visit_end_date`, depending on the value of the `interval` argument.
TheCedarPrince commented 1 year ago

Thanks @VarshC for adding this feature!