├── .Rbuildignore
├── .github
├── .gitignore
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── R-CMD-check.yaml
│ ├── pkgdown.yaml
│ └── test-coverage.yaml
├── .gitignore
├── CRAN-SUBMISSION
├── CodelistGenerator.Rproj
├── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── NAMESPACE
├── NEWS.md
├── R
├── CodelistFromCodelistWithDetails.R
├── CodelistGenerator-package.R
├── buildAchillesTables.R
├── checks.R
├── codesFromConceptSet.R
├── codesInUse.R
├── compareCodelists.R
├── documentation_helper.R
├── drugCodes.R
├── getCandidateCodes.R
├── getDoseUnit.R
├── getICD10StandardCodes.R
├── getMappings.R
├── getRoutes.R
├── helperFunctions.R
├── mockVocabRef.R
├── reexports.R
├── runSearch.R
├── stratifyByConcept.R
├── stratifyByDoseUnit.R
├── stratifyByRoute.R
├── subsetOnDomain.R
├── subsetOnDoseUnit.R
├── subsetOnRouteCategory.R
├── summariseAchillesCodeUse.R
├── summariseCodeUse.R
├── summariseOrphanCodes.R
├── summariseUnmappedCodes.R
├── sysdata.rda
├── tableAchillesCodeUse.R
├── tableCodeUse.R
├── tableUnmappedCodes.R
└── vocabUtilities.R
├── README.Rmd
├── README.md
├── _pkgdown.yml
├── codecov.yml
├── cran-comments.md
├── data-raw
├── dose_form_to_route.csv
└── internalData.R
├── docs
├── 404.html
├── LICENSE-text.html
├── LICENSE.html
├── README.knit.html
├── articles
│ ├── Introduction_to_CodelistGenerator.html
│ ├── Introduction_to_CodelistGenerator_files
│ │ ├── crosstalk-1.2.0
│ │ │ ├── css
│ │ │ │ └── crosstalk.min.css
│ │ │ ├── js
│ │ │ │ ├── crosstalk.js
│ │ │ │ ├── crosstalk.js.map
│ │ │ │ ├── crosstalk.min.js
│ │ │ │ └── crosstalk.min.js.map
│ │ │ └── scss
│ │ │ │ └── crosstalk.scss
│ │ ├── datatables-binding-0.21
│ │ │ └── datatables.js
│ │ ├── datatables-css-0.0.0
│ │ │ └── datatables-crosstalk.css
│ │ ├── dt-core-1.11.3
│ │ │ ├── css
│ │ │ │ ├── jquery.dataTables.extra.css
│ │ │ │ └── jquery.dataTables.min.css
│ │ │ └── js
│ │ │ │ └── jquery.dataTables.min.js
│ │ └── htmlwidgets-1.5.4
│ │ │ └── htmlwidgets.js
│ └── index.html
├── authors.html
├── bootstrap-toc.css
├── bootstrap-toc.js
├── docsearch.css
├── docsearch.js
├── index.html
├── link.svg
├── pkgdown.css
├── pkgdown.js
├── pkgdown.yml
├── reference
│ ├── Rplot001.png
│ ├── clean_words.html
│ ├── figures
│ │ └── README-pressure-1.png
│ ├── get_candidate_codes.html
│ ├── index.html
│ └── show_mappings.html
└── sitemap.xml
├── inst
├── WORDLIST
├── cohorts_for_mock
│ ├── oa_desc.json
│ └── oa_no_desc.json
├── cohorts_for_mock_dups
│ ├── oa_desc.json
│ └── oa_no_desc.json
├── cohorts_for_mock_with_exclude
│ └── oa_desc.json
├── cohorts_for_mock_with_mapped
│ ├── oa_desc.json
│ └── oa_no_desc.json
├── concepts_dbms
│ ├── oa_desc.json
│ └── oa_no_desc.json
├── concepts_for_mock
│ ├── arthritis_desc.json
│ ├── arthritis_no_desc.json
│ └── arthritis_with_excluded.json
├── concepts_for_mock_with_exclude
│ ├── oa_desc.json
│ ├── oa_with_excluded.json
│ └── oa_with_excluded2.json
└── concepts_for_mock_with_mapped
│ ├── oa_desc.json
│ └── oa_with_mapped.json
├── man
├── CodelistGenerator-package.Rd
├── ageGroupDoc.Rd
├── availableATC.Rd
├── availableICD10.Rd
├── availableIngredients.Rd
├── buildAchillesTables.Rd
├── byConceptDoc.Rd
├── bySexDoc.Rd
├── byYearDoc.Rd
├── cdmDoc.Rd
├── codesFromCohort.Rd
├── codesFromConceptSet.Rd
├── codesInUse.Rd
├── compareCodelists.Rd
├── countByDoc.Rd
├── domainDoc.Rd
├── doseFormDoc.Rd
├── doseUnitDoc.Rd
├── dot-optionsDoc.Rd
├── figures
│ ├── README-unnamed-chunk-8-1.png
│ └── logo.png
├── getATCCodes.Rd
├── getCandidateCodes.Rd
├── getConceptClassId.Rd
├── getDescendants.Rd
├── getDomains.Rd
├── getDoseForm.Rd
├── getDoseUnit.Rd
├── getDrugIngredientCodes.Rd
├── getICD10StandardCodes.Rd
├── getMappings.Rd
├── getRelationshipId.Rd
├── getRouteCategories.Rd
├── getVocabVersion.Rd
├── getVocabularies.Rd
├── groupColumnDoc.Rd
├── groupColumnStrataDoc.Rd
├── headerDoc.Rd
├── headerStrataDoc.Rd
├── hideDoc.Rd
├── hideStrataDoc.Rd
├── includeDescendantsDoc.Rd
├── ingredientRangeDoc.Rd
├── keepOriginalDoc.Rd
├── levelATCDoc.Rd
├── levelICD10Doc.Rd
├── minimumCountDoc.Rd
├── mockVocabRef.Rd
├── nameStyleDoc.Rd
├── reexports.Rd
├── routeCategoryDoc.Rd
├── sourceCodesInUse.Rd
├── standardConceptDoc.Rd
├── stratifyByConcept.Rd
├── stratifyByDoseUnit.Rd
├── stratifyByRouteCategory.Rd
├── subsetOnDomain.Rd
├── subsetOnDoseUnit.Rd
├── subsetOnRouteCategory.Rd
├── subsetToCodesInUse.Rd
├── summariseAchillesCodeUse.Rd
├── summariseCodeUse.Rd
├── summariseCohortCodeUse.Rd
├── summariseOrphanCodes.Rd
├── summariseUnmappedCodes.Rd
├── tableAchillesCodeUse.Rd
├── tableCodeUse.Rd
├── tableCohortCodeUse.Rd
├── tableDoc.Rd
├── tableOrphanCodes.Rd
├── tableUnmappedCodes.Rd
├── typeBroadDoc.Rd
├── typeNarrowDoc.Rd
├── typeTableDoc.Rd
└── xDoc.Rd
├── tests
├── testthat.R
└── testthat
│ ├── setup.R
│ ├── test-buildAchillesTables.R
│ ├── test-codesFrom.R
│ ├── test-codesInUse.R
│ ├── test-compareCodelists.R
│ ├── test-data.R
│ ├── test-dbms.R
│ ├── test-drugCodes.R
│ ├── test-findUnmappedCodes.R
│ ├── test-getCandidateCodes.R
│ ├── test-getDoseUnit.R
│ ├── test-getICD10StandardCodes.R
│ ├── test-getMappings.R
│ ├── test-getRouteCategories.R
│ ├── test-helperFunctions.R
│ ├── test-mockVocabRef.R
│ ├── test-restrictToCodesInUse.R
│ ├── test-stratifyByConcept.R
│ ├── test-stratifyByDoseUnit.R
│ ├── test-stratifyByRouteCategory.R
│ ├── test-subsetOnDomain.R
│ ├── test-subsetOnDoseUnit.R
│ ├── test-subsetOnRouteCategory.R
│ ├── test-summariseAchillesCodeUse.R
│ ├── test-summariseCodeUse.R
│ ├── test-summariseOrphanCodes.R
│ ├── test-summariseUnmappedCodes.R
│ ├── test-synthea_sql_server.R
│ ├── test-tableAchillesCodeUse.R
│ ├── test-tableCodeUse.R
│ ├── test-tableUnmappedCodes.R
│ ├── test-tidyWords.R
│ └── test-vocabUtilities.R
└── vignettes
├── .gitignore
├── Figures
├── 1.png
├── 10.png
├── 11.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
└── 9.png
├── a01_GettingOmopCdmVocabularies.Rmd
├── a02_ExploreCDMvocabulary.Rmd
├── a03_GenerateCandidateCodelist.Rmd
├── a04_GenerateVocabularyBasedCodelist.Rmd
├── a04b_icd_codes.Rmd
├── a05_ExtractCodelistFromJSONfile.Rmd
├── a06_CreateSubsetsFromCodelist.Rmd
└── a07_RunCodelistDiagnostics.Rmd
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^CodelistGenerator\.Rproj$
2 | ^\.Rproj\.user$
3 | ^LICENSE\.md$
4 | ^README\.Rmd$
5 | ^_pkgdown\.yml$
6 | ^docs$
7 | ^pkgdown$
8 | ^\.github$
9 | ^codecov\.yml$
10 | ^doc$
11 | ^Meta$
12 | ^LICENSE
13 | ^extras$
14 | ^cran-comments\.md$
15 | ^data-raw$
16 | ^CRAN-SUBMISSION$
17 |
--------------------------------------------------------------------------------
/.github/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to CodelistGenerator
2 |
3 | ## Filing issues
4 | If you have found a bug, have a question, or want to suggest a new feature please open an issue. If reporting a bug, then a [reprex](https://reprex.tidyverse.org/) would be much appreciated.
5 |
6 | ## Contributing code or documentation
7 |
8 | > This package has been developed as part of the DARWIN EU(R) project and is closed to external contributions.
9 |
10 | Before contributing either documentation or code, please make sure to open an issue beforehand to identify what needs to be done and who will do it.
11 |
12 | #### Documenting the package
13 | Run the below to update and check package documentation:
14 | ``` r
15 | devtools::document()
16 | devtools::run_examples()
17 | devtools::build_readme()
18 | devtools::build_vignettes()
19 | devtools::check_man()
20 | ```
21 |
22 | Note that `devtools::check_man()` should not return any warnings. If your commit is limited to only package documentation, running the above should be sufficient (although running `devtools::check()` will always generally be a good idea before submitting a pull request.
23 |
24 | #### Run tests
25 | Before starting to contribute any code, first make sure the package tests are all passing. If not raise an issue before going any further (although please first make sure you have all the packages from imports and suggests installed). As you then contribute code, make sure that all the current tests and any you add continue to pass. All package tests can be run together with:
26 | ``` r
27 | devtools::test()
28 | ```
29 |
30 | Code to add new functionality should be accompanied by tests. Code coverage can be checked using:
31 | ``` r
32 | # note, you may first have to detach the package
33 | # detach("package:CodelistGenerator", unload=TRUE)
34 | devtools::test_coverage()
35 | ```
36 |
37 | #### Adhere to code style
38 | Please adhere to the code style when adding any new code. Do not though restyle any code unrelated to your pull request as this will make code review more difficult.
39 |
40 | ``` r
41 | lintr::lint_package(".",
42 | linters = lintr::linters_with_defaults(
43 | lintr::object_name_linter(styles = "camelCase")
44 | )
45 | )
46 | ```
47 |
48 | #### Run check() before opening a pull request
49 | Before opening any pull request please make sure to run:
50 | ``` r
51 | devtools::check()
52 | ```
53 | No warnings should be seen.
54 |
55 | If the package is on CRAN or is close to being submitted to CRAN then please also run:
56 | ``` r
57 | rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
58 | devtools::check_win_devel()
59 | ```
60 | Also it can be worth checking spelling and any urls
61 | ``` r
62 | spelling::spell_check_package()
63 | urlchecker::url_check()
64 | ```
65 |
66 | #### Precompute vignette data
67 | The search results presented in the vignettes are precomputed against a database with a full vocabulary. If making changes that will affect these results, they should be recomputed. Note you may need to change the database connection details in this script.
68 | ``` r
69 | source(here::here("extras", "precomputeVignetteData.R"))
70 | ```
71 |
72 |
73 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/workflows/R-CMD-check.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | on:
4 | push:
5 | branches: [main, master]
6 | pull_request:
7 | branches: [main, master]
8 |
9 | name: R-CMD-check
10 |
11 | permissions: read-all
12 |
13 | jobs:
14 | R-CMD-check:
15 | runs-on: ${{ matrix.config.os }}
16 |
17 | name: ${{ matrix.config.os }} (${{ matrix.config.r }})
18 |
19 | strategy:
20 | fail-fast: false
21 | matrix:
22 | config:
23 | - {os: ubuntu-latest, r: 'release'}
24 |
25 | env:
26 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
27 | R_KEEP_PKG_SOURCE: yes
28 |
29 | steps:
30 | - uses: actions/checkout@v4
31 |
32 | - uses: r-lib/actions/setup-pandoc@v2
33 |
34 | - uses: r-lib/actions/setup-r@v2
35 | with:
36 | r-version: ${{ matrix.config.r }}
37 | http-user-agent: ${{ matrix.config.http-user-agent }}
38 | use-public-rspm: true
39 |
40 | - uses: r-lib/actions/setup-r-dependencies@v2
41 | with:
42 | extra-packages: any::rcmdcheck
43 | needs: check
44 |
45 | - uses: r-lib/actions/check-r-package@v2
46 | with:
47 | upload-snapshots: true
48 | build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
49 |
--------------------------------------------------------------------------------
/.github/workflows/pkgdown.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | on:
4 | push:
5 | branches: [main, master]
6 | pull_request:
7 | branches: [main, master]
8 | release:
9 | types: [published]
10 | workflow_dispatch:
11 |
12 | name: pkgdown
13 |
14 | jobs:
15 | pkgdown:
16 | runs-on: ubuntu-latest
17 | # Only restrict concurrency for non-PR jobs
18 | concurrency:
19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
20 | env:
21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
22 | steps:
23 | - uses: actions/checkout@v3
24 |
25 | - uses: r-lib/actions/setup-pandoc@v2
26 |
27 | - uses: r-lib/actions/setup-r@v2
28 | with:
29 | use-public-rspm: true
30 |
31 | - uses: r-lib/actions/setup-r-dependencies@v2
32 | with:
33 | extra-packages: any::pkgdown, local::.
34 | needs: website
35 |
36 | - name: Build site
37 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
38 | shell: Rscript {0}
39 |
40 | - name: Deploy to GitHub pages 🚀
41 | if: github.event_name != 'pull_request'
42 | uses: JamesIves/github-pages-deploy-action@v4.4.1
43 | with:
44 | clean: false
45 | branch: gh-pages
46 | folder: docs
47 |
--------------------------------------------------------------------------------
/.github/workflows/test-coverage.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | on:
4 | push:
5 | branches: [main, master]
6 | pull_request:
7 | branches: [main, master]
8 |
9 | name: test-coverage.yaml
10 |
11 | permissions: read-all
12 |
13 | jobs:
14 | test-coverage:
15 | runs-on: ubuntu-latest
16 | env:
17 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
18 |
19 | steps:
20 | - uses: actions/checkout@v4
21 |
22 | - uses: r-lib/actions/setup-r@v2
23 | with:
24 | use-public-rspm: true
25 |
26 | - uses: r-lib/actions/setup-r-dependencies@v2
27 | with:
28 | extra-packages: any::covr, any::xml2
29 | needs: coverage
30 |
31 | - name: Test coverage
32 | run: |
33 | cov <- covr::package_coverage(
34 | quiet = FALSE,
35 | clean = FALSE,
36 | install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
37 | )
38 | covr::to_cobertura(cov)
39 | shell: Rscript {0}
40 |
41 | - uses: codecov/codecov-action@v4
42 | with:
43 | fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
44 | file: ./cobertura.xml
45 | plugin: noop
46 | disable_search: true
47 | token: ${{ secrets.CODECOV_TOKEN }}
48 |
49 | - name: Show testthat output
50 | if: always()
51 | run: |
52 | ## --------------------------------------------------------------------
53 | find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
54 | shell: bash
55 |
56 | - name: Upload test results
57 | if: failure()
58 | uses: actions/upload-artifact@v4
59 | with:
60 | name: coverage-test-failures
61 | path: ${{ runner.temp }}/package
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | inst/doc
4 | db.sqlite
5 | db1.sqlite
6 | vocab_cdm.sqlite
7 | docs
8 | postgresql-42.2.18.jar
9 | /doc/
10 | /Meta/
11 | extras/arrow_vocab/*
12 | extras/SQLite/vocab.sqlite
13 | tests/testthat/vocab.sqlite
14 | *.jar
15 | GiBleed_5.3.zip
16 | .Rdata
17 | .httr-oauth
18 | .DS_Store
19 | .quarto
20 | extras/Extra.R
21 | extras/log_2025-03-12.txt
22 | extras/log_2025-03-18.txt
23 | /shiny
24 |
--------------------------------------------------------------------------------
/CRAN-SUBMISSION:
--------------------------------------------------------------------------------
1 | Version: 3.4.1
2 | Date: 2025-03-26 14:28:52 UTC
3 | SHA: f5925a75a02bb52ac2f18ef2a98bc2af86521d6d
4 |
--------------------------------------------------------------------------------
/CodelistGenerator.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 | ProjectId: c06ec832-344f-438c-853f-48d0b3049c7b
3 |
4 | RestoreWorkspace: No
5 | SaveWorkspace: No
6 | AlwaysSaveHistory: Default
7 |
8 | EnableCodeIndexing: Yes
9 | UseSpacesForTab: Yes
10 | NumSpacesForTab: 2
11 | Encoding: UTF-8
12 |
13 | RnwWeave: Sweave
14 | LaTeX: pdfLaTeX
15 |
16 | AutoAppendNewline: Yes
17 | StripTrailingWhitespace: Yes
18 | LineEndingConversion: Posix
19 |
20 | BuildType: Package
21 | PackageUseDevtools: Yes
22 | PackageInstallArgs: --no-multiarch --with-keep.source
23 | PackageRoxygenize: rd,collate,namespace
24 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: CodelistGenerator
2 | Title: Identify Relevant Clinical Codes and Evaluate Their Use
3 | Version: 3.5.0
4 | Authors@R: c(
5 | person("Edward", "Burn", email = "edward.burn@ndorms.ox.ac.uk",
6 | role = c("aut", "cre"),
7 | comment = c(ORCID = "0000-0002-9286-1128")),
8 | person("Marti", "Catala", email = "marti.catalasabate@ndorms.ox.ac.uk",
9 | role = c("ctb"),
10 | comment = c(ORCID = "0000-0003-3308-9905")),
11 | person("Xihang", "Chen", email = "xihang.chen@ndorms.ox.ac.uk",
12 | role = c("aut"),
13 | comment = c(ORCID = "0009-0001-8112-8959")),
14 | person("Nuria", "Mercade-Besora", email = "nuria.mercadebesora@ndorms.ox.ac.uk",
15 | role = c("aut"), comment = c(ORCID = "0009-0006-7948-3747")),
16 | person("Mike", "Du", email = "mike.du@ndorms.ox.ac.uk",
17 | role = c("ctb"),
18 | comment = c(ORCID = "0000-0002-9517-8834")),
19 | person("Danielle", "Newby", email = "danielle.newby@ndorms.ox.ac.uk",
20 | role = c("ctb"),
21 | comment = c(ORCID = "0000-0002-3001-1478")),
22 | person( "Marta", "Alcalde-Herraiz", email = "marta.alcaldeherraiz@ndorms.ox.ac.uk",
23 | role = c("ctb"),
24 | comment = c(ORCID = "0009-0002-4405-1814")
25 | ))
26 | Description: Generate a candidate code list for the Observational Medical Outcomes Partnership (OMOP) common data model based on string matching. For a given search strategy, a candidate code list will be returned.
27 | License: Apache License (>= 2)
28 | Encoding: UTF-8
29 | Roxygen: list(markdown = TRUE)
30 | RoxygenNote: 7.3.2
31 | Depends:
32 | R (>= 4.1)
33 | Imports:
34 | DBI (>= 1.1.0),
35 | dplyr (>= 1.1.0),
36 | omopgenerics (>= 1.1.1),
37 | rlang (>= 1.0.0),
38 | glue (>= 1.5.0),
39 | stringr (>= 1.4.0),
40 | stringi (>= 1.8.1),
41 | tidyr (>= 1.2.0),
42 | cli (>= 3.1.0),
43 | purrr,
44 | clock,
45 | PatientProfiles (>= 1.3.1),
46 | vctrs,
47 | jsonlite,
48 | lifecycle
49 | Suggests:
50 | covr,
51 | duckdb,
52 | CDMConnector (>= 1.7.0),
53 | visOmopResults (>= 1.0.0),
54 | knitr,
55 | rmarkdown,
56 | testthat (>= 3.0.0),
57 | RPostgres,
58 | odbc,
59 | spelling,
60 | tibble,
61 | gt,
62 | flextable,
63 | omock,
64 | CohortConstructor
65 | Config/testthat/edition: 3
66 | Config/testthat/parallel: true
67 | VignetteBuilder: knitr
68 | URL: https://darwin-eu.github.io/CodelistGenerator/
69 | Language: en-US
70 | LazyData: true
71 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | YEAR: 2022
2 | COPYRIGHT HOLDER: CodelistGenerator authors
3 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | export(availableATC)
4 | export(availableICD10)
5 | export(availableIngredients)
6 | export(buildAchillesTables)
7 | export(codesFromCohort)
8 | export(codesFromConceptSet)
9 | export(codesInUse)
10 | export(cohortCodelist)
11 | export(compareCodelists)
12 | export(exportCodelist)
13 | export(exportConceptSetExpression)
14 | export(getATCCodes)
15 | export(getCandidateCodes)
16 | export(getConceptClassId)
17 | export(getDescendants)
18 | export(getDomains)
19 | export(getDoseForm)
20 | export(getDoseUnit)
21 | export(getDrugIngredientCodes)
22 | export(getICD10StandardCodes)
23 | export(getMappings)
24 | export(getRelationshipId)
25 | export(getRouteCategories)
26 | export(getVocabVersion)
27 | export(getVocabularies)
28 | export(importCodelist)
29 | export(importConceptSetExpression)
30 | export(mockVocabRef)
31 | export(newCodelist)
32 | export(newCodelistWithDetails)
33 | export(newConceptSetExpression)
34 | export(sourceCodesInUse)
35 | export(stratifyByConcept)
36 | export(stratifyByDoseUnit)
37 | export(stratifyByRouteCategory)
38 | export(subsetOnDomain)
39 | export(subsetOnDoseUnit)
40 | export(subsetOnRouteCategory)
41 | export(subsetToCodesInUse)
42 | export(summariseAchillesCodeUse)
43 | export(summariseCodeUse)
44 | export(summariseCohortCodeUse)
45 | export(summariseOrphanCodes)
46 | export(summariseUnmappedCodes)
47 | export(tableAchillesCodeUse)
48 | export(tableCodeUse)
49 | export(tableCohortCodeUse)
50 | export(tableOrphanCodes)
51 | export(tableUnmappedCodes)
52 | importFrom(omopgenerics,cohortCodelist)
53 | importFrom(omopgenerics,exportCodelist)
54 | importFrom(omopgenerics,exportConceptSetExpression)
55 | importFrom(omopgenerics,importCodelist)
56 | importFrom(omopgenerics,importConceptSetExpression)
57 | importFrom(omopgenerics,newCodelist)
58 | importFrom(omopgenerics,newCodelistWithDetails)
59 | importFrom(omopgenerics,newConceptSetExpression)
60 | importFrom(rlang,":=")
61 | importFrom(rlang,.data)
62 | importFrom(rlang,.env)
63 |
--------------------------------------------------------------------------------
/NEWS.md:
--------------------------------------------------------------------------------
1 | # CodelistGenerator 3.0
2 | * Add function getRelationshipId
3 | * Add functions summariseAchillesCodeUse (replaces achillesCodeUse), summariseOrphanCodes (replaces findOrphanCodes), tableAchillesCodeUse, tableCodeUse, tableCohortCodeUse, tableOrphanCodes.
4 |
5 | # CodelistGenerator 2.2.3
6 | * Fix for forthcoming breaking change in dependency omopgenerics
7 |
8 | # CodelistGenerator 2.2.2
9 | * Fix for edge case with multiple exclusion criteria
10 |
11 | # CodelistGenerator 2.2.1
12 | * Working with omopgenerics
13 |
14 | # CodelistGenerator 2.2.0
15 | * Added functions findOrphanCodes, restrictToCodesInUse, sourceCodesInUse.
16 | * Speed improvements in getCandidateCodes from doing search in place (e.g. on database side).
17 | * Dropped explicit support of an Arrow cdm.
18 |
19 | # CodelistGenerator 2.1.1
20 | * Improved support of device domain.
21 |
22 | # CodelistGenerator 2.0.0
23 | * Simplified the interface of getCandidateCodes, with a number of arguments removed.
24 | * Added function summariseCohortCodeUse.
25 |
26 | # CodelistGenerator 1.7.0
27 | * Added function codesFromCohort.
28 |
29 | # CodelistGenerator 1.6.0
30 | * Improved getICD10StandardCodes function.
31 | * Added function codesFromConceptSet.
32 |
33 | # CodelistGenerator 1.5.0
34 | * Require CDMConnector v1.0.0 or above.
35 |
36 | # CodelistGenerator 1.4.0
37 | * Added function summariseCodeUse.
38 |
39 | # CodelistGenerator 1.3.0
40 | * Added function getICD10StandardCodes.
41 |
42 | # CodelistGenerator 1.2.0
43 | * Added functions getATCCodes and getDrugIngredientCodes.
44 |
45 | # CodelistGenerator 1.1.0
46 | * Added exactMatch and includeSequela options to getCandidateCodes function.
47 |
48 | # CodelistGenerator 1.0.0
49 | * Added a `NEWS.md` file to track changes to the package.
50 |
--------------------------------------------------------------------------------
/R/CodelistFromCodelistWithDetails.R:
--------------------------------------------------------------------------------
1 | codelistFromCodelistWithDetails <- function(x){
2 |
3 | if(isFALSE(inherits(x, "codelist_with_details"))){
4 | cli::cli_abort("x is not class codelist_with_details but {class(x)}")
5 | }
6 |
7 | for(i in seq_along(x)){
8 | x[[i]] <- x[[i]] |>
9 | dplyr::pull("concept_id")
10 | }
11 |
12 | x <- omopgenerics::newCodelist(x)
13 |
14 | x
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/R/CodelistGenerator-package.R:
--------------------------------------------------------------------------------
1 | #' @keywords internal
2 | "_PACKAGE"
3 |
4 | ## usethis namespace: start
5 | #' @importFrom rlang .data
6 | #' @importFrom rlang .env
7 | #' @importFrom rlang :=
8 | ## usethis namespace: end
9 | NULL
10 |
--------------------------------------------------------------------------------
/R/checks.R:
--------------------------------------------------------------------------------
1 | # Copyright 2025 DARWIN EU®
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | checkInputs <- function(...) {
18 | inputs <- list(...)
19 | lapply(names(inputs), function(x) {
20 | funName <- paste0(
21 | "check", toupper(substr(x, 1, 1)), substr(x, 2, nchar(x))
22 | )
23 | varName <- eval(parse(text = paste0("names(formals(", funName, "))")))
24 | eval(parse(text = paste0(
25 | funName, "(",
26 | paste0(paste0("inputs[[\"", varName, "\"]]"), collapse = ", "), ")"
27 | )))
28 | })
29 | invisible(NULL)
30 | }
31 |
32 | checkPath <- function(path) {
33 | if(typeof(path) != "character" || length(path) != 1) {
34 | cli::cli_abort("path is not a character of length 1")
35 | }
36 |
37 | if (!file.exists(path)) {
38 | cli::cli_abort(glue::glue("Invalid path: {path}"))
39 | }
40 | }
41 |
42 | checkCdm <- function(cdm) {
43 | if (!("cdm_reference" %in% class(cdm))) {
44 | cli::cli_abort(
45 | "Argument cdm is not a valid cdm reference, please use
46 | CDMConnector::cdmFromCon() to create a valid cdm reference"
47 | )
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/R/compareCodelists.R:
--------------------------------------------------------------------------------
1 | # Copyright 2025 DARWIN EU®
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 |
18 | #' Compare overlap between two sets of codes
19 | #'
20 | #' @param codelist1 Output of getCandidateCodes or a codelist
21 | #' @param codelist2 Output of getCandidateCodes.
22 | #'
23 | #' @return Tibble with information on the overlap of codes in both codelists.
24 | #' @export
25 | #'
26 | #' @examples
27 | #' \donttest{
28 | #' cdm <- mockVocabRef()
29 | #' codes1 <- getCandidateCodes(
30 | #' cdm = cdm,
31 | #' keywords = "Arthritis",
32 | #' domains = "Condition",
33 | #' includeDescendants = TRUE
34 | #' )
35 | #' codes2 <- getCandidateCodes(
36 | #' cdm = cdm,
37 | #' keywords = c("knee osteoarthritis", "arthrosis"),
38 | #' domains = "Condition",
39 | #' includeDescendants = TRUE
40 | #')
41 | #' compareCodelists(
42 | #' codelist1 = codes1,
43 | #' codelist2 = codes2
44 | #' )
45 | #' }
46 | compareCodelists <- function(codelist1,
47 | codelist2) {
48 |
49 | if(is.list(codelist1) && !is.data.frame(codelist1)){
50 | if(length(codelist1)>1){
51 | cli::cli_abort("Codelist must be singular")
52 | }
53 | codelist1 <- omopgenerics::newCodelist(codelist1)
54 | codelist1 <- dplyr::tibble(concept_id = codelist1[[1]],
55 | concept_name = NA_character_)
56 | }
57 |
58 | if(is.list(codelist2) && !is.data.frame(codelist2)){
59 | if(length(codelist2)>1){
60 | cli::cli_abort("Codelist must be singular")
61 | }
62 | codelist2 <- omopgenerics::newCodelist(codelist2)
63 | codelist2 <- dplyr::tibble(concept_id = codelist2[[1]],
64 | concept_name = NA_character_)
65 | }
66 |
67 | # initial checks
68 | omopgenerics::assertTable(codelist1, columns = c("concept_id", "concept_name"))
69 | omopgenerics::assertTable(codelist2, columns = c("concept_id", "concept_name"))
70 |
71 | codes <- dplyr::full_join(codelist1 |>
72 | dplyr::select("concept_id", "concept_name") |>
73 | dplyr::mutate(codelist_1 = 1) |>
74 | dplyr::distinct(),
75 | codelist2 |>
76 | dplyr::select("concept_id", "concept_name") |>
77 | dplyr::mutate(codelist_2 = 1) |>
78 | dplyr::distinct(),
79 | by = c("concept_id", "concept_name"))
80 |
81 | codes <- codes |>
82 | dplyr::mutate(
83 | codelist =
84 | dplyr::case_when(
85 | !is.na(codelist_1) & is.na(codelist_2) ~ "Only codelist 1",
86 | is.na(codelist_1) & !is.na(codelist_2) ~ "Only codelist 2",
87 | !is.na(codelist_1) & !is.na(codelist_2) ~ "Both"
88 | ))
89 |
90 | return(codes)
91 | }
92 |
--------------------------------------------------------------------------------
/R/getDoseUnit.R:
--------------------------------------------------------------------------------
1 | # Copyright 2024 DARWIN EU (C)
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | #' Get available dose units
18 | #'
19 | #' @description
20 | #' Get the dose form categories available in the database (see
21 | #' https://doi.org/10.1002/pds.5809 for more details on how routes
22 | #' were classified).
23 | #'
24 | #'
25 | #' @inheritParams cdmDoc
26 | #'
27 | #' @return A character vector with available routes.
28 | #' @export
29 | #'
30 | #'
31 | #' @examples
32 | #' \donttest{
33 | #' library(CodelistGenerator)
34 | #'
35 | #' cdm <- mockVocabRef()
36 | #'
37 | #' getDoseUnit(cdm)
38 | #'
39 | #' }
40 | getDoseUnit <- function(cdm){
41 |
42 | # initial checks
43 | cdm <- omopgenerics::validateCdmArgument(cdm = cdm)
44 |
45 | if(isFALSE(inherits(cdm, "cdm_reference"))){
46 | cli::cli_abort("{.arg cdm} is not a cdm reference")
47 | }
48 |
49 | sort(unique(c(cdm$drug_strength |>
50 | dplyr::select("amount_unit_concept_id") |>
51 | dplyr::filter(!is.na(.data$amount_unit_concept_id)) |>
52 | dplyr::distinct() |>
53 | dplyr::left_join(cdm$concept,
54 | by = c("amount_unit_concept_id" = "concept_id")) |>
55 | dplyr::pull("concept_name"),
56 | cdm$drug_strength |>
57 | dplyr::select("numerator_unit_concept_id") |>
58 | dplyr::filter(!is.na(.data$numerator_unit_concept_id)) |>
59 | dplyr::distinct() |>
60 | dplyr::left_join(cdm$concept,
61 | by = c("numerator_unit_concept_id" = "concept_id")) |>
62 | dplyr::pull("concept_name"))))
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/R/getRoutes.R:
--------------------------------------------------------------------------------
1 | # Copyright 2024 DARWIN EU (C)
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | #' Get available drug routes
18 | #'
19 | #' @description
20 | #' Get the dose form categories available in the database (see
21 | #' https://doi.org/10.1002/pds.5809) for more details on how routes
22 | #' were classified).
23 | #'
24 | #'
25 | #' @inheritParams cdmDoc
26 | #'
27 | #' @return A character vector with all available routes.
28 | #' @export
29 | #'
30 | #' @examples
31 | #' \donttest{
32 | #' library(CodelistGenerator)
33 | #'
34 | #' cdm <- mockVocabRef()
35 | #'
36 | #' getRouteCategories(cdm)
37 | #'
38 | #' }
39 | getRouteCategories <- function(cdm) {
40 |
41 | # relate does form concept id with the classification established by
42 | # doseFormToRoute
43 | doseRouteData <- doseFormToRoute
44 |
45 | routeCategory <- cdm$concept_relationship |>
46 | # get dose form available in the cdm
47 | dplyr::filter(.data$relationship_id == "RxNorm has dose form") |>
48 | dplyr::select("concept_id_2") |>
49 | dplyr::rename("concept_id" = "concept_id_2") |>
50 | dplyr::distinct() |>
51 | dplyr::collect() |>
52 | dplyr::left_join(
53 | doseRouteData, by = c("concept_id" = "dose_form_concept_id")
54 | ) |>
55 | dplyr::mutate(route_category = dplyr::if_else(
56 | is.na(.data$route_category),
57 | "unclassified_route",
58 | .data$route_category
59 | )) |>
60 | dplyr::select("route_category") |>
61 | dplyr::distinct() |>
62 | dplyr::pull()
63 |
64 | # sort alphabetically the result
65 | routeCategory <- sort(routeCategory)
66 |
67 | return(routeCategory)
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/R/helperFunctions.R:
--------------------------------------------------------------------------------
1 | # Copyright 2025 DARWIN EU®
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | #' Get the names of all available drug ingredients
18 | #'
19 | #' @inheritParams cdmDoc
20 | #'
21 | #' @return A vector containing the concept names for all ingredient level codes
22 | #' found in the concept table of cdm.
23 | #'
24 | #' @export
25 | #'
26 | #' @examples
27 | #' \donttest{
28 | #' cdm <- mockVocabRef()
29 | #' availableIngredients(cdm)
30 | #'}
31 | availableIngredients <- function(cdm) {
32 | cdm <- omopgenerics::validateCdmArgument(cdm = cdm)
33 |
34 | ingredientConcepts <- cdm$concept |>
35 | dplyr::filter(.data$standard_concept == "S") |>
36 | dplyr::filter(.data$concept_class_id == "Ingredient") |>
37 | dplyr::pull("concept_name")
38 |
39 | return(ingredientConcepts)
40 | }
41 |
42 | #' Get the names of all available Anatomical Therapeutic Chemical (ATC) classification codes
43 | #'
44 | #' @inheritParams cdmDoc
45 | #' @inheritParams levelATCDoc
46 | #'
47 | #' @return A vector containing the names of ATC codes for the chosen level(s)
48 | #' found in the concept table of cdm.
49 | #'
50 | #' @export
51 | #'
52 | #' @examples
53 | #' \donttest{
54 | #' cdm <- mockVocabRef()
55 | #' availableATC(cdm)
56 | #'}
57 | #'
58 | availableATC <- function(cdm,
59 | level = c("ATC 1st")) {
60 | cdm <- omopgenerics::validateCdmArgument(cdm = cdm)
61 | omopgenerics::assertChoice(level, choices = c(
62 | "ATC 1st",
63 | "ATC 2nd",
64 | "ATC 3rd",
65 | "ATC 4th",
66 | "ATC 5th"
67 | ))
68 |
69 | atc_names <- cdm$concept |>
70 | dplyr::filter(.data$vocabulary_id == "ATC") |>
71 | dplyr::filter(.data$concept_class_id %in% .env$level) |>
72 | dplyr::pull("concept_name")
73 |
74 | return(atc_names)
75 | }
76 |
77 | #' Get the names of all International Classification of Diseases (ICD) 10 codes
78 | #'
79 | #' @inheritParams cdmDoc
80 | #' @inheritParams levelICD10Doc
81 | #'
82 | #' @return A vector containing the names of all ICD-10 codes for the chosen
83 | #' level(s) found in the concept table of cdm.
84 | #'
85 | #' @export
86 | #'
87 | #' @examples
88 | #' \donttest{
89 | #' cdm <- mockVocabRef()
90 | #' availableICD10(cdm)
91 | #'}
92 | availableICD10 <- function(cdm,
93 | level = c(
94 | "ICD10 Chapter",
95 | "ICD10 SubChapter"
96 | )){
97 |
98 | cdm <- omopgenerics::validateCdmArgument(cdm = cdm)
99 | omopgenerics::assertChoice(level, choices = c(
100 | "ICD10 Chapter",
101 | "ICD10 SubChapter",
102 | "ICD10 Hierarchy",
103 | "ICD10 Code"
104 | ))
105 |
106 | if("ICD10 Code" %in% level){
107 | level <- c(level, "ICD10 code") # for compatability with older vocab versions
108 | }
109 |
110 | ICD10Concepts <- list()
111 | for(i in seq_along(level)){
112 | working_level <- level[i]
113 | ICD10Concepts[[i]] <- cdm$concept |>
114 | dplyr::filter(.data$vocabulary_id == "ICD10",
115 | .data$concept_class_id %in%
116 | .env$working_level) |>
117 | dplyr::pull("concept_name")
118 | }
119 | ICD10Concepts <- purrr::flatten_chr(ICD10Concepts)
120 |
121 | return(ICD10Concepts)
122 | }
123 |
--------------------------------------------------------------------------------
/R/reexports.R:
--------------------------------------------------------------------------------
1 | #' @importFrom omopgenerics cohortCodelist
2 | #' @export
3 | omopgenerics::cohortCodelist
4 |
5 | #' @importFrom omopgenerics importCodelist
6 | #' @export
7 | omopgenerics::importCodelist
8 |
9 | #' @importFrom omopgenerics importConceptSetExpression
10 | #' @export
11 | omopgenerics::importConceptSetExpression
12 |
13 | #' @importFrom omopgenerics exportCodelist
14 | #' @export
15 | omopgenerics::exportCodelist
16 |
17 | #' @importFrom omopgenerics exportConceptSetExpression
18 | #' @export
19 | omopgenerics::exportConceptSetExpression
20 |
21 | #' @importFrom omopgenerics newCodelist
22 | #' @export
23 | omopgenerics::newCodelist
24 |
25 | #' @importFrom omopgenerics newCodelistWithDetails
26 | #' @export
27 | omopgenerics::newCodelistWithDetails
28 |
29 | #' @importFrom omopgenerics newConceptSetExpression
30 | #' @export
31 | omopgenerics::newConceptSetExpression
32 |
--------------------------------------------------------------------------------
/R/stratifyByConcept.R:
--------------------------------------------------------------------------------
1 | # Copyright 2025 DARWIN EU®
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 |
18 | #' Stratify a codelist by the concepts included within it.
19 | #'
20 | #' @inheritParams xDoc
21 | #' @inheritParams cdmDoc
22 | #' @inheritParams keepOriginalDoc
23 | #'
24 | #' @return The codelist or a codelist with details with the required
25 | #' stratifications, as different elements of the list.
26 | #' @export
27 | #' @examples
28 | #' \donttest{
29 | #' library(CodelistGenerator)
30 | #' cdm <- mockVocabRef()
31 | #' codes <- list("concepts" = c(20,21))
32 | #' new_codes <- stratifyByConcept(x = codes,
33 | #' cdm = cdm,
34 | #' keepOriginal = TRUE)
35 | #' new_codes
36 | #' }
37 | stratifyByConcept <- function(x,
38 | cdm,
39 | keepOriginal = FALSE){
40 |
41 |
42 | if(inherits(x, "list") & !inherits(x, "codelist_with_details")){
43 | x <- omopgenerics::newCodelist(x)
44 | }
45 |
46 | x_start <- x
47 |
48 | if(inherits(x_start, "codelist")){
49 | x <- addDetails(x, cdm = cdm)
50 | }
51 |
52 | for(i in seq_along(x)){
53 | x[[i]] <- x[[i]] |>
54 | dplyr::mutate(c_name = names(x[i])) |>
55 | dplyr::mutate(new_c_name = paste0(.data$c_name, "_",
56 | omopgenerics::toSnakeCase(.data$concept_name)))
57 | }
58 |
59 | x <- purrr::list_rbind(x)
60 |
61 | if(any(is.na(x$concept_name))){
62 | nMissingConceptName <- sum(is.na(x$concept_name))
63 | cli::cli_warn("Dropping {nMissingConceptName} concepts that do not have a concept name")
64 | x <- x |>
65 | dplyr::filter(!is.na(.data$concept_name))
66 | }
67 |
68 | x <- split(x,
69 | x[, c("new_c_name")]
70 | )
71 |
72 | if(inherits(x_start, "codelist")){
73 | for(i in seq_along(x)){
74 | x[[i]] <- x[[i]] |>
75 | dplyr::pull("concept_id")
76 | }
77 | }
78 |
79 | if(inherits(x_start, "codelist_with_details")){
80 | for(i in seq_along(x)){
81 | x[[i]] <- x[[i]] |>
82 | dplyr::select(!"c_name") |>
83 | dplyr::select(!"new_c_name")
84 | }
85 | }
86 |
87 | if(isTRUE(keepOriginal)){
88 | x <- purrr::list_flatten(list(x_start, x))
89 | }
90 |
91 | x <- x[order(names(x))]
92 |
93 | if(inherits(x_start, "codelist")){
94 | x <- omopgenerics::newCodelist(x)
95 | } else{
96 | x <- omopgenerics::newCodelistWithDetails(x)
97 | }
98 |
99 | x
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/R/subsetOnDomain.R:
--------------------------------------------------------------------------------
1 | # Copyright 2024 DARWIN EU (C)
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | #' Subset a codelist to only those codes from a particular domain.
18 | #'
19 | #' @inheritParams xDoc
20 | #' @inheritParams cdmDoc
21 | #' @inheritParams domainDoc
22 | #' @param negate If FALSE, only concepts with the domain specified will be
23 | #' returned. If TRUE, concepts with the domain specified will be excluded.
24 | #'
25 | #' @return The codelist with only those concepts associated with the domain
26 | #' (if negate = FALSE) or the codelist without those concepts associated with
27 | #' the domain (if negate = TRUE).
28 | #' @export
29 | #'
30 | #' @examples
31 | #' \donttest{
32 | #' library(CodelistGenerator)
33 | #' cdm <- mockVocabRef()
34 | #' codes <- subsetOnDomain(
35 | #' x = list("codes" = c(10,13,15)),
36 | #' cdm = cdm,
37 | #' domain = "Drug")
38 | #' codes
39 | #' }
40 | subsetOnDomain <- function(x,
41 | cdm,
42 | domain,
43 | negate = FALSE){
44 |
45 | omopgenerics::validateCdmArgument(cdm)
46 | omopgenerics::assertCharacter(domain)
47 | omopgenerics::assertLogical(negate)
48 | x <- omopgenerics::newCodelist(x)
49 |
50 | tableCodelist <- paste0(omopgenerics::uniqueTableName(),
51 | omopgenerics::uniqueId())
52 |
53 | for(i in seq_along(x)){
54 | cdm <- omopgenerics::insertTable(cdm = cdm,
55 | name = tableCodelist,
56 | table = dplyr::tibble(concept_id = x[[i]]),
57 | overwrite = TRUE,
58 | temporary = FALSE)
59 | x[[i]] <- cdm[[tableCodelist]] |>
60 | dplyr::inner_join(cdm[["concept"]] ,
61 | by = "concept_id") |>
62 | dplyr::select("concept_id",
63 | "domain_id") |>
64 | dplyr::distinct() |>
65 | dplyr::collect()
66 |
67 | if(isTRUE(negate)){
68 | x[[i]] <- x[[i]] |>
69 | dplyr::filter(!tolower(.data$domain_id) %in% tolower(.env$domain))
70 | }else{
71 | x[[i]] <- x[[i]] |>
72 | dplyr::filter(tolower(.data$domain_id) %in% tolower(.env$domain))
73 | }
74 |
75 | x[[i]] <- x[[i]] |>
76 | dplyr::pull("concept_id")
77 |
78 | x[[i]] <- sort(unique(x[[i]]))
79 | }
80 |
81 | x <- x |>
82 | vctrs::list_drop_empty()
83 |
84 | if(length(x) == 0){
85 | x <- omopgenerics::emptyCodelist()
86 | }
87 |
88 | CDMConnector::dropTable(cdm = cdm, name = tableCodelist)
89 |
90 | return(x)
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/R/subsetOnRouteCategory.R:
--------------------------------------------------------------------------------
1 | # Copyright 2024 DARWIN EU (C)
2 | #
3 | # This file is part of CodelistGenerator
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | #' Subset a codelist to only those with a particular route category
18 | #'
19 | #' @inheritParams xDoc
20 | #' @inheritParams cdmDoc
21 | #' @inheritParams routeCategoryDoc
22 | #' @param negate If FALSE, only concepts with the routeCategory specified will
23 | #' be returned. If TRUE, concepts with the routeCategory specified will be excluded.
24 | #'
25 | #' @return The codelist with only those concepts associated with the
26 | #' specified route categories (if negate is FALSE) or the codelist without those
27 | #' concepts associated with the specified route categories (if negate is TRUE).
28 | #' @export
29 | #'
30 | #' @examples
31 | #' \donttest{
32 | #' library(CodelistGenerator)
33 | #' cdm <- mockVocabRef()
34 | #' codes <- subsetOnRouteCategory(
35 | #' x = list("codes" = c(20,21)),
36 | #' cdm = cdm,
37 | #' routeCategory = "topical")
38 | #' codes
39 | #' }
40 | subsetOnRouteCategory <- function(x,
41 | cdm,
42 | routeCategory,
43 | negate = FALSE){
44 |
45 | omopgenerics::assertList(x, named = TRUE)
46 | omopgenerics::validateCdmArgument(cdm)
47 | omopgenerics::assertCharacter(routeCategory)
48 | omopgenerics::assertLogical(negate)
49 |
50 | if(inherits(x, "codelist_with_details")){
51 | x_original <- x
52 | withDetails <- TRUE
53 | x <- codelistFromCodelistWithDetails(x)
54 | } else {
55 | withDetails <- FALSE
56 | }
57 |
58 | x <- omopgenerics::newCodelist(x)
59 |
60 | doseRouteData <- doseFormToRoute
61 |
62 | tableCodelist <- paste0(omopgenerics::uniqueTableName(),
63 | omopgenerics::uniqueId())
64 |
65 | for(i in seq_along(x)){
66 | cdm <- omopgenerics::insertTable(cdm = cdm,
67 | name = tableCodelist,
68 | table = dplyr::tibble(concept_id = x[[i]]),
69 | overwrite = TRUE,
70 | temporary = FALSE)
71 |
72 | x[[i]] <- cdm[[tableCodelist]] |>
73 | dplyr::inner_join(cdm$concept_relationship |>
74 | dplyr::filter(.data$relationship_id == "RxNorm has dose form"),
75 | by = c("concept_id" = "concept_id_1")
76 | ) |>
77 | dplyr::select("concept_id",
78 | "concept_id_2") |>
79 | dplyr::collect() |>
80 | dplyr::left_join(
81 | doseRouteData, by = c("concept_id_2" = "dose_form_concept_id")
82 | ) |>
83 | dplyr::mutate(route_category = dplyr::if_else(
84 | is.na(.data$route_category),
85 | "unclassified_route",
86 | .data$route_category
87 | ))
88 |
89 | if(isTRUE(negate)){
90 | x[[i]] <- x[[i]] |>
91 | dplyr::filter(!.data$route_category %in% .env$routeCategory)
92 | }else{
93 | x[[i]] <- x[[i]] |>
94 | dplyr::filter(.data$route_category %in% .env$routeCategory)
95 | }
96 |
97 | x[[i]] <- x[[i]] |>
98 | dplyr::select("concept_id") |>
99 | dplyr::distinct() |>
100 | dplyr::pull("concept_id")
101 |
102 | x[[i]] <- sort(x[[i]])
103 |
104 | if(isTRUE(withDetails)){
105 | x[[i]] <- x_original[[i]] |>
106 | dplyr::filter(.data$concept_id %in% x[[i]])
107 | }
108 | }
109 |
110 | x <- x |>
111 | vctrs::list_drop_empty()
112 |
113 | CDMConnector::dropTable(cdm = cdm, name = tableCodelist)
114 |
115 | return(x)
116 | }
117 |
--------------------------------------------------------------------------------
/R/sysdata.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/R/sysdata.rda
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: github_document
3 | ---
4 |
5 |
6 |
7 | ```{r, include = FALSE}
8 | knitr::opts_chunk$set(
9 | collapse = TRUE,
10 | comment = "#>",
11 | fig.path = "man/figures/README-",
12 | out.width = "100%",
13 | message=FALSE,
14 | warning=FALSE
15 | )
16 | ```
17 |
18 | # CodelistGenerator
19 |
20 |
21 | [](https://CRAN.R-project.org/package=CodelistGenerator)
22 | [](https://app.codecov.io/github/darwin-eu/CodelistGenerator?branch=main)
23 | [](https://github.com/darwin-eu/CodelistGenerator/actions)
24 | [](https://lifecycle.r-lib.org/articles/stages.html#stable)
25 |
26 |
27 | ## Installation
28 | You can install CodelistGenerator from CRAN
29 | ``` r
30 | install.packages("CodelistGenerator")
31 | ```
32 | Or you can also install the development version of CodelistGenerator
33 | ``` r
34 | install.packages("remotes")
35 | remotes::install_github("darwin-eu/CodelistGenerator")
36 | ```
37 |
38 | ## Example usage
39 | ```{r}
40 | library(dplyr)
41 | library(CDMConnector)
42 | library(CodelistGenerator)
43 | ```
44 |
45 | For this example we'll use the Eunomia dataset (which only contains a subset of the OMOP CDM vocabularies)
46 | ```{r}
47 | requireEunomia()
48 | db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
49 | cdm <- cdmFromCon(db,
50 | cdmSchema = "main",
51 | writeSchema = "main",
52 | writePrefix = "cg_")
53 | ```
54 |
55 | ## Exploring the OMOP CDM Vocabulary tables
56 | OMOP CDM vocabularies are frequently updated, and we can identify the version of the vocabulary of our Eunomia data
57 | ```{r}
58 | getVocabVersion(cdm = cdm)
59 | ```
60 |
61 | ## Vocabulary based codelists using CodelistGenerator
62 | CodelistGenerator provides functions to extract code lists based on vocabulary hierarchies. One example is `getDrugIngredientCodes, which we can use, for example, to get the concept IDs used to represent aspirin and diclofenac.
63 | ```{r}
64 | ing <- getDrugIngredientCodes(cdm = cdm,
65 | name = c("aspirin", "diclofenac"),
66 | nameStyle = "{concept_name}")
67 | ing
68 | ing$aspirin
69 | ing$diclofenac
70 | ```
71 |
72 | ## Systematic search using CodelistGenerator
73 | CodelistGenerator can also support systematic searches of the vocabulary tables to support codelist development. A little like the process for a systematic review, the idea is that for a specified search strategy, CodelistGenerator will identify a set of concepts that may be relevant, with these then being screened to remove any irrelevant codes by clinical experts.
74 |
75 | We can do a simple search for asthma
76 | ```{r}
77 | asthma_codes1 <- getCandidateCodes(
78 | cdm = cdm,
79 | keywords = "asthma",
80 | domains = "Condition"
81 | )
82 | asthma_codes1 |>
83 | glimpse()
84 | ```
85 |
86 | But perhaps we want to exclude certain concepts as part of the search strategy, in this case we can add these like so
87 | ```{r}
88 | asthma_codes2 <- getCandidateCodes(
89 | cdm = cdm,
90 | keywords = "asthma",
91 | exclude = "childhood",
92 | domains = "Condition"
93 | )
94 | asthma_codes2 |>
95 | glimpse()
96 | ```
97 |
98 |
99 | ## Summarising code use
100 |
101 | As well as functions for finding codes, we also have functions to summarise their use. Here for
102 |
103 | ```{r}
104 | library(flextable)
105 | asthma_code_use <- summariseCodeUse(list("asthma" = asthma_codes1$concept_id),
106 | cdm = cdm
107 | )
108 | tableCodeUse(asthma_code_use, type = "flextable")
109 | ```
110 |
111 |
112 | ```{r, echo=FALSE}
113 | DBI::dbDisconnect(db)
114 | ```
115 |
--------------------------------------------------------------------------------
/_pkgdown.yml:
--------------------------------------------------------------------------------
1 | url: https://darwin-eu.github.io/CodelistGenerator/
2 | template:
3 | bootstrap: 5
4 | bootswatch: flatly
5 |
6 | navbar:
7 | structure:
8 | right: [github]
9 |
10 | reference:
11 | - subtitle: Search for codes following a systematic search strategy
12 | - contents:
13 | - getCandidateCodes
14 | - subtitle: Create vocabulary-based codelists
15 | - contents:
16 | - getDrugIngredientCodes
17 | - getATCCodes
18 | - getICD10StandardCodes
19 | - subtitle: Run codelist diagnostics
20 | - contents:
21 | - summariseAchillesCodeUse
22 | - summariseCodeUse
23 | - summariseCohortCodeUse
24 | - summariseOrphanCodes
25 | - summariseUnmappedCodes
26 | - subtitle: Present codelist diagnostics results in a table
27 | - contents:
28 | - tableAchillesCodeUse
29 | - tableCodeUse
30 | - tableCohortCodeUse
31 | - tableOrphanCodes
32 | - tableUnmappedCodes
33 | - subtitle: Extract codelists from JSON files
34 | - contents:
35 | - codesFromCohort
36 | - codesFromConceptSet
37 | - subtitle: Codelist utility functions
38 | - contents:
39 | - compareCodelists
40 | - subsetToCodesInUse
41 | - subsetOnRouteCategory
42 | - subsetOnDoseUnit
43 | - subsetOnDomain
44 | - stratifyByRouteCategory
45 | - stratifyByDoseUnit
46 | - stratifyByConcept
47 | - getMappings
48 | - subtitle: Vocabulary utility functions
49 | - contents:
50 | - getVocabVersion
51 | - getVocabularies
52 | - getConceptClassId
53 | - getDomains
54 | - getDescendants
55 | - getDoseForm
56 | - getRouteCategories
57 | - getDoseUnit
58 | - getRelationshipId
59 | - codesInUse
60 | - sourceCodesInUse
61 | - availableATC
62 | - availableICD10
63 | - availableIngredients
64 | - subtitle: Create a mock dataset that contains vocabulary tables
65 | - contents:
66 | - mockVocabRef
67 | - buildAchillesTables
68 |
69 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: false
2 |
3 | coverage:
4 | status:
5 | project:
6 | default:
7 | target: auto
8 | threshold: 1%
9 | informational: true
10 | patch:
11 | default:
12 | target: auto
13 | threshold: 1%
14 | informational: true
15 |
--------------------------------------------------------------------------------
/cran-comments.md:
--------------------------------------------------------------------------------
1 | ## R CMD check results
2 |
3 | This is a new release.
4 |
--------------------------------------------------------------------------------
/docs/articles/Introduction_to_CodelistGenerator_files/crosstalk-1.2.0/css/crosstalk.min.css:
--------------------------------------------------------------------------------
1 | .container-fluid.crosstalk-bscols{margin-left:-30px;margin-right:-30px;white-space:normal}body>.container-fluid.crosstalk-bscols{margin-left:auto;margin-right:auto}.crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column{display:inline-block;padding-right:12px;vertical-align:top}@media only screen and (max-width: 480px){.crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column{display:block;padding-right:inherit}}.crosstalk-input{margin-bottom:15px}.crosstalk-input .control-label{margin-bottom:0;vertical-align:middle}.crosstalk-input input[type="checkbox"]{margin:4px 0 0;margin-top:1px;line-height:normal}.crosstalk-input .checkbox{position:relative;display:block;margin-top:10px;margin-bottom:10px}.crosstalk-input .checkbox>label{padding-left:20px;margin-bottom:0;font-weight:400;cursor:pointer}.crosstalk-input .checkbox input[type="checkbox"],.crosstalk-input .checkbox-inline input[type="checkbox"]{position:absolute;margin-top:2px;margin-left:-20px}.crosstalk-input .checkbox+.checkbox{margin-top:-5px}.crosstalk-input .checkbox-inline{position:relative;display:inline-block;padding-left:20px;margin-bottom:0;font-weight:400;vertical-align:middle;cursor:pointer}.crosstalk-input .checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}
2 |
--------------------------------------------------------------------------------
/docs/articles/Introduction_to_CodelistGenerator_files/crosstalk-1.2.0/scss/crosstalk.scss:
--------------------------------------------------------------------------------
1 | /* Adjust margins outwards, so column contents line up with the edges of the
2 | parent of container-fluid. */
3 | .container-fluid.crosstalk-bscols {
4 | margin-left: -30px;
5 | margin-right: -30px;
6 | white-space: normal;
7 | }
8 |
9 | /* But don't adjust the margins outwards if we're directly under the body,
10 | i.e. we were the top-level of something at the console. */
11 | body > .container-fluid.crosstalk-bscols {
12 | margin-left: auto;
13 | margin-right: auto;
14 | }
15 |
16 | .crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column {
17 | display: inline-block;
18 | padding-right: 12px;
19 | vertical-align: top;
20 | }
21 |
22 | @media only screen and (max-width:480px) {
23 | .crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column {
24 | display: block;
25 | padding-right: inherit;
26 | }
27 | }
28 |
29 | /* Relevant BS3 styles to make filter_checkbox() look reasonable without Bootstrap */
30 | .crosstalk-input {
31 | margin-bottom: 15px; /* a la .form-group */
32 | .control-label {
33 | margin-bottom: 0;
34 | vertical-align: middle;
35 | }
36 | input[type="checkbox"] {
37 | margin: 4px 0 0;
38 | margin-top: 1px;
39 | line-height: normal;
40 | }
41 | .checkbox {
42 | position: relative;
43 | display: block;
44 | margin-top: 10px;
45 | margin-bottom: 10px;
46 | }
47 | .checkbox > label{
48 | padding-left: 20px;
49 | margin-bottom: 0;
50 | font-weight: 400;
51 | cursor: pointer;
52 | }
53 | .checkbox input[type="checkbox"],
54 | .checkbox-inline input[type="checkbox"] {
55 | position: absolute;
56 | margin-top: 2px;
57 | margin-left: -20px;
58 | }
59 | .checkbox + .checkbox {
60 | margin-top: -5px;
61 | }
62 | .checkbox-inline {
63 | position: relative;
64 | display: inline-block;
65 | padding-left: 20px;
66 | margin-bottom: 0;
67 | font-weight: 400;
68 | vertical-align: middle;
69 | cursor: pointer;
70 | }
71 | .checkbox-inline + .checkbox-inline {
72 | margin-top: 0;
73 | margin-left: 10px;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/docs/articles/Introduction_to_CodelistGenerator_files/datatables-css-0.0.0/datatables-crosstalk.css:
--------------------------------------------------------------------------------
1 | .dt-crosstalk-fade {
2 | opacity: 0.2;
3 | }
4 |
5 | html body div.DTS div.dataTables_scrollBody {
6 | background: none;
7 | }
8 |
9 |
10 | /*
11 | Fix https://github.com/rstudio/DT/issues/563
12 | If the `table.display` is set to "block" (e.g., pkgdown), the browser will display
13 | datatable objects strangely. The search panel and the page buttons will still be
14 | in full-width but the table body will be "compact" and shorter.
15 | In therory, having this attributes will affect `dom="t"`
16 | with `display: block` users. But in reality, there should be no one.
17 | We may remove the below lines in the future if the upstream agree to have this there.
18 | See https://github.com/DataTables/DataTablesSrc/issues/160
19 | */
20 |
21 | table.dataTable {
22 | display: table;
23 | }
24 |
--------------------------------------------------------------------------------
/docs/articles/Introduction_to_CodelistGenerator_files/dt-core-1.11.3/css/jquery.dataTables.extra.css:
--------------------------------------------------------------------------------
1 | /* Selected rows/cells */
2 | table.dataTable tr.selected td, table.dataTable td.selected {
3 | background-color: #b0bed9 !important;
4 | }
5 | /* In case of scrollX/Y or FixedHeader */
6 | .dataTables_scrollBody .dataTables_sizing {
7 | visibility: hidden;
8 | }
9 |
10 | /* The datatables' theme CSS file doesn't define
11 | the color but with white background. It leads to an issue that
12 | when the HTML's body color is set to 'white', the user can't
13 | see the text since the background is white. One case happens in the
14 | RStudio's IDE when inline viewing the DT table inside an Rmd file,
15 | if the IDE theme is set to "Cobalt".
16 |
17 | See https://github.com/rstudio/DT/issues/447 for more info
18 |
19 | This fixes should have little side-effects because all the other elements
20 | of the default theme use the #333 font color.
21 |
22 | TODO: The upstream may use relative colors for both the table background
23 | and the color. It means the table can display well without this patch
24 | then. At that time, we need to remove the below CSS attributes.
25 | */
26 | div.datatables {
27 | color: #333;
28 | }
29 |
--------------------------------------------------------------------------------
/docs/bootstrap-toc.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3 | * Copyright 2015 Aidan Feldman
4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5 |
6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */
7 |
8 | /* All levels of nav */
9 | nav[data-toggle='toc'] .nav > li > a {
10 | display: block;
11 | padding: 4px 20px;
12 | font-size: 13px;
13 | font-weight: 500;
14 | color: #767676;
15 | }
16 | nav[data-toggle='toc'] .nav > li > a:hover,
17 | nav[data-toggle='toc'] .nav > li > a:focus {
18 | padding-left: 19px;
19 | color: #563d7c;
20 | text-decoration: none;
21 | background-color: transparent;
22 | border-left: 1px solid #563d7c;
23 | }
24 | nav[data-toggle='toc'] .nav > .active > a,
25 | nav[data-toggle='toc'] .nav > .active:hover > a,
26 | nav[data-toggle='toc'] .nav > .active:focus > a {
27 | padding-left: 18px;
28 | font-weight: bold;
29 | color: #563d7c;
30 | background-color: transparent;
31 | border-left: 2px solid #563d7c;
32 | }
33 |
34 | /* Nav: second level (shown on .active) */
35 | nav[data-toggle='toc'] .nav .nav {
36 | display: none; /* Hide by default, but at >768px, show it */
37 | padding-bottom: 10px;
38 | }
39 | nav[data-toggle='toc'] .nav .nav > li > a {
40 | padding-top: 1px;
41 | padding-bottom: 1px;
42 | padding-left: 30px;
43 | font-size: 12px;
44 | font-weight: normal;
45 | }
46 | nav[data-toggle='toc'] .nav .nav > li > a:hover,
47 | nav[data-toggle='toc'] .nav .nav > li > a:focus {
48 | padding-left: 29px;
49 | }
50 | nav[data-toggle='toc'] .nav .nav > .active > a,
51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a,
52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a {
53 | padding-left: 28px;
54 | font-weight: 500;
55 | }
56 |
57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */
58 | nav[data-toggle='toc'] .nav > .active > ul {
59 | display: block;
60 | }
61 |
--------------------------------------------------------------------------------
/docs/docsearch.js:
--------------------------------------------------------------------------------
1 | $(function() {
2 |
3 | // register a handler to move the focus to the search bar
4 | // upon pressing shift + "/" (i.e. "?")
5 | $(document).on('keydown', function(e) {
6 | if (e.shiftKey && e.keyCode == 191) {
7 | e.preventDefault();
8 | $("#search-input").focus();
9 | }
10 | });
11 |
12 | $(document).ready(function() {
13 | // do keyword highlighting
14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */
15 | var mark = function() {
16 |
17 | var referrer = document.URL ;
18 | var paramKey = "q" ;
19 |
20 | if (referrer.indexOf("?") !== -1) {
21 | var qs = referrer.substr(referrer.indexOf('?') + 1);
22 | var qs_noanchor = qs.split('#')[0];
23 | var qsa = qs_noanchor.split('&');
24 | var keyword = "";
25 |
26 | for (var i = 0; i < qsa.length; i++) {
27 | var currentParam = qsa[i].split('=');
28 |
29 | if (currentParam.length !== 2) {
30 | continue;
31 | }
32 |
33 | if (currentParam[0] == paramKey) {
34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20"));
35 | }
36 | }
37 |
38 | if (keyword !== "") {
39 | $(".contents").unmark({
40 | done: function() {
41 | $(".contents").mark(keyword);
42 | }
43 | });
44 | }
45 | }
46 | };
47 |
48 | mark();
49 | });
50 | });
51 |
52 | /* Search term highlighting ------------------------------*/
53 |
54 | function matchedWords(hit) {
55 | var words = [];
56 |
57 | var hierarchy = hit._highlightResult.hierarchy;
58 | // loop to fetch from lvl0, lvl1, etc.
59 | for (var idx in hierarchy) {
60 | words = words.concat(hierarchy[idx].matchedWords);
61 | }
62 |
63 | var content = hit._highlightResult.content;
64 | if (content) {
65 | words = words.concat(content.matchedWords);
66 | }
67 |
68 | // return unique words
69 | var words_uniq = [...new Set(words)];
70 | return words_uniq;
71 | }
72 |
73 | function updateHitURL(hit) {
74 |
75 | var words = matchedWords(hit);
76 | var url = "";
77 |
78 | if (hit.anchor) {
79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor;
80 | } else {
81 | url = hit.url + '?q=' + escape(words.join(" "));
82 | }
83 |
84 | return url;
85 | }
86 |
--------------------------------------------------------------------------------
/docs/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/docs/pkgdown.js:
--------------------------------------------------------------------------------
1 | /* http://gregfranko.com/blog/jquery-best-practices/ */
2 | (function($) {
3 | $(function() {
4 |
5 | $('.navbar-fixed-top').headroom();
6 |
7 | $('body').css('padding-top', $('.navbar').height() + 10);
8 | $(window).resize(function(){
9 | $('body').css('padding-top', $('.navbar').height() + 10);
10 | });
11 |
12 | $('[data-toggle="tooltip"]').tooltip();
13 |
14 | var cur_path = paths(location.pathname);
15 | var links = $("#navbar ul li a");
16 | var max_length = -1;
17 | var pos = -1;
18 | for (var i = 0; i < links.length; i++) {
19 | if (links[i].getAttribute("href") === "#")
20 | continue;
21 | // Ignore external links
22 | if (links[i].host !== location.host)
23 | continue;
24 |
25 | var nav_path = paths(links[i].pathname);
26 |
27 | var length = prefix_length(nav_path, cur_path);
28 | if (length > max_length) {
29 | max_length = length;
30 | pos = i;
31 | }
32 | }
33 |
34 | // Add class to parent
, and enclosing if in dropdown
35 | if (pos >= 0) {
36 | var menu_anchor = $(links[pos]);
37 | menu_anchor.parent().addClass("active");
38 | menu_anchor.closest("li.dropdown").addClass("active");
39 | }
40 | });
41 |
42 | function paths(pathname) {
43 | var pieces = pathname.split("/");
44 | pieces.shift(); // always starts with /
45 |
46 | var end = pieces[pieces.length - 1];
47 | if (end === "index.html" || end === "")
48 | pieces.pop();
49 | return(pieces);
50 | }
51 |
52 | // Returns -1 if not found
53 | function prefix_length(needle, haystack) {
54 | if (needle.length > haystack.length)
55 | return(-1);
56 |
57 | // Special case for length-0 haystack, since for loop won't run
58 | if (haystack.length === 0) {
59 | return(needle.length === 0 ? 0 : -1);
60 | }
61 |
62 | for (var i = 0; i < haystack.length; i++) {
63 | if (needle[i] != haystack[i])
64 | return(i);
65 | }
66 |
67 | return(haystack.length);
68 | }
69 |
70 | /* Clipboard --------------------------*/
71 |
72 | function changeTooltipMessage(element, msg) {
73 | var tooltipOriginalTitle=element.getAttribute('data-original-title');
74 | element.setAttribute('data-original-title', msg);
75 | $(element).tooltip('show');
76 | element.setAttribute('data-original-title', tooltipOriginalTitle);
77 | }
78 |
79 | if(ClipboardJS.isSupported()) {
80 | $(document).ready(function() {
81 | var copyButton = "";
82 |
83 | $("div.sourceCode").addClass("hasCopyButton");
84 |
85 | // Insert copy buttons:
86 | $(copyButton).prependTo(".hasCopyButton");
87 |
88 | // Initialize tooltips:
89 | $('.btn-copy-ex').tooltip({container: 'body'});
90 |
91 | // Initialize clipboard:
92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', {
93 | text: function(trigger) {
94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, "");
95 | }
96 | });
97 |
98 | clipboardBtnCopies.on('success', function(e) {
99 | changeTooltipMessage(e.trigger, 'Copied!');
100 | e.clearSelection();
101 | });
102 |
103 | clipboardBtnCopies.on('error', function() {
104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy');
105 | });
106 | });
107 | }
108 | })(window.jQuery || window.$)
109 |
--------------------------------------------------------------------------------
/docs/pkgdown.yml:
--------------------------------------------------------------------------------
1 | pandoc: 2.7.2
2 | pkgdown: 2.0.2
3 | pkgdown_sha: ~
4 | articles:
5 | Introduction_to_CodelistGenerator: Introduction_to_CodelistGenerator.html
6 | last_built: 2022-04-04T21:53Z
7 |
8 |
--------------------------------------------------------------------------------
/docs/reference/Rplot001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/docs/reference/Rplot001.png
--------------------------------------------------------------------------------
/docs/reference/figures/README-pressure-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/docs/reference/figures/README-pressure-1.png
--------------------------------------------------------------------------------
/docs/sitemap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | /404.html
5 |
6 |
7 | /articles/index.html
8 |
9 |
10 | /articles/Introduction_to_CodelistGenerator.html
11 |
12 |
13 | /authors.html
14 |
15 |
16 | /index.html
17 |
18 |
19 | /LICENSE-text.html
20 |
21 |
22 | /LICENSE.html
23 |
24 |
25 | /README.knit.html
26 |
27 |
28 | /reference/clean_words.html
29 |
30 |
31 | /reference/get_candidate_codes.html
32 |
33 |
34 | /reference/index.html
35 |
36 |
37 | /reference/show_mappings.html
38 |
39 |
40 |
--------------------------------------------------------------------------------
/inst/WORDLIST:
--------------------------------------------------------------------------------
1 | CDM
2 | CDMConnector
3 | CMD
4 | Codelist
5 | Codelists
6 | Eunomia
7 | ICD
8 | Levenshtein
9 | Lifecycle
10 | Musculoskeletal
11 | OMOP
12 | ORCID
13 | Osteoarthrosis
14 | Quant
15 | agrep
16 | cdm
17 | codecov
18 | codelist
19 | codelists
20 | concpet
21 | duckdb
22 | getCandidateCodes
23 | getConceptClassId
24 | getDescendants
25 | getDomains
26 | getDoseForm
27 | getVocabVersion
28 | getVocabularies
29 | includeAncestor
30 | includeDescendants
31 | io
32 | magrittr
33 | searchViaSynonyms
34 | snomed
35 | tibble
36 |
--------------------------------------------------------------------------------
/inst/cohorts_for_mock/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "arthritis",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Arthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | },
21 | "includeDescendants": true
22 | }
23 | ]
24 | }
25 | },
26 | {
27 | "id": 1,
28 | "name": "Other",
29 | "expression": {
30 | "items": [
31 | {
32 | "concept": {
33 | "CONCEPT_CLASS_ID": "Clinical Finding",
34 | "CONCEPT_CODE": "422504002",
35 | "CONCEPT_ID": 5,
36 | "CONCEPT_NAME": "Osteoarthritis of hip",
37 | "DOMAIN_ID": "Condition",
38 | "INVALID_REASON": "V",
39 | "INVALID_REASON_CAPTION": "Valid",
40 | "STANDARD_CONCEPT": "S",
41 | "STANDARD_CONCEPT_CAPTION": "Standard",
42 | "VOCABULARY_ID": "SNOMED"
43 | }
44 | }
45 | ]
46 | }
47 | }
48 | ],
49 | "PrimaryCriteria": {
50 | "CriteriaList": [
51 | {
52 | "ConditionOccurrence": {
53 | "CodesetId": 0
54 | }
55 | },
56 | {
57 | "Observation": {
58 | "CodesetId": 0
59 | }
60 | },
61 | {
62 | "ConditionOccurrence": {
63 | "CodesetId": 1
64 | }
65 | }
66 | ],
67 | "ObservationWindow": {
68 | "PriorDays": 0,
69 | "PostDays": 0
70 | },
71 | "PrimaryCriteriaLimit": {
72 | "Type": "First"
73 | }
74 | },
75 | "QualifiedLimit": {
76 | "Type": "First"
77 | },
78 | "ExpressionLimit": {
79 | "Type": "First"
80 | },
81 | "InclusionRules": [],
82 | "CensoringCriteria": [],
83 | "CollapseSettings": {
84 | "CollapseType": "ERA",
85 | "EraPad": 0
86 | },
87 | "CensorWindow": {},
88 | "cdmVersionRange": ">=5.0.0"
89 | }
90 |
--------------------------------------------------------------------------------
/inst/cohorts_for_mock/oa_no_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "OA no descendants",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Osteoarthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | }
21 | }
22 | ]
23 | }
24 | },
25 | {
26 | "id": 1,
27 | "name": "Other",
28 | "expression": {
29 | "items": [
30 | {
31 | "concept": {
32 | "CONCEPT_CLASS_ID": "Clinical Finding",
33 | "CONCEPT_CODE": "422504002",
34 | "CONCEPT_ID": 5,
35 | "CONCEPT_NAME": "Ischemic stroke",
36 | "DOMAIN_ID": "Condition",
37 | "INVALID_REASON": "V",
38 | "INVALID_REASON_CAPTION": "Valid",
39 | "STANDARD_CONCEPT": "S",
40 | "STANDARD_CONCEPT_CAPTION": "Standard",
41 | "VOCABULARY_ID": "SNOMED"
42 | }
43 | }
44 | ]
45 | }
46 | }
47 | ],
48 | "PrimaryCriteria": {
49 | "CriteriaList": [
50 | {
51 | "ConditionOccurrence": {
52 | "CodesetId": 0
53 | }
54 | },
55 | {
56 | "Observation": {
57 | "CodesetId": 0
58 | }
59 | },
60 | {
61 | "ConditionOccurrence": {
62 | "CodesetId": 1
63 | }
64 | }
65 | ],
66 | "ObservationWindow": {
67 | "PriorDays": 0,
68 | "PostDays": 0
69 | },
70 | "PrimaryCriteriaLimit": {
71 | "Type": "First"
72 | }
73 | },
74 | "QualifiedLimit": {
75 | "Type": "First"
76 | },
77 | "ExpressionLimit": {
78 | "Type": "First"
79 | },
80 | "InclusionRules": [],
81 | "CensoringCriteria": [],
82 | "CollapseSettings": {
83 | "CollapseType": "ERA",
84 | "EraPad": 0
85 | },
86 | "CensorWindow": {},
87 | "cdmVersionRange": ">=5.0.0"
88 | }
--------------------------------------------------------------------------------
/inst/cohorts_for_mock_dups/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "OA",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Osteoarthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | },
21 | "includeDescendants": true
22 | }
23 | ]
24 | }
25 | },
26 | {
27 | "id": 1,
28 | "name": "Other",
29 | "expression": {
30 | "items": [
31 | {
32 | "concept": {
33 | "CONCEPT_CLASS_ID": "Clinical Finding",
34 | "CONCEPT_CODE": "422504002",
35 | "CONCEPT_ID": 5,
36 | "CONCEPT_NAME": "Ischemic stroke",
37 | "DOMAIN_ID": "Condition",
38 | "INVALID_REASON": "V",
39 | "INVALID_REASON_CAPTION": "Valid",
40 | "STANDARD_CONCEPT": "S",
41 | "STANDARD_CONCEPT_CAPTION": "Standard",
42 | "VOCABULARY_ID": "SNOMED"
43 | }
44 | }
45 | ]
46 | }
47 | }
48 | ],
49 | "PrimaryCriteria": {
50 | "CriteriaList": [
51 | {
52 | "ConditionOccurrence": {
53 | "CodesetId": 0
54 | }
55 | },
56 | {
57 | "Observation": {
58 | "CodesetId": 0
59 | }
60 | },
61 | {
62 | "ConditionOccurrence": {
63 | "CodesetId": 1
64 | }
65 | }
66 | ],
67 | "ObservationWindow": {
68 | "PriorDays": 0,
69 | "PostDays": 0
70 | },
71 | "PrimaryCriteriaLimit": {
72 | "Type": "First"
73 | }
74 | },
75 | "QualifiedLimit": {
76 | "Type": "First"
77 | },
78 | "ExpressionLimit": {
79 | "Type": "First"
80 | },
81 | "InclusionRules": [],
82 | "CensoringCriteria": [],
83 | "CollapseSettings": {
84 | "CollapseType": "ERA",
85 | "EraPad": 0
86 | },
87 | "CensorWindow": {},
88 | "cdmVersionRange": ">=5.0.0"
89 | }
--------------------------------------------------------------------------------
/inst/cohorts_for_mock_dups/oa_no_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "OA",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Osteoarthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | }
21 | }
22 | ]
23 | }
24 | },
25 | {
26 | "id": 1,
27 | "name": "Other",
28 | "expression": {
29 | "items": [
30 | {
31 | "concept": {
32 | "CONCEPT_CLASS_ID": "Clinical Finding",
33 | "CONCEPT_CODE": "422504002",
34 | "CONCEPT_ID": 5,
35 | "CONCEPT_NAME": "Ischemic stroke",
36 | "DOMAIN_ID": "Condition",
37 | "INVALID_REASON": "V",
38 | "INVALID_REASON_CAPTION": "Valid",
39 | "STANDARD_CONCEPT": "S",
40 | "STANDARD_CONCEPT_CAPTION": "Standard",
41 | "VOCABULARY_ID": "SNOMED"
42 | }
43 | }
44 | ]
45 | }
46 | }
47 | ],
48 | "PrimaryCriteria": {
49 | "CriteriaList": [
50 | {
51 | "ConditionOccurrence": {
52 | "CodesetId": 0
53 | }
54 | },
55 | {
56 | "Observation": {
57 | "CodesetId": 0
58 | }
59 | },
60 | {
61 | "ConditionOccurrence": {
62 | "CodesetId": 1
63 | }
64 | }
65 | ],
66 | "ObservationWindow": {
67 | "PriorDays": 0,
68 | "PostDays": 0
69 | },
70 | "PrimaryCriteriaLimit": {
71 | "Type": "First"
72 | }
73 | },
74 | "QualifiedLimit": {
75 | "Type": "First"
76 | },
77 | "ExpressionLimit": {
78 | "Type": "First"
79 | },
80 | "InclusionRules": [],
81 | "CensoringCriteria": [],
82 | "CollapseSettings": {
83 | "CollapseType": "ERA",
84 | "EraPad": 0
85 | },
86 | "CensorWindow": {},
87 | "cdmVersionRange": ">=5.0.0"
88 | }
--------------------------------------------------------------------------------
/inst/cohorts_for_mock_with_exclude/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "OA",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Osteoarthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | },
21 | "includeDescendants": true
22 | },
23 | {
24 | "concept": {
25 | "CONCEPT_CLASS_ID": "Clinical Finding",
26 | "CONCEPT_CODE": "422504002",
27 | "CONCEPT_ID": 4,
28 | "CONCEPT_NAME": "Ischemic stroke",
29 | "DOMAIN_ID": "Condition",
30 | "INVALID_REASON": "V",
31 | "INVALID_REASON_CAPTION": "Valid",
32 | "STANDARD_CONCEPT": "S",
33 | "STANDARD_CONCEPT_CAPTION": "Standard",
34 | "VOCABULARY_ID": "SNOMED"
35 | },
36 | "isExcluded": true
37 | }
38 | ]
39 | }
40 | },
41 | {
42 | "id": 1,
43 | "name": "Other",
44 | "expression": {
45 | "items": [
46 | {
47 | "concept": {
48 | "CONCEPT_CLASS_ID": "Clinical Finding",
49 | "CONCEPT_CODE": "422504002",
50 | "CONCEPT_ID": 6,
51 | "CONCEPT_NAME": "Ischemic stroke",
52 | "DOMAIN_ID": "Condition",
53 | "INVALID_REASON": "V",
54 | "INVALID_REASON_CAPTION": "Valid",
55 | "STANDARD_CONCEPT": "S",
56 | "STANDARD_CONCEPT_CAPTION": "Standard",
57 | "VOCABULARY_ID": "SNOMED"
58 | }
59 | }
60 | ]
61 | }
62 | }
63 | ],
64 | "PrimaryCriteria": {
65 | "CriteriaList": [
66 | {
67 | "ConditionOccurrence": {
68 | "CodesetId": 0
69 | }
70 | },
71 | {
72 | "Observation": {
73 | "CodesetId": 0
74 | }
75 | },
76 | {
77 | "ConditionOccurrence": {
78 | "CodesetId": 1
79 | }
80 | }
81 | ],
82 | "ObservationWindow": {
83 | "PriorDays": 0,
84 | "PostDays": 0
85 | },
86 | "PrimaryCriteriaLimit": {
87 | "Type": "First"
88 | }
89 | },
90 | "QualifiedLimit": {
91 | "Type": "First"
92 | },
93 | "ExpressionLimit": {
94 | "Type": "First"
95 | },
96 | "InclusionRules": [],
97 | "CensoringCriteria": [],
98 | "CollapseSettings": {
99 | "CollapseType": "ERA",
100 | "EraPad": 0
101 | },
102 | "CensorWindow": {},
103 | "cdmVersionRange": ">=5.0.0"
104 | }
--------------------------------------------------------------------------------
/inst/cohorts_for_mock_with_mapped/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "OA",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Osteoarthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | },
21 | "includeDescendants": true
22 | }
23 | ]
24 | }
25 | },
26 | {
27 | "id": 1,
28 | "name": "Other",
29 | "expression": {
30 | "items": [
31 | {
32 | "concept": {
33 | "CONCEPT_CLASS_ID": "Clinical Finding",
34 | "CONCEPT_CODE": "422504002",
35 | "CONCEPT_ID": 5,
36 | "CONCEPT_NAME": "Ischemic stroke",
37 | "DOMAIN_ID": "Condition",
38 | "INVALID_REASON": "V",
39 | "INVALID_REASON_CAPTION": "Valid",
40 | "STANDARD_CONCEPT": "S",
41 | "STANDARD_CONCEPT_CAPTION": "Standard",
42 | "VOCABULARY_ID": "SNOMED"
43 | },
44 | "includeMapped": true
45 | }
46 | ]
47 | }
48 | }
49 | ],
50 | "PrimaryCriteria": {
51 | "CriteriaList": [
52 | {
53 | "ConditionOccurrence": {
54 | "CodesetId": 0
55 | }
56 | },
57 | {
58 | "Observation": {
59 | "CodesetId": 0
60 | }
61 | },
62 | {
63 | "ConditionOccurrence": {
64 | "CodesetId": 1
65 | }
66 | }
67 | ],
68 | "ObservationWindow": {
69 | "PriorDays": 0,
70 | "PostDays": 0
71 | },
72 | "PrimaryCriteriaLimit": {
73 | "Type": "First"
74 | }
75 | },
76 | "QualifiedLimit": {
77 | "Type": "First"
78 | },
79 | "ExpressionLimit": {
80 | "Type": "First"
81 | },
82 | "InclusionRules": [],
83 | "CensoringCriteria": [],
84 | "CollapseSettings": {
85 | "CollapseType": "ERA",
86 | "EraPad": 0
87 | },
88 | "CensorWindow": {},
89 | "cdmVersionRange": ">=5.0.0"
90 | }
--------------------------------------------------------------------------------
/inst/cohorts_for_mock_with_mapped/oa_no_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConceptSets": [
3 | {
4 | "id": 0,
5 | "name": "OA no descendants",
6 | "expression": {
7 | "items": [
8 | {
9 | "concept": {
10 | "CONCEPT_CLASS_ID": "Clinical Finding",
11 | "CONCEPT_CODE": "396275006",
12 | "CONCEPT_ID": 3,
13 | "CONCEPT_NAME": "Osteoarthritis",
14 | "DOMAIN_ID": "Condition",
15 | "INVALID_REASON": "V",
16 | "INVALID_REASON_CAPTION": "Valid",
17 | "STANDARD_CONCEPT": "S",
18 | "STANDARD_CONCEPT_CAPTION": "Standard",
19 | "VOCABULARY_ID": "SNOMED"
20 | }
21 | }
22 | ]
23 | }
24 | },
25 | {
26 | "id": 1,
27 | "name": "Other",
28 | "expression": {
29 | "items": [
30 | {
31 | "concept": {
32 | "CONCEPT_CLASS_ID": "Clinical Finding",
33 | "CONCEPT_CODE": "422504002",
34 | "CONCEPT_ID": 5,
35 | "CONCEPT_NAME": "Ischemic stroke",
36 | "DOMAIN_ID": "Condition",
37 | "INVALID_REASON": "V",
38 | "INVALID_REASON_CAPTION": "Valid",
39 | "STANDARD_CONCEPT": "S",
40 | "STANDARD_CONCEPT_CAPTION": "Standard",
41 | "VOCABULARY_ID": "SNOMED"
42 | }
43 | }
44 | ]
45 | }
46 | }
47 | ],
48 | "PrimaryCriteria": {
49 | "CriteriaList": [
50 | {
51 | "ConditionOccurrence": {
52 | "CodesetId": 0
53 | }
54 | },
55 | {
56 | "Observation": {
57 | "CodesetId": 0
58 | }
59 | },
60 | {
61 | "ConditionOccurrence": {
62 | "CodesetId": 1
63 | }
64 | }
65 | ],
66 | "ObservationWindow": {
67 | "PriorDays": 0,
68 | "PostDays": 0
69 | },
70 | "PrimaryCriteriaLimit": {
71 | "Type": "First"
72 | }
73 | },
74 | "QualifiedLimit": {
75 | "Type": "First"
76 | },
77 | "ExpressionLimit": {
78 | "Type": "First"
79 | },
80 | "InclusionRules": [],
81 | "CensoringCriteria": [],
82 | "CollapseSettings": {
83 | "CollapseType": "ERA",
84 | "EraPad": 0
85 | },
86 | "CensorWindow": {},
87 | "cdmVersionRange": ">=5.0.0"
88 | }
--------------------------------------------------------------------------------
/inst/concepts_dbms/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 4079750
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/inst/concepts_dbms/oa_no_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 4079750
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": false,
9 | "includeMapped": false
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/inst/concepts_for_mock/arthritis_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/inst/concepts_for_mock/arthritis_no_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": false,
9 | "includeMapped": false
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/inst/concepts_for_mock/arthritis_with_excluded.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | },
11 | {
12 | "concept": {
13 | "CONCEPT_ID": 4
14 | },
15 | "isExcluded": true,
16 | "includeDescendants": false,
17 | "includeMapped": false
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/inst/concepts_for_mock_with_exclude/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/inst/concepts_for_mock_with_exclude/oa_with_excluded.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | },
11 | {
12 | "concept": {
13 | "CONCEPT_ID": 4
14 | },
15 | "isExcluded": true,
16 | "includeDescendants": false,
17 | "includeMapped": false
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/inst/concepts_for_mock_with_exclude/oa_with_excluded2.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | },
11 | {
12 | "concept": {
13 | "CONCEPT_ID": 4
14 | },
15 | "isExcluded": true,
16 | "includeDescendants": false,
17 | "includeMapped": false
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/inst/concepts_for_mock_with_mapped/oa_desc.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": false
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/inst/concepts_for_mock_with_mapped/oa_with_mapped.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "concept": {
5 | "CONCEPT_ID": 3
6 | },
7 | "isExcluded": false,
8 | "includeDescendants": true,
9 | "includeMapped": true
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/man/CodelistGenerator-package.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/CodelistGenerator-package.R
3 | \docType{package}
4 | \name{CodelistGenerator-package}
5 | \alias{CodelistGenerator}
6 | \alias{CodelistGenerator-package}
7 | \title{CodelistGenerator: Identify Relevant Clinical Codes and Evaluate Their Use}
8 | \description{
9 | \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
10 |
11 | Generate a candidate code list for the Observational Medical Outcomes Partnership (OMOP) common data model based on string matching. For a given search strategy, a candidate code list will be returned.
12 | }
13 | \seealso{
14 | Useful links:
15 | \itemize{
16 | \item \url{https://darwin-eu.github.io/CodelistGenerator/}
17 | }
18 |
19 | }
20 | \author{
21 | \strong{Maintainer}: Edward Burn \email{edward.burn@ndorms.ox.ac.uk} (\href{https://orcid.org/0000-0002-9286-1128}{ORCID})
22 |
23 | Authors:
24 | \itemize{
25 | \item Xihang Chen \email{xihang.chen@ndorms.ox.ac.uk} (\href{https://orcid.org/0009-0001-8112-8959}{ORCID})
26 | \item Nuria Mercade-Besora \email{nuria.mercadebesora@ndorms.ox.ac.uk} (\href{https://orcid.org/0009-0006-7948-3747}{ORCID})
27 | }
28 |
29 | Other contributors:
30 | \itemize{
31 | \item Marti Catala \email{marti.catalasabate@ndorms.ox.ac.uk} (\href{https://orcid.org/0000-0003-3308-9905}{ORCID}) [contributor]
32 | \item Mike Du \email{mike.du@ndorms.ox.ac.uk} (\href{https://orcid.org/0000-0002-9517-8834}{ORCID}) [contributor]
33 | \item Danielle Newby \email{danielle.newby@ndorms.ox.ac.uk} (\href{https://orcid.org/0000-0002-3001-1478}{ORCID}) [contributor]
34 | \item Marta Alcalde-Herraiz \email{marta.alcaldeherraiz@ndorms.ox.ac.uk} (\href{https://orcid.org/0009-0002-4405-1814}{ORCID}) [contributor]
35 | }
36 |
37 | }
38 | \keyword{internal}
39 |
--------------------------------------------------------------------------------
/man/ageGroupDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{ageGroupDoc}
4 | \alias{ageGroupDoc}
5 | \title{Helper for consistent documentation of \code{ageGroup}.}
6 | \arguments{
7 | \item{ageGroup}{If not NULL, a list of ageGroup vectors of length two.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{ageGroup}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/availableATC.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/helperFunctions.R
3 | \name{availableATC}
4 | \alias{availableATC}
5 | \title{Get the names of all available Anatomical Therapeutic Chemical (ATC) classification codes}
6 | \usage{
7 | availableATC(cdm, level = c("ATC 1st"))
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 |
12 | \item{level}{ATC level. Can be one or more of "ATC 1st", "ATC 2nd",
13 | "ATC 3rd", "ATC 4th", and "ATC 5th".}
14 | }
15 | \value{
16 | A vector containing the names of ATC codes for the chosen level(s)
17 | found in the concept table of cdm.
18 | }
19 | \description{
20 | Get the names of all available Anatomical Therapeutic Chemical (ATC) classification codes
21 | }
22 | \examples{
23 | \donttest{
24 | cdm <- mockVocabRef()
25 | availableATC(cdm)
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/man/availableICD10.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/helperFunctions.R
3 | \name{availableICD10}
4 | \alias{availableICD10}
5 | \title{Get the names of all International Classification of Diseases (ICD) 10 codes}
6 | \usage{
7 | availableICD10(cdm, level = c("ICD10 Chapter", "ICD10 SubChapter"))
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 |
12 | \item{level}{Can be either "ICD10 Chapter", "ICD10 SubChapter",
13 | "ICD10 Hierarchy", or "ICD10 Code".}
14 | }
15 | \value{
16 | A vector containing the names of all ICD-10 codes for the chosen
17 | level(s) found in the concept table of cdm.
18 | }
19 | \description{
20 | Get the names of all International Classification of Diseases (ICD) 10 codes
21 | }
22 | \examples{
23 | \donttest{
24 | cdm <- mockVocabRef()
25 | availableICD10(cdm)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/man/availableIngredients.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/helperFunctions.R
3 | \name{availableIngredients}
4 | \alias{availableIngredients}
5 | \title{Get the names of all available drug ingredients}
6 | \usage{
7 | availableIngredients(cdm)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 | }
12 | \value{
13 | A vector containing the concept names for all ingredient level codes
14 | found in the concept table of cdm.
15 | }
16 | \description{
17 | Get the names of all available drug ingredients
18 | }
19 | \examples{
20 | \donttest{
21 | cdm <- mockVocabRef()
22 | availableIngredients(cdm)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/man/buildAchillesTables.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/buildAchillesTables.R
3 | \name{buildAchillesTables}
4 | \alias{buildAchillesTables}
5 | \title{Add the achilles tables with specified analyses}
6 | \usage{
7 | buildAchillesTables(cdm, achillesId = NULL)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 |
12 | \item{achillesId}{A vector of achilles ids. If NULL default analysis will be
13 | used.}
14 | }
15 | \value{
16 | The cdm_reference object with the achilles tables populated.
17 | }
18 | \description{
19 | If the cdm reference does not contain the achilles tables, this function
20 | will create them for the analyses used by other functions in the package.
21 | }
22 | \examples{
23 | \donttest{
24 | dbName <- "GiBleed"
25 | CDMConnector::requireEunomia(dbName)
26 | con <- duckdb::dbConnect(duckdb::duckdb(), CDMConnector::eunomiaDir(dbName))
27 | cdm <- CDMConnector::cdmFromCon(
28 | con = con, cdmSchema = "main", writeSchema = "main"
29 | )
30 |
31 | cdm <- buildAchillesTables(cdm = cdm)
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/man/byConceptDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{byConceptDoc}
4 | \alias{byConceptDoc}
5 | \title{Helper for consistent documentation of \code{byConcept}.}
6 | \arguments{
7 | \item{byConcept}{TRUE or FALSE. If TRUE code use will be summarised by
8 | concept.}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{byConcept}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/bySexDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{bySexDoc}
4 | \alias{bySexDoc}
5 | \title{Helper for consistent documentation of \code{bySex}.}
6 | \arguments{
7 | \item{bySex}{TRUE or FALSE. If TRUE code use will be summarised by sex.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{bySex}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/byYearDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{byYearDoc}
4 | \alias{byYearDoc}
5 | \title{Helper for consistent documentation of \code{byYear}.}
6 | \arguments{
7 | \item{byYear}{TRUE or FALSE. If TRUE code use will be summarised by year.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{byYear}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/cdmDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{cdmDoc}
4 | \alias{cdmDoc}
5 | \title{Helper for consistent documentation of \code{cdm}.}
6 | \arguments{
7 | \item{cdm}{A cdm reference via CDMConnector.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{cdm}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/codesFromCohort.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/codesFromConceptSet.R
3 | \name{codesFromCohort}
4 | \alias{codesFromCohort}
5 | \title{Get concept ids from JSON files containing cohort definitions}
6 | \usage{
7 | codesFromCohort(path, cdm, type = c("codelist"))
8 | }
9 | \arguments{
10 | \item{path}{Path to a file or folder containing JSONs of cohort definitions.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{type}{Can be "codelist", "codelist_with_details" or
15 | "concept_set_expression".}
16 | }
17 | \value{
18 | Named list with concept_ids for each concept set.
19 | }
20 | \description{
21 | Get concept ids from JSON files containing cohort definitions
22 | }
23 | \examples{
24 | \donttest{
25 | cdm <- mockVocabRef("database")
26 | x <- codesFromCohort(cdm = cdm,
27 | path = system.file(package = "CodelistGenerator",
28 | "cohorts_for_mock"))
29 | x
30 | CDMConnector::cdmDisconnect(cdm)
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/man/codesFromConceptSet.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/codesFromConceptSet.R
3 | \name{codesFromConceptSet}
4 | \alias{codesFromConceptSet}
5 | \title{Get concept ids from JSON files containing concept sets}
6 | \usage{
7 | codesFromConceptSet(path, cdm, type = c("codelist"))
8 | }
9 | \arguments{
10 | \item{path}{Path to a file or folder containing JSONs of concept sets.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{type}{Can be "codelist", "codelist_with_details" or
15 | "concept_set_expression".}
16 | }
17 | \value{
18 | Named list with concept_ids for each concept set.
19 | }
20 | \description{
21 | Get concept ids from JSON files containing concept sets
22 | }
23 | \examples{
24 | \donttest{
25 | cdm <- mockVocabRef("database")
26 | x <- codesFromConceptSet(cdm = cdm,
27 | path = system.file(package = "CodelistGenerator",
28 | "concepts_for_mock"))
29 | x
30 | CDMConnector::cdmDisconnect(cdm)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/man/codesInUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/codesInUse.R
3 | \name{codesInUse}
4 | \alias{codesInUse}
5 | \title{Get the concepts being used in patient records}
6 | \usage{
7 | codesInUse(
8 | cdm,
9 | minimumCount = 0L,
10 | table = c("condition_occurrence", "device_exposure", "drug_exposure", "measurement",
11 | "observation", "procedure_occurrence", "visit_occurrence")
12 | )
13 | }
14 | \arguments{
15 | \item{cdm}{A cdm reference via CDMConnector.}
16 |
17 | \item{minimumCount}{Any codes with a frequency under this will be removed.}
18 |
19 | \item{table}{cdm table of interest.}
20 | }
21 | \value{
22 | A list of integers indicating codes being used in the database.
23 | }
24 | \description{
25 | Get the concepts being used in patient records
26 | }
27 | \examples{
28 | \donttest{
29 | cdm <- mockVocabRef("database")
30 | x <- codesInUse(cdm = cdm)
31 | x
32 | CDMConnector::cdmDisconnect(cdm)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/man/compareCodelists.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/compareCodelists.R
3 | \name{compareCodelists}
4 | \alias{compareCodelists}
5 | \title{Compare overlap between two sets of codes}
6 | \usage{
7 | compareCodelists(codelist1, codelist2)
8 | }
9 | \arguments{
10 | \item{codelist1}{Output of getCandidateCodes or a codelist}
11 |
12 | \item{codelist2}{Output of getCandidateCodes.}
13 | }
14 | \value{
15 | Tibble with information on the overlap of codes in both codelists.
16 | }
17 | \description{
18 | Compare overlap between two sets of codes
19 | }
20 | \examples{
21 | \donttest{
22 | cdm <- mockVocabRef()
23 | codes1 <- getCandidateCodes(
24 | cdm = cdm,
25 | keywords = "Arthritis",
26 | domains = "Condition",
27 | includeDescendants = TRUE
28 | )
29 | codes2 <- getCandidateCodes(
30 | cdm = cdm,
31 | keywords = c("knee osteoarthritis", "arthrosis"),
32 | domains = "Condition",
33 | includeDescendants = TRUE
34 | )
35 | compareCodelists(
36 | codelist1 = codes1,
37 | codelist2 = codes2
38 | )
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/man/countByDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{countByDoc}
4 | \alias{countByDoc}
5 | \title{Helper for consistent documentation of \code{countBy}.}
6 | \arguments{
7 | \item{countBy}{Either "record" for record-level counts or "person" for
8 | person-level counts.}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{countBy}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/domainDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{domainDoc}
4 | \alias{domainDoc}
5 | \title{Helper for consistent documentation of \code{domain}.}
6 | \arguments{
7 | \item{domain}{Character vector with one or more of the OMOP CDM domains.
8 | The results will be restricted to the given domains. Check the available
9 | ones by running getDomains(). If NULL, all supported domains are included:
10 | Condition, Drug, Procedure, Device, Observation, and Measurement.}
11 | }
12 | \description{
13 | Helper for consistent documentation of \code{domain}.
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/doseFormDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{doseFormDoc}
4 | \alias{doseFormDoc}
5 | \title{Helper for consistent documentation of \code{doseForm}.}
6 | \arguments{
7 | \item{doseForm}{Only codes with the specified dose form
8 | will be returned. If NULL, descendant codes will be returned regardless
9 | of dose form. Use 'getDoseForm()' to see the available dose forms.}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{doseForm}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/doseUnitDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{doseUnitDoc}
4 | \alias{doseUnitDoc}
5 | \title{Helper for consistent documentation of \code{doseUnit}.}
6 | \arguments{
7 | \item{doseUnit}{Only codes with the specified dose unit
8 | will be returned. If NULL, descendant codes will be returned regardless
9 | of dose unit Use 'getDoseUnit()' to see the available dose units.}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{doseUnit}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/dot-optionsDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{.optionsDoc}
4 | \alias{.optionsDoc}
5 | \title{Helper for consistent documentation of \code{.options}.}
6 | \arguments{
7 | \item{.options}{Named list with additional formatting options.
8 | visOmopResults::tableOptions() shows allowed arguments and
9 | their default values.}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{.options}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/figures/README-unnamed-chunk-8-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/man/figures/README-unnamed-chunk-8-1.png
--------------------------------------------------------------------------------
/man/figures/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/man/figures/logo.png
--------------------------------------------------------------------------------
/man/getATCCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/drugCodes.R
3 | \name{getATCCodes}
4 | \alias{getATCCodes}
5 | \title{Get the descendant codes of Anatomical Therapeutic Chemical (ATC) classification codes}
6 | \usage{
7 | getATCCodes(
8 | cdm,
9 | level = c("ATC 1st"),
10 | name = NULL,
11 | nameStyle = "{concept_code}_{concept_name}",
12 | doseForm = NULL,
13 | doseUnit = NULL,
14 | routeCategory = NULL,
15 | type = "codelist"
16 | )
17 | }
18 | \arguments{
19 | \item{cdm}{A cdm reference via CDMConnector.}
20 |
21 | \item{level}{ATC level. Can be one or more of "ATC 1st", "ATC 2nd",
22 | "ATC 3rd", "ATC 4th", and "ATC 5th".}
23 |
24 | \item{name}{ATC name of interest. For example, c("Dermatologicals",
25 | "Nervous System"), would result in a list of length two with the descendant
26 | concepts for these two particular ATC groups.}
27 |
28 | \item{nameStyle}{Name style to apply to returned list. Can be one of
29 | \code{"{concept_code}"},\code{"{concept_id}"}, \code{"{concept_name}"}, or a combination (i.e.,
30 | \code{"{concept_code}_{concept_name}"}).}
31 |
32 | \item{doseForm}{Only codes with the specified dose form
33 | will be returned. If NULL, descendant codes will be returned regardless
34 | of dose form. Use 'getDoseForm()' to see the available dose forms.}
35 |
36 | \item{doseUnit}{Only codes with the specified dose unit
37 | will be returned. If NULL, descendant codes will be returned regardless
38 | of dose unit Use 'getDoseUnit()' to see the available dose units.}
39 |
40 | \item{routeCategory}{Only codes with the specified route will be
41 | returned. If NULL, descendant codes will be returned regardless of route
42 | category. Use getRoutes() to find the available route categories.}
43 |
44 | \item{type}{Can be "codelist" or "codelist_with_details".}
45 | }
46 | \value{
47 | Concepts with their format based on the type argument
48 | }
49 | \description{
50 | Get the descendant codes of Anatomical Therapeutic Chemical (ATC) classification codes
51 | }
52 | \examples{
53 | \donttest{
54 | library(CodelistGenerator)
55 | cdm <- mockVocabRef()
56 | getATCCodes(cdm = cdm, level = "ATC 1st")
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/man/getCandidateCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/getCandidateCodes.R
3 | \name{getCandidateCodes}
4 | \alias{getCandidateCodes}
5 | \title{Generate a candidate codelist}
6 | \usage{
7 | getCandidateCodes(
8 | cdm,
9 | keywords,
10 | exclude = NULL,
11 | domains = "Condition",
12 | standardConcept = "Standard",
13 | searchInSynonyms = FALSE,
14 | searchNonStandard = FALSE,
15 | includeDescendants = TRUE,
16 | includeAncestor = FALSE
17 | )
18 | }
19 | \arguments{
20 | \item{cdm}{A cdm reference via CDMConnector.}
21 |
22 | \item{keywords}{Character vector of words to search for.
23 | Where more than one word is given (e.g. "knee osteoarthritis"),
24 | all combinations of those words should be identified
25 | positions (e.g. "osteoarthritis of knee") should be identified.}
26 |
27 | \item{exclude}{Character vector of words
28 | to identify concepts to exclude.}
29 |
30 | \item{domains}{Character vector with one or more of the OMOP CDM domain. If NULL, all supported domains are included: Condition, Drug, Procedure, Device, Observation, and Measurement.}
31 |
32 | \item{standardConcept}{Character vector with one or more of "Standard",
33 | "Classification", and "Non-standard". These correspond to the flags used
34 | for the standard_concept field in the concept table of the cdm.}
35 |
36 | \item{searchInSynonyms}{Either TRUE or FALSE. If TRUE the code will also
37 | search using both the primary name in the concept table and synonyms from
38 | the concept synonym table.}
39 |
40 | \item{searchNonStandard}{Either TRUE or FALSE. If TRUE the code will also
41 | search via non-standard concepts.}
42 |
43 | \item{includeDescendants}{Either TRUE or FALSE. If TRUE descendant concepts
44 | of identified concepts will be included in the candidate codelist. If FALSE
45 | only direct mappings from ICD-10 codes to standard codes will be returned.}
46 |
47 | \item{includeAncestor}{Either TRUE or FALSE.
48 | If TRUE the direct ancestor concepts of identified concepts
49 | will be included in the candidate codelist.}
50 | }
51 | \value{
52 | A tibble with the information on the potential codes of interest.
53 | }
54 | \description{
55 | This function generates a set of codes that
56 | can be considered for creating a phenotype
57 | using the OMOP CDM.
58 | }
59 | \examples{
60 | \donttest{
61 | cdm <- CodelistGenerator::mockVocabRef()
62 | CodelistGenerator::getCandidateCodes(
63 | cdm = cdm,
64 | keywords = "osteoarthritis"
65 | )
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/man/getConceptClassId.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getConceptClassId}
4 | \alias{getConceptClassId}
5 | \title{Get the concept classes used in a given set of domains}
6 | \usage{
7 | getConceptClassId(cdm, standardConcept = "Standard", domain = NULL)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 |
12 | \item{standardConcept}{Character vector with one or more of "Standard",
13 | "Classification", and "Non-standard". These correspond to the flags used
14 | for the standard_concept field in the concept table of the cdm.}
15 |
16 | \item{domain}{Character vector with one or more of the OMOP CDM domains.
17 | The results will be restricted to the given domains. Check the available
18 | ones by running getDomains(). If NULL, all supported domains are included:
19 | Condition, Drug, Procedure, Device, Observation, and Measurement.}
20 | }
21 | \value{
22 | The concept classes used for the requested domains.
23 | }
24 | \description{
25 | Get the concept classes used in a given set of domains
26 | }
27 | \examples{
28 | \donttest{
29 | cdm <- mockVocabRef()
30 | getConceptClassId(cdm = cdm, domain = "drug")
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/man/getDescendants.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getDescendants}
4 | \alias{getDescendants}
5 | \title{Get descendant codes for a given concept}
6 | \usage{
7 | getDescendants(
8 | cdm,
9 | conceptId,
10 | withAncestor = FALSE,
11 | ingredientRange = c(0, Inf),
12 | doseForm = NULL
13 | )
14 | }
15 | \arguments{
16 | \item{cdm}{A cdm reference via CDMConnector.}
17 |
18 | \item{conceptId}{concept_id to search}
19 |
20 | \item{withAncestor}{If TRUE, return column with ancestor. In case of multiple
21 | ancestors, concepts will be separated by ";".}
22 |
23 | \item{ingredientRange}{Used to restrict descendant codes to those
24 | associated with a specific number of drug ingredients. Must be a vector of
25 | length two with the first element the minimum number of ingredients allowed
26 | and the second the maximum. A value of c(2, 2) would restrict to only
27 | concepts associated with two ingredients.}
28 |
29 | \item{doseForm}{Only codes with the specified dose form
30 | will be returned. If NULL, descendant codes will be returned regardless
31 | of dose form. Use 'getDoseForm()' to see the available dose forms.}
32 | }
33 | \value{
34 | The descendants of a given concept id.
35 | }
36 | \description{
37 | Get descendant codes for a given concept
38 | }
39 | \examples{
40 | \donttest{
41 | cdm <- mockVocabRef()
42 | getDescendants(cdm = cdm, conceptId = 1)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/man/getDomains.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getDomains}
4 | \alias{getDomains}
5 | \title{Get the domains available in the cdm}
6 | \usage{
7 | getDomains(cdm, standardConcept = "Standard")
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 |
12 | \item{standardConcept}{Character vector with one or more of "Standard",
13 | "Classification", and "Non-standard". These correspond to the flags used
14 | for the standard_concept field in the concept table of the cdm.}
15 | }
16 | \value{
17 | A vector with the domains of the cdm.
18 | }
19 | \description{
20 | Get the domains available in the cdm
21 | }
22 | \examples{
23 | \donttest{
24 | cdm <- mockVocabRef()
25 | getDomains(cdm = cdm)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/man/getDoseForm.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getDoseForm}
4 | \alias{getDoseForm}
5 | \title{Get the dose forms available for drug concepts}
6 | \usage{
7 | getDoseForm(cdm)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 | }
12 | \value{
13 | The dose forms available for drug concepts.
14 | }
15 | \description{
16 | Get the dose forms available for drug concepts
17 | }
18 | \examples{
19 | \donttest{
20 | cdm <- mockVocabRef()
21 | getDoseForm(cdm = cdm)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/man/getDoseUnit.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/getDoseUnit.R
3 | \name{getDoseUnit}
4 | \alias{getDoseUnit}
5 | \title{Get available dose units}
6 | \usage{
7 | getDoseUnit(cdm)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 | }
12 | \value{
13 | A character vector with available routes.
14 | }
15 | \description{
16 | Get the dose form categories available in the database (see
17 | https://doi.org/10.1002/pds.5809 for more details on how routes
18 | were classified).
19 | }
20 | \examples{
21 | \donttest{
22 | library(CodelistGenerator)
23 |
24 | cdm <- mockVocabRef()
25 |
26 | getDoseUnit(cdm)
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/man/getDrugIngredientCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/drugCodes.R
3 | \name{getDrugIngredientCodes}
4 | \alias{getDrugIngredientCodes}
5 | \title{Get descendant codes of drug ingredients}
6 | \usage{
7 | getDrugIngredientCodes(
8 | cdm,
9 | name = NULL,
10 | nameStyle = "{concept_code}_{concept_name}",
11 | doseForm = NULL,
12 | doseUnit = NULL,
13 | routeCategory = NULL,
14 | ingredientRange = c(1, Inf),
15 | type = "codelist"
16 | )
17 | }
18 | \arguments{
19 | \item{cdm}{A cdm reference via CDMConnector.}
20 |
21 | \item{name}{Names of ingredients of interest. For example, c("acetaminophen",
22 | "codeine"), would result in a list of length two with the descendant
23 | concepts for these two particular drug ingredients. Users can also specify the
24 | concept ID instead of the name (e.g., c(1125315, 42948451)) using a numeric vector.}
25 |
26 | \item{nameStyle}{Name style to apply to returned list. Can be one of
27 | \code{"{concept_code}"},\code{"{concept_id}"}, \code{"{concept_name}"}, or a combination (i.e.,
28 | \code{"{concept_code}_{concept_name}"}).}
29 |
30 | \item{doseForm}{Only codes with the specified dose form
31 | will be returned. If NULL, descendant codes will be returned regardless
32 | of dose form. Use 'getDoseForm()' to see the available dose forms.}
33 |
34 | \item{doseUnit}{Only codes with the specified dose unit
35 | will be returned. If NULL, descendant codes will be returned regardless
36 | of dose unit Use 'getDoseUnit()' to see the available dose units.}
37 |
38 | \item{routeCategory}{Only codes with the specified route will be
39 | returned. If NULL, descendant codes will be returned regardless of route
40 | category. Use getRoutes() to find the available route categories.}
41 |
42 | \item{ingredientRange}{Used to restrict descendant codes to those
43 | associated with a specific number of drug ingredients. Must be a vector of
44 | length two with the first element the minimum number of ingredients allowed
45 | and the second the maximum. A value of c(2, 2) would restrict to only
46 | concepts associated with two ingredients.}
47 |
48 | \item{type}{Can be "codelist" or "codelist_with_details".}
49 | }
50 | \value{
51 | Concepts with their format based on the type argument.
52 | }
53 | \description{
54 | Get descendant codes of drug ingredients
55 | }
56 | \examples{
57 | \donttest{
58 | cdm <- mockVocabRef()
59 | getDrugIngredientCodes(cdm = cdm, name = "Adalimumab",
60 | nameStyle = "{concept_name}")
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/man/getICD10StandardCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/getICD10StandardCodes.R
3 | \name{getICD10StandardCodes}
4 | \alias{getICD10StandardCodes}
5 | \title{Get corresponding standard codes for International Classification of Diseases (ICD) 10 codes}
6 | \usage{
7 | getICD10StandardCodes(
8 | cdm,
9 | level = c("ICD10 Chapter", "ICD10 SubChapter"),
10 | name = NULL,
11 | nameStyle = "{concept_code}_{concept_name}",
12 | includeDescendants = TRUE,
13 | type = "codelist"
14 | )
15 | }
16 | \arguments{
17 | \item{cdm}{A cdm reference via CDMConnector.}
18 |
19 | \item{level}{Can be either "ICD10 Chapter", "ICD10 SubChapter",
20 | "ICD10 Hierarchy", or "ICD10 Code".}
21 |
22 | \item{name}{Name of chapter or sub-chapter of interest. If NULL, all
23 | will be considered.}
24 |
25 | \item{nameStyle}{Name style to apply to returned list. Can be one of
26 | \code{"{concept_code}"},\code{"{concept_id}"}, \code{"{concept_name}"}, or a combination (i.e.,
27 | \code{"{concept_code}_{concept_name}"}).}
28 |
29 | \item{includeDescendants}{Either TRUE or FALSE. If TRUE descendant concepts
30 | of identified concepts will be included in the candidate codelist. If FALSE
31 | only direct mappings from ICD-10 codes to standard codes will be returned.}
32 |
33 | \item{type}{Can be "codelist" or "codelist_with_details".}
34 | }
35 | \value{
36 | A named list, with each element containing the corresponding
37 | standard codes (and descendants) of ICD chapters and sub-chapters.
38 | }
39 | \description{
40 | Get corresponding standard codes for International Classification of Diseases (ICD) 10 codes
41 | }
42 | \examples{
43 | \donttest{
44 | library(CodelistGenerator)
45 | cdm <- mockVocabRef()
46 | getICD10StandardCodes(cdm = cdm, level = c(
47 | "ICD10 Chapter",
48 | "ICD10 SubChapter"
49 | ))
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/man/getMappings.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/getMappings.R
3 | \name{getMappings}
4 | \alias{getMappings}
5 | \title{Show mappings from non-standard vocabularies to standard.}
6 | \usage{
7 | getMappings(
8 | candidateCodelist,
9 | cdm = NULL,
10 | nonStandardVocabularies = c("ATC", "ICD10CM", "ICD10PCS", "ICD9CM", "ICD9Proc",
11 | "LOINC", "OPCS4", "Read", "RxNorm", "RxNorm Extension", "SNOMED")
12 | )
13 | }
14 | \arguments{
15 | \item{candidateCodelist}{Dataframe.}
16 |
17 | \item{cdm}{A cdm reference via CDMConnector.}
18 |
19 | \item{nonStandardVocabularies}{Character vector.}
20 | }
21 | \value{
22 | Tibble with the information of potential standard to non-standard
23 | mappings for the codelist of interest.
24 | }
25 | \description{
26 | Show mappings from non-standard vocabularies to standard.
27 | }
28 | \examples{
29 | \donttest{
30 | cdm <- CodelistGenerator::mockVocabRef()
31 | codes <- CodelistGenerator::getCandidateCodes(
32 | cdm = cdm,
33 | keywords = "osteoarthritis"
34 | )
35 | CodelistGenerator::getMappings(
36 | cdm = cdm,
37 | candidateCodelist = codes,
38 | nonStandardVocabularies = "READ"
39 | )
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/man/getRelationshipId.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getRelationshipId}
4 | \alias{getRelationshipId}
5 | \title{Get available relationships between concepts}
6 | \usage{
7 | getRelationshipId(
8 | cdm,
9 | standardConcept1 = "standard",
10 | standardConcept2 = "standard",
11 | domains1 = "condition",
12 | domains2 = "condition"
13 | )
14 | }
15 | \arguments{
16 | \item{cdm}{A cdm reference via CDMConnector.}
17 |
18 | \item{standardConcept1}{Character vector with one or more of "Standard",
19 | "Classification", and "Non-standard". These correspond to the flags used
20 | for the standard_concept field in the concept table of the cdm.}
21 |
22 | \item{standardConcept2}{Character vector with one or more of "Standard",
23 | "Classification", and "Non-standard". These correspond to the flags used
24 | for the standard_concept field in the concept table of the cdm.}
25 |
26 | \item{domains1}{Character vector with one or more of the OMOP CDM domain.}
27 |
28 | \item{domains2}{Character vector with one or more of the OMOP CDM domain.}
29 | }
30 | \value{
31 | A character vector with unique concept relationship values.
32 | }
33 | \description{
34 | Get available relationships between concepts
35 | }
36 | \examples{
37 | \donttest{
38 | cdm <- mockVocabRef()
39 | getRelationshipId(cdm = cdm)
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/man/getRouteCategories.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/getRoutes.R
3 | \name{getRouteCategories}
4 | \alias{getRouteCategories}
5 | \title{Get available drug routes}
6 | \usage{
7 | getRouteCategories(cdm)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 | }
12 | \value{
13 | A character vector with all available routes.
14 | }
15 | \description{
16 | Get the dose form categories available in the database (see
17 | https://doi.org/10.1002/pds.5809) for more details on how routes
18 | were classified).
19 | }
20 | \examples{
21 | \donttest{
22 | library(CodelistGenerator)
23 |
24 | cdm <- mockVocabRef()
25 |
26 | getRouteCategories(cdm)
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/man/getVocabVersion.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getVocabVersion}
4 | \alias{getVocabVersion}
5 | \title{Get the version of the vocabulary used in the cdm}
6 | \usage{
7 | getVocabVersion(cdm)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 | }
12 | \value{
13 | The vocabulary version being used in the cdm.
14 | }
15 | \description{
16 | Get the version of the vocabulary used in the cdm
17 | }
18 | \examples{
19 | \donttest{
20 | cdm <- mockVocabRef()
21 | getVocabVersion(cdm = cdm)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/man/getVocabularies.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/vocabUtilities.R
3 | \name{getVocabularies}
4 | \alias{getVocabularies}
5 | \title{Get the vocabularies available in the cdm}
6 | \usage{
7 | getVocabularies(cdm)
8 | }
9 | \arguments{
10 | \item{cdm}{A cdm reference via CDMConnector.}
11 | }
12 | \value{
13 | Names of available vocabularies.
14 | }
15 | \description{
16 | Get the vocabularies available in the cdm
17 | }
18 | \examples{
19 | \donttest{
20 | cdm <- mockVocabRef()
21 | getVocabularies(cdm = cdm)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/man/groupColumnDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{groupColumnDoc}
4 | \alias{groupColumnDoc}
5 | \title{Helper for consistent documentation of \code{groupColumn}.}
6 | \arguments{
7 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
8 | "cdm_name", "codelist_name", "domain_id", "standard_concept_name",
9 | "standard_concept_id", "estimate_name", "standard_concept", "vocabulary_id".
10 | These cannot be used in header.}
11 | }
12 | \description{
13 | Helper for consistent documentation of \code{groupColumn}.
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/groupColumnStrataDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{groupColumnStrataDoc}
4 | \alias{groupColumnStrataDoc}
5 | \title{Helper for consistent documentation of \code{groupColumn}.}
6 | \arguments{
7 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
8 | "cdm_name", "codelist_name", "standard_concept_name", "standard_concept_id",
9 | "estimate_name", "source_concept_name", "source_concept_id", "domain_id". If
10 | results are stratified, "year", "sex", "age_group" can also be used.
11 | These cannot be used in header.}
12 | }
13 | \description{
14 | Helper for consistent documentation of \code{groupColumn}.
15 | }
16 | \keyword{internal}
17 |
--------------------------------------------------------------------------------
/man/headerDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{headerDoc}
4 | \alias{headerDoc}
5 | \title{Helper for consistent documentation of \code{header}.}
6 | \arguments{
7 | \item{header}{A vector specifying the elements to include in the header. The
8 | order of elements matters, with the first being the topmost header.
9 | The header vector can contain one of the following variables: "cdm_name",
10 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
11 | "estimate_name", "standard_concept", "vocabulary_id".
12 | Alternatively, it can include other names to use as overall header labels.}
13 | }
14 | \description{
15 | Helper for consistent documentation of \code{header}.
16 | }
17 | \keyword{internal}
18 |
--------------------------------------------------------------------------------
/man/headerStrataDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{headerStrataDoc}
4 | \alias{headerStrataDoc}
5 | \title{Helper for consistent documentation of \code{header}.}
6 | \arguments{
7 | \item{header}{A vector specifying the elements to include in the header. The
8 | order of elements matters, with the first being the topmost header.
9 | The header vector can contain one of the following variables: "cdm_name",
10 | "codelist_name", "standard_concept_name", "standard_concept_id",
11 | "estimate_name", "source_concept_name", "source_concept_id", "domain_id". If
12 | results are stratified, "year", "sex", "age_group" can also be used.
13 | Alternatively, it can include other names to use as overall header labels.}
14 | }
15 | \description{
16 | Helper for consistent documentation of \code{header}.
17 | }
18 | \keyword{internal}
19 |
--------------------------------------------------------------------------------
/man/hideDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{hideDoc}
4 | \alias{hideDoc}
5 | \title{Helper for consistent documentation of \code{hide}.}
6 | \arguments{
7 | \item{hide}{Table columns to exclude, options are: "cdm_name",
8 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
9 | "estimate_name", "standard_concept", "vocabulary_id". These cannot be used in
10 | header or groupColumn.}
11 | }
12 | \description{
13 | Helper for consistent documentation of \code{hide}.
14 | }
15 | \keyword{internal}
16 |
--------------------------------------------------------------------------------
/man/hideStrataDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{hideStrataDoc}
4 | \alias{hideStrataDoc}
5 | \title{Helper for consistent documentation of \code{hide}.}
6 | \arguments{
7 | \item{hide}{Table columns to exclude, options are: "cdm_name",
8 | "codelist_name", "year", "sex", "age_group", "standard_concept_name",
9 | "standard_concept_id", "estimate_name", "source_concept_name",
10 | "source_concept_id", "domain_id". If results are stratified, "year", "sex",
11 | "age_group" can also be used. These cannot be used in header or groupColumn.}
12 | }
13 | \description{
14 | Helper for consistent documentation of \code{hide}.
15 | }
16 | \keyword{internal}
17 |
--------------------------------------------------------------------------------
/man/includeDescendantsDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{includeDescendantsDoc}
4 | \alias{includeDescendantsDoc}
5 | \title{Helper for consistent documentation of \code{includeDescendants}.}
6 | \arguments{
7 | \item{includeDescendants}{Either TRUE or FALSE. If TRUE descendant concepts
8 | of identified concepts will be included in the candidate codelist. If FALSE
9 | only direct mappings from ICD-10 codes to standard codes will be returned.}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{includeDescendants}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/ingredientRangeDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{ingredientRangeDoc}
4 | \alias{ingredientRangeDoc}
5 | \title{Helper for consistent documentation of \code{ingredientRange}.}
6 | \arguments{
7 | \item{ingredientRange}{Used to restrict descendant codes to those
8 | associated with a specific number of drug ingredients. Must be a vector of
9 | length two with the first element the minimum number of ingredients allowed
10 | and the second the maximum. A value of c(2, 2) would restrict to only
11 | concepts associated with two ingredients.}
12 | }
13 | \description{
14 | Helper for consistent documentation of \code{ingredientRange}.
15 | }
16 | \keyword{internal}
17 |
--------------------------------------------------------------------------------
/man/keepOriginalDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{keepOriginalDoc}
4 | \alias{keepOriginalDoc}
5 | \title{Helper for consistent documentation of \code{keepOriginal}.}
6 | \arguments{
7 | \item{keepOriginal}{Whether to keep the original codelist and append the
8 | stratify (if TRUE) or just return the stratified codelist (if FALSE).}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{keepOriginal}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/levelATCDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{levelATCDoc}
4 | \alias{levelATCDoc}
5 | \title{Helper for consistent documentation of \code{level}.}
6 | \arguments{
7 | \item{level}{ATC level. Can be one or more of "ATC 1st", "ATC 2nd",
8 | "ATC 3rd", "ATC 4th", and "ATC 5th".}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{level}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/levelICD10Doc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{levelICD10Doc}
4 | \alias{levelICD10Doc}
5 | \title{Helper for consistent documentation of \code{level}.}
6 | \arguments{
7 | \item{level}{Can be either "ICD10 Chapter", "ICD10 SubChapter",
8 | "ICD10 Hierarchy", or "ICD10 Code".}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{level}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/minimumCountDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{minimumCountDoc}
4 | \alias{minimumCountDoc}
5 | \title{Helper for consistent documentation of \code{minimumCount}.}
6 | \arguments{
7 | \item{minimumCount}{Any codes with a frequency under this will be removed.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{minimumCount}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/mockVocabRef.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/mockVocabRef.R
3 | \name{mockVocabRef}
4 | \alias{mockVocabRef}
5 | \title{Generate example vocabulary database}
6 | \usage{
7 | mockVocabRef(backend = "data_frame")
8 | }
9 | \arguments{
10 | \item{backend}{'database' (duckdb) or 'data_frame'.}
11 | }
12 | \value{
13 | cdm reference with mock vocabulary.
14 | }
15 | \description{
16 | Generate example vocabulary database
17 | }
18 | \examples{
19 | \donttest{
20 | library(CodelistGenerator)
21 | cdm <- mockVocabRef()
22 | cdm
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/man/nameStyleDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{nameStyleDoc}
4 | \alias{nameStyleDoc}
5 | \title{Helper for consistent documentation of \code{nameStyle}.}
6 | \arguments{
7 | \item{nameStyle}{Name style to apply to returned list. Can be one of
8 | \code{"{concept_code}"},\code{"{concept_id}"}, \code{"{concept_name}"}, or a combination (i.e.,
9 | \code{"{concept_code}_{concept_name}"}).}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{nameStyle}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/reexports.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/reexports.R
3 | \docType{import}
4 | \name{reexports}
5 | \alias{reexports}
6 | \alias{cohortCodelist}
7 | \alias{importCodelist}
8 | \alias{importConceptSetExpression}
9 | \alias{exportCodelist}
10 | \alias{exportConceptSetExpression}
11 | \alias{newCodelist}
12 | \alias{newCodelistWithDetails}
13 | \alias{newConceptSetExpression}
14 | \title{Objects exported from other packages}
15 | \keyword{internal}
16 | \description{
17 | These objects are imported from other packages. Follow the links
18 | below to see their documentation.
19 |
20 | \describe{
21 | \item{omopgenerics}{\code{\link[omopgenerics]{cohortCodelist}}, \code{\link[omopgenerics]{exportCodelist}}, \code{\link[omopgenerics]{exportConceptSetExpression}}, \code{\link[omopgenerics]{importCodelist}}, \code{\link[omopgenerics]{importConceptSetExpression}}, \code{\link[omopgenerics]{newCodelist}}, \code{\link[omopgenerics]{newCodelistWithDetails}}, \code{\link[omopgenerics]{newConceptSetExpression}}}
22 | }}
23 |
24 |
--------------------------------------------------------------------------------
/man/routeCategoryDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{routeCategoryDoc}
4 | \alias{routeCategoryDoc}
5 | \title{Helper for consistent documentation of \code{routeCategory}.}
6 | \arguments{
7 | \item{routeCategory}{Only codes with the specified route will be
8 | returned. If NULL, descendant codes will be returned regardless of route
9 | category. Use getRoutes() to find the available route categories.}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{routeCategory}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/sourceCodesInUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/codesInUse.R
3 | \name{sourceCodesInUse}
4 | \alias{sourceCodesInUse}
5 | \title{Get the source codes being used in patient records}
6 | \usage{
7 | sourceCodesInUse(
8 | cdm,
9 | table = c("condition_occurrence", "device_exposure", "drug_exposure", "measurement",
10 | "observation", "procedure_occurrence", "visit_occurrence")
11 | )
12 | }
13 | \arguments{
14 | \item{cdm}{A cdm reference via CDMConnector.}
15 |
16 | \item{table}{cdm table of interest.}
17 | }
18 | \value{
19 | A list of source codes used in the database.
20 | }
21 | \description{
22 | Get the source codes being used in patient records
23 | }
24 | \examples{
25 | \donttest{
26 | cdm <- mockVocabRef("database")
27 | x <- sourceCodesInUse(cdm = cdm)
28 | x
29 | CDMConnector::cdmDisconnect(cdm)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/man/standardConceptDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{standardConceptDoc}
4 | \alias{standardConceptDoc}
5 | \title{Helper for consistent documentation of \code{standardConcept}.}
6 | \arguments{
7 | \item{standardConcept}{Character vector with one or more of "Standard",
8 | "Classification", and "Non-standard". These correspond to the flags used
9 | for the standard_concept field in the concept table of the cdm.}
10 | }
11 | \description{
12 | Helper for consistent documentation of \code{standardConcept}.
13 | }
14 | \keyword{internal}
15 |
--------------------------------------------------------------------------------
/man/stratifyByConcept.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/stratifyByConcept.R
3 | \name{stratifyByConcept}
4 | \alias{stratifyByConcept}
5 | \title{Stratify a codelist by the concepts included within it.}
6 | \usage{
7 | stratifyByConcept(x, cdm, keepOriginal = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{keepOriginal}{Whether to keep the original codelist and append the
15 | stratify (if TRUE) or just return the stratified codelist (if FALSE).}
16 | }
17 | \value{
18 | The codelist or a codelist with details with the required
19 | stratifications, as different elements of the list.
20 | }
21 | \description{
22 | Stratify a codelist by the concepts included within it.
23 | }
24 | \examples{
25 | \donttest{
26 | library(CodelistGenerator)
27 | cdm <- mockVocabRef()
28 | codes <- list("concepts" = c(20,21))
29 | new_codes <- stratifyByConcept(x = codes,
30 | cdm = cdm,
31 | keepOriginal = TRUE)
32 | new_codes
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/man/stratifyByDoseUnit.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/stratifyByDoseUnit.R
3 | \name{stratifyByDoseUnit}
4 | \alias{stratifyByDoseUnit}
5 | \title{Stratify a codelist by dose unit.}
6 | \usage{
7 | stratifyByDoseUnit(x, cdm, keepOriginal = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{keepOriginal}{Whether to keep the original codelist and append the
15 | stratify (if TRUE) or just return the stratified codelist (if FALSE).}
16 | }
17 | \value{
18 | The codelist with the required stratifications, as different elements
19 | of the list.
20 | }
21 | \description{
22 | Stratify a codelist by dose unit.
23 | }
24 | \examples{
25 | \donttest{
26 | library(CodelistGenerator)
27 | cdm <- mockVocabRef()
28 | codes <- list("concepts" = c(20,21))
29 | new_codes <- stratifyByDoseUnit(x = codes,
30 | cdm = cdm,
31 | keepOriginal = TRUE)
32 | new_codes
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/man/stratifyByRouteCategory.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/stratifyByRoute.R
3 | \name{stratifyByRouteCategory}
4 | \alias{stratifyByRouteCategory}
5 | \title{Stratify a codelist by route category.}
6 | \usage{
7 | stratifyByRouteCategory(x, cdm, keepOriginal = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{keepOriginal}{Whether to keep the original codelist and append the
15 | stratify (if TRUE) or just return the stratified codelist (if FALSE).}
16 | }
17 | \value{
18 | The codelist with the required stratifications, as different elements
19 | of the list.
20 | }
21 | \description{
22 | Stratify a codelist by route category.
23 | }
24 | \examples{
25 | \donttest{
26 | library(CodelistGenerator)
27 | cdm <- mockVocabRef()
28 | codes <- list("concepts" = c(20,21))
29 | new_codes <- stratifyByRouteCategory(x = codes,
30 | cdm = cdm,
31 | keepOriginal = TRUE)
32 | new_codes
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/man/subsetOnDomain.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/subsetOnDomain.R
3 | \name{subsetOnDomain}
4 | \alias{subsetOnDomain}
5 | \title{Subset a codelist to only those codes from a particular domain.}
6 | \usage{
7 | subsetOnDomain(x, cdm, domain, negate = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{domain}{Character vector with one or more of the OMOP CDM domains.
15 | The results will be restricted to the given domains. Check the available
16 | ones by running getDomains(). If NULL, all supported domains are included:
17 | Condition, Drug, Procedure, Device, Observation, and Measurement.}
18 |
19 | \item{negate}{If FALSE, only concepts with the domain specified will be
20 | returned. If TRUE, concepts with the domain specified will be excluded.}
21 | }
22 | \value{
23 | The codelist with only those concepts associated with the domain
24 | (if negate = FALSE) or the codelist without those concepts associated with
25 | the domain (if negate = TRUE).
26 | }
27 | \description{
28 | Subset a codelist to only those codes from a particular domain.
29 | }
30 | \examples{
31 | \donttest{
32 | library(CodelistGenerator)
33 | cdm <- mockVocabRef()
34 | codes <- subsetOnDomain(
35 | x = list("codes" = c(10,13,15)),
36 | cdm = cdm,
37 | domain = "Drug")
38 | codes
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/man/subsetOnDoseUnit.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/subsetOnDoseUnit.R
3 | \name{subsetOnDoseUnit}
4 | \alias{subsetOnDoseUnit}
5 | \title{Subset a codelist to only those with a particular dose unit.}
6 | \usage{
7 | subsetOnDoseUnit(x, cdm, doseUnit, negate = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{doseUnit}{Only codes with the specified dose unit
15 | will be returned. If NULL, descendant codes will be returned regardless
16 | of dose unit Use 'getDoseUnit()' to see the available dose units.}
17 |
18 | \item{negate}{If FALSE, only concepts with the dose unit specified will be
19 | returned. If TRUE, concepts with the dose unit specified will be excluded.}
20 | }
21 | \value{
22 | The codelist with only those concepts associated with the
23 | dose unit (if negate = FALSE) or codelist without those concepts associated with the
24 | dose unit(if negate = TRUE).
25 | }
26 | \description{
27 | Subset a codelist to only those with a particular dose unit.
28 | }
29 | \examples{
30 | \donttest{
31 | library(CodelistGenerator)
32 | cdm <- mockVocabRef()
33 | codes <- subsetOnDoseUnit(x = list("codes" = c(20,21)),
34 | cdm = cdm,
35 | doseUnit = c("milligram"))
36 |
37 | codes
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/man/subsetOnRouteCategory.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/subsetOnRouteCategory.R
3 | \name{subsetOnRouteCategory}
4 | \alias{subsetOnRouteCategory}
5 | \title{Subset a codelist to only those with a particular route category}
6 | \usage{
7 | subsetOnRouteCategory(x, cdm, routeCategory, negate = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{routeCategory}{Only codes with the specified route will be
15 | returned. If NULL, descendant codes will be returned regardless of route
16 | category. Use getRoutes() to find the available route categories.}
17 |
18 | \item{negate}{If FALSE, only concepts with the routeCategory specified will
19 | be returned. If TRUE, concepts with the routeCategory specified will be excluded.}
20 | }
21 | \value{
22 | The codelist with only those concepts associated with the
23 | specified route categories (if negate is FALSE) or the codelist without those
24 | concepts associated with the specified route categories (if negate is TRUE).
25 | }
26 | \description{
27 | Subset a codelist to only those with a particular route category
28 | }
29 | \examples{
30 | \donttest{
31 | library(CodelistGenerator)
32 | cdm <- mockVocabRef()
33 | codes <- subsetOnRouteCategory(
34 | x = list("codes" = c(20,21)),
35 | cdm = cdm,
36 | routeCategory = "topical")
37 | codes
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/man/subsetToCodesInUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/codesInUse.R
3 | \name{subsetToCodesInUse}
4 | \alias{subsetToCodesInUse}
5 | \title{Filter a codelist to keep only the codes being used in patient records}
6 | \usage{
7 | subsetToCodesInUse(
8 | x,
9 | cdm,
10 | minimumCount = 0L,
11 | table = c("condition_occurrence", "device_exposure", "drug_exposure", "measurement",
12 | "observation", "procedure_occurrence", "visit_occurrence")
13 | )
14 | }
15 | \arguments{
16 | \item{x}{A codelist.}
17 |
18 | \item{cdm}{A cdm reference via CDMConnector.}
19 |
20 | \item{minimumCount}{Any codes with a frequency under this will be removed.}
21 |
22 | \item{table}{cdm table of interest.}
23 | }
24 | \value{
25 | The filtered codelist with only the codes used in the database
26 | }
27 | \description{
28 | Filter a codelist to keep only the codes being used in patient records
29 | }
30 | \examples{
31 | \donttest{
32 | cdm <- mockVocabRef("database")
33 | codes <- getCandidateCodes(cdm = cdm,
34 | keywords = "arthritis",
35 | domains = "Condition",
36 | includeDescendants = FALSE)
37 | x <- subsetToCodesInUse(list("cs1" = codes$concept_id,
38 | "cs2" = 999),
39 | cdm = cdm)
40 |
41 | x
42 | CDMConnector::cdmDisconnect(cdm)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/man/summariseAchillesCodeUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summariseAchillesCodeUse.R
3 | \name{summariseAchillesCodeUse}
4 | \alias{summariseAchillesCodeUse}
5 | \title{Summarise code use from achilles counts.}
6 | \usage{
7 | summariseAchillesCodeUse(x, cdm, countBy = c("record", "person"))
8 | }
9 | \arguments{
10 | \item{x}{A codelist.}
11 |
12 | \item{cdm}{A cdm reference via CDMConnector.}
13 |
14 | \item{countBy}{Either "record" for record-level counts or "person" for
15 | person-level counts.}
16 | }
17 | \value{
18 | A tibble with summarised counts.
19 | }
20 | \description{
21 | Summarise code use from achilles counts.
22 | }
23 | \examples{
24 | \donttest{
25 | cdm <- mockVocabRef("database")
26 | oa <- getCandidateCodes(cdm = cdm, keywords = "osteoarthritis")
27 | result_achilles <- summariseAchillesCodeUse(list(oa = oa$concept_id), cdm = cdm)
28 | result_achilles
29 | CDMConnector::cdmDisconnect(cdm)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/man/summariseCodeUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summariseCodeUse.R
3 | \name{summariseCodeUse}
4 | \alias{summariseCodeUse}
5 | \title{Summarise code use in patient-level data.}
6 | \usage{
7 | summariseCodeUse(
8 | x,
9 | cdm,
10 | countBy = c("record", "person"),
11 | byConcept = TRUE,
12 | byYear = FALSE,
13 | bySex = FALSE,
14 | ageGroup = NULL,
15 | dateRange = as.Date(c(NA, NA))
16 | )
17 | }
18 | \arguments{
19 | \item{x}{A codelist.}
20 |
21 | \item{cdm}{A cdm reference via CDMConnector.}
22 |
23 | \item{countBy}{Either "record" for record-level counts or "person" for
24 | person-level counts.}
25 |
26 | \item{byConcept}{TRUE or FALSE. If TRUE code use will be summarised by
27 | concept.}
28 |
29 | \item{byYear}{TRUE or FALSE. If TRUE code use will be summarised by year.}
30 |
31 | \item{bySex}{TRUE or FALSE. If TRUE code use will be summarised by sex.}
32 |
33 | \item{ageGroup}{If not NULL, a list of ageGroup vectors of length two.}
34 |
35 | \item{dateRange}{Two dates. The first indicating the earliest cohort start
36 | date and the second indicating the latest possible cohort end date. If NULL
37 | or the first date is set as missing, the earliest observation_start_date in
38 | the observation_period table will be used for the former. If NULL or the
39 | second date is set as missing, the latest observation_end_date in the
40 | observation_period table will be used for the latter.}
41 | }
42 | \value{
43 | A tibble with count results overall and, if specified, by strata.
44 | }
45 | \description{
46 | Summarise code use in patient-level data.
47 | }
48 | \examples{
49 | \dontrun{
50 | con <- DBI::dbConnect(duckdb::duckdb(),
51 | dbdir = CDMConnector::eunomiaDir())
52 | cdm <- CDMConnector::cdmFromCon(con,
53 | cdmSchema = "main",
54 | writeSchema = "main")
55 | acetiminophen <- c(1125315, 1127433, 40229134,
56 | 40231925, 40162522, 19133768, 1127078)
57 | poliovirus_vaccine <- c(40213160)
58 | cs <- list(acetiminophen = acetiminophen,
59 | poliovirus_vaccine = poliovirus_vaccine)
60 | results <- summariseCodeUse(cs,cdm = cdm)
61 | results
62 | CDMConnector::cdmDisconnect(cdm)
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/man/summariseCohortCodeUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summariseCodeUse.R
3 | \name{summariseCohortCodeUse}
4 | \alias{summariseCohortCodeUse}
5 | \title{Summarise code use among a cohort in the cdm reference}
6 | \usage{
7 | summariseCohortCodeUse(
8 | x,
9 | cdm,
10 | cohortTable,
11 | cohortId = NULL,
12 | timing = "any",
13 | countBy = c("record", "person"),
14 | byConcept = TRUE,
15 | byYear = FALSE,
16 | bySex = FALSE,
17 | ageGroup = NULL
18 | )
19 | }
20 | \arguments{
21 | \item{x}{A codelist.}
22 |
23 | \item{cdm}{A cdm reference via CDMConnector.}
24 |
25 | \item{cohortTable}{A cohort table from the cdm reference.}
26 |
27 | \item{cohortId}{A vector of cohort IDs to include}
28 |
29 | \item{timing}{When to assess the code use relative cohort dates. This can
30 | be "any"(code use any time by individuals in the cohort) or "entry" (code
31 | use on individuals' cohort start date).}
32 |
33 | \item{countBy}{Either "record" for record-level counts or "person" for
34 | person-level counts.}
35 |
36 | \item{byConcept}{TRUE or FALSE. If TRUE code use will be summarised by
37 | concept.}
38 |
39 | \item{byYear}{TRUE or FALSE. If TRUE code use will be summarised by year.}
40 |
41 | \item{bySex}{TRUE or FALSE. If TRUE code use will be summarised by sex.}
42 |
43 | \item{ageGroup}{If not NULL, a list of ageGroup vectors of length two.}
44 | }
45 | \value{
46 | A tibble with results overall and, if specified, by strata
47 | }
48 | \description{
49 | Summarise code use among a cohort in the cdm reference
50 | }
51 | \examples{
52 | \dontrun{
53 | library(CodelistGenerator)
54 | library(duckdb)
55 | library(DBI)
56 | library(CDMConnector)
57 | con <- dbConnect(duckdb(),
58 | dbdir = eunomiaDir())
59 | cdm <- cdmFromCon(con,
60 | cdmSchema = "main",
61 | writeSchema = "main")
62 | cdm <- generateConceptCohortSet(cdm = cdm,
63 | conceptSet = list(a = 260139,
64 | b = 1127433),
65 | name = "cohorts",
66 | end = "observation_period_end_date",
67 | overwrite = TRUE)
68 |
69 | results_cohort_mult <-
70 | summariseCohortCodeUse(list(cs = c(260139,19133873)),
71 | cdm = cdm,
72 | cohortTable = "cohorts",
73 | timing = "entry")
74 |
75 | results_cohort_mult
76 | CDMConnector::cdmDisconnect(cdm)
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/man/summariseOrphanCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summariseOrphanCodes.R
3 | \name{summariseOrphanCodes}
4 | \alias{summariseOrphanCodes}
5 | \title{Find orphan codes related to a codelist using achilles counts and, if
6 | available, PHOEBE concept recommendations}
7 | \usage{
8 | summariseOrphanCodes(
9 | x,
10 | cdm,
11 | domain = c("condition", "device", "drug", "measurement", "observation", "procedure",
12 | "visit")
13 | )
14 | }
15 | \arguments{
16 | \item{x}{A codelist.}
17 |
18 | \item{cdm}{A cdm reference via CDMConnector.}
19 |
20 | \item{domain}{Character vector with one or more of the OMOP CDM domains.
21 | The results will be restricted to the given domains. Check the available
22 | ones by running getDomains(). If NULL, all supported domains are included:
23 | Condition, Drug, Procedure, Device, Observation, and Measurement.}
24 | }
25 | \value{
26 | A summarised result containg the frequency of codes related
27 | to (but not in) the codelist.
28 | }
29 | \description{
30 | Find orphan codes related to a codelist using achilles counts and, if
31 | available, PHOEBE concept recommendations
32 | }
33 | \examples{
34 | \donttest{
35 | cdm <- mockVocabRef("database")
36 | codes <- getCandidateCodes(cdm = cdm,
37 | keywords = "Musculoskeletal disorder",
38 | domains = "Condition",
39 | includeDescendants = FALSE)
40 |
41 | orphan_codes <- summariseOrphanCodes(x = list("msk" = codes$concept_id),
42 | cdm = cdm)
43 |
44 | orphan_codes
45 | CDMConnector::cdmDisconnect(cdm)
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/man/summariseUnmappedCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/summariseUnmappedCodes.R
3 | \name{summariseUnmappedCodes}
4 | \alias{summariseUnmappedCodes}
5 | \title{Find unmapped concepts related to codelist}
6 | \usage{
7 | summariseUnmappedCodes(
8 | x,
9 | cdm,
10 | table = c("condition_occurrence", "device_exposure", "drug_exposure", "measurement",
11 | "observation", "procedure_occurrence")
12 | )
13 | }
14 | \arguments{
15 | \item{x}{A codelist.}
16 |
17 | \item{cdm}{A cdm reference via CDMConnector.}
18 |
19 | \item{table}{Names of clinical tables in which to search for unmapped codes.
20 | Can be one or more of "condition_occurrence", "device_exposure",
21 | "drug_exposure", "measurement", "observation", and "procedure_occurrence".}
22 | }
23 | \value{
24 | A summarised result of unmapped concepts related to given codelist.
25 | }
26 | \description{
27 | Find unmapped concepts related to codelist
28 | }
29 | \examples{
30 | \donttest{
31 | cdm <- mockVocabRef("database")
32 | codes <- list("Musculoskeletal disorder" = 1)
33 | cdm <- omopgenerics::insertTable(cdm, "condition_occurrence",
34 | dplyr::tibble(person_id = 1,
35 | condition_occurrence_id = 1,
36 | condition_concept_id = 0,
37 | condition_start_date = as.Date("2000-01-01"),
38 | condition_type_concept_id = NA,
39 | condition_source_concept_id = 7))
40 | summariseUnmappedCodes(x = list("osteoarthritis" = 2), cdm = cdm,
41 | table = "condition_occurrence")
42 |
43 | CDMConnector::cdmDisconnect(cdm)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/man/tableAchillesCodeUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/tableAchillesCodeUse.R
3 | \name{tableAchillesCodeUse}
4 | \alias{tableAchillesCodeUse}
5 | \title{Format the result of summariseAchillesCodeUse into a table}
6 | \usage{
7 | tableAchillesCodeUse(
8 | result,
9 | type = "gt",
10 | header = c("cdm_name", "estimate_name"),
11 | groupColumn = character(),
12 | hide = character(),
13 | .options = list()
14 | )
15 | }
16 | \arguments{
17 | \item{result}{A \verb{} with results of the type
18 | "achilles_code_use".}
19 |
20 | \item{type}{Type of desired formatted table. To see supported formats
21 | use visOmopResults::tableType().}
22 |
23 | \item{header}{A vector specifying the elements to include in the header. The
24 | order of elements matters, with the first being the topmost header.
25 | The header vector can contain one of the following variables: "cdm_name",
26 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
27 | "estimate_name", "standard_concept", "vocabulary_id".
28 | Alternatively, it can include other names to use as overall header labels.}
29 |
30 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
31 | "cdm_name", "codelist_name", "domain_id", "standard_concept_name",
32 | "standard_concept_id", "estimate_name", "standard_concept", "vocabulary_id".
33 | These cannot be used in header.}
34 |
35 | \item{hide}{Table columns to exclude, options are: "cdm_name",
36 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
37 | "estimate_name", "standard_concept", "vocabulary_id". These cannot be used in
38 | header or groupColumn.}
39 |
40 | \item{.options}{Named list with additional formatting options.
41 | visOmopResults::tableOptions() shows allowed arguments and
42 | their default values.}
43 | }
44 | \value{
45 | A table with a formatted version of the summariseCohortCodeUse
46 | result.
47 | }
48 | \description{
49 | Format the result of summariseAchillesCodeUse into a table
50 | }
51 | \examples{
52 | \donttest{
53 | cdm <- mockVocabRef("database")
54 | oa <- getCandidateCodes(cdm = cdm, keywords = "osteoarthritis")
55 | result_achilles <- summariseAchillesCodeUse(list(oa = oa$concept_id), cdm = cdm)
56 | tableAchillesCodeUse(result_achilles)
57 | CDMConnector::cdmDisconnect(cdm)
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/man/tableCodeUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/tableCodeUse.R
3 | \name{tableCodeUse}
4 | \alias{tableCodeUse}
5 | \title{Format the result of summariseCodeUse into a table.}
6 | \usage{
7 | tableCodeUse(
8 | result,
9 | type = "gt",
10 | header = c("cdm_name", "estimate_name"),
11 | groupColumn = character(),
12 | hide = character(),
13 | .options = list()
14 | )
15 | }
16 | \arguments{
17 | \item{result}{A \verb{} with results of the type "code_use".}
18 |
19 | \item{type}{Type of desired formatted table. To see supported formats
20 | use visOmopResults::tableType().}
21 |
22 | \item{header}{A vector specifying the elements to include in the header. The
23 | order of elements matters, with the first being the topmost header.
24 | The header vector can contain one of the following variables: "cdm_name",
25 | "codelist_name", "standard_concept_name", "standard_concept_id",
26 | "estimate_name", "source_concept_name", "source_concept_id", "domain_id". If
27 | results are stratified, "year", "sex", "age_group" can also be used.
28 | Alternatively, it can include other names to use as overall header labels.}
29 |
30 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
31 | "cdm_name", "codelist_name", "standard_concept_name", "standard_concept_id",
32 | "estimate_name", "source_concept_name", "source_concept_id", "domain_id". If
33 | results are stratified, "year", "sex", "age_group" can also be used.
34 | These cannot be used in header.}
35 |
36 | \item{hide}{Table columns to exclude, options are: "cdm_name",
37 | "codelist_name", "year", "sex", "age_group", "standard_concept_name",
38 | "standard_concept_id", "estimate_name", "source_concept_name",
39 | "source_concept_id", "domain_id". If results are stratified, "year", "sex",
40 | "age_group" can also be used. These cannot be used in header or groupColumn.}
41 |
42 | \item{.options}{Named list with additional formatting options.
43 | visOmopResults::tableOptions() shows allowed arguments and
44 | their default values.}
45 | }
46 | \value{
47 | A table with a formatted version of the summariseCodeUse result.
48 | }
49 | \description{
50 | Format the result of summariseCodeUse into a table.
51 | }
52 | \examples{
53 | \dontrun{
54 | con <- DBI::dbConnect(duckdb::duckdb(),
55 | dbdir = CDMConnector::eunomiaDir())
56 | cdm <- CDMConnector::cdmFromCon(con,
57 | cdmSchema = "main",
58 | writeSchema = "main")
59 | acetiminophen <- c(1125315, 1127433, 40229134,
60 | 40231925, 40162522, 19133768, 1127078)
61 | poliovirus_vaccine <- c(40213160)
62 | cs <- list(acetiminophen = acetiminophen,
63 | poliovirus_vaccine = poliovirus_vaccine)
64 | results <- summariseCodeUse(cs,cdm = cdm)
65 | tableCodeUse(results)
66 | CDMConnector::cdmDisconnect(cdm)
67 | }
68 |
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/man/tableCohortCodeUse.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/tableCodeUse.R
3 | \name{tableCohortCodeUse}
4 | \alias{tableCohortCodeUse}
5 | \title{Format the result of summariseCohortCodeUse into a table.}
6 | \usage{
7 | tableCohortCodeUse(
8 | result,
9 | type = "gt",
10 | header = c("cdm_name", "estimate_name"),
11 | groupColumn = character(),
12 | hide = c("timing"),
13 | .options = list(),
14 | timing = lifecycle::deprecated()
15 | )
16 | }
17 | \arguments{
18 | \item{result}{A \verb{} with results of the type "cohort_code_use".}
19 |
20 | \item{type}{Type of desired formatted table. To see supported formats
21 | use visOmopResults::tableType().}
22 |
23 | \item{header}{A vector specifying the elements to include in the header. The
24 | order of elements matters, with the first being the topmost header.
25 | The header vector can contain one of the following variables: "cdm_name",
26 | "codelist_name", "standard_concept_name", "standard_concept_id",
27 | "estimate_name", "source_concept_name", "source_concept_id", "domain_id". If
28 | results are stratified, "year", "sex", "age_group" can also be used.
29 | Alternatively, it can include other names to use as overall header labels.}
30 |
31 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
32 | "cdm_name", "codelist_name", "standard_concept_name", "standard_concept_id",
33 | "estimate_name", "source_concept_name", "source_concept_id", "domain_id". If
34 | results are stratified, "year", "sex", "age_group" can also be used.
35 | These cannot be used in header.}
36 |
37 | \item{hide}{Table columns to exclude, options are: "cdm_name",
38 | "codelist_name", "year", "sex", "age_group", "standard_concept_name",
39 | "standard_concept_id", "estimate_name", "source_concept_name",
40 | "source_concept_id", "domain_id". If results are stratified, "year", "sex",
41 | "age_group" can also be used. These cannot be used in header or groupColumn.}
42 |
43 | \item{.options}{Named list with additional formatting options.
44 | visOmopResults::tableOptions() shows allowed arguments and
45 | their default values.}
46 |
47 | \item{timing}{deprecated.}
48 | }
49 | \value{
50 | A table with a formatted version of the summariseCohortCodeUse
51 | result.
52 | }
53 | \description{
54 | Format the result of summariseCohortCodeUse into a table.
55 | }
56 | \examples{
57 | \dontrun{
58 | con <- DBI::dbConnect(duckdb::duckdb(),
59 | dbdir = CDMConnector::eunomiaDir())
60 | cdm <- CDMConnector::cdmFromCon(con,
61 | cdmSchema = "main",
62 | writeSchema = "main")
63 | cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
64 | conceptSet = list(a = 260139,
65 | b = 1127433),
66 | name = "cohorts",
67 | end = "observation_period_end_date",
68 | overwrite = TRUE)
69 |
70 | results_cohort_mult <-
71 | summariseCohortCodeUse(list(cs = c(260139,19133873)),
72 | cdm = cdm,
73 | cohortTable = "cohorts",
74 | timing = "entry")
75 |
76 | tableCohortCodeUse(results_cohort_mult)
77 | CDMConnector::cdmDisconnect(cdm)
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/man/tableDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{tableDoc}
4 | \alias{tableDoc}
5 | \title{Helper for consistent documentation of \code{table}.}
6 | \arguments{
7 | \item{table}{cdm table of interest.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{table}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/tableOrphanCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/tableAchillesCodeUse.R
3 | \name{tableOrphanCodes}
4 | \alias{tableOrphanCodes}
5 | \title{Format the result of summariseOrphanCodes into a table}
6 | \usage{
7 | tableOrphanCodes(
8 | result,
9 | type = "gt",
10 | header = c("cdm_name", "estimate_name"),
11 | groupColumn = character(),
12 | hide = character(),
13 | .options = list()
14 | )
15 | }
16 | \arguments{
17 | \item{result}{A \verb{} with results of the type
18 | "orphan_codes".}
19 |
20 | \item{type}{Type of desired formatted table. To see supported formats
21 | use visOmopResults::tableType().}
22 |
23 | \item{header}{A vector specifying the elements to include in the header. The
24 | order of elements matters, with the first being the topmost header.
25 | The header vector can contain one of the following variables: "cdm_name",
26 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
27 | "estimate_name", "standard_concept", "vocabulary_id".
28 | Alternatively, it can include other names to use as overall header labels.}
29 |
30 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
31 | "cdm_name", "codelist_name", "domain_id", "standard_concept_name",
32 | "standard_concept_id", "estimate_name", "standard_concept", "vocabulary_id".
33 | These cannot be used in header.}
34 |
35 | \item{hide}{Table columns to exclude, options are: "cdm_name",
36 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
37 | "estimate_name", "standard_concept", "vocabulary_id". These cannot be used in
38 | header or groupColumn.}
39 |
40 | \item{.options}{Named list with additional formatting options.
41 | visOmopResults::tableOptions() shows allowed arguments and
42 | their default values.}
43 | }
44 | \value{
45 | A table with a formatted version of the summariseOrphanCodes
46 | result.
47 | }
48 | \description{
49 | Format the result of summariseOrphanCodes into a table
50 | }
51 | \examples{
52 | \donttest{
53 | cdm <- mockVocabRef("database")
54 | codes <- getCandidateCodes(cdm = cdm,
55 | keywords = "Musculoskeletal disorder",
56 | domains = "Condition",
57 | includeDescendants = FALSE)
58 |
59 | orphan_codes <- summariseOrphanCodes(x = list("msk" = codes$concept_id),
60 | cdm = cdm)
61 |
62 | tableOrphanCodes(orphan_codes)
63 |
64 | CDMConnector::cdmDisconnect(cdm)
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/man/tableUnmappedCodes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/tableUnmappedCodes.R
3 | \name{tableUnmappedCodes}
4 | \alias{tableUnmappedCodes}
5 | \title{Format the result of summariseUnmappedCodeUse into a table}
6 | \usage{
7 | tableUnmappedCodes(
8 | result,
9 | type = "gt",
10 | header = c("cdm_name", "estimate_name"),
11 | groupColumn = character(),
12 | hide = character(),
13 | .options = list()
14 | )
15 | }
16 | \arguments{
17 | \item{result}{A \verb{} with results of the type
18 | "umapped_codes".}
19 |
20 | \item{type}{Type of desired formatted table. To see supported formats
21 | use visOmopResults::tableType().}
22 |
23 | \item{header}{A vector specifying the elements to include in the header. The
24 | order of elements matters, with the first being the topmost header.
25 | The header vector can contain one of the following variables: "cdm_name",
26 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
27 | "estimate_name", "standard_concept", "vocabulary_id".
28 | Alternatively, it can include other names to use as overall header labels.}
29 |
30 | \item{groupColumn}{Variables to use as group labels. Allowed columns are:
31 | "cdm_name", "codelist_name", "domain_id", "standard_concept_name",
32 | "standard_concept_id", "estimate_name", "standard_concept", "vocabulary_id".
33 | These cannot be used in header.}
34 |
35 | \item{hide}{Table columns to exclude, options are: "cdm_name",
36 | "codelist_name", "domain_id", "standard_concept_name", "standard_concept_id",
37 | "estimate_name", "standard_concept", "vocabulary_id". These cannot be used in
38 | header or groupColumn.}
39 |
40 | \item{.options}{Named list with additional formatting options.
41 | visOmopResults::tableOptions() shows allowed arguments and
42 | their default values.}
43 | }
44 | \value{
45 | A table with a formatted version of the summariseUnmappedCodes
46 | result.
47 | }
48 | \description{
49 | Format the result of summariseUnmappedCodeUse into a table
50 | }
51 | \examples{
52 | \donttest{
53 | cdm <- mockVocabRef("database")
54 | codes <- list("Musculoskeletal disorder" = 1)
55 | cdm <- omopgenerics::insertTable(cdm, "condition_occurrence",
56 | dplyr::tibble(person_id = 1,
57 | condition_occurrence_id = 1,
58 | condition_concept_id = 0,
59 | condition_start_date = as.Date("2000-01-01"),
60 | condition_type_concept_id = NA,
61 | condition_source_concept_id = 7))
62 | unmapped_codes <- summariseUnmappedCodes(x = list("osteoarthritis" = 2),
63 | cdm = cdm, table = "condition_occurrence")
64 | tableUnmappedCodes(unmapped_codes)
65 |
66 | cdm <- omopgenerics::insertTable(
67 | cdm,
68 | "measurement",
69 | dplyr::tibble(
70 | person_id = 1,
71 | measurement_id = 1,
72 | measurement_concept_id = 0,
73 | measurement_date = as.Date("2000-01-01"),
74 | measurement_type_concept_id = NA,
75 | measurement_source_concept_id = 7
76 | )
77 | )
78 | table <- summariseUnmappedCodes(x = list("cs" = 2),
79 | cdm = cdm,
80 | table = c("measurement"))
81 | tableUnmappedCodes(unmapped_codes)
82 |
83 | CDMConnector::cdmDisconnect(cdm)
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/man/typeBroadDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{typeBroadDoc}
4 | \alias{typeBroadDoc}
5 | \title{Helper for consistent documentation of \code{type}.}
6 | \arguments{
7 | \item{type}{Can be "codelist", "codelist_with_details" or
8 | "concept_set_expression".}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{type}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/typeNarrowDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{typeNarrowDoc}
4 | \alias{typeNarrowDoc}
5 | \title{Helper for consistent documentation of \code{type}.}
6 | \arguments{
7 | \item{type}{Can be "codelist" or "codelist_with_details".}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{type}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/man/typeTableDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{typeTableDoc}
4 | \alias{typeTableDoc}
5 | \title{Helper for consistent documentation of \code{type}.}
6 | \arguments{
7 | \item{type}{Type of desired formatted table. To see supported formats
8 | use visOmopResults::tableType().}
9 | }
10 | \description{
11 | Helper for consistent documentation of \code{type}.
12 | }
13 | \keyword{internal}
14 |
--------------------------------------------------------------------------------
/man/xDoc.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/documentation_helper.R
3 | \name{xDoc}
4 | \alias{xDoc}
5 | \title{Helper for consistent documentation of \code{x}.}
6 | \arguments{
7 | \item{x}{A codelist.}
8 | }
9 | \description{
10 | Helper for consistent documentation of \code{x}.
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | # This file is part of the standard setup for testthat.
2 | # It is recommended that you do not modify it.
3 | #
4 | # Where should you do additional test configuration?
5 | # Learn more about the roles of various files in:
6 | # * https://r-pkgs.org/tests.html
7 | # * https://testthat.r-lib.org/reference/test_package.html#special-files
8 |
9 | library(testthat)
10 | library(CodelistGenerator)
11 |
12 | test_check("CodelistGenerator")
13 |
--------------------------------------------------------------------------------
/tests/testthat/setup.R:
--------------------------------------------------------------------------------
1 |
2 | # download eunomia
3 | CDMConnector::requireEunomia()
4 |
--------------------------------------------------------------------------------
/tests/testthat/test-buildAchillesTables.R:
--------------------------------------------------------------------------------
1 | test_that("test buildAchillesTables", {
2 | skip_on_cran()
3 | con <- duckdb::dbConnect(duckdb::duckdb(), CDMConnector::eunomiaDir())
4 | cdm <- CDMConnector::cdmFromCon(
5 | con = con, cdmSchema = "main", writeSchema = "main"
6 | )
7 | expect_false(any(c("achilles_analysis", "achilles_results", "achilles_results_dist") %in% names(cdm)))
8 | expect_no_error(cdm <- buildAchillesTables(cdm = cdm))
9 | expect_true(all(c("achilles_analysis", "achilles_results", "achilles_results_dist") %in% names(cdm)))
10 | expect_identical(
11 | cdm$achilles_analysis |> dplyr::pull("analysis_id") |> sort(),
12 | achillesAnalisisDetails$analysis_id |> sort()
13 | )
14 | expect_identical(
15 | cdm$condition_occurrence |>
16 | dplyr::filter(condition_concept_id == 4112343) |>
17 | dplyr::distinct(.data$person_id) |>
18 | dplyr::tally() |>
19 | dplyr::pull() |>
20 | as.integer(),
21 | cdm$achilles_results |>
22 | dplyr::filter(.data$stratum_1 == "4112343", .data$analysis_id == 400) |>
23 | dplyr::pull("count_value")
24 | )
25 | expect_identical(
26 | cdm$condition_occurrence |>
27 | dplyr::filter(condition_concept_id == 4112343) |>
28 | dplyr::tally() |>
29 | dplyr::pull() |>
30 | as.integer(),
31 | cdm$achilles_results |>
32 | dplyr::filter(.data$stratum_1 == "4112343", .data$analysis_id == 401) |>
33 | dplyr::pull("count_value")
34 | )
35 | expect_identical(
36 | cdm$condition_occurrence |>
37 | dplyr::filter(condition_source_concept_id == 40479768) |>
38 | dplyr::tally() |>
39 | dplyr::pull() |>
40 | as.integer(),
41 | cdm$achilles_results |>
42 | dplyr::filter(.data$stratum_1 == "40479768", .data$analysis_id == 425) |>
43 | dplyr::pull("count_value")
44 | )
45 |
46 | omopgenerics::cdmDisconnect(cdm = cdm)
47 | })
48 |
--------------------------------------------------------------------------------
/tests/testthat/test-codesInUse.R:
--------------------------------------------------------------------------------
1 | test_that("tests with mock db", {
2 |
3 | # mock db
4 | cdm <- mockVocabRef("database")
5 |
6 | codes <- getCandidateCodes(
7 | cdm = cdm,
8 | keywords = "arthritis",
9 | domains = "Condition",
10 | includeDescendants = FALSE
11 | )
12 | expect_true(all(c("4", "5") %in%
13 | subsetToCodesInUse(list("cs" = codes$concept_id),
14 | cdm = cdm)[[1]]))
15 |
16 | expect_true(length(subsetToCodesInUse(list("cs1" = codes$concept_id,
17 | "cs2" = 999),
18 | cdm = cdm)) == 1) # will just have cs1
19 |
20 | # no codes in db
21 | codes <- getCandidateCodes(
22 | cdm = cdm,
23 | keywords = "Musculoskeletal",
24 | domains = "Condition",
25 | includeDescendants = FALSE
26 | )
27 | expect_message(subsetToCodesInUse(list("cs" = codes$concept_id),
28 | cdm = cdm))
29 |
30 | CDMConnector::cdmDisconnect(cdm)
31 |
32 | cdm <- omock::mockCdmReference()
33 | expect_error(codesInUse(cdm))
34 | expect_error(subsetToCodesInUse(x = list("a" = 1), cdm = cdm))
35 | })
36 |
37 | test_that("sql server with achilles", {
38 |
39 | testthat::skip_if(Sys.getenv("CDM5_SQL_SERVER_SERVER") == "")
40 | testthat::skip_if(Sys.getenv("SQL_SERVER_DRIVER") == "")
41 | testthat::skip_if(packageVersion("CDMConnector") <= "1.2.0")
42 |
43 | db <- DBI::dbConnect(odbc::odbc(),
44 | Driver = Sys.getenv("SQL_SERVER_DRIVER"),
45 | Server = Sys.getenv("CDM5_SQL_SERVER_SERVER"),
46 | Database = Sys.getenv("CDM5_SQL_SERVER_CDM_DATABASE"),
47 | UID = Sys.getenv("CDM5_SQL_SERVER_USER"),
48 | PWD = Sys.getenv("CDM5_SQL_SERVER_PASSWORD"),
49 | TrustServerCertificate="yes",
50 | Port = Sys.getenv("CDM5_SQL_SERVER_PORT"))
51 | cdm <- CDMConnector::cdmFromCon(db,
52 | cdmSchema = c("CDMV54", "dbo"),
53 | achillesSchema = c("CDMV54", "dbo"),
54 | writeSchema = c("ohdsi", "dbo"))
55 |
56 | asthma_codes <- getCandidateCodes(
57 | cdm = cdm,
58 | keywords = "asthma",
59 | domains = c("Condition"),
60 | includeDescendants = TRUE
61 | )
62 | asthma_cl <- list("cs" = asthma_codes$concept_id)
63 |
64 | asthma_codes_present <- subsetToCodesInUse(x = asthma_cl,
65 | cdm = cdm)
66 |
67 | expect_equal(sort(asthma_codes_present[[1]]),
68 | sort(cdm$condition_occurrence |>
69 | dplyr::filter(.data$condition_concept_id %in%
70 | !!asthma_codes$concept_id) |>
71 | dplyr::select("condition_concept_id") |>
72 | dplyr::distinct() |>
73 | dplyr::pull()))
74 |
75 |
76 | CDMConnector::cdmDisconnect(cdm)
77 | })
78 |
--------------------------------------------------------------------------------
/tests/testthat/test-data.R:
--------------------------------------------------------------------------------
1 | test_that("load route data", {
2 | expect_identical(colnames(doseFormToRoute),
3 | c("dose_form_concept_id", "route_category"))
4 | })
5 |
--------------------------------------------------------------------------------
/tests/testthat/test-findUnmappedCodes.R:
--------------------------------------------------------------------------------
1 | test_that("achilles code use", {
2 |
3 | testthat::skip_if(Sys.getenv("CDM5_REDSHIFT_DBNAME") == "")
4 | testthat::skip_if_offline()
5 |
6 | db <- DBI::dbConnect(RPostgres::Redshift(),
7 | dbname = Sys.getenv("CDM5_REDSHIFT_DBNAME"),
8 | host = Sys.getenv("CDM5_REDSHIFT_HOST"),
9 | port = Sys.getenv("CDM5_REDSHIFT_PORT"),
10 | user = Sys.getenv("CDM5_REDSHIFT_USER"),
11 | password = Sys.getenv("CDM5_REDSHIFT_PASSWORD"))
12 |
13 | cdm <- CDMConnector::cdmFromCon(con = db,
14 | cdm_schema = Sys.getenv("CDM5_REDSHIFT_CDM_SCHEMA"),
15 | write_schema = Sys.getenv("CDM5_REDSHIFT_SCRATCH_SCHEMA"),
16 | cdmVersion = "5.3")
17 |
18 |
19 | x <- "Nonallopathic lesions"
20 |
21 | candidateCodes <- getCandidateCodes(
22 | cdm = cdm,
23 | keywords = "Nonallopathic lesions",
24 | domains = "Condition",
25 | standardConcept = "Non-standard",
26 | searchInSynonyms = FALSE,
27 | searchNonStandard = FALSE,
28 | includeDescendants = FALSE,
29 | includeAncestor = FALSE)
30 |
31 | # source codes used in the database
32 | dbCandidateCodes <- intersect(unmappedSourceCodesInUse(cdm = cdm),
33 | candidateCodes$concept_id)
34 |
35 |
36 | a<- candidateCodes
37 |
38 | a<-cdm$condition_occurrence |>
39 | dplyr::filter(condition_concept_id == 0) |>
40 | dplyr::collect()
41 |
42 |
43 | CDMConnector::cdmDisconnect(cdm)
44 | })
45 |
--------------------------------------------------------------------------------
/tests/testthat/test-getDoseUnit.R:
--------------------------------------------------------------------------------
1 | test_that("get dose unit", {
2 |
3 | # none in our mock
4 | cdm <- mockVocabRef()
5 | expect_no_error(getDoseUnit(cdm))
6 |
7 | # expected error
8 | expect_error(getDoseUnit("a"))
9 |
10 | cdm <- omock::mockPerson(seed = 1) |>
11 | omock::mockObservationPeriod(seed = 1) |>
12 | omock::mockConcepts(conceptSet = 1, seed = 1) |>
13 | omock::mockVocabularyTables()
14 |
15 | expect_identical(c("milligram", "percent"), getDoseUnit(cdm))
16 |
17 | })
18 |
--------------------------------------------------------------------------------
/tests/testthat/test-getMappings.R:
--------------------------------------------------------------------------------
1 | test_that("tests with mock", {
2 | backends <- c("database")
3 |
4 | for (i in seq_along(backends)) {
5 | # mock db
6 | cdm <- mockVocabRef(backends[[i]])
7 |
8 | # tests
9 | codes <- getCandidateCodes(
10 | cdm = cdm,
11 | keywords = "Musculoskeletal disorder",
12 | domains = "Condition",
13 | includeDescendants = TRUE
14 | )
15 | mappings <- getMappings(
16 | cdm = cdm,
17 | candidateCodelist = codes,
18 | nonStandardVocabularies = "READ"
19 | )
20 | expect_true(
21 | any(mappings$standard_concept_name %in% "Osteoarthrosis")
22 | )
23 | expect_true(
24 | any(mappings$non_standard_concept_name %in% "Degenerative arthropathy")
25 | )
26 | expect_true(
27 | any(mappings$standard_concept_name %in% "Osteoarthritis of knee")
28 | )
29 | expect_true(
30 | any(mappings$non_standard_concept_name %in% "Knee osteoarthritis")
31 | )
32 |
33 | expect_true(all(c(
34 | "standard_concept_id",
35 | "standard_concept_name",
36 | "standard_vocabulary_id",
37 | "non_standard_concept_id",
38 | "non_standard_concept_name",
39 | "non_standard_concept_code",
40 | "non_standard_vocabulary_id"
41 | ) %in%
42 | names(mappings)))
43 |
44 | # expect error if not a cdm reference
45 | expect_error(getMappings(
46 | cdm = "Not a cdm",
47 | candidateCodelist = codes,
48 | nonStandardVocabularies = "READ"
49 | ))
50 |
51 | # expect error if nonStandardVocabularies does not exist
52 | # expect works
53 | mappings <- getMappings(
54 | cdm = cdm,
55 | candidateCodelist = codes,
56 | nonStandardVocabularies = "READ"
57 | )
58 | # expect error
59 | expect_error(getMappings(
60 | cdm = cdm,
61 | candidateCodelist = codes,
62 | nonStandardVocabularies = "READX"
63 | ))
64 | expect_error(getMappings(
65 | cdm = cdm,
66 | candidateCodelist = codes,
67 | nonStandardVocabularies = c("Read", "READX")
68 | ))
69 |
70 | if (backends[[i]] == "database") {
71 | CDMConnector::cdmDisconnect(cdm)
72 | }
73 | }
74 | })
75 |
--------------------------------------------------------------------------------
/tests/testthat/test-getRouteCategories.R:
--------------------------------------------------------------------------------
1 | test_that("getRoutes works with categories", {
2 | # none in our mock cdm
3 | cdm <- mockVocabRef()
4 | expect_no_error(getRouteCategories(cdm))
5 | expect_equal(getRouteCategories(cdm), c("topical","transmucosal_nasal","unclassified_route"))
6 | })
7 |
--------------------------------------------------------------------------------
/tests/testthat/test-helperFunctions.R:
--------------------------------------------------------------------------------
1 | test_that("input validation", {
2 | skip_on_cran()
3 | backends <- c("database", "data_frame")
4 | for (i in seq_along(backends)) {
5 | cdm <- mockVocabRef(backends[[i]])
6 | expect_no_error(
7 | availableIngredients(cdm)
8 | )
9 | expect_no_error(
10 | availableATC(cdm)
11 | )
12 | expect_no_error(
13 | availableATC(cdm, level = c("ATC 2nd"))
14 | )
15 | expect_error(
16 | availableATC(cdm, level = c("ATC 3nd"))
17 | )
18 | expect_no_error(
19 | availableICD10(cdm)
20 | )
21 | expect_no_error(
22 | availableICD10(cdm, level = "ICD10 Chapter")
23 | )
24 | expect_error(
25 | availableICD10(cdm, level = "ICD10 Chapters")
26 | )
27 | }
28 | })
29 |
30 | test_that("available ingredients", {
31 | skip_on_cran()
32 | backends <- c("database", "data_frame")
33 | for (i in seq_along(backends)) {
34 | cdm <- mockVocabRef(backends[[i]])
35 | expect_no_error(
36 | res <- availableIngredients(cdm)
37 | )
38 | manual_res <- cdm$concept |>
39 | dplyr::filter(standard_concept == "S" & concept_class_id == "Ingredient") |>
40 | dplyr::pull("concept_name")
41 | expect_true(setequal(res, manual_res))
42 | }
43 | })
44 |
45 | test_that("available ATC", {
46 | skip_on_cran()
47 | backends <- c("database", "data_frame")
48 | for (i in seq_along(backends)) {
49 | cdm <- mockVocabRef(backends[[i]])
50 | expect_no_error(
51 | res1 <- availableATC(cdm, level = c("ATC 1st", "ATC 2nd"))
52 | )
53 | expect_no_error(
54 | res2 <- availableATC(cdm, level = c("ATC 1st"))
55 | )
56 | expect_true(setequal(intersect(res2, res1), res2)) # res 2 is a subset of res 1
57 | }
58 | })
59 |
60 | test_that("available ICD10", {
61 | skip_on_cran()
62 | backends <- c("database", "data_frame")
63 | for (i in seq_along(backends)) {
64 | cdm <- mockVocabRef(backends[[i]])
65 | expect_no_error(
66 | res1 <- availableICD10(cdm)
67 | )
68 | expect_no_error(
69 | res2 <- availableICD10(cdm, level = c("ICD10 Chapter"))
70 | )
71 | expect_true(setequal(intersect(res2, res1), res2)) # res 2 is a subset of res 1
72 | }
73 | })
74 |
--------------------------------------------------------------------------------
/tests/testthat/test-mockVocabRef.R:
--------------------------------------------------------------------------------
1 | test_that("mock vocab db", {
2 | cdmDb <- mockVocabRef("database")
3 | cdmDF <- mockVocabRef("data_frame")
4 |
5 | conceptFromDb <- cdmDb$concept |> dplyr::collect()
6 | conceptFromDf <- cdmDF$concept |> dplyr::collect()
7 |
8 | expect_equal(conceptFromDb,
9 | conceptFromDf,
10 | ignore_attr = TRUE)
11 |
12 | CDMConnector::cdmDisconnect(cdm = cdmDb)
13 | })
14 |
--------------------------------------------------------------------------------
/tests/testthat/test-restrictToCodesInUse.R:
--------------------------------------------------------------------------------
1 | test_that("restrict to codes in use", {
2 | cdm <- mockVocabRef("database")
3 | startCl <- list(a = c(4,5,6),
4 | b = c(1,2))
5 | endCl <- subsetToCodesInUse(startCl, cdm)
6 |
7 | expect_true(all(c(4,5) %in% endCl[["a"]]))
8 | expect_false(c(6) %in% endCl[["a"]])
9 | # b will have been dropped
10 | expect_true(length(endCl) == 1)
11 |
12 |
13 | # restrict on minimum count
14 | endCl2 <- subsetToCodesInUse(startCl, cdm, minimumCount = 300)
15 | expect_true(c(4) %in% endCl2[["a"]])
16 | expect_false(c(5) %in% endCl2[["a"]])
17 | expect_false(c(6) %in% endCl2[["a"]])
18 |
19 | # none with sufficient count
20 | endCl3 <- subsetToCodesInUse(startCl, cdm, minimumCount = 500)
21 | expect_true(length(endCl3) == 0)
22 |
23 | })
24 |
--------------------------------------------------------------------------------
/tests/testthat/test-stratifyByConcept.R:
--------------------------------------------------------------------------------
1 | test_that("multiplication works", {
2 |
3 | cdm <- mockVocabRef()
4 | cl <- omopgenerics::newCodelist(list(a = c(1,2,3),
5 | b = c(3,4,5)))
6 |
7 | cl_s1 <- stratifyByConcept(cl, cdm, keepOriginal = FALSE)
8 | expect_true(length(cl_s1) == 6)
9 |
10 |
11 | cl_s2 <- stratifyByConcept(cl, cdm, keepOriginal = TRUE)
12 | expect_true(length(cl_s2) == 8)
13 | expect_true(all(sort(names(cl)) == sort(setdiff(names(cl_s2), names(cl_s1)))))
14 |
15 |
16 |
17 | cl <- omopgenerics::newCodelistWithDetails(list(a = data.frame(concept_id = c(1,2,3),
18 | concept_name = c("a", "b", "c")),
19 | b = data.frame(concept_id = c(1,2,3),
20 | concept_name = c("c", "d", "e"))))
21 |
22 | cl_s1 <- stratifyByConcept(cl, cdm, keepOriginal = FALSE)
23 | expect_true(length(cl_s1) == 6)
24 |
25 |
26 | cl_s2 <- stratifyByConcept(cl, cdm, keepOriginal = TRUE)
27 | expect_true(length(cl_s2) == 8)
28 | expect_true(all(sort(names(cl)) == sort(setdiff(names(cl_s2), names(cl_s1)))))
29 |
30 | # if concepts are not in the cdm
31 | cdm <- mockVocabRef()
32 | cl <- omopgenerics::newCodelist(list(a = c(1,2,3),
33 | b = c(3,4,5,99999)))
34 | expect_warning(cl_s1 <- stratifyByConcept(cl, cdm, keepOriginal = FALSE))
35 | expect_true(length(cl_s1) == 6) # concept 99999 will have been dropped
36 |
37 | # if concepts are a list
38 | expect_no_error(cl_s2 <- stratifyByConcept(list("a" = c(1,2,3)), cdm, keepOriginal = FALSE))
39 | })
40 |
--------------------------------------------------------------------------------
/tests/testthat/test-stratifyByDoseUnit.R:
--------------------------------------------------------------------------------
1 | test_that("stratifyByDoseUnit in mock", {
2 | cdm <- mockVocabRef()
3 | ing <- getDrugIngredientCodes(cdm = cdm)
4 |
5 | # no dose units in the mock
6 | expect_no_error(stratifyByDoseUnit(x = ing, cdm = cdm))
7 |
8 | # if concepts are not from the drug domain we should get empty codelist back
9 | oa <- getCandidateCodes(cdm = cdm, "osteoarthritis")
10 | oa_str <- stratifyByDoseUnit(list(oa = oa$concept_id),
11 | cdm, keepOriginal = FALSE)
12 | expect_true(length(oa_str)==0)
13 |
14 | oa_str <- stratifyByDoseUnit(omopgenerics::newCodelistWithDetails(list(oa = oa)),
15 | cdm, keepOriginal = FALSE)
16 | expect_true(length(oa_str)==0)
17 |
18 | # expected errors
19 | expect_error(stratifyByDoseUnit(x = ing, cdm = "a"))
20 | expect_error(stratifyByDoseUnit(x = "a", cdm = cdm))
21 |
22 | })
23 |
--------------------------------------------------------------------------------
/tests/testthat/test-stratifyByRouteCategory.R:
--------------------------------------------------------------------------------
1 | test_that("stratify by route works", {
2 | backends <- c("database", "data_frame")
3 |
4 | for (i in seq_along(backends)) {
5 | cdm <- mockVocabRef(backends[[i]])
6 | ing_codes <- getDrugIngredientCodes(cdm)
7 |
8 | ing_codes_str <- stratifyByRouteCategory(ing_codes, cdm)
9 | # all will are unclassified
10 | expect_true( all(stringr::str_detect(names(ing_codes_str),
11 | "unclassified")))
12 |
13 | # can also keep the original
14 | ing_codes_str_all <- stratifyByRouteCategory(ing_codes, cdm,
15 | keepOriginal = TRUE)
16 | expect_true(length(ing_codes_str_all) == 4)
17 |
18 |
19 | # if concepts are not from the drug domain we should get empty codelist back
20 | oa <- getCandidateCodes(cdm = cdm, "osteoarthritis")
21 | oa_str <- stratifyByRouteCategory(list(oa = oa$concept_id),
22 | cdm, keepOriginal = FALSE)
23 | expect_true(length(oa_str)==0)
24 |
25 | oa_str <- stratifyByRouteCategory(omopgenerics::newCodelistWithDetails(list(oa = oa)),
26 | cdm, keepOriginal = FALSE)
27 | expect_true(length(oa_str)==0)
28 |
29 | # expected errors
30 | expect_error(stratifyByRouteCategory("a", cdm))
31 | expect_error(stratifyByRouteCategory(ing_codes, "a"))
32 |
33 |
34 | if (backends[[i]] == "database") {
35 | CDMConnector::cdmDisconnect(cdm)
36 | }
37 | }
38 | })
39 |
--------------------------------------------------------------------------------
/tests/testthat/test-subsetOnDomain.R:
--------------------------------------------------------------------------------
1 | test_that("subset on domain", {
2 |
3 | backends <- c("database", "data_frame")
4 |
5 | for (i in seq_along(backends)) {
6 | cdm <- mockVocabRef(backends[[i]])
7 | ing_codes <- getDrugIngredientCodes(cdm)
8 |
9 | # all will have been empty and dropped
10 | ing_codes_sub <- subsetOnDomain(ing_codes, cdm, "condition")
11 | expect_true(length(ing_codes_sub) == 0)
12 |
13 | ing_codes_sub2 <- subsetOnDomain(ing_codes, cdm, "drug")
14 | expect_identical(ing_codes, ing_codes_sub2)
15 |
16 | mixed_codelist <- omopgenerics::newCodelist(list("mixed_codes" = c(1L, # condition
17 | 9L, # observation
18 | 10L))) # drug
19 | mixed_codelist1 <- subsetOnDomain(mixed_codelist, cdm, "condition")
20 | expect_true(mixed_codelist1[[1]] == 1L)
21 | expect_true(length(mixed_codelist1[[1]]) == 1)
22 |
23 | mixed_codelist2 <- subsetOnDomain(mixed_codelist, cdm,
24 | c("condition", "drug"))
25 | expect_true(all(sort(mixed_codelist2[[1]]) == c(1L, 10L)))
26 | expect_true(length(mixed_codelist2[[1]]) == 2)
27 |
28 | mixed_codelist3 <- subsetOnDomain(mixed_codelist, cdm,
29 | c("condition", "drug", "observation"))
30 | expect_true(all(sort(mixed_codelist3[[1]]) == c(1L, 9L, 10L)))
31 | expect_true(length(mixed_codelist3[[1]]) == 3)
32 |
33 | # Check negate argument
34 | all_concepts <- list("a" = cdm$concept |> dplyr::pull("concept_id"))
35 | codes1 <- subsetOnDomain(all_concepts, cdm, domain = c("Drug","Observation", "Unit"))
36 | codes2 <- subsetOnDomain(all_concepts, cdm, domain = "Condition", negate = TRUE)
37 |
38 | expect_identical(codes1, codes2)
39 | expect_identical(cdm$concept |>
40 | dplyr::filter(concept_id %in% codes2$a) |>
41 | dplyr::pull("domain_id") |>
42 | unique() |>
43 | sort(na.last = TRUE), c("Drug", "Observation", "Unit"))
44 |
45 | # Check if domain = NA
46 | cdm$concept <- cdm$concept |>
47 | dplyr::mutate(domain_id = dplyr::if_else(concept_id == 1, NA, domain_id)) |>
48 | dplyr::compute(name = "concept")
49 | codes1 <- subsetOnDomain(list("a" = 1), cdm, domain = c("Condition"))
50 | expect_true(length(codes1) == 0)
51 |
52 | # expected errors
53 | expect_error(subsetOnDomain("a", cdm, "condition"))
54 | expect_error(subsetOnDomain(ing_codes, "a", "condition"))
55 | expect_error(subsetOnDomain(ing_codes, cdm, 1234))
56 |
57 | if (backends[[i]] == "database") {
58 | CDMConnector::cdmDisconnect(cdm)
59 | }
60 | }
61 |
62 | })
63 |
--------------------------------------------------------------------------------
/tests/testthat/test-subsetOnDoseUnit.R:
--------------------------------------------------------------------------------
1 | test_that("subsetOnDoseUnit in mock", {
2 | cdm <- mockVocabRef()
3 | ing <- getDrugIngredientCodes(cdm = cdm)
4 |
5 | # no dose units
6 | expect_no_error(subsetOnDoseUnit(x = ing, cdm = cdm,
7 | doseUnit = "hello"))
8 |
9 | # argument NEGATE
10 | codes <- list("codes" = c(20,21))
11 | codes1 <- subsetOnDoseUnit(x = codes, cdm = cdm, doseUnit = c("milligram"))
12 | codes2 <- subsetOnDoseUnit(x = codes, cdm = cdm, doseUnit = c("percent"), negate = TRUE)
13 | expect_identical(codes1, codes2)
14 |
15 | # Check if dose = NA are included
16 | codes1 <- subsetOnDoseUnit(x = list("codes" = c(10,21)), cdm = cdm, doseUnit = c("milligram"))
17 | expect_identical(codes1$codes, 21L)
18 |
19 | # expected errors
20 | expect_error(subsetOnDoseUnit(x = ing, cdm = cdm,
21 | doseUnit = 1))
22 | expect_error(subsetOnDoseUnit(x = ing, cdm = "a",
23 | doseUnit = "milligram"))
24 | expect_error(subsetOnDoseUnit(x = "a", cdm = "a",
25 | doseUnit = "milligram"))
26 |
27 | })
28 |
--------------------------------------------------------------------------------
/tests/testthat/test-subsetOnRouteCategory.R:
--------------------------------------------------------------------------------
1 | test_that("subset on route category", {
2 |
3 | backends <- c("database", "data_frame")
4 |
5 | for (i in seq_along(backends)) {
6 | cdm <- mockVocabRef(backends[[i]])
7 | ing_codes <- getDrugIngredientCodes(cdm)
8 |
9 | ing_codes_sub <- subsetOnRouteCategory(ing_codes, cdm, "oral")
10 | # all will have been empty and dropped
11 | expect_true(length(ing_codes_sub) == 0)
12 |
13 | ing_codes_sub <- subsetOnRouteCategory(ing_codes, cdm, "oral")
14 |
15 | ing_codes_sub2 <- subsetOnRouteCategory(ing_codes, cdm, "unclassified_route")
16 | expect_identical(ing_codes, ing_codes_sub2)
17 |
18 | # expected errors
19 | expect_error(subsetOnRouteCategory("a", cdm, "oral"))
20 | expect_error(subsetOnRouteCategory(ing_codes, "a", "oral"))
21 | expect_error(subsetOnRouteCategory(ing_codes, cdm, 1234))
22 |
23 | # Check negate option
24 | cdm <- mockVocabRef()
25 | x <- list("codes" = c(20L,21L))
26 |
27 | topical1 <- subsetOnRouteCategory(x, cdm, routeCategory = "topical")
28 | topical2 <- subsetOnRouteCategory(x, cdm, routeCategory = "transmucosal_nasal", negate = TRUE)
29 |
30 | expect_equal(topical1$codes, topical2$codes)
31 | expect_true(cdm$concept |>
32 | dplyr::filter(concept_id %in% topical2$codes) |>
33 | dplyr::select("concept_id") |>
34 | dplyr::left_join(
35 | cdm$concept_relationship |>
36 | dplyr::select("concept_id" = "concept_id_1",
37 | "concept_id_2", "relationship_id") |>
38 | dplyr::filter(relationship_id == "RxNorm has dose form"),
39 | by = "concept_id"
40 | ) |>
41 | dplyr::left_join(
42 | doseFormToRoute |>
43 | dplyr::rename("concept_id_2" = "dose_form_concept_id"),
44 | by = "concept_id_2"
45 | ) |>
46 | dplyr::pull("route_category") |>
47 | unique() == "topical")
48 |
49 | if (backends[[i]] == "database") {
50 | CDMConnector::cdmDisconnect(cdm)
51 | }
52 | }
53 | })
54 |
55 |
--------------------------------------------------------------------------------
/tests/testthat/test-summariseAchillesCodeUse.R:
--------------------------------------------------------------------------------
1 | test_that("achilles code use", {
2 | # mock db
3 | cdm <- mockVocabRef("database")
4 |
5 | expect_message(summariseAchillesCodeUse(x = omopgenerics::emptyCodelist(), cdm))
6 |
7 | oa <- getCandidateCodes(cdm = cdm, keywords = "osteoarthritis")
8 | # two codes: "Osteoarthritis of knee" "Osteoarthritis of hip"
9 | result_achilles <- summariseAchillesCodeUse(list(oa = oa$concept_id),
10 | cdm = cdm)
11 | expect_true(result_achilles |>
12 | dplyr::filter(stringr::str_detect(variable_level, "4")) |>
13 | dplyr::pull("estimate_value") == "400")
14 | expect_true(result_achilles |>
15 | dplyr::filter(stringr::str_detect(variable_level, "5")) |>
16 | dplyr::pull("estimate_value") == "200")
17 | expect_true(nrow(result_achilles) == 2)
18 | expect_equal(c("oa", "oa"),
19 | result_achilles |>
20 | dplyr::pull("group_level"))
21 |
22 | # check is a summarised result
23 | expect_true("summarised_result" %in% class(result_achilles))
24 |
25 | # applying min cell count where estimate should be obscured
26 | result_achilles <- summariseAchillesCodeUse(list(oa = oa$concept_id),
27 | cdm = cdm)
28 | expect_true(all(result_achilles |>
29 | omopgenerics::suppress(minCellCount = 500) |>
30 | dplyr::pull("estimate_value") == "-"
31 | ))
32 |
33 |
34 | # edge cases
35 | # concept id not in achilles
36 | expect_message(result_achilles <- summariseAchillesCodeUse(list(asthma = 123),
37 | cdm = cdm))
38 | expect_true(nrow(result_achilles) == 0)
39 | # expect_true("summarised_result" %in% class(result_achilles))
40 |
41 | # expected errors
42 | expect_error(summariseAchillesCodeUse(123, #not list
43 | cdm = cdm))
44 | expect_error(summariseAchillesCodeUse(list(123), #not named list
45 | cdm = cdm))
46 | expect_error(summariseAchillesCodeUse(asthma,
47 | cdm = "cdm")) # not a cdm
48 | expect_error(summariseAchillesCodeUse(asthma,
49 | cdm = cdm,
50 | countBy = "not an option"))
51 |
52 | CDMConnector::cdmDisconnect(cdm)
53 |
54 | cdm <- omock::mockCdmReference()
55 | expect_error(summariseAchillesCodeUse(x = list("a" = 1), cdm))
56 | })
57 |
58 | test_that("achilles code use: multipe codelists", {
59 |
60 | # mock db
61 | cdm <- mockVocabRef("database")
62 |
63 | # two codelists: "Osteoarthritis of knee" "Osteoarthritis of hip"
64 | result_achilles <- summariseAchillesCodeUse(list(knee_oa = 4,
65 | hip_oa = 5),
66 | cdm = cdm)
67 |
68 | expect_true(result_achilles |>
69 | dplyr::filter(group_level == "knee_oa") |>
70 | dplyr::pull("estimate_value") == "400")
71 | expect_true(result_achilles |>
72 | dplyr::filter(group_level == "hip_oa") |>
73 | dplyr::pull("estimate_value") == "200")
74 | expect_true(result_achilles |>
75 | dplyr::filter(stringr::str_detect(variable_level, "4")) |>
76 | dplyr::pull("estimate_value") == "400")
77 | expect_true(result_achilles |>
78 | dplyr::filter(stringr::str_detect(variable_level, "5")) |>
79 | dplyr::pull("estimate_value") == "200")
80 | expect_true(nrow(result_achilles) == 2)
81 | expect_equal(c("knee_oa", "hip_oa"),
82 | result_achilles |>
83 | dplyr::pull("group_level"))
84 |
85 | CDMConnector::cdmDisconnect(cdm)
86 | })
87 |
--------------------------------------------------------------------------------
/tests/testthat/test-summariseOrphanCodes.R:
--------------------------------------------------------------------------------
1 | test_that("tests with mock db", {
2 | # mock db
3 | cdm <- mockVocabRef("database")
4 |
5 | codes <- getCandidateCodes(
6 | cdm = cdm,
7 | keywords = "Musculoskeletal disorder",
8 | domains = "Condition",
9 | includeDescendants = FALSE
10 | )
11 |
12 | orphan_codes <- summariseOrphanCodes(x = list("msk" = codes$concept_id),
13 | cdm = cdm)
14 |
15 | # we should pick up knee osteoarthritis from our achilles tables
16 | expect_true(all(stringr::str_detect(orphan_codes |>
17 | dplyr::pull("variable_level"), c("4", "5"))))
18 | expect_equal(orphan_codes |>
19 | dplyr::pull("estimate_value"),
20 | c("400", "200"))
21 | settings <- omopgenerics::settings(orphan_codes)
22 | expect_true(all(settings$result_type == "orphan_code_use"))
23 |
24 | # with phoebe present
25 | cdm <- omopgenerics::insertTable(cdm,
26 | name = "concept_recommended",
27 | table = data.frame(concept_id_1 = 1,
28 | concept_id_2 = 9,
29 | relationship_id = "from phoebe"),
30 | overwrite = TRUE,
31 | temporary = FALSE)
32 |
33 | orphan_codes <- summariseOrphanCodes(x = list("msk" = codes$concept_id),
34 | cdm = cdm)
35 | expect_true(9 %in% orphan_codes$variable_level)
36 |
37 |
38 | cdm <- omopgenerics::insertTable(cdm,
39 | name = "concept_recommended",
40 | table = data.frame(concept_id_1 = 8,
41 | concept_id_2 = 9,
42 | relationship_id = "from phoebe"),
43 | overwrite = TRUE,
44 | temporary = FALSE)
45 | orphan_codes <- summariseOrphanCodes(x = list("msk" = codes$concept_id),
46 | cdm = cdm)
47 | expect_true(!9 %in% orphan_codes$variable_level)
48 |
49 | #expected error
50 | expect_error(summariseOrphanCodes(x = "a", cdm = cdm))
51 | expect_error(summariseOrphanCodes(x = list("msk" = codes$concept_id),
52 | cdm = "a"))
53 |
54 | # requires achilles
55 | cdm$achilles_results <- NULL
56 | expect_error(summariseOrphanCodes(x = list("msk" = codes$concept_id),
57 | cdm = cdm))
58 |
59 | CDMConnector::cdmDisconnect(cdm)
60 |
61 | cdm <- omock::mockCdmReference()
62 | expect_error(summariseOrphanCodes(x = list("a" = 1), cdm))
63 | })
64 |
--------------------------------------------------------------------------------
/tests/testthat/test-synthea_sql_server.R:
--------------------------------------------------------------------------------
1 | test_that("test with synthea on sql server", {
2 | skip_if(Sys.getenv("darwinDbDatabaseServer") == "")
3 |
4 | db <-DBI::dbConnect(odbc::odbc(),
5 | Driver = Sys.getenv("SQL_SERVER_DRIVER"),
6 | # Driver = "ODBC Driver 17 for SQL Server", #asdf
7 | Server = Sys.getenv("CDM5_SQL_SERVER_SERVER"),
8 | Database = Sys.getenv("CDM5_SQL_SERVER_CDM_DATABASE"),
9 | UID = Sys.getenv("CDM5_SQL_SERVER_USER"),
10 | PWD = Sys.getenv("CDM5_SQL_SERVER_PASSWORD"),
11 | TrustServerCertificate="yes",
12 | Port = Sys.getenv("CDM5_SQL_SERVER_PORT"))
13 |
14 | cdm <- CDMConnector::cdmFromCon(
15 | con = db,
16 | cdmSchema = strsplit(Sys.getenv("CDM5_SQL_SERVER_CDM_SCHEMA"), "\\.")[[1]],
17 | writeSchema = strsplit(Sys.getenv("CDM5_SQL_SERVER_SCRATCH_SCHEMA"), "\\.")[[1]])
18 |
19 | vocabVersion <- getVocabVersion(cdm = cdm)
20 | expect_true(length(vocabVersion) == 1)
21 | expect_true(is.character(vocabVersion))
22 |
23 | # search in database
24 | asthma <- getCandidateCodes(
25 | cdm = cdm,
26 | keywords = "asthma",
27 | domains = "Condition"
28 | )
29 | expect_true(all(c(
30 | "concept_id", "concept_name",
31 | "domain_id", "vocabulary_id"
32 | ) %in%
33 | names(asthma)))
34 | expect_true(nrow(asthma) > 0)
35 |
36 | asthmaIcdMappings <- getMappings(
37 | cdm = cdm,
38 | candidateCodelist = asthma,
39 | nonStandardVocabularies = "ICD10CM"
40 | )
41 | expect_true(all(c(
42 | "standard_concept_id",
43 | "standard_concept_name",
44 | "standard_vocabulary_id",
45 | "non_standard_concept_id",
46 | "non_standard_concept_name",
47 | "non_standard_concept_code",
48 | "non_standard_vocabulary_id"
49 | ) %in%
50 | names(asthmaIcdMappings)))
51 | expect_true(nrow(asthmaIcdMappings) > 0)
52 |
53 | dbDisconnect(db)
54 | })
55 |
--------------------------------------------------------------------------------
/tests/testthat/test-tableUnmappedCodes.R:
--------------------------------------------------------------------------------
1 | test_that("unmapped codes", {
2 |
3 | cdm <- mockVocabRef("database")
4 | cdm <- omopgenerics::insertTable(cdm, "condition_occurrence",
5 | dplyr::tibble(person_id = NA,
6 | condition_occurrence_id = NA,
7 | condition_concept_id = NA,
8 | condition_start_date = NA,
9 | condition_type_concept_id = NA,
10 | condition_source_concept_id = NA))
11 | cdm <- omopgenerics::insertTable(cdm, "drug_exposure",
12 | dplyr::tibble(person_id = NA,
13 | drug_exposure_id = NA,
14 | drug_concept_id = NA,
15 | drug_exposure_start_date = NA,
16 | drug_exposure_end_date = NA,
17 | drug_type_concept_id = NA,
18 | drug_source_concept_id = NA))
19 | cdm <- omopgenerics::insertTable(cdm, "observation",
20 | dplyr::tibble(person_id = NA,
21 | observation_id = NA,
22 | observation_concept_id = NA,
23 | observation_date = NA,
24 | observation_type_concept_id = NA,
25 | observation_source_concept_id = NA))
26 | cdm <- omopgenerics::insertTable(cdm, "procedure_occurrence",
27 | dplyr::tibble(person_id = NA,
28 | procedure_occurrence_id = NA,
29 | procedure_concept_id = NA,
30 | procedure_date = NA,
31 | procedure_type_concept_id = NA,
32 | procedure_source_concept_id = NA))
33 | cdm <- omopgenerics::insertTable(cdm, "device_exposure",
34 | dplyr::tibble(person_id = NA,
35 | device_exposure_id = NA,
36 | device_concept_id = NA,
37 | device_exposure_start_date = NA,
38 | device_type_concept_id = NA,
39 | device_source_concept_id = NA))
40 | cdm <- omopgenerics::insertTable(cdm, "measurement",
41 | dplyr::tibble(person_id = 1,
42 | measurement_id = 1,
43 | measurement_concept_id = 0,
44 | measurement_date = as.Date("2000-01-01"),
45 | measurement_type_concept_id = NA,
46 | measurement_source_concept_id = 7))
47 | expect_no_error(unmappedCodes <- summariseUnmappedCodes(
48 | x = list("cs" = 2),
49 | cdm = cdm))
50 | expect_no_error(tableUnmappedCodes(unmappedCodes))
51 | expect_no_error(tableUnmappedCodes(unmappedCodes, type = "tibble"))
52 | expect_no_error(tableUnmappedCodes(unmappedCodes, header = NULL))
53 |
54 | expect_no_error(tableUnmappedCodes(unmappedCodes |>
55 | omopgenerics::suppress()))
56 |
57 |
58 | })
59 |
--------------------------------------------------------------------------------
/tests/testthat/test-tidyWords.R:
--------------------------------------------------------------------------------
1 | test_that("trailing spaces", {
2 | expect_equal(tidyWords("abc"), tidyWords(" abc "))
3 | })
4 | test_that("hyphens", {
5 | expect_equal(tidyWords("ab c"), tidyWords("ab-c"))
6 | })
7 | test_that("capitalisation", {
8 | expect_equal(tidyWords("AbC"), tidyWords("abc"))
9 | })
10 |
--------------------------------------------------------------------------------
/vignettes/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.R
3 |
--------------------------------------------------------------------------------
/vignettes/Figures/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/1.png
--------------------------------------------------------------------------------
/vignettes/Figures/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/10.png
--------------------------------------------------------------------------------
/vignettes/Figures/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/11.png
--------------------------------------------------------------------------------
/vignettes/Figures/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/2.png
--------------------------------------------------------------------------------
/vignettes/Figures/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/3.png
--------------------------------------------------------------------------------
/vignettes/Figures/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/4.png
--------------------------------------------------------------------------------
/vignettes/Figures/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/5.png
--------------------------------------------------------------------------------
/vignettes/Figures/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/6.png
--------------------------------------------------------------------------------
/vignettes/Figures/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/7.png
--------------------------------------------------------------------------------
/vignettes/Figures/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/8.png
--------------------------------------------------------------------------------
/vignettes/Figures/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darwin-eu/CodelistGenerator/0a0bd1411be19427923462d5f53441095390498a/vignettes/Figures/9.png
--------------------------------------------------------------------------------
/vignettes/a02_ExploreCDMvocabulary.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Exploring the OMOP CDM vocabulary tables"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{a02_ExploreCDMvocabulary}
6 | %\VignetteEncoding{UTF-8}
7 | %\VignetteEngine{knitr::rmarkdown}
8 | editor_options:
9 | chunk_output_type: console
10 | ---
11 |
12 | ```{r, include = FALSE}
13 | NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true")
14 | knitr::opts_chunk$set(
15 | collapse = TRUE,
16 | comment = "#>",
17 | eval = NOT_CRAN
18 | )
19 | ```
20 |
21 | ```{r, include = FALSE}
22 | CDMConnector::requireEunomia("synpuf-1k", "5.3")
23 | ```
24 |
25 | In this vignette, we will explore the functions that help us delve into the vocabularies used in our database. These functions allow us to explore the different vocabularies and concepts characteristics.
26 |
27 | First of all, we will load the required packages and a eunomia database.
28 | ```{r, warning=FALSE, message=FALSE}
29 | library(DBI)
30 | library(dplyr)
31 | library(CDMConnector)
32 | library(CodelistGenerator)
33 |
34 | # Connect to the database and create the cdm object
35 | con <- dbConnect(duckdb::duckdb(),
36 | eunomiaDir("synpuf-1k", "5.3"))
37 | cdm <- cdmFromCon(con = con,
38 | cdmName = "Eunomia Synpuf",
39 | cdmSchema = "main",
40 | writeSchema = "main",
41 | achillesSchema = "main")
42 | ```
43 |
44 | Note that we have included [achilles tables](https://github.com/OHDSI/Achilles) in our cdm reference, which are used for some of the analyses.
45 |
46 | ## Vocabulary characteristics
47 |
48 | We can first start by getting the vocabulary version of our CDM object:
49 | ```{r}
50 | getVocabVersion(cdm)
51 | ```
52 |
53 | And the available vocabularies, which correspond to the column *vocabulary_id* from the concept table:
54 | ```{r}
55 | getVocabularies(cdm)
56 | ```
57 |
58 | ## Domains
59 |
60 | We can also explore the domains that our CDM object has, which is the column *domain_id* from the concept table:
61 | ```{r}
62 | getDomains(cdm)
63 | ```
64 |
65 | or restrict the search among *standard* concepts:
66 | ```{r}
67 | getDomains(cdm,
68 | standardConcept = "Standard")
69 | ```
70 |
71 | ## Concept class
72 |
73 | We can further explore the different classes that we have (reported in *concept_class_id* column from the concept table):
74 | ```{r}
75 | getConceptClassId(cdm)
76 | ```
77 |
78 | Or restrict the search among *non-standard* concepts with *condition* domain:
79 | ```{r}
80 | getConceptClassId(cdm,
81 | standardConcept = "Non-standard",
82 | domain = "Condition")
83 | ```
84 |
85 | ## Relationships
86 |
87 | We can also explore the different relationships that are present in our CDM:
88 | ```{r}
89 | getRelationshipId(cdm)
90 | ```
91 |
92 | Or narrow the search among *standard* concepts with domain *observation*:
93 | ```{r}
94 | getRelationshipId(cdm,
95 | standardConcept1 = "standard",
96 | standardConcept2 = "standard",
97 | domains1 = "observation",
98 | domains2 = "observation")
99 | ```
100 |
101 | ## Codes in use
102 | Finally, we can easily get those codes that are in use (that means, that are recorded at least one time in the database):
103 | ```{r}
104 | result <- sourceCodesInUse(cdm)
105 | head(result, n = 5) # Only the first 5 will be shown
106 | ```
107 | Notice that [achilles tables](https://github.com/OHDSI/Achilles) are used in this function. If you CDM does not have them loaded, an empty result will be returned.
108 |
109 | And we can restrict the search within specific CDM tables (for example, *condition_occurrence* and *device_exposure* table):
110 | ```{r}
111 | result <- sourceCodesInUse(cdm, table = c("device_exposure", "condition_occurrence"))
112 | head(result, n = 5) # Only the first 5 will be shown
113 | ```
114 |
--------------------------------------------------------------------------------