Chuyển đến nội dung chính

Lesson 13: DEATH, EPISODE & EPISODE_EVENT

Record deaths (DEATH), long-term disease processes (EPISODE — new CDM 5.4) such as cancer treatment, and associate events in episodes (EPISODE_EVENT).

🏗️ Architecture — Lesson 13 DEATH, EPISODE & EPISODE_EVENT OMOP CDM 5.4 for Beginners — Understand A to Z Part 4: Expanded clinical table xdev.asia

Introduction

The last three tables in the Clinical Data group: DEATH records death events, EPISODE (new in CDM 5.4) records long-term clinical/treatment progression, and EPISODE_EVENT links events within an episode. EPISODE is the most notable addition to CDM 5.4, especially important for cancer research.


1. DEATH — Death record

1.1. Table structure

ColumnTypeRequiredDescription
person_idINTEGER✅ PK/FKPatient (1 record/patient)
death_dateDATE✅Date of death
death_datetimeDATETIMEDate and time of death
death_type_concept_idINTEGER✅Data source
cause_concept_idINTEGERCause of death (SNOMED)
cause_source_valueVARCHAR(50)Original ICD
cause_source_concept_idINTEGEROriginal concept

1.2. Important characteristics

  • 1 unique record per person — if there are multiple sources, choose the most trustworthy
  • person_id is both PK and FK → does not have its own death_id
  • cause_concept_id: use SNOMED for the main cause

1.3. death_type_concept_id

Concept IDSourceDescription
32817EHRRecorded from HIS
32810ClaimSocial insurance data
32885Death certificateDeath certificate
32886National Death IndexNational Register

1.4. For example

-- BN tử vong do nhồi máu cơ tim cấp
INSERT INTO death (
    person_id, death_date,
    death_type_concept_id,
    cause_concept_id,
    cause_source_value,
    cause_source_concept_id
) VALUES (
    100001, '2024-06-20',
    32885,                        -- Death certificate
    4329847,                      -- SNOMED: AMI
    'I21.9',                      -- ICD-10
    45572161                      -- ICD10CM concept
);

1.5. SQL analysis

-- Top 10 nguyên nhân tử vong
SELECT
    c.concept_name AS cause_of_death,
    COUNT(*) AS death_count,
    ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER(), 1) AS pct
FROM death d
JOIN concept c ON d.cause_concept_id = c.concept_id
WHERE d.cause_concept_id != 0
GROUP BY c.concept_name
ORDER BY death_count DESC
LIMIT 10;

-- Tỉ lệ tử vong sau nhập viện ICU
SELECT
    ROUND(
        COUNT(DISTINCT d.person_id) * 100.0 /
        NULLIF(COUNT(DISTINCT v.person_id), 0), 1
    ) AS mortality_rate_pct
FROM visit_occurrence v
LEFT JOIN death d ON v.person_id = d.person_id
    AND d.death_date BETWEEN v.visit_start_date
    AND v.visit_start_date + INTERVAL '30 days'
WHERE v.visit_concept_id = 32037;  -- ICU visit

2. EPISODE — Pathological process (new CDM 5.4)

2.1. Why do we need EPISODE?

Before CDM 5.4, there was no way to represent the "cancer treatment process" — events (diagnosis, chemotherapy, radiation therapy, surgery) were scattered across multiple tables. EPISODE brings them together into a complete "story".

  Trước CDM 5.4:

  CONDITION: Ung thư phổi ─────────── (rời rạc)
  PROCEDURE: Sinh thiết phổi ────────── (rời rạc)
  DRUG:      Cisplatin cycle 1 ──────── (rời rạc)
  DRUG:      Cisplatin cycle 2 ──────── (rời rạc)
  PROCEDURE: Phẫu thuật cắt thùy phổi ─ (rời rạc)

  Sau CDM 5.4:

  EPISODE: "Điều trị ung thư phổi giai đoạn 3"
       │
       ├── EPISODE_EVENT → CONDITION (chẩn đoán)
       ├── EPISODE_EVENT → PROCEDURE (sinh thiết)
       ├── EPISODE_EVENT → DRUG (hóa trị cycle 1)
       ├── EPISODE_EVENT → DRUG (hóa trị cycle 2)
       └── EPISODE_EVENT → PROCEDURE (phẫu thuật)

2.2. EPISODE table structure

ColumnTypeRequiredDescription
episode_idBIGINT✅ PKUnique ID
person_idINTEGER✅ FKPatients
episode_concept_idINTEGER✅Episode type
episode_start_dateDATE✅Start date
episode_start_datetimeDATETIME
episode_end_dateDATEEnd date
episode_end_datetimeDATETIME
episode_parent_idBIGINTEpisode parent (hierarchy)
episode_numberINTEGERSerial number
episode_object_concept_idINTEGER✅Episode object
episode_type_concept_idINTEGER✅Data source
episode_source_valueVARCHAR(50)Original code
episode_source_concept_idINTEGER

2.3. episode_concept_id — Episode type

