Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TESTS] Overhauling Tutorial 1 by Adding Doctests #83

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
40 changes: 20 additions & 20 deletions docs/src/tutorials/beginner_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand All @@ -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)
```
Expand All @@ -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)
```

Expand All @@ -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)
```

Expand All @@ -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],
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DataFrames
using Dates
using Documenter
using FunSQL:
From,
Fun,
Expand All @@ -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

Expand Down
Loading