Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Capr v2.0.6 release candidate. #78

Merged
merged 62 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8f6461f
fix R check issues
ablack3 Apr 27, 2023
ff849d0
fix tests for r check
ablack3 Apr 27, 2023
999e692
update site and github action workflow
ablack3 Apr 27, 2023
167ef55
add trailing slash to link in description file
ablack3 Apr 27, 2023
9d0ca82
update docs
ablack3 Apr 28, 2023
ad0e40c
Merge pull request #9 from OdyOSG/cran
mdlavallee92 May 1, 2023
3ba08dc
change pkgdown version
mdlavallee92 May 16, 2023
c1083b8
Merge branch 'develop' of https://github.com/OHDSI/Capr into cran
mdlavallee92 May 16, 2023
4091b4f
add super class
mdlavallee92 May 16, 2023
d993e5b
fix start data attribute name
mdlavallee92 Aug 1, 2023
8304415
update version in desc
mdlavallee92 Aug 1, 2023
9924cd1
remove .data from across
mdlavallee92 Aug 1, 2023
312aa72
fix attribute unit tests
mdlavallee92 Aug 1, 2023
0c89402
update news
mdlavallee92 Aug 1, 2023
3533fa2
fix merge conflicts. Merge ohdsi/main
ablack3 Aug 14, 2023
1d8b049
merge
ablack3 Aug 14, 2023
9d984b4
rcheck
ablack3 Aug 14, 2023
c21d7ca
github actions
ablack3 Aug 14, 2023
4296726
Merge branch 'develop' into cran
ablack3 Aug 14, 2023
ef86558
Merge pull request #66 from OHDSI/cran
ablack3 Aug 14, 2023
929b702
fix issue 75
ablack3 Aug 14, 2023
4a23b2f
r check issues
ablack3 Aug 14, 2023
ba1fab4
update docs"
ablack3 Aug 14, 2023
7ae4140
spellcheck
ablack3 Aug 14, 2023
84dfd72
debug actions
ablack3 Aug 14, 2023
8d60cb2
add makeCohortSet function
mdlavallee92 Sep 6, 2023
23687f1
update namespace and news
mdlavallee92 Sep 6, 2023
6fc04f3
pull Adam changes for CRAN
mdlavallee92 Sep 6, 2023
4676563
remove merge conflict for cohort
mdlavallee92 Sep 6, 2023
efd2924
revert to v2.0.6
mdlavallee92 Sep 6, 2023
0e3de84
cran submission files
mdlavallee92 Sep 6, 2023
1cb82f1
fix examples. don't use dontrun per cran comments.
ablack3 Sep 6, 2023
5dbf093
add return message for cohort and cohortEra
mdlavallee92 Sep 6, 2023
f1cfe03
Merge branch 'develop' of https://github.com/OHDSI/Capr into develop
mdlavallee92 Sep 6, 2023
0873887
add return tags for attributes
ablack3 Sep 6, 2023
4670b9b
add return desc for criteria and exit
mdlavallee92 Sep 6, 2023
e941e7f
Merge branch 'develop' of https://github.com/OHDSI/Capr into develop
mdlavallee92 Sep 6, 2023
0c89f10
add return tags for window.R functions
ablack3 Sep 6, 2023
bf9173a
add return desc to attributes-nested
mdlavallee92 Sep 6, 2023
1684ee8
Merge branch 'develop' of https://github.com/OHDSI/Capr into develop
mdlavallee92 Sep 6, 2023
85dbcbf
remove template fn add return desc
mdlavallee92 Sep 6, 2023
fda8d47
add return tags to cohort.R
ablack3 Sep 6, 2023
d7975ad
update documentation and namespace
mdlavallee92 Sep 6, 2023
5756bcd
fix conflict
ablack3 Sep 6, 2023
d6d5a60
Merge branch 'develop' of github.com:OHDSI/Capr into develop
ablack3 Sep 6, 2023
991bb69
correct vignette to use groups in attrition
mdlavallee92 Sep 6, 2023
145d816
Merge branch 'develop' of https://github.com/OHDSI/Capr into develop
mdlavallee92 Sep 6, 2023
bc63c2f
change capr_to_circe to compile
mdlavallee92 Sep 6, 2023
ec9f312
restore @include tags
ablack3 Sep 6, 2023
d75253d
Merge branch 'develop' of github.com:OHDSI/Capr into develop
ablack3 Sep 6, 2023
aa838ff
rcheck
ablack3 Sep 6, 2023
ec77939
update cran comments
ablack3 Sep 6, 2023
71f1dd8
skip makeCohortSet test if CirceR is not installed
ablack3 Sep 6, 2023
31a4286
remove deprecated endpoint functions
ablack3 Sep 6, 2023
0b9160c
fix eventStart documentation
mdlavallee92 Sep 6, 2023
3e3b1fe
update docs
ablack3 Sep 6, 2023
2ac6544
pull Adam change on window
mdlavallee92 Sep 6, 2023
c1a5425
Merge branch 'develop' of https://github.com/OHDSI/Capr into develop
mdlavallee92 Sep 6, 2023
086242e
add dateAdjustment attribute
mdlavallee92 Sep 7, 2023
5294f7c
expose EventAperture class
mdlavallee92 Sep 7, 2023
e881019
update package documentation for release
mdlavallee92 Sep 7, 2023
7a50bb9
update pkg site for release
mdlavallee92 Sep 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/R_CMD_check_Hades.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true

