Skip to content

Commit e6ad3c1

Browse files
authored
Merge pull request #78 from OHDSI/develop
Capr v2.0.6 release candidate.
2 parents fa03ba0 + 7a50bb9 commit e6ad3c1

389 files changed

Lines changed: 1671 additions & 27105 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/R_CMD_check_Hades.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
- uses: r-lib/actions/setup-r@v2
5252
with:
5353
r-version: ${{ matrix.config.r }}
54+
use-public-rspm: true
5455

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

@@ -86,6 +87,7 @@ jobs:
8687
8788
- name: Install dependencies
8889
run: |
90+
install.packages("curl")
8991
remotes::install_deps(dependencies = TRUE, INSTALL_opts=c("--no-multiarch"))
9092
remotes::install_cran("rcmdcheck")
9193
shell: Rscript {0}

CRAN-SUBMISSION

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Version: 2.0.6
2+
Date: 2023-09-06 18:37:34 UTC
3+
SHA: 71f1dd8bb419ec22cb023ee8502417a1bb82ccef

DESCRIPTION

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
Package: Capr
22
Title: Cohort Definition Application Programming
3-
Version: 2.0.5
3+
Version: 2.0.6
44
Authors@R: c(
5-
person("Martin", "Lavallee", , "mdlavallee92@gmail.com", role = c("aut", "cre")),
6-
person("Adam", "Black", , "black@ohdsi.org", role = "aut")
5+
person("Martin", "Lavallee", , "martin.lavallee@odysseusinc.com", role = c("aut")),
6+
person("Adam", "Black", , "black@ohdsi.org", role = c("aut", "cre"))
77
)
8-
Description: Provides a programming language for defining OHDSI cohort definitions in R to use in studies for Observational
8+
Description: Provides a programming language for defining cohort definitions in R to use in studies for Observational
99
Health Data Sciences and Informatics (OHDSI). The functions in 'Capr' allow for the programmatic creation of
10-
OHDSI concept sets and cohorts that can be serialized to 'Atlas/CIRCE-BE' compatible 'json' files or to 'OHDSI-SQL'.
10+
OHDSI concept sets and cohorts that can be serialized to 'OHDSI' compatible 'json' files or to 'OHDSI-SQL'.
1111
'Capr' functions can be used to create, save, and load component parts to a cohort definition allowing
1212
R programmers to easily reuse cohort logic. 'Capr' provides tools to create a large number of OHDSI cohorts
13-
programmatically while also helping bridge the gap between human readable descriptions of clinical phenotypes
14-
and their computational implmentation.
13+
while also helping bridge the gap between human readable descriptions of clinical phenotypes
14+
and their computational implementation.
1515
License: Apache License (>= 2)
16-
URL: https://ohdsi.github.io/Capr, https://github.com/OHDSI/Capr
17-
BugReports: https://github.com/OHDSI/Capr/issues
16+
URL: https://ohdsi.github.io/Capr/, https://github.com/OHDSI/Capr/
17+
BugReports: https://github.com/OHDSI/Capr/issues/
1818
Encoding: UTF-8
1919
RoxygenNote: 7.2.3
2020
Depends:
@@ -41,22 +41,26 @@ Imports:
4141
SqlRender,
4242
generics
4343
Suggests:
44-
testthat (>= 3.0.0),
45-
knitr,
46-
rmarkdown
44+
testthat (>= 3.0.0),
45+
knitr,
46+
rmarkdown
47+
Enhances:
48+
CirceR
4749
VignetteBuilder: knitr
4850
Config/testthat/edition: 3
51+
Additional_repositories: https://OHDSI.github.io/drat
4952
Collate:
5053
'Capr.R'
5154
'conceptSet.R'
55+
'attributes-concept.R'
56+
'attributes-dateAdjustment.R'
57+
'attributes-logic.R'
5258
'query.R'
5359
'window.R'
5460
'criteria.R'
55-
'exit.R'
56-
'cohort.R'
57-
'attributes-concept.R'
58-
'attributes-logic.R'
5961
'attributes-nested.R'
6062
'attributes-op.R'
63+
'exit.R'
64+
'cohort.R'
6165
'collectCodesetId.R'
6266
'utils.R'

