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 New Function `GetDrugExposureEndDate` #69

Closed TheCedarPrince closed 5 months ago

TheCedarPrince commented 5 months ago

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

function GetDrugExposureEndDate(
    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_end_date) |>
        q -> render(q, dialect=dialect)

    return String(sql)

end

function GetDrugExposureEndDate(
    drug_exposure_ids,
    conn;
    tab = drug_exposure 
)

    df = DBInterface.execute(conn, GetDrugExposureEndDate(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!

Jay-sanjay commented 5 months ago

closed with #71