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] Mitigate Boilerplate for `GenerateDatabaseDetails` #50

Open TheCedarPrince opened 1 year ago

TheCedarPrince commented 1 year ago

Currently, GenerateDatabaseDetails is a bespoke boilerplate function that could be significantly simplified. I think what we could do is break up the function as it stands like this:

import HealthSampleData: Eunomia
import SQLite: DB
import OMOPCDMCohortCreator as occ

eunomia = Eunomia()

conn = DB(eunomia)

occ.GenerateDatabaseDetails(
    :sqlite,
    "main"
)

occ.GenerateTables(conn)

Into something like this:

import HealthSampleData: Eunomia
import DBConnector: DBConnect
import OMOPCDMCohortCreator as occ

eunomia = Eunomia()

occ.GenerateDatabaseDetails(conn = DBConnect(eunomia), schema = "main")

Basically, the function GenerateDatabaseDetails should accept as an object a DBConnect object that comes from DBConnector.jl. This object should contain information about the type of connection that was made (was it a sqlite connection? PostgreSQL connection?) and GenerateDatabaseDetails should then be able to internally set the flavor of SQL being used. Additionally, GenerateTables can be deprecated -- I'll detail that in another issue.

However, GenerateDatabaseDetails can still provide additional arguments like schema, SQL_type, etc in case someone needs additional configuration options in the future. But in my mind, this reduces complexity significantly.

TheCedarPrince commented 12 months ago

After all the work we have done within DBConnector.jl @Farreeda , I think we will be able to pursue something like this but it depends on https://github.com/JuliaDatabases/DBConnector.jl/pull/8 and https://github.com/JuliaDatabases/DBConnector.jl/pull/7 being done and also some cleaning up of the repository.