Concept IDEpisode TypeExample
32528Disease first occurrenceLung cancer for the first time
32529Disease recurrenceCancer recurrence
32531Treatment regimenCisplatin-Etoposide regimen
32532Treatment cycleCycle 1, Cycle 2...

2.4. For example: Lung cancer treatment

-- Episode cha: Bệnh ung thư phổi
INSERT INTO episode (
    episode_id, person_id,
    episode_concept_id,
    episode_start_date, episode_end_date,
    episode_parent_id,
    episode_object_concept_id,
    episode_type_concept_id
) VALUES (
    200001, 100001,
    32528,                            -- Disease first occurrence
    '2024-01-15', NULL,               -- Chưa kết thúc
    NULL,                             -- Không có cha
    4311499,                          -- SNOMED: Lung cancer
    32817                             -- EHR
);

-- Episode con: Phác đồ hóa trị
INSERT INTO episode (
    episode_id, person_id,
    episode_concept_id,
    episode_start_date, episode_end_date,
    episode_parent_id,
    episode_number,
    episode_object_concept_id,
    episode_type_concept_id
) VALUES (
    200002, 100001,
    32531,                            -- Treatment regimen
    '2024-02-01', '2024-06-30',
    200001,                           -- Thuộc episode ung thư phổi
    1,
    35804410,                         -- Cisplatin regimen
    32817
);

-- Episode con: Cycle 1
INSERT INTO episode (
    episode_id, person_id,
    episode_concept_id,
    episode_start_date, episode_end_date,
    episode_parent_id,
    episode_number,
    episode_object_concept_id,
    episode_type_concept_id
) VALUES (
    200003, 100001,
    32532,                            -- Treatment cycle
    '2024-02-01', '2024-02-21',
    200002,                           -- Thuộc phác đồ
    1,                                -- Cycle 1
    35804410,
    32817
);

3. EPISODE_EVENT — Event binding

3.1. Table structure

ColumnTypeRequiredDescription
episode_idBIGINT✅ FKEpisode
event_idBIGINT✅Event ID
episode_event_field_concept_idINTEGER✅Table containing event

3.2. episode_event_field_concept_id

Concept IDEvent Table
1147127condition_occurrence.condition_occurrence_id
1147094drug_exposure.drug_exposure_id
1147082procedure_occurrence.procedure_occurrence_id
1147138measurement.measurement_id
1147165device_exposure.device_exposure_id

3.3. For example: Attach events to Cycle 1

-- Chẩn đoán ung thư → Episode chẩn đoán
INSERT INTO episode_event VALUES (
    200001,                           -- Episode: lung cancer
    70010,                            -- condition_occurrence_id
    1147127                           -- condition_occurrence table
);

-- Hóa trị Cisplatin → Episode Cycle 1
INSERT INTO episode_event VALUES (
    200003,                           -- Episode: Cycle 1
    80010,                            -- drug_exposure_id (Cisplatin)
    1147094                           -- drug_exposure table
);

-- XN máu trước hóa trị → Episode Cycle 1
INSERT INTO episode_event VALUES (
    200003,
    110020,                           -- measurement_id (CBC)
    1147138                           -- measurement table
);

4. Application of EPISODE in research

-- Tìm BN ung thư phổi có >= 4 cycle hóa trị
SELECT
    e_disease.person_id,
    c_disease.concept_name AS cancer_type,
    COUNT(e_cycle.episode_id) AS total_cycles
FROM episode e_disease
JOIN concept c_disease
    ON e_disease.episode_object_concept_id = c_disease.concept_id
JOIN episode e_regimen
    ON e_disease.episode_id = e_regimen.episode_parent_id
    AND e_regimen.episode_concept_id = 32531  -- Treatment regimen
JOIN episode e_cycle
    ON e_regimen.episode_id = e_cycle.episode_parent_id
    AND e_cycle.episode_concept_id = 32532    -- Treatment cycle
WHERE e_disease.episode_concept_id = 32528    -- First occurrence
  AND c_disease.concept_id = 4311499          -- Lung cancer
GROUP BY e_disease.person_id, c_disease.concept_name
HAVING COUNT(e_cycle.episode_id) >= 4;

-- Timeline điều trị 1 BN
SELECT
    e.episode_number,
    ec.concept_name AS episode_type,
    e.episode_start_date,
    e.episode_end_date,
    oc.concept_name AS episode_object
FROM episode e
JOIN concept ec ON e.episode_concept_id = ec.concept_id
JOIN concept oc ON e.episode_object_concept_id = oc.concept_id
WHERE e.person_id = 100001
ORDER BY e.episode_start_date, e.episode_number;

Summary

  1. DEATH: 1 record/person, cause of death using SNOMED
  2. EPISODE (new CDM 5.4): pathology/treatment process, parent-child hierarchy support
  3. EPISODE_EVENT: link events from multiple tables to the episode
  4. EPISODE is designed primarily for oncology but is applicable to all chronic diseases
  5. Structure: Disease → Treatment Regimen → Treatment Cycle → Events

Next article: Start Part 5 — Standardized Vocabularies, a standardized dictionary system.


References