HCRU & Direct Cost Extraction Logic
This document outlines the extraction and linkage logic for
Healthcare Resource Utilization (HCRU) and direct medical expenditures
from the OMOP CDM COST table across the omopHeor
ecosystem.
1. Dual Cost Extraction Modalities
omopHeor provides two complementary mechanisms for extracting cost data:
-
In-Database Cohort Enrichment
(
CohortCosts::addCosts()):- Appends windowed domain cost columns (
cost_inpatient_*,cost_outpatient_*,cost_drug_*,cost_procedure_*,cost_total_*) directly to any OMOP cohort table in the database write schema. - Suited for epidemiological studies, patient profiling, and multivariable regression.
- Appends windowed domain cost columns (
-
Pipeline State-Cost Extraction
(
CohortEconomics::extract_hcru()):- Links clinical event expenditures to study subjects and tags each
cost with the patient’s health state (e.g.
State_BaselinevsState_Outcome). - Feeds state-specific cost distributions directly into Stage 4
(
compile_trajectories()) and Stage 5 Markov simulations (simulate_economics()).
- Links clinical event expenditures to study subjects and tags each
cost with the patient’s health state (e.g.
2. Extraction Decision Flow
+-------------------------------------+
| addCosts() or extract_hcru() called |
+------------------+------------------+
|
v
+-----------------------+
| Does 'cost' table |
| exist in the CDM? |
+-------+-------+-------+
| |
[No] | | [Yes]
v v
+--------------------+ +---------------------------+
| Warn user: No cost | | Is 'cost' table empty? |
| table found. Fill | | (record count == 0) |
| columns with 0.0. | +-------+---------+---------+
+--------------------+ | |
[Yes]| | [No]
v |
+--------------------+ |
| Warn user: Table | |
| exists but empty. | |
| Return 0.0 values. | |
+--------------------+ v
+--------------------------------+
| Are financial metrics |
| (total_paid, total_charge) |
| available and populated? |
+---------+-------------+--------+
| |
[No] | | [Yes]
v |
+---------------------------+ |
| Do drg_concept_id or | |
| drg_source_value exist | |
| in the table? | |
+-------+---------+---------+ |
| | |
[No] | | [Yes] |
v v |
+------------------------+ +-------------------+ |
| Zero-fill cost columns | | Prompt user for | |
| or warn missing metric | | DRG-to-Cost | |
| | | lookup dictionary | |
+------------------------+ +--------+----------+ |
| |
| |
v v
+--------------------------------+
| Link by cost_event_id across |
| Condition, Visit, Drug, and |
| Procedure occurrence tables |
+--------------------------------+
|
v
+--------------------------------+
| Aggregate across temporal |
| windows & zero-fill subjects |
+--------------------------------+
3. Polymorphic Event Linkage Strategy
OMOP CDM v5.3+ stores costs in a polymorphic COST table
where cost_event_id references the primary key of the
domain table indicated by cost_domain_id:
SELECT
c.person_id,
c.cost_domain_id,
c.cost_type_concept_id,
c.total_paid,
c.total_charge,
c.paid_by_payer,
c.paid_by_patient,
v.visit_concept_id,
v.visit_start_date,
v.visit_end_date
FROM cdm.cost c
JOIN cdm.visit_occurrence v
ON c.cost_event_id = v.visit_occurrence_id
AND c.cost_domain_id = 'Visit'
WHERE c.person_id IN (SELECT subject_id FROM study_cohort);Supported Cost Domains
-
Inpatient Visits
(
cost_domain_id = 'Visit'andvisit_concept_idin Inpatient/ICU concepts). -
Outpatient Visits
(
cost_domain_id = 'Visit'andvisit_concept_idin Outpatient concepts). -
Pharmacy (
cost_domain_id = 'Drug'linked viadrug_exposure_id). -
Procedures & Diagnostics
(
cost_domain_id = 'Procedure'or'Measurement'). -
Conditions
(
cost_domain_id = 'Condition'linked viacondition_occurrence_id).
4. Resilience & Fallback Rules
-
Missing Cost Table: If the database schema lacks a
COSTtable, a clear warning is emitted (Missing 'cost' table in CDM), and all cost columns are safely populated with0.0to prevent pipeline crashes. -
Empty Cost Table: If the table exists with 0 rows,
subjects are retained with
0.0expenditures. -
Missing Subject Records: Zero-utilization subjects
in the cohort are preserved via left joins with coalesce to
0.0, ensuring no patient attrition during cost enrichment.