Package {CohortCosts}


Title: Direct Medical Cost Extraction and Health Economics Costing on OMOP CDM
Version: 0.6.1
Description: Links polymorphic Observational Medical Outcomes Partnership (OMOP) COST records to clinical events and tracks medical expenditures, unit cost tariffs, and healthcare price indices for OMOP Common Data Model (CDM) cohorts following DARWIN EU standards.
License: MIT + file LICENSE
Copyright: IOMED, S.L.
URL: https://www.iomed.health/, https://github.com/iomedhealth/omopHeor
BugReports: https://github.com/iomedhealth/omopHeor/issues
Depends: R (≥ 4.1.0)
Imports: CDMConnector (≥ 1.4.0), omopgenerics (≥ 0.3.0), dbplyr (≥ 2.4.0), dplyr (≥ 1.1.0), ggplot2, rlang, cli, glue
Suggests: DBI, tibble, gt, PatientProfiles (≥ 1.2.0), visOmopResults, duckdb, testthat (≥ 3.0.0), withr
Config/testthat/edition: 3
Config/roxygen2/version: 8.1.0
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2026-08-21 11:20:23 UTC; gabriel.maeztu
Author: Gabriel Maeztu [aut, cre]
Maintainer: Gabriel Maeztu <gabriel@iomed.health>
Repository: CRAN
Date/Publication: 2026-08-30 09:00:07 UTC

CohortCosts: Direct Medical Cost Extraction and Health Economics Costing on OMOP CDM

Description

Links polymorphic Observational Medical Outcomes Partnership (OMOP) COST records to clinical events and tracks medical expenditures, unit cost tariffs, and healthcare price indices for OMOP Common Data Model (CDM) cohorts following DARWIN EU standards.

Author(s)

Maintainer: Gabriel Maeztu gabriel@iomed.health

Authors:

See Also

Useful links:


Add Direct Medical Costs to a Cohort

Description

Add Direct Medical Costs to a Cohort

Usage

addCosts(
  x,
  indexDate = "cohort_start_date",
  censorDate = NULL,
  window = list(c(-365, -1), c(0, 365)),
  costField = "total_paid",
  domains = c("Inpatient", "Outpatient", "Drug", "Procedure"),
  nameStyle = "cost_{domain}_{window_name}",
  name = NULL
)

Arguments

x

A cohort table or cdm_table.

indexDate

Date variable in x anchoring the observation window. Default: "cohort_start_date".

censorDate

Optional date variable in x to censor observation.

window

A named or unnamed list of 2-element numeric vectors. Default: list(c(-365, -1), c(0, 365)).

costField

Column name in cost table to aggregate. Default: "total_paid".

domains

Clinical domains to extract. Default: c("Inpatient", "Outpatient", "Drug", "Procedure").

nameStyle

Column naming pattern. Default: "cost_{domain}_{window_name}".

name

Name of the new table in the write schema. If NULL, a temporary table is returned.

Value

The cohort table x with added direct medical cost columns.


Plot Summarised Direct Medical Costs

Description

Plot Summarised Direct Medical Costs

Usage

plotCosts(result, costColumn = "cost_total", plotType = "barplot")

Arguments

result

A summarised_result object from summariseCosts().

costColumn

Cost column name pattern to plot. Default: "cost_total".

plotType

Visualization type: "barplot" or "boxplot". Default: "barplot".

Value

A ggplot2 visualization object.


Summarise Direct Medical Costs for a Cohort

Description

Summarise Direct Medical Costs for a Cohort

Usage

summariseCosts(
  cohort,
  group = list("cohort_name"),
  strata = list(),
  costColumns = NULL,
  estimates = c("mean", "sd", "median", "q25", "q75", "min", "max")
)

Arguments

cohort

An enriched cohort table containing cost columns.

group

List of character vectors specifying grouping columns. Default: list("cohort_name").

strata

List of character vectors specifying stratification columns. Default: list().

costColumns

Character vector of cost columns to summarise. If NULL, selects all columns starting with cost_.

estimates

Summary estimators to compute. Default: c("mean", "sd", "median", "q25", "q75", "min", "max").

Value

An omopgenerics::summarised_result object.


Format Summarised Direct Costs as a Table

Description

Format Summarised Direct Costs as a Table

Usage

tableCosts(
  result,
  type = "gt",
  header = c("cdm_name", "cohort_name"),
  estimateName = c(N = "<count>", `Mean (SD)` = "<mean> (<sd>)", `Median (IQR)` =
    "<median> (<q25> - <q75>)", `Min - Max` = "<min> - <max>"),
  ...
)

Arguments

result

A summarised_result object from summariseCosts().

type

Output table format: "gt", "flextable", or "tibble". Default: "gt".

header

Character vector of columns to include in the header. Default: c("cdm_name", "cohort_name").

estimateName

Named character vector mapping estimate names.

...

Additional arguments passed to visOmopResults::visOmopTable().

Value

A formatted table object (gt_tbl, flextable, or tibble).