diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..92faf3b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug Report +about: Create an error or bug report to help us improve +title: '[BUG]: Title of the Error You Encountered' +labels: bug +assignees: '' + +--- + +**Before Filing a Report** + +- Did I look through the [documentation](https://juliahealth.org/OMOPCDMPathways.jl/)? + +- Did I search the [OMOPCDMPathways.jl GitHub Issues](https://github.com/JuliaHealth/OMOPCDMPathways.jl/issues?q=is%3Aissue+sort%3Aupdated-desc+) to see if this bug has already been reported? + +- Do I have the latest version of [OMOPCDMPathways.jl](https://github.com/JuliaHealth/OMOPCDMPathways.jl/releases) installed? + +**Describe the Bug or Error** + +A clear and concise description of what the bug is. + +**How To Reproduce the Bug or Error** + +1. Julia Version (i.e. output of `julia -v`): + +2. Operating system (Mac, Linux, Windows): + +3. OMOPCDMPathways.jl version (i.e output of `] status OMOPCDMPathways` in the Julia REPL) + +4. Minimum working code example that led to bug: + +**Expected Behavior and Actual Behavior** + +A clear and concise description of what you expected to happen followed up with an explanation of what actually happened. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..92f7b42 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,25 @@ +--- +name: Feature Request +about: Suggest a new feature for this package +title: '[FEATURE REQUEST]: Title for Your Request' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please explain.** + +A clear and concise description of what the problem is. (Examples: "I'm always frustrated when [...]", "I did not expect this function to do [...]") + +**Describe the solution you'd like** + +- A clear and concise description of what you would like to do +- How you imagine the package could support this +- An example of how you see using this feature + +**Describe alternatives you've considered** + +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context (blogs, papers, videos) or screenshots about the feature request here. diff --git a/Project.toml b/Project.toml index 853b24c..366af6d 100644 --- a/Project.toml +++ b/Project.toml @@ -4,14 +4,14 @@ authors = ["Jay-sanjay and contributors"] version = "0.0.1" [deps] -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365" -LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589" +DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +FunSQL = "cf6cc811-59f4-4a10-b258-a8547a8f6407" +OMOPCDMCohortCreator = "f525a15e-a73f-4eef-870f-f901257eae22" +TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" [compat] -Documenter = "1" -DocumenterVitepress = "0.0.19, 0.0.20" -LiveServer = "1" julia = "1.6" [extras] diff --git a/docs/Project.toml b/docs/Project.toml index 0ddbea2..dafbc65 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,4 +1,8 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365" +LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589" OMOPCDMPathways = "413b2380-0cee-426e-ad22-874d5a2600da" + +[compat] +DocumenterVitepress = "0.0.19" diff --git a/docs/make.jl b/docs/make.jl index 5d5101c..8461124 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,15 +6,16 @@ DocMeta.setdocmeta!(OMOPCDMPathways, :DocTestSetup, :(using OMOPCDMPathways); re pgs=[ "Home" => "index.md", - "Tutorials" => "tutorials.md", + "Tutorials" => [ + "Tutorials" => "tutorials.md", + "Beginner Tutorial 🐣" => "beginner_tutorial.md", + ], "Api" => "api.md", "Contributing" => "contributing.md" ] fmt = DocumenterVitepress.MarkdownVitepress( repo="https://github.com/JuliaHealth/OMOPCDMPathways.jl", - devbranch = "main", - devurl = "dev" ) makedocs(; @@ -24,11 +25,6 @@ makedocs(; sitename = "OMOPCDMPathways.jl", format = fmt, pages = pgs, - warnonly = true, - draft = false, - source = "src", - build = "build", - checkdocs=:all ) deploydocs(; diff --git a/docs/src/assets/favicon.ico b/docs/src/assets/favicon.ico new file mode 100644 index 0000000..54dfe90 Binary files /dev/null and b/docs/src/assets/favicon.ico differ diff --git a/docs/src/assets/logo.png b/docs/src/assets/logo.png new file mode 100644 index 0000000..f1d8243 Binary files /dev/null and b/docs/src/assets/logo.png differ diff --git a/docs/src/beginner_tutorial.md b/docs/src/beginner_tutorial.md new file mode 100644 index 0000000..c29cd43 --- /dev/null +++ b/docs/src/beginner_tutorial.md @@ -0,0 +1,3 @@ +# Beginner Tutorial 🐣 + +> NOTE: Tutorials are forthcoming and will be made available soon! diff --git a/docs/src/contributing.md b/docs/src/contributing.md index d5307d7..2dba88b 100644 --- a/docs/src/contributing.md +++ b/docs/src/contributing.md @@ -1 +1,118 @@ -# Contributing to OMOPCDMPathways 😁 \ No newline at end of file +# Contributing to `OMOPCDMPathways.jl` 😁 + +`OMOPCDMPathways.jl` is currently under heavy development as we push to a primary release version. +We follow a workflow pattern that is directly inspired by the [development workflow guide](http://docs.juliaplots.org/latest/contributing/#Development-Workflow-1) found in [`Plots.jl`](https://github.com/JuliaPlots/Plots.jl). +The general workflow we expect contributors to adhere to is as follows: + +## 1. Create an Issue about the Problem πŸ“ + +If you want to [add functionality] or to work on a bug you found, open an issue first. Also, it is highly recommended to go through this [Bug Template](https://github.com/JuliaHealth/OMOPCDMPathways.jl/blob/dev/.github/ISSUE_TEMPLATE/bug_report.md) before filling a Bug and this [Feature Addition Template](https://github.com/JuliaHealth/OMOPCDMPathways.jl/blob/dev/.github/ISSUE_TEMPLATE/feature_request.md) before filling a Feature request. +That'll save you from doing work that we may not support for OMOPCDMPathways. + +## 2. Fork the repo to your account 🍴 + +A complete step-by-step procedure to fork any repository can be found [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) + +## 3. Create a branch based on what you are developing 🌳 + +Before making a branch, make sure to check that you are even with master via the following commands within your fork: + +```sh +git fetch origin +git checkout master +git merge --ff-only origin/main +``` + +> The `--ff-only` flag will "fast forward" to newer commits. It will not create new merge commits. + +Then, go ahead and create a branch that you could edit with the changes you want to see. +This is done by going into the root and typing: `git branch -b [name of your branch]` + +## 4. Test, code, and commit ✏️ + +Once you have a fork, it is useful to make sure the fork was successful. +To verify that everything is operational, let's test it. +The following procedure is as follows: + +1. Go into the root of your fork: + +`cd OMOPCDMPathways` + +2. Open your Julia REPL and type the following within the repo: +```julia +julia> ] +pkg> activate . +pkg> test +``` + +This might take some time, but if the installation on your computer is successful, it should say all tests passed. + +After making the changes you wanted to make, run the tests again to make sure you did not introduce any breaking changes. +If everything passed, we can continue on to the next step. +If not, it is the responsibility of the contributor to resolve any conflicts or failing tests. +Don't worry! +We're happy to help you resolve errors. πŸ˜„ +If you are stuck, go ahead and continue with this tutorial. + +The way we do this is in three steps: + +1. Add the files you have added or changed via `git add` + +2. After adding the files, we need to say what you did to the files (i.e. commit the files). This can be accomplished thusly: `git commit -m "your message"` + +3. Finally, let's push these changes to GitHub using `git push --set-upstream origin [name of the branch you made]` + +## 5. Submitting your changes to the main project βœ… + +Almost done! Go to your fork and there should be a section that asks you to make a pull request (PR) from your branch. This allows the maintainers of `OMOPCDMPathways.jl` to see if they can add your changes to the main project. If not, you can click the "New pull request" button. + +Make sure the "base" branch is `dev` and the "compare" branch is the branch on your fork. +To your PR, add an informative title and description, and link your PR to relevant issues or discussions. +Finally, click "Create pull request". + +You may get some questions about it, and possibly suggestions of how to make it ready to go into the main project. +If you had test errors or problems, we are happy to help you. +Then, if all goes according to plan, it gets merged... **Thanks for the contribution!!** πŸŽ‰ πŸŽ‰ πŸŽ‰ + +## Note on Adding Dependencies πŸ“š + +As a rule, we try to avoid having too many dependencies. +Therefore, we request that if you have a PR that adds a new dependency, please have opened an issue previously. + +### Adding Core Dependencies πŸ“’ + +If you are working on introducing a new core dependency, make sure to add that dependency to the main `Project.toml` for `OMOPCDMPathways.jl`. +To do this, follow these steps: + +1. Enter the root of the `OMOPCDMPathways` directory + +```sh +cd /path/to/OMOPCDMPathways.jl +``` + +2. Activate the `OMOPCDMPathways` environment and add the dependency: + +```julia +julia> ] +pkg> activate . +(OMOPCDMPathways) pkg> add [NAME OF DEPENDENCY] +``` + +### Adding Test Dependencies πŸ“‹ + +If you are introducing a new test dependency, make sure to add that dependency to the `Project.toml` located in the `OMOPCDMPathways` test directory. +To do this, follow these steps: + +1. Enter the test directory inside of the `OMOPCDMPathways` directory + +```sh +cd /path/to/OMOPCDMPathways.jl/test/ +``` + +2. Activate the `OMOPCDMPathways` test environment and add the dependency: + +```julia +julia> ] +pkg> activate . +(test) pkg> add [NAME OF DEPENDENCY] +``` diff --git a/docs/src/index.md b/docs/src/index.md index 1370759..14628f6 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,14 +1,21 @@ -```@meta -CurrentModule = OMOPCDMPathways -``` - # Welcome to the `OMOPCDMPathways.jl` Docs! πŸ‘‹ -Documentation for [OMOPCDMPathways](https://github.com/JuliaHealth/OMOPCDMPathways.jl). +> Find the pathways patients take while receiving care! + +This package allows one to extract the various pathways a patient could take while receiving treatments and care. +It expects patient data to be formatted within a database that adheres to the [OMOP Common Data Model](https://www.ohdsi.org/data-standardization/the-common-data-model/). + +**Here's how to get started with the package**: + +- Visit the [Tutorials](https://github.com/JuliaHealth/OMOPCDMPathways.jl/blob/main/docs/src/tutorials.md) section to see how this package can be used. + +- Check out the [API](https://github.com/JuliaHealth/OMOPCDMPathways.jl/blob/main/docs/src/api.md) section to see all the functions available. + +If you want to contribute, please check out our [Contributing](https://github.com/JuliaHealth/OMOPCDMPathways.jl/blob/main/docs/src/contributing.md) guide! -```@index -``` +## Why Research Patient Pathways? πŸ€” -```@autodocs -Modules = [OMOPCDMPathways] -``` +[Patient pathways outline](https://bmcpsychiatry.biomedcentral.com/articles/10.1186/s12888-019-2418-7) a patient’s care process, from initial contact to subsequent future patient and health provider interactions. +Understanding patient pathways is an active area of research within observational health studies as they give insight into combinations of drugs patients may be prescribed, duration of treatments, where care is received and overlaps with other treatment regimens patients may be receiving simultaneously. +This package provides a generalized methodology to interrogate patient care evolution in OMOP CDM database settings to further motivate the investigation of questions in health economics (such as costs of care), pharmacovigilance, access to care, and observational health research. +By analyzing these pathways, researchers can identify patterns, assess adherence to treatment, identify gaps in care, optimize resource allocation, and potentially improve patient outcomes and the quality of healthcare delivery. diff --git a/src/OMOPCDMPathways.jl b/src/OMOPCDMPathways.jl index 7fa9905..3823d00 100644 --- a/src/OMOPCDMPathways.jl +++ b/src/OMOPCDMPathways.jl @@ -1,10 +1,44 @@ module OMOPCDMPathways + using DataFrames + using Dates + using DBInterface + using FunSQL: + SQLTable, + Agg, + As, + Define, + From, + Fun, + Get, + Group, + Join, + Order, + Select, + WithExternal, + Where, + render, + Limit, + ID, + LeftJoin, + reflect + using TimeZones -# Write your package code here. -function hello() - "world" -end -export hello + using OMOPCDMCohortCreator + + function MakeTables(conn, dialect, schema) + + @eval global dialect = $(QuoteNode(dialect)) + GenerateDatabaseDetails(dialect, schema) + db_info = GenerateTables(conn, inplace = false, exported = true) + for key in keys(db_info) + @eval global $(Symbol(lowercase(string(key)))) = $(db_info[key]) + @info "$(lowercase(string(key))) table generated internally" + end + + end + + export MakeTables +include("preprocessing.jl") end diff --git a/src/preprocessing.jl b/src/preprocessing.jl new file mode 100644 index 0000000..f884243 --- /dev/null +++ b/src/preprocessing.jl @@ -0,0 +1,29 @@ +using Dates + +function Dummy( + drug_exposure_ids, + conn; + tab = drug_exposure +) + + df = DBInterface.execute(conn, Dummy(drug_exposure_ids; tab=tab)) |> DataFrame + + return df +end + +function Dummy( + 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 + +export Dummy diff --git a/test/Data-Preprocessing/preprocessing.jl b/test/Data-Preprocessing/preprocessing.jl new file mode 100644 index 0000000..3512462 --- /dev/null +++ b/test/Data-Preprocessing/preprocessing.jl @@ -0,0 +1,13 @@ +using Test + +@testset "Dummy Tests" begin + MakeTables(sqlite_conn, :sqlite, "main") + test_drug_exposure_ids = [1.0, 2.0, 3.0, 4.0] + test_drug_exposure_start_date = [-3.727296e8, 2.90304e7, -5.333472e8, -8.18208e7] + test_df1 = DataFrame(drug_exposure_id = test_drug_exposure_ids, drug_exposure_start_date = test_drug_exposure_start_date) + result = Dummy(test_drug_exposure_ids, sqlite_conn) + + @test test_drug_exposure_start_date == result.drug_exposure_start_date[1:4] + @test test_drug_exposure_ids == result.drug_exposure_id[1:4] + +end \ No newline at end of file diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 0000000..2061d6e --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,12 @@ +[deps] +DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +FunSQL = "cf6cc811-59f4-4a10-b258-a8547a8f6407" +HealthSampleData = "b8464e9a-ae38-46a4-977b-86f00930f698" +JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" +OHDSICohortExpressions = "b1469e29-13af-4897-a4a9-3c363a260582" +OMOPCDMCohortCreator = "f525a15e-a73f-4eef-870f-f901257eae22" +SQLite = "0aa819cd-b072-5ff4-a722-6bc24af294d9" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" diff --git a/test/runtests.jl b/test/runtests.jl index ae834ac..e6702eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,39 @@ using OMOPCDMPathways +using DataFrames +using Dates +using FunSQL: + From, + Fun, + Get, + Where, + Group, + Limit, + Select, + render, + Agg, + LeftJoin +using HealthSampleData +using OMOPCDMCohortCreator +using SQLite using Test +using TimeZones -@testset "OMOPCDMPathways.jl" begin - # Write your tests here. - @test hello() == "world" - +using JSON3 +using OHDSICohortExpressions: translate, Model + +import DBInterface as DBI + +# For allowing HealthSampleData to always download sample data +ENV["DATADEPS_ALWAYS_ACCEPT"] = true + +# SQLite Data Source +sqlite_conn = SQLite.DB(Eunomia()) +GenerateDatabaseDetails(:sqlite, "main") +GenerateTables(sqlite_conn) + +@testset "OMOPCDMPathways" begin + @testset "Data-Preprocessing" begin + include("Data-Preprocessing/preprocessing.jl") + end end +