OHDSI / CohortGenerator

An R package for instantiating cohorts using data in the CDM.
https://ohdsi.github.io/CohortGenerator/
11 stars 10 forks source link

Allow integer as cohort ID #146

Closed schuemie closed 2 weeks ago

schuemie commented 1 month ago

The isCohortDefinitionSet() currently throws an error if the cohortId is an integer. However, I think integer should be totally fine. Could we be a bit more lenient?

(Currently Capr::makeCohortSet() generates the concept ID as integer, I would prefer it to work without having to convert the integer to numeric.)

Reproducible example:

cds <- data.frame(cohortId = as.integer(1),
                  cohortName = "",
                  sql = "",
                  json = "")
CohortGenerator::isCohortDefinitionSet(cds)
# [1] FALSE                                                                                                                                                                                                                     
# Warning message:
# In checkAndFixCohortDefinitionSetDataTypes(x = x, fixDataTypes = FALSE,  :
#   Your cohortDefinitionSet had a mismatch in data types. Please check your cohortDefinitionSet to ensure it conforms to the following expected data types:Expected column == data type
# --------------------------
# cohortId == numeric
# cohortName == character
# sql == character
# json == character
# --------------------------
# Your cohortDefinitionSet 
# --------------------------
# cohortId == integer
# cohortName == character
# sql == character
# json == character
anthonysena commented 1 month ago

Absolutely. I'd like to tackle #152 and then make this check more lenient once we remove bit64.