Closed pa-nathaniel closed 1 year ago
I just found some relevant documentation in at https://github.com/OHDSI/Capr/blob/fa03ba051993380a3c69a3b5a6c23273a2cdc390/vignettes/capr_objects.Rmd#L101-L106 I'll keep learning and post an answer if I can solve it!
@pa-nathaniel thanks for your question. you have indeed found a bug. If you want to observe the attrition based on age you can add the age as a demographic criteria to a group. This is what happens in ATLAS. I need to add a container that holds the demographic criteria to apply it to the group. A group must take in a criteria class. Code would look as such:
library(Capr)
t1dConceptSet <- cs(descendants(195771), name = "T1D")
cd <- cohort(
entry = entry(
t1dConceptSet,
observationWindow = continuousObservation(priorDays = 365L),
primaryCriteriaLimit = "All"
),
attrition = attrition(
'atLeast18' = withAll(
demographic(age(gte(18L))) # function to add
)
)
)
Ah interesting, I thought I had solved it yesterday evening by doing something like the code below. Would this not do it?
library(Capr)
t1dConceptSet <- cs(descendants(195771), name = "T1D")
cd <- cohort(
entry = entry(
t1dConceptSet,
observationWindow = continuousObservation(priorDays = 365L),
primaryCriteriaLimit = "All"
),
attrition = attrition(
"At least 18 at entry" = withAll(
atLeast(
1,
conditionOccurrence(
t1dConceptSet,
age(gte(18)), firstOccurrence()
)
)
)
If you are using age as an attribute to a condition this is indeed correct. However, circe allows you to use a demographic attribute as a point of attrition. This is not covered in Capr
v2 and needs to be added.
Ah great glad I wasn't too far off, thanks!
I'm interested in applying inclusion criteria "is at least 18 at index"
I bet I want to leverage the
age()
function (https://github.com/OHDSI/Capr/blob/fa03ba051993380a3c69a3b5a6c23273a2cdc390/R/attributes-op.R#L328-L343), but I'm struggling a bit to figure out how to use it in an exampleI looked at the examples in https://ohdsi.github.io/Capr/articles/Examples.html but didn't find one. Also couldn't seem to find one anywhere else in the repo.
Any tips? Thanks!!