Skip to content

Commit

Permalink
Make package HADES (#33)
Browse files Browse the repository at this point in the history
#30

* Added tests
* Add vignette
* Update DESCRIPTION
* Package maintenance

Co-authored-by: Jamie Gilbert <[email protected]>

Co-authored-by: Jamie Gilbert <[email protected]>
  • Loading branch information
gowthamrao and azimov authored Jul 7, 2022
1 parent e6d4b45 commit a366603
Show file tree
Hide file tree
Showing 22 changed files with 615 additions and 58 deletions.
14 changes: 10 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
Package: PhenotypeLibrary
Type: Package
Title: The OHDSI Phenotype library
Version: 3.1.0
Date: 2022-07-06
Version: 3.1.1
Date: 2022-07-07
Author: Gowtham Rao [aut, cre]
Maintainer: Gowtham Rao <[email protected]>
Description: A repository to store the content of the OHDSI Phenotype library.
Imports:
checkmate,
readr,
dplyr,
rlang,
checkmate
rlang
Suggests:
DatabaseConnector,
testthat,
rmarkdown,
knitr
License: Apache License
RoxygenNote: 7.2.0
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
Language: en-US
VignetteBuilder: knitr
URL: https://ohdsi.github.io/PhenotypeLibrary/, https://github.com/OHDSI/PhenotypeLibrary
BugReports: https://github.com/OHDSI/PhenotypeLibrary/issues
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
PhenotypeLibrary 3.1.1
======================

Added Vignette: How to use Phenotype Library R Package
Added tests to conform to HADES
This package is now part of OHDSI HADES.

PhenotypeLibrary 3.1.0
======================

Expand Down
32 changes: 17 additions & 15 deletions R/Phenotypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,58 @@
#'
#' @examples
#' listPhenotypes()
#'
#'
#' @export
listPhenotypes <- function() {
cohorts <- readr::read_csv(system.file("Cohorts.csv", package = "PhenotypeLibrary"), col_types = readr::cols())
return(cohorts)
return(cohorts)
}

#' Get a cohort definition set
#'
#' @param cohortIds IDs of cohorts to extraction from the library.
#'
#' @return
#' A tibble with the cohort ID, name, sql, and JSON for the provided cohort IDs. Can be used by the
#' A tibble with the cohort ID, name, sql, and JSON for the provided cohort IDs. Can be used by the
#' `CohortGenerator` package.
#'
#'
#' @examples
#' cohorts <- listPhenotypes()
#' subsetIds <- cohorts$cohortId[1:3]
#' getPlCohortDefinitionSet(subsetIds)
#'
#'
#' @export
getPlCohortDefinitionSet <- function(cohortIds) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertIntegerish(cohortIds, min.len = 1, add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)
cohorts <- listPhenotypes() %>%

cohorts <- listPhenotypes() %>%
filter(.data$cohortId %in% cohortIds)
jsonFolder <- system.file("cohorts", package = "PhenotypeLibrary")
sqlFolder <- system.file("sql", "sql_server", package = "PhenotypeLibrary")

readFile <- function(fileName) {
if (file.exists(fileName)) {
return(paste(readr::read_lines(fileName), collapse = "\n"))
} else {
stop(paste0("File not found: ", fileName))
}
}

getJsonAndSql <- function(i) {
json <- readFile(file.path(jsonFolder, paste0(cohorts$cohortId[i], ".json")))
sql <- readFile(file.path(sqlFolder, paste0(cohorts$cohortId[i], ".sql")))
cohorts[i, ] %>%
mutate(json = !!json,
sql = !!sql) %>%
return()
mutate(
json = !!json,
sql = !!sql
) %>%
return()
}

result <- lapply(seq_len(nrow(cohorts)), getJsonAndSql) %>%
bind_rows()

return(result)
}
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ PhenotypeLibrary

Introduction
============
PhenotypeLibrary is a repository to store the content of the OHDSI Phenotype library.
PhenotypeLibrary is a repository to store the content of the OHDSI Phenotype library. These phenotype/cohort definitions have under gone an OHDSI best practice Phenotype Development and Evaluation Process by the OHDSI Phenotype Development and Evaluation work group. This [workgroup](https://forums.ohdsi.org/t/ohdsi-phenotype-library-announcements/16910), through a OHDSI community wide collaboration effort, evaluates and maintains cohort definitions in an [Atlas instance](https://atlas-phenotype.ohdsi.org/#/home). Definitions that have graduated through this process are published in this repository, and are thus considered high quality cohort definitions.

cohortId's in this repository are persistent (similar to OMOP Concept Id) i.e. once published it maybe expected to stay the same between releases of the Phenotype library (i.e. backward compatible). Version numbers in this repository follows [HADES](https://ohdsi.github.io/Hades/index.html) convention, and changes (addition or deletions) are reported as [News](https://ohdsi.github.io/PhenotypeLibrary/news/index.html). Phenotype Development and Evaluation Workgroup will be responsible to maintain a cadence for the cohort life cycle - including deprecation and additions.

Features
========
- Contains all approved phenotypes (ie. cohort definitions) of the OHDSI Phenotype Library.
- Contains all phenotypes (ie. cohort definitions) that have been approved by the OHDSI Phenotype Development and Evaluation workgroup.
- Phenotypes are available as SQL statements and JSON.
- Can directly be used with the OHDSI [CohortGenerator](https://ohdsi.github.io/CohortGenerator/) package to instantiate cohorts.
- Can provide cohortDefinitionSet object that maybe directly used as input by other OHDSI R packages like OHDSI [CohortGenerator](https://ohdsi.github.io/CohortGenerator/) and [CohortGenerator] (https://ohdsi.github.io/CohortDiagnostics/). See accompanying vignettes.

Technology
============
Expand Down
14 changes: 13 additions & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a366603

Please sign in to comment.