Welcome to the omopHeor repository. omopHeor is an R package ecosystem for Real-World Evidence (RWE) and Health Economics and Outcomes Research (HEOR) focused on Healthcare Resource Utilization (HCRU) and Cost-Effectiveness Analysis (CEA) on OMOP CDM data.
1. Core Architecture & The 6-Stage Analytical Pipeline
Agents developing functions or modules in omopHeor must align their implementations with the 6-stage framework:
-
Stage 1: Cohort Generation
- Define target treatment, comparator, and clinical outcome cohorts using standardized vocabularies.
- Enforce
omopgenericsstandards for cohort table creation and cohort naming (snake_case, <100 characters).
-
Stage 2: Descriptive Baseline & HCRU Characterization
- Build unadjusted baseline tables enriched with demographics.
- Evaluate entry timing and cohort attrition.
- Extract raw unadjusted care utilization (hospitalizations, outpatient visits, ED visits, drug prescriptions) and direct medical costs.
-
Stage 3: Causal Propensity Score (PS) Adjustment
- Fit high-dimensional regularized logistic regression models based on baseline clinical features.
- Provide modular helpers for matching, trimming, weighting, and SMD balance diagnostic plots.
-
Stage 4: Trajectory Compilation & State-Cost Extraction
- Aggregate longitudinal patient timelines into discrete, mutually exclusive health states over uniform time cycles.
- Compute state-to-state transition probability matrices and pull state-specific cost distributions directly from the OMOP
COSTtable.
-
Stage 5: Economic Simulation
- Provide wrappers and exporters for decision-analytic state-transition models and microsimulations incorporating parametric uncertainty.
-
Stage 6: Decision Analysis & Post-Processing (CEA)
- Export standardized summaries and plots for Incremental Cost-Effectiveness Ratios (ICER), Net Monetary Benefit (NMB), and Cost-Effectiveness Acceptability Curves (CEAC).
2. Code Style & Development Guidelines
- Language: R (Target R >= 4.1).
-
Pipes: Always use the base R pipe
|>instead of%>%. -
Assignment: Always use
<-for assignment (never=). -
Naming Conventions (DARWIN EU Standard):
-
Functions & Arguments: Use
lowerCamelCase(e.g.addInpatientHcru(),computeHospitalizationCohorts(),indexDate = "cohort_start_date"). Provide snake_case aliases if backward compatibility is needed. -
Database & Cohort Columns: Use
snake_casefor all table column names (e.g.cohort_start_date,inpatient_admissions,days_supply,total_paid). -
S3 Classes: Use
snake_caseprefixed withhermes_(e.g.hermes_study,hermes_hcru).
-
Functions & Arguments: Use
-
OMOP/OHDSI Rules:
- Never modify core OMOP tables. Write temporary work tables to designated result/scratch schemas.
- Rely on
omopgenericsaccessors (cohortCount(),settings()). - Do not create custom extractors where official OHDSI/DARWIN package methods exist.
-
Testing:
- Place unit tests in
tests/testthat/. - Ensure all new logic has test coverage using
testthat.
- Place unit tests in
-
Formatting & Linting:
- Adhere to
.github/CONTRIBUTING.mdandextras/PackageMaintenance.R. - Run
styler::style_dir()andlintr::lint_package(".", linters = lintr::linters_with_defaults(lintr::object_name_linter(styles = "camelCase")))before committing.
- Adhere to
3. Mandatory CI, Build & Monorepo Conformance Rules
Before staging, committing, or pushing any changes, every agent must strictly verify the following conformance checks:
-
Package Name Case Sensitivity:
- The metapackage name is strictly
omopHeor. Always writelibrary(omopHeor)andtest_check("omopHeor"). Never use variants that fail on case-sensitive Linux CI runners.
- The metapackage name is strictly
-
Local Monorepo Subpackage Resolution:
-
Subpackages (
CohortUtilisation,CohortCosts,CohortEconomics) must be installed and documented locally before building the root metapackage:pak::pkg_install(c("local::packages/CohortUtilisation", "local::packages/CohortCosts", "local::packages/CohortEconomics")) In GitHub Actions workflows (
.github/workflows/), always passlocal::packages/*toextra-packagesinr-lib/actions/setup-r-dependencies@v2.
-
-
Vignette Execution Verification:
-
Every vignette under
vignettes/*.Rmdmust render cleanly without errors before pushing:lapply(list.files("vignettes", pattern = "[.]Rmd$", full.names = TRUE), rmarkdown::render, output_dir = tempdir()) Ensure all function signatures and arguments called in vignettes match active exported APIs.
-
-
Documentation &
pkgdownIndex Conformance:- Run
devtools::document()across all subpackages (packages/*) and root (.). - Every exported function and alias in
man/*.Rdmust be indexed underreference:in_pkgdown.yml. - Verify site build locally:
pkgdown::build_site(preview = FALSE, install = FALSE).
- Run
-
Clean
R CMD check:- Ensure
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning")passes with 0 errors and 0 warnings on all 3 subpackages and root.
- Ensure
4. Release & Version Management
-
Monorepo Version Synchronization Rule:
- The root metapackage
omopHeorand all 3 subpackages (CohortUtilisation,CohortCosts,CohortEconomics) must strictly maintain synchronized semantic versioning across allDESCRIPTIONfiles and internal dependency bounds (CohortUtilisation (>= X.Y.Z)).
- The root metapackage
-
Automated Version Bumping:
-
Agents must use
extras/bumpVersion.Rto bump versions: Can also be sourced and invoked within R:
bumpVersion("patch").
-
-
Release & CRAN Submission Checklist:
Bump Version: Run
make bump-patch(orminor/major) to synchronize all 4DESCRIPTIONfiles and refresh documentation.Verify Conformance: Run
make testandmake check(ormake cran-dry-run).-
Commit & Tag: Stage, commit, and tag release:
-
Phased CRAN Submission (via
Makefile/extras/submitCran.R):-
Wave 1:
make cran-wave1(SubmitsCohortUtilisation&CohortCosts). Confirm email link. -
Wave 2:
make cran-wave2(SubmitsCohortEconomicsonce Wave 1 is live). Confirm email link. -
Wave 3:
make cran-wave3(Submits rootomopHeoronce Wave 2 is live). Confirm email link.
-
Wave 1:
-
Publish GitHub Release:
5. Python ETL & Airflow Pipeline Orchestration
CohortCosts contains ground-source cost ingestion and catalog normalization pipelines located under packages/CohortCosts/:
-
Airflow DAG:
packages/CohortCosts/dags/cost_extraction_dag.py(hermes_cost_catalogs_etl). -
ETL Scripts:
packages/CohortCosts/scripts/(download_costs_sources.py,scrape_costs_es.py,generate_eda_report.py,build_dashboard_html.py). -
Developer Make Targets:
-
make venv: Initialize virtualenv at.venv. -
make py-deps: Install Python dependencies fromrequirements.txt. -
make dag-test: Execute standalone local test of the TaskFlow DAG. -
make dag-run/make dag-airflow: Execute DAG via Airflow CLI test runner. -
make etl-download: Download official regional gazettes and INE price series. -
make etl-scrape: Run offline cost extraction and normalization. -
make etl-report: Generate EDA report (audit/eda_costs_spain_report.md) and HTML dashboard (audit/dashboard.html). -
make etl-all: Orchestrate full end-to-end data pipeline.
-
-
CRAN Build Isolation: All ETL raw/intermediate data, DAG files, and Python scripts are excluded from CRAN builds via
packages/CohortCosts/.Rbuildignore.
For additional context about technologies to be used, project structure, shell commands, and other important information, read the current plan: specs/005-hcru-domain-extraction/plan.md