OHDSI / ClinicalCharacteristics

[under development] table shell approach to OMOP characterization
Apache License 2.0
0 stars 0 forks source link

ClinChar R6 update part 2 #26

Closed mdlavallee92 closed 4 days ago

mdlavallee92 commented 1 month ago

📣📝READY FOR REVIEW📝📣

End point of PR...basic clinChar functionality. End to end example as shown:


executionSettings <- createExecutionSettings(
  connectionDetails = connectionDetails,
  cdmDatabaseSchema = "cdmschema",
  workDatabaseSchema = "workschema",
  tempEmulationSchema = "tempschema",
  targetCohortTable = "cohort",
  cdmSourceName = "omopData"
)

library(Capr)

# baseline conditions
cs1 <- list(
  't2d' = cs(descendants(201826), name = "t2d"),
  'ckd' = cs(descendants(46271022), name = "ckd")
)

# drugs
cs2 <- list(
  'pirfenidone' = cs(descendants(45775206), name = "pirfenidone"),
  'nintedanib' = cs(descendants(45775396), name = "nintedanib")
)

# time windows
tw <- list(
  timeInterval(lb = -365, rb = -1)
)

tw1 <- list(
  timeInterval(lb = -365, rb = -1),
  timeInterval(lb = 0, rb = 90)
)

# make table shell
tableShell <- createTableShell(
  title = "Test",
  targetCohorts = list(
    createTargetCohort(id = 3, name = "ipf")
  ),
  lineItems = lineItems(
    createAgeLineItem(),
    createGenderLineItem(),
    createConceptSetLineItemBatch(
      name = "Baseline Conditions",
      domain = "condition_occurrence",
      statistic = createPresence(),
      conceptSets = cs1,
      timeInterval = tw
    ),
    createConceptSetLineItemBatch(
      name = "Drug Usage",
      domain = "drug_exposure",
      statistic = createPresence(),
      conceptSets = cs2,
      timeIntervals = tw1
    ),
    createConceptSetLineItemBatch(
      name = "Drug Usage",
      domain = "drug_exposure",
      statistic = createCount(),
      conceptSets = cs2,
      timeIntervals = tw1
    )
  )
)

res <- generateTableShell(tableShell, executionSettings)
previewTableShell(res)