NAMESPACE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ export(attrition)
1010
export(bt)
1111
export(censoringEvents)
1212
export(cohort)
13-
export(compile.Cohort)
13+
export(compile)
1414
export(conditionEra)
1515
export(conditionOccurrence)
1616
export(continuousObservation)
1717
export(cs)
18+
export(dateAdjustment)
1819
export(daysOfSupply)
1920
export(death)
2021
export(descendants)
@@ -36,12 +37,12 @@ export(exit)
3637
export(female)
3738
export(firstOccurrence)
3839
export(fixedExit)
39-
export(generateCaprTemplate)
4040
export(getConceptSetDetails)
4141
export(gt)
4242
export(gte)
4343
export(lt)
4444
export(lte)
45+
export(makeCohortSet)
4546
export(male)
4647
export(mapped)
4748
export(measurement)
@@ -68,6 +69,7 @@ export(withAtMost)
6869
export(writeCohort)
6970
export(writeConceptSet)
7071
exportMethods("==")
72+
exportMethods(compile)
7173
import(dplyr)
7274
importFrom(generics,compile)
7375
importFrom(magrittr,"%>%")

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
Capr 2.0.6
3+
==========
4+
- correct date attribute names (OccurrenceStartDate, OccurrenceEndDate)
5+
- add `makeCohortSet()` function to pipe into `CohortGenerator` (from Issue #79)
6+
- add `dateAdjustment()` function to deploy new circe attribute to a query (from Issue #77)
7+
- prepare for CRAN release
8+
19
Capr 2.0.5
210
==========
311
- change query functions to match known syntax (i.e. drug => drugExposure, condition => conditionOccurrence)

R/attributes-concept.R

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' name the name of the attribute
66
#' @slot
77
#' conceptSet a list representing the concepts for the attribute
8-
# @include conceptSet.R
8+
#' @include conceptSet.R
99
setClass("conceptAttribute",
1010
slots = c(name = "character",
1111
conceptSet = "list" # TODO why is this a list and not a concept set object?
@@ -46,11 +46,9 @@ setMethod("show", "conceptAttribute", function(object) {
4646
#' attributes male demographic attribute
4747
#'
4848
#' @examples
49-
#' \dontrun{
5049
#' # Create a cohort of males with Type 1 diabetes
51-
#' t1dm <- cs(descendants(201254, 435216, 40484648))
52-
#' t1dm_males <- cohort(condition(t1dm, male()))
53-
#' }
50+
#' t1dm <- cs(descendants(201254, 435216, 40484648), name = "type 1 diabetes")
51+
#' t1dm_males <- cohort(conditionOccurrence(t1dm, male()))
5452
male <- function() {
5553

5654
methods::new("conceptAttribute",
@@ -68,11 +66,9 @@ male <- function() {
6866
#' @describeIn
6967
#' attributes female demographic attribute
7068
#' @examples
71-
#' \dontrun{
7269
#' # Create a cohort of males with Type 1 diabetes
73-
#' t1dm <- cs(descendants(201254, 435216, 40484648))
74-
#' t1dm_females <- cohort(condition(t1dm, female()))
75-
#' }
70+
#' t1dm <- cs(descendants(201254, 435216, 40484648), name = "type 1 diabetes")
71+
#' t1dm_females <- cohort(conditionOccurrence(t1dm, female()))
7672
female <- function() {
7773

7874
methods::new("conceptAttribute",
@@ -88,12 +84,12 @@ female <- function() {
8884
#' @return
8985
#' An attribute that can be used in a query function
9086
#' @export
87+
#'
88+
#'
9189
#' @examples
92-
#' \dontrun{
9390
#' # create a unit attribute
9491
#' unit(8713L)
9592
#' unit("%")
96-
#' }
9793
unit <- function(x) {
9894
if (missing(x)) {
9995
rlang::abort("Unit must be specified")

R/attributes-dateAdjustment.R

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# date Adjustment Attribute
2+
3+
4+
# Class ----------------------------
5+
6+
#' An S4 class for a date adjustment attribute
7+
#' @slot name the name of the attribute
8+
#' @slot startWith character string either START_DATE or END_DATE
9+
#' @slot startOffset an integer value, default 0
10+
#' @slot endWith character string either START_DATE or END_DATE
11+
#' @slot endOffset an integer value, default 0
12+
setClass("dateAdjustmentAttribute",
13+
slots = c(name = "character",
14+
startWith = "character",
15+
startOffset = "integer",
16+
endWith = "character",
17+
endOffset = "integer"
18+
),
19+
prototype = list(
20+
name = "DateAdjustment",
21+
startWith = "START_DATE",
22+
startOffset = 0L,
23+
endWith = "END_DATE",
24+
endOffset = 0L
25+
)
26+
)
27+
28+
# Builder -----------------
29+
30+
#' Function to create age attribute
31+
#' @param startWith character string either START_DATE or END_DATE
32+
#' @param startOffset an integer value, default 0
33+
#' @param endWith character string either START_DATE or END_DATE
34+
#' @param endOffset an integer value, default 0
35+
#' @return A dateAdjustment attribute class that can be used with a query
36+
#' @export
37+
dateAdjustment <- function(startWith = "START_DATE",
38+
startOffset = 0L,
39+
endWith = "END_DATE",
40+
endOffset = 0L) {
41+
42+
43+
methods::new("dateAdjustmentAttribute",
44+
startWith = startWith,
45+
startOffset = startOffset,
46+
endWith = endWith,
47+
endOffset = endOffset)
48+
49+
}
50+
51+
# Coercion --------------
52+
53+
setMethod("as.list", "dateAdjustmentAttribute", function(x) {
54+
55+
atr <- list(
56+
StartWith = x@startWith,
57+
StartOffset = x@startOffset,
58+
EndWith = x@endWith,
59+
EndOffset = x@endOffset)
60+
61+
tibble::lst(`:=`(!!x@name, atr))
62+
})

R/attributes-nested.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#' name the name of the attribute
66
#' @slot
77
#' conceptSet a list representing the concepts for the attribute
8-
# @include criteria.R
8+
#'
9+
#' @include criteria.R
910
setClass("nestedAttribute",
1011
slots = c(name = "character", group = "Group"),
1112
prototype = list(name = "CorrelatedCriteria",
@@ -14,16 +15,17 @@ setClass("nestedAttribute",
1415

1516
# Constructor -------------------
1617

17-
#' Function to construct a nested group where all criteria and groups must be satisfied
18+
#' Construct a nested group where all criteria and groups must be satisfied
1819
#' @param ... a set of criteria or groups
1920
#'
2021
#' @export
2122
nestedWithAll <- function(...) {
2223
items <- list(...)
2324
methods::new("nestedAttribute",
24-
group = methods::new("Group", occurrence = methods::new("Occurrence",
25-
type = "all"), criteria = purrr::discard(items, is.Group), group = purrr::keep(items, is.Group)))
26-
25+
group = methods::new("Group",
26+
occurrence = methods::new("Occurrence", type = "all"),
27+
criteria = purrr::discard(items, is.Group),
28+
group = purrr::keep(items, is.Group)))
2729
}
2830

2931
#' Function to construct a nested group where any criteria and groups may be satisfied
@@ -32,8 +34,10 @@ nestedWithAll <- function(...) {
3234
nestedWithAny <- function(...) {
3335
items <- list(...)
3436
methods::new("nestedAttribute",
35-
group = methods::new("Group", occurrence = methods::new("Occurrence",
36-
type = "any"), criteria = purrr::discard(items, is.Group), group = purrr::keep(items, is.Group)))
37+
group = methods::new("Group",
38+
occurrence = methods::new("Occurrence", type = "any"),
39+
criteria = purrr::discard(items, is.Group),
40+
group = purrr::keep(items, is.Group)))
3741
}
3842

3943
#' Function to construct a nested group where at least some of the criteria or groups must be

R/attributes-op.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ setMethod("nbt", "Date", function(x, y) {
328328
#' Function to create age attribute
329329
#' @param op an opAttribute object that is either numeric or integer that defines the logical
330330
#' operation used to determine eligible patient age
331+
#' @return An age attribute that can be used in a cohort definition
331332
#' @export
332333
age <- function(op) {
333334

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

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

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

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

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

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

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

@@ -487,7 +495,7 @@ startDate <- function(op) {
487495
}
488496

489497
methods::new("opAttributeDate",
490-
name = "StartDate",
498+
name = "OccurrenceStartDate",
491499
op = op@op,
492500
value = op@value,
493501
extent = op@extent)
@@ -496,6 +504,7 @@ startDate <- function(op) {
496504
#' Function that creates a end date attribute
497505
#' @param op an opAttribute object must be a date that defines the logical operation used to
498506
#' determine eligible end dates
507+
#' @return An attribute that can be used in a cohort definition
499508
#' @export
500509
endDate <- function(op) {
501510

@@ -505,7 +514,7 @@ endDate <- function(op) {
505514
}
506515

507516
methods::new("opAttributeDate",
508-
name = "EndDate",
517+
name = "OccurrenceEndDate",
509518
op = op@op,
510519
value = op@value,
511520
extent = op@extent)

0 commit comments

Comments
 (0)