These functions convert a cohort definition exported from Atlas (Circe JSON)
into equivalent Capr R code (concept sets and cohort() calls).
jsonToCapr(jsonPath, mode = c("strict", "skip"), returnSkipped = FALSE)Character. Path to the cohort JSON file.
"strict" (default): stop on unsupported elements.
"skip": omit unsupported parts and emit # SKIPPED: comments (unsafe).
If TRUE, return a list with lines, skipped, and emptyGroupWarnings instead of just the character string (for regression/reporting).
A single character string of R code with newlines between lines (so cat(jsonToCapr(...)) prints nicely), or if returnSkipped = TRUE, a list with lines, skipped, emptyGroupWarnings. The generated code starts with library(Capr) so the file is self-contained and can be sourced directly.
Concept sets (cs()), primary criteria and entry, additional criteria
(withAll/withAny), inclusion rules (attrition()), correlated
criteria (nestedWithAll/nestedWithAny), start/end windows
(duringInterval), occurrence (exactly/atLeast/atMost),
common attributes (age, dates, firstOccurrence, dateAdjustment, source concepts),
Measurement/DrugExposure attributes, exit strategies (fixedExit,
drugExit, observationExit), censoring criteria, and era collapse.
mode = "skip")Domains: Specimen, VisitDetail; VisitOccurrence.ProviderSpecialty;
any *TypeExclude == TRUE or *Type lists (Type lists require vocabulary lookup in Capr);
Unknown domain keys are reported via detectUnsupportedKeys() to avoid silent drift.