diff --git a/docs/Project.toml b/docs/Project.toml index c49adf0..16b78bf 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,4 +1,6 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8" +HealthSampleData = "b8464e9a-ae38-46a4-977b-86f00930f698" OMOPCDMCohortCreator = "f525a15e-a73f-4eef-870f-f901257eae22" +SQLite = "0aa819cd-b072-5ff4-a722-6bc24af294d9" diff --git a/docs/src/tutorials/beginner_tutorial.md b/docs/src/tutorials/beginner_tutorial.md index d916f97..43d4712 100644 --- a/docs/src/tutorials/beginner_tutorial.md +++ b/docs/src/tutorials/beginner_tutorial.md @@ -34,44 +34,44 @@ To learn more about these packages, see the [Appendix](#appendix). For this tutorial, we will work with data from [Eunomia](https://github.com/OHDSI/Eunomia) that is stored in a SQLite format. To install the data on your machine, execute the following code block and follow the prompts - you will need a stable internet connection for the download to complete: -```julia -import HealthSampleData: Eunomia +```jldoctest doctest-scope +julia> import HealthSampleData: Eunomia -eunomia = Eunomia() +julia> eunomia = Eunomia(); +[ Info: Eunomia data source is downloaded! ``` ## Connecting to the Eunomia Database 💾 After you have finished your set up in the Julia, we need to establish a connection to the Eunomia SQLite database that we will use for the rest of the tutorial: -```julia -import SQLite: DB +```jldoctest doctest-scope +julia> import SQLite: DB -conn = DB(eunomia) +julia> conn = DB(eunomia); ``` With Eunomia, the database's schema is simply called "main". We will use this to generate database connection details that will inform `OMOPCDMCohortCreator` about the type of queries we will write (i.e. SQLite) and the name of the database's schema. For this step, we will use `OMOPCDMCohortCreator`: -```julia -import OMOPCDMCohortCreator as occ +```jldoctest doctest-scope +julia> import OMOPCDMCohortCreator as occ -occ.GenerateDatabaseDetails( - :sqlite, - "main" -) +julia> occ.GenerateDatabaseDetails(:sqlite, "main"); +[ Info: Global database dialect set to: sqlite +[ Info: Global schema set to: main ``` Finally, we will generate internal representations of each table found within Eunomia for OMOPCDMCohortCreator to use: -```julia +```jldoctest doctest-scope occ.GenerateTables(conn) ``` As a check to make sure everything was correctly installed and works properly, the following block should work and return a list of all person ids in this data: -```julia +```jldoctest doctest-scope occ.GetDatabasePersonIDs(conn) ``` @@ -91,12 +91,12 @@ Using the [API](@ref), find all patients with strep throat. Suggested solution: -```julia +```jldoctest doctest-scope strep_patients = occ.ConditionFilterPersonIDs(28060, conn) ``` Note: This function can accept more than one condition_concept_id. Example: -``` +```julia concept_ids = [28060, 433037, 372654, 443599, 436519] patients = occ.ConditionFilterPersonIDs(concept_ids, conn) ``` @@ -107,7 +107,7 @@ For the patients who have strep throat diagnoses, find their race. Suggested solution: -```julia +```jldoctest doctest-scope strep_patients_race = occ.GetPatientRace(strep_patients.person_id, conn) ``` @@ -117,7 +117,7 @@ For the patients who have strep throat diagnoses, find their gender. Suggested solution: -```julia +```jldoctest doctest-scope strep_patients_gender = occ.GetPatientGender(strep_patients.person_id, conn) ``` @@ -128,7 +128,7 @@ The age groupings must follow $5$ year intervals when assigned to a person up to Suggested solution: -```julia +```jldoctest doctest-scope age_groups = [ [0, 4], [5, 9], @@ -162,7 +162,7 @@ Hint: The DataFrames.jl [documentation section on joins](https://dataframes.juli Suggested solution: -```julia +```jldoctest doctest-scope import DataFrames as DF strep_patients_characterized = DF.outerjoin(strep_patients_race, strep_patients_gender, strep_patients_age_group; on = :person_id, matchmissing = :equal) diff --git a/test/Project.toml b/test/Project.toml index be3edb0..844678d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,6 +2,7 @@ DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" FunSQL = "cf6cc811-59f4-4a10-b258-a8547a8f6407" HealthSampleData = "b8464e9a-ae38-46a4-977b-86f00930f698" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" diff --git a/test/runtests.jl b/test/runtests.jl index bc08b0b..6f96f8d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,6 @@ using DataFrames using Dates +using Documenter using FunSQL: From, Fun, @@ -22,6 +23,9 @@ using OHDSICohortExpressions: translate, Model import DBInterface as DBI +# Testing doctests within the documentation +doctest(OMOPCDMCohortCreator) + # For allowing HealthSampleData to always download sample data ENV["DATADEPS_ALWAYS_ACCEPT"] = true