Closed edward-burn closed 1 month ago
library(CDMConnector) library(PatientProfiles) library(CodelistGenerator) con <- DBI::dbConnect(duckdb::duckdb(dbdir = eunomia_dir())) cdm <- cdm_from_con(con = con, cdm_schema = "main", write_schema = "main", cdm_name = "my_duckdb_database") meds_cs <- getDrugIngredientCodes( cdm = cdm, name = c( "acetaminophen", "morphine", "warfarin" ) ) cdm <- generateConceptCohortSet( cdm = cdm, name = "meds", conceptSet = meds_cs, end = "event_end_date", limit = "all", overwrite = TRUE ) # works fine cdm$meds %>% PatientProfiles::addCohortIntersectFlag( targetCohortTable = "meds", window = c(0, 0), nameStyle = "{cohort_name}" ) #> # Source: table<og_005_1721072669> [?? x 7] #> # Database: DuckDB v1.0.0 [eburn@Windows 10 x64:R 4.2.1/C:\Users\eburn\AppData\Local\Temp\Rtmp2nuAo7\file97dc4b041d54.duckdb] #> cohort_definition_id subject_id cohort_start_date cohort_end_date #> <int> <int> <date> <date> #> 1 2 9 1985-06-15 1985-06-29 #> 2 2 65 2009-05-28 2009-06-04 #> 3 2 114 2009-11-30 2009-12-07 #> 4 2 135 2001-01-06 2001-02-03 #> 5 2 143 1982-10-29 1982-11-12 #> 6 2 160 1980-01-14 1980-01-28 #> 7 2 162 2013-12-31 2014-01-07 #> 8 2 184 1964-01-25 1964-02-08 #> 9 2 225 2016-12-01 2016-12-22 #> 10 2 264 1978-06-15 1978-06-29 #> # ℹ more rows #> # ℹ 3 more variables: `161_acetaminophen` <dbl>, `11289_warfarin` <dbl>, #> # `7052_morphine` <dbl> # uninformative error cdm$meds %>% PatientProfiles::addCohortIntersectFlag( targetCohortTable = cdm$meds , window = c(0, 0), nameStyle = "{cohort_name}" ) #> Error in `checkCdm()`: #> ! tables: list(con = new("duckdb_connection", conn_ref = <pointer: #> 0x0000022743f6e020>, driver = new("duckdb_driver", database_ref = <pointer: #> 0x0000022748349c60>, config = list(extension_directory = #> "C:\\Users\\eburn\\AppData\\Roaming/R/data/R/duckdb/extensions", #> secret_directory = #> "C:\\Users\\eburn\\AppData\\Roaming/R/data/R/duckdb/stored_secrets"), dbdir = #> "C:\\Users\\eburn\\AppData\\Local\\Temp\\Rtmp2nuAo7\\file97dc4b041d54.duckdb", #> read_only = FALSE, bigint = "numeric"), debug = FALSE, timezone_out = "UTC", #> tz_out_convert = "with", reserved_words = c("abort", "absolute", "access", #> "action", "add", "admin", "after", "aggregate", "all", "also", "alter", #> "always", "analyse", "analyze", "and", "anti", "any", "array", "as", "asc", #> "asof", "assertion", "assignment", "asymmetric", "at", "attach", "attribute", #> "authorization", "backward", "before", "begin", "between", "bigint", #> "binary", "bit", "boolean", "both", "by", "cache", "call", "called", #> "cascade", "cascaded", "case", "cast", "catalog", "centuries", "century", #> "chain", "char", "character", "characteristics", "check", "checkpoint", #> "class", "close", "cluster", "coalesce", "collate", "collation", "column", #> "columns", "comment", "comments", "commit", "committed", "compression", #> "concurrently", "configuration", "conflict", "connection", "constraint", #> "constraints", "content", "continue", "conversion", "copy", "cost", "create", #> "cross", "csv", "cube", "current", "cursor", "cycle", "data", "database", #> "day", "days", "deallocate", "dec", "decade", "decades", "decimal", #> "declare", "default", "defaults", "deferrable", "deferred", "definer", #> "delete", "delimiter", "delimiters", "depends", "desc", "describe", "detach", #> "dictionary", "disable", "discard", "distinct", "do", "document", "domain", #> "double", "drop", "each", "else", "enable", "encoding", "encrypted", "end", #> "enum", "escape", "event", "except", "exclude", "excluding", "exclusive", #> "execute", "exists", "explain", "export", "export_state", "extension", #> "extensions", "external", "extract", "false", "family", "fetch", "filter", #> "first", "float", "following", "for", "force", "foreign", "forward", #> "freeze", "from", "full", "function", "functions", "generated", "glob", #> "global", "grant", "granted", "group", "grouping", "grouping_id", "groups", #> "handler", "having", "header", "hold", "hour", "hours", "identity", "if", #> "ignore", "ilike", "immediate", "immutable", "implicit", "import", "in", #> "include", "including", "increment", "index", "indexes", "inherit", #> "inherits", "initially", "inline", "inner", "inout", "input", "insensitive", #> "insert", "install", "instead", "int", "integer", "intersect", "interval", #> "into", "invoker", "is", "isnull", "isolation", "join", "json", "key", #> "label", "language", "large", "last", "lateral", "leading", "leakproof", #> "left", "level", "like", "limit", "listen", "load", "local", "location", #> "lock", "locked", "logged", "macro", "map", "mapping", "match", #> "materialized", "maxvalue", "method", "microsecond", "microseconds", #> "millennia", "millennium", "millisecond", "milliseconds", "minute", #> "minutes", "minvalue", "mode", "month", "months", "move", "name", "names", #> "national", "natural", "nchar", "new", "next", "no", "none", "not", #> "nothing", "notify", "notnull", "nowait", "null", "nullif", "nulls", #> "numeric", "object", "of", "off", "offset", "oids", "old", "on", "only", #> "operator", "option", "options", "or", "order", "ordinality", "others", #> "out", "outer", "over", "overlaps", "overlay", "overriding", "owned", #> "owner", "parallel", "parser", "partial", "partition", "passing", "password", #> "percent", "persistent", "pivot", "pivot_longer", "pivot_wider", "placing", #> "plans", "policy", "position", "positional", "pragma", "preceding", #> "precision", "prepare", "prepared", "preserve", "primary", "prior", #> "privileges", "procedural", "procedure", "program", "publication", "qualify", #> "quarter", "quarters", "quote", "range", "read", "real", "reassign", #> "recheck", "recursive", "ref", "references", "referencing", "refresh", #> "reindex", "relative", "release", "rename", "repeatable", "replace", #> "replica", "reset", "respect", "restart", "restrict", "returning", "returns", #> "revoke", "right", "role", "rollback", "rollup", "row", "rows", "rule", #> "sample", "savepoint", "schema", "schemas", "scope", "scroll", "search", #> "second", "seconds", "secret", "security", "select", "semi", "sequence", #> "sequences", "serializable", "server", "session", "set", "setof", "sets", #> "share", "show", "similar", "simple", "skip", "smallint", "snapshot", "some", #> "sql", "stable", "standalone", "start", "statement", "statistics", "stdin", #> "stdout", "storage", "stored", "strict", "strip", "struct", "subscription", #> "substring", "summarize", "symmetric", "sysid", "system", "table", "tables", #> "tablesample", "tablespace", "temp", "template", "temporary", "text", "then", #> "ties", "time", "timestamp", "to", "trailing", "transaction", "transform", #> "treat", "trigger", "trim", "true", "truncate", "trusted", "try_cast", #> "type", "types", "unbounded", "uncommitted", "unencrypted", "union", #> "unique", "unknown", "unlisten", "unlogged", "unpivot", "until", "update", #> "use", "user", "using", "vacuum", "valid", "validate", "validator", "value", #> "values", "varchar", "variadic", "varying", "verbose", "version", "view", #> "views", "virtual", "volatile", "week", "weeks", "when", "where", #> "whitespace", "window", "with", "within", "without", "work", "wrapper", #> "write", "xml", "xmlattributes", "xmlconcat", "xmlelement", "xmlexists", #> "xmlforest", "xmlnamespaces", "xmlparse", "xmlpi", "xmlroot", "xmlserialize", #> "xmltable", "year", "years", "yes", "zone"), bigint = "numeric"), disco = #> NULL), list(x = "main.meds", vars = c("cohort_definition_id", "subject_id", #> "cohort_start_date", "cohort_end_date"), group_vars = character(0), #> order_vars = NULL, frame = NULL) are not present in the cdm object #> Backtrace: #> ▆ #> 1. ├─cdm$meds %>% ... #> 2. └─PatientProfiles::addCohortIntersectFlag(...) #> 3. └─PatientProfiles:::checkCdm(cdm, tables = targetCohortTable) #> 4. └─cli::cli_abort(...) #> 5. └─rlang::abort(...)
Created on 2024-07-15 with reprex v2.0.2
Created on 2024-07-15 with reprex v2.0.2