- uses: r-lib/actions/setup-tinytex@v2

Expand Down Expand Up @@ -86,6 +87,7 @@ jobs:

- name: Install dependencies
run: |
install.packages("curl")
remotes::install_deps(dependencies = TRUE, INSTALL_opts=c("--no-multiarch"))
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
Expand Down
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 2.0.6
Date: 2023-09-06 18:37:34 UTC
SHA: 71f1dd8bb419ec22cb023ee8502417a1bb82ccef
36 changes: 20 additions & 16 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Package: Capr
Title: Cohort Definition Application Programming
Version: 2.0.5
Version: 2.0.6
Authors@R: c(
person("Martin", "Lavallee", , "mdlavallee92@gmail.com", role = c("aut", "cre")),
person("Adam", "Black", , "[email protected]", role = "aut")
person("Martin", "Lavallee", , "martin.lavallee@odysseusinc.com", role = c("aut")),
person("Adam", "Black", , "[email protected]", role = c("aut", "cre"))
)
Description: Provides a programming language for defining OHDSI cohort definitions in R to use in studies for Observational
Description: Provides a programming language for defining cohort definitions in R to use in studies for Observational
Health Data Sciences and Informatics (OHDSI). The functions in 'Capr' allow for the programmatic creation of
OHDSI concept sets and cohorts that can be serialized to 'Atlas/CIRCE-BE' compatible 'json' files or to 'OHDSI-SQL'.
OHDSI concept sets and cohorts that can be serialized to 'OHDSI' compatible 'json' files or to 'OHDSI-SQL'.
'Capr' functions can be used to create, save, and load component parts to a cohort definition allowing
R programmers to easily reuse cohort logic. 'Capr' provides tools to create a large number of OHDSI cohorts
programmatically while also helping bridge the gap between human readable descriptions of clinical phenotypes
and their computational implmentation.
while also helping bridge the gap between human readable descriptions of clinical phenotypes
and their computational implementation.
License: Apache License (>= 2)
URL: https://ohdsi.github.io/Capr, https://github.com/OHDSI/Capr
BugReports: https://github.com/OHDSI/Capr/issues
URL: https://ohdsi.github.io/Capr/, https://github.com/OHDSI/Capr/
BugReports: https://github.com/OHDSI/Capr/issues/
Encoding: UTF-8
RoxygenNote: 7.2.3
Depends:
Expand All @@ -41,22 +41,26 @@ Imports:
SqlRender,
generics
Suggests:
testthat (>= 3.0.0),
knitr,
rmarkdown
testthat (>= 3.0.0),
knitr,
rmarkdown
Enhances:
CirceR
VignetteBuilder: knitr
Config/testthat/edition: 3
Additional_repositories: https://OHDSI.github.io/drat
Collate:
'Capr.R'
'conceptSet.R'
'attributes-concept.R'
'attributes-dateAdjustment.R'
'attributes-logic.R'
'query.R'
'window.R'
'criteria.R'
'exit.R'
'cohort.R'
'attributes-concept.R'
'attributes-logic.R'
'attributes-nested.R'
'attributes-op.R'
'exit.R'
'cohort.R'
'collectCodesetId.R'
'utils.R'
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ export(attrition)
export(bt)
export(censoringEvents)
export(cohort)
export(compile.Cohort)
export(compile)
export(conditionEra)
export(conditionOccurrence)
export(continuousObservation)
export(cs)
export(dateAdjustment)
export(daysOfSupply)
export(death)
export(descendants)
Expand All @@ -36,12 +37,12 @@ export(exit)
export(female)
export(firstOccurrence)
export(fixedExit)
export(generateCaprTemplate)
export(getConceptSetDetails)
export(gt)
export(gte)
export(lt)
export(lte)
export(makeCohortSet)
export(male)
export(mapped)
export(measurement)
Expand All @@ -68,6 +69,7 @@ export(withAtMost)
export(writeCohort)
export(writeConceptSet)
exportMethods("==")
exportMethods(compile)
import(dplyr)
importFrom(generics,compile)
importFrom(magrittr,"%>%")
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

