JuliaHealth / OMOPCDMCohortCreator.jl

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

[FEATURE] Add New Function `GetDrugExposureStartDate` #68

Closed TheCedarPrince closed 8 months ago

TheCedarPrince commented 9 months ago

The following code gets the start dates associated with a particular drug exposure:

function GetDrugExposureStartDate(
    drug_exposure_ids;
    tab = drug_exposure
)

    sql =
        From(tab) |>
        Where(Fun.in(Get.drug_exposure_id, drug_exposure_ids...)) |>
        Select(Get.drug_exposure_id, Get.drug_exposure_start_date) |>
        q -> render(q, dialect=dialect)

    return String(sql)

end

function GetDrugExposureStartDate(
    drug_exposure_ids,
    conn;
    tab = drug_exposure 
)

    df = DBInterface.execute(conn, GetDrugExposureStartDate(drug_exposure_ids; tab=tab)) |> DataFrame

    return df
end

I just haven't had the time yet to add this code into CohortCreator as a new feature. Would be nice to add it in. The implementation is exactly the same as PR #59 and requires a bit more documentation, tests, and a dispatch for DataFrames.

A great issue for beginners and to get started!

nitverse commented 9 months ago

Can You Assign it to me? Or Should I directly raise the PR

TheCedarPrince commented 8 months ago

Hey @nitverse -- thanks for your interest and trying out making a new PR! I commented over on the PR; happy to help more with it! Cheers! :deciduous_tree:

P.S. Also, welcome to JuliaHealth! Have you joined the Julia Slack? I haven't seen you around in the #health-and-medicine channel yet. We'd love to have you!