darwin-eu-dev / omopgenerics

https://darwin-eu-dev.github.io/omopgenerics/
Apache License 2.0
2 stars 1 forks source link

Limiting cohort name length #400

Closed edward-burn closed 1 month ago

edward-burn commented 2 months ago

@catalamarti as part of the cohort validation, we might well want to limit cohort name length. Here is a downstream error I get on postgres if my cohort has an unreasonably long name

library(PatientProfiles)
library(CodelistGenerator)
db <- DBI::dbConnect(RPostgres::Postgres(),
                     dbname = Sys.getenv("CDM5_POSTGRESQL_DBNAME"),
                     host = Sys.getenv("CDM5_POSTGRESQL_HOST"),
                     user = Sys.getenv("CDM5_POSTGRESQL_USER"),
                     password = Sys.getenv("CDM5_POSTGRESQL_PASSWORD"))
cdm <- CDMConnector::cdm_from_con(
  con = db,
  cdm_schema = Sys.getenv("CDM5_POSTGRESQL_CDM_SCHEMA"),
  write_schema = c(schema =  Sys.getenv("CDM5_POSTGRESQL_SCRATCH_SCHEMA"),
                   prefix = "incp_"),
  achilles_schema = Sys.getenv("CDM5_POSTGRESQL_CDM_SCHEMA")
)

diclofenac_codes <- getDrugIngredientCodes(cdm, name = c("diclofenac"))
diclofenac_codes <- stratifyByConcept(diclofenac_codes, cdm = cdm)
diclofenac_codes <- suppressMessages(subsetToCodesInUse(diclofenac_codes, 
                                                        cdm = cdm))
dc <- diclofenac_codes[1:3]
nchar(names(dc))

cdm <- CDMConnector::generateConceptCohortSet(cdm = cdm,
                                              conceptSet = dc,
                                              name = "diclofenac")

cdm$diclofenac %>%
  addCohortIntersectFlag(
    targetCohortTable = "diclofenac",
    window = c(0, 0),
    nameStyle = "{cohort_name}"
  )

image

catalamarti commented 1 month ago

to cohort name to 100 characters