Capr 2.0.6
==========
- correct date attribute names (OccurrenceStartDate, OccurrenceEndDate)
- add `makeCohortSet()` function to pipe into `CohortGenerator` (from Issue #79)
- add `dateAdjustment()` function to deploy new circe attribute to a query (from Issue #77)
- prepare for CRAN release

Capr 2.0.5
==========
- change query functions to match known syntax (i.e. drug => drugExposure, condition => conditionOccurrence)
Expand Down
18 changes: 7 additions & 11 deletions R/attributes-concept.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' name the name of the attribute
#' @slot
#' conceptSet a list representing the concepts for the attribute
# @include conceptSet.R
#' @include conceptSet.R
setClass("conceptAttribute",
slots = c(name = "character",
conceptSet = "list" # TODO why is this a list and not a concept set object?
Expand Down Expand Up @@ -46,11 +46,9 @@ setMethod("show", "conceptAttribute", function(object) {
#' attributes male demographic attribute
#'
#' @examples
#' \dontrun{
#' # Create a cohort of males with Type 1 diabetes
#' t1dm <- cs(descendants(201254, 435216, 40484648))
#' t1dm_males <- cohort(condition(t1dm, male()))
#' }
#' t1dm <- cs(descendants(201254, 435216, 40484648), name = "type 1 diabetes")
#' t1dm_males <- cohort(conditionOccurrence(t1dm, male()))
male <- function() {

methods::new("conceptAttribute",
Expand All @@ -68,11 +66,9 @@ male <- function() {
#' @describeIn
#' attributes female demographic attribute
#' @examples
#' \dontrun{
#' # Create a cohort of males with Type 1 diabetes
#' t1dm <- cs(descendants(201254, 435216, 40484648))
#' t1dm_females <- cohort(condition(t1dm, female()))
#' }
#' t1dm <- cs(descendants(201254, 435216, 40484648), name = "type 1 diabetes")
#' t1dm_females <- cohort(conditionOccurrence(t1dm, female()))
female <- function() {

methods::new("conceptAttribute",
Expand All @@ -88,12 +84,12 @@ female <- function() {
#' @return
#' An attribute that can be used in a query function
#' @export
#'
#'
#' @examples
#' \dontrun{
#' # create a unit attribute
#' unit(8713L)
#' unit("%")
#' }
unit <- function(x) {
if (missing(x)) {
rlang::abort("Unit must be specified")
Expand Down
62 changes: 62 additions & 0 deletions R/attributes-dateAdjustment.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# date Adjustment Attribute


# Class ----------------------------

#' An S4 class for a date adjustment attribute
#' @slot name the name of the attribute
#' @slot startWith character string either START_DATE or END_DATE
#' @slot startOffset an integer value, default 0
#' @slot endWith character string either START_DATE or END_DATE
#' @slot endOffset an integer value, default 0
setClass("dateAdjustmentAttribute",
slots = c(name = "character",
startWith = "character",
startOffset = "integer",
endWith = "character",
endOffset = "integer"
),
prototype = list(
name = "DateAdjustment",
startWith = "START_DATE",
startOffset = 0L,
endWith = "END_DATE",
endOffset = 0L
)
)

# Builder -----------------

#' Function to create age attribute
#' @param startWith character string either START_DATE or END_DATE
#' @param startOffset an integer value, default 0
#' @param endWith character string either START_DATE or END_DATE
#' @param endOffset an integer value, default 0
#' @return A dateAdjustment attribute class that can be used with a query
#' @export
dateAdjustment <- function(startWith = "START_DATE",
startOffset = 0L,
endWith = "END_DATE",
endOffset = 0L) {


methods::new("dateAdjustmentAttribute",
startWith = startWith,
startOffset = startOffset,
endWith = endWith,
endOffset = endOffset)

}

# Coercion --------------

setMethod("as.list", "dateAdjustmentAttribute", function(x) {

atr <- list(
StartWith = x@startWith,
StartOffset = x@startOffset,
EndWith = x@endWith,
EndOffset = x@endOffset)

tibble::lst(`:=`(!!x@name, atr))
})
18 changes: 11 additions & 7 deletions R/attributes-nested.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#' name the name of the attribute
#' @slot
#' conceptSet a list representing the concepts for the attribute
# @include criteria.R
#'
#' @include criteria.R
setClass("nestedAttribute",
slots = c(name = "character", group = "Group"),
prototype = list(name = "CorrelatedCriteria",
Expand All @@ -14,16 +15,17 @@ setClass("nestedAttribute",

# Constructor -------------------

#' Function to construct a nested group where all criteria and groups must be satisfied
#' Construct a nested group where all criteria and groups must be satisfied
#' @param ... a set of criteria or groups
#'
#' @export
nestedWithAll <- function(...) {
items <- list(...)
methods::new("nestedAttribute",
group = methods::new("Group", occurrence = methods::new("Occurrence",
type = "all"), criteria = purrr::discard(items, is.Group), group = purrr::keep(items, is.Group)))

group = methods::new("Group",
occurrence = methods::new("Occurrence", type = "all"),
criteria = purrr::discard(items, is.Group),
group = purrr::keep(items, is.Group)))
}

#' Function to construct a nested group where any criteria and groups may be satisfied
Expand All @@ -32,8 +34,10 @@ nestedWithAll <- function(...) {
nestedWithAny <- function(...) {
items <- list(...)
methods::new("nestedAttribute",
group = methods::new("Group", occurrence = methods::new("Occurrence",
type = "any"), criteria = purrr::discard(items, is.Group), group = purrr::keep(items, is.Group)))
group = methods::new("Group",
occurrence = methods::new("Occurrence", type = "any"),
criteria = purrr::discard(items, is.Group),
group = purrr::keep(items, is.Group)))
}

#' Function to construct a nested group where at least some of the criteria or groups must be
Expand Down
13 changes: 11 additions & 2 deletions R/attributes-op.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ setMethod("nbt", "Date", function(x, y) {
#' Function to create age attribute
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible patient age
#' @return An age attribute that can be used in a cohort definition
#' @export
age <- function(op) {

Expand All @@ -349,6 +350,7 @@ age <- function(op) {
#' the op logic.
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible number of days of supply
#' @return An attribute that can be used in a cohort definition
#' @export
daysOfSupply <- function(op) {

Expand All @@ -368,6 +370,7 @@ daysOfSupply <- function(op) {
#' op logic.
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible number of refills
#' @return An attribute that can be used in a cohort definition
#' @export
drugRefills <- function(op) {

Expand All @@ -391,6 +394,7 @@ drugRefills <- function(op) {
#' determined by the op logic.
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible patient age
#' @return An attribute that can be used in a cohort definition
#' @export
valueAsNumber <- function(op) {

Expand All @@ -412,6 +416,7 @@ valueAsNumber <- function(op) {
#' determined by the op logic.
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible range high
#' @return An attribute that can be used in a cohort definition
#' @export
rangeHigh <- function(op) {

Expand All @@ -433,6 +438,7 @@ rangeHigh <- function(op) {
#' determined by the op logic.
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible range low
#' @return An attribute that can be used in a cohort definition
#' @export
rangeLow <- function(op) {

Expand All @@ -456,6 +462,7 @@ rangeLow <- function(op) {
#' op logic.
#' @param op an opAttribute object that is either numeric or integer that defines the logical
#' operation used to determine eligible quantity
#' @return An attribute that can be used in a cohort definition
#' @export
drugQuantity <- function(op) {

Expand All @@ -478,6 +485,7 @@ drugQuantity <- function(op) {
#' Function that creates a start date attribute
#' @param op an opAttribute object must be a date that defines the logical operation used to
#' determine eligible start dates
#' @return An attribute that can be used in a cohort definition
#' @export
startDate <- function(op) {

Expand All @@ -487,7 +495,7 @@ startDate <- function(op) {
}

methods::new("opAttributeDate",
name = "StartDate",
name = "OccurrenceStartDate",
op = op@op,
value = op@value,
extent = op@extent)
Expand All @@ -496,6 +504,7 @@ startDate <- function(op) {
#' Function that creates a end date attribute
#' @param op an opAttribute object must be a date that defines the logical operation used to
#' determine eligible end dates
#' @return An attribute that can be used in a cohort definition
#' @export
endDate <- function(op) {

Expand All @@ -505,7 +514,7 @@ endDate <- function(op) {
}

methods::new("opAttributeDate",
name = "EndDate",
name = "OccurrenceEndDate",
op = op@op,
value = op@value,
extent = op@extent)
Expand Down
Loading
Loading