@xdev-asia/xdev-knowledge-mcp 1.0.56 → 1.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/01-phan-1-tong-quan-nen-tang/lessons/bai-1-omop-cdm-la-gi-tai-sao-can-chuan-hoa-du-lieu-y-te.md +339 -0
  2. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/01-phan-1-tong-quan-nen-tang/lessons/bai-2-kien-truc-tong-the-omop-cdm-5-4-nhom-bang-nguyen-ly-thiet-ke.md +440 -0
  3. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/01-phan-1-tong-quan-nen-tang/lessons/bai-3-hieu-concept-trai-tim-cua-omop-cdm.md +441 -0
  4. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/02-phan-2-person-visit-nen-tang/lessons/bai-4-bang-person-quan-ly-danh-tinh-benh-nhan.md +323 -0
  5. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/02-phan-2-person-visit-nen-tang/lessons/bai-5-observation-period-khoang-thoi-gian-theo-doi-benh-nhan.md +308 -0
  6. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/02-phan-2-person-visit-nen-tang/lessons/bai-6-visit-occurrence-visit-detail-luot-kham-chi-tiet.md +353 -0
  7. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/03-phan-3-su-kien-lam-sang-chinh/lessons/bai-10-measurement-xet-nghiem-do-luong.md +409 -0
  8. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/03-phan-3-su-kien-lam-sang-chinh/lessons/bai-7-condition-occurrence-chan-doan-benh-ly.md +285 -0
  9. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/03-phan-3-su-kien-lam-sang-chinh/lessons/bai-8-drug-exposure-thuoc-dieu-tri.md +354 -0
  10. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/03-phan-3-su-kien-lam-sang-chinh/lessons/bai-9-procedure-occurrence-thu-thuat-phau-thuat.md +291 -0
  11. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/04-phan-4-bang-lam-sang-mo-rong/lessons/bai-11-observation-su-kien-lam-sang-tong-hop.md +289 -0
  12. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/04-phan-4-bang-lam-sang-mo-rong/lessons/bai-12-device-exposure-specimen-note.md +313 -0
  13. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/04-phan-4-bang-lam-sang-mo-rong/lessons/bai-13-death-episode-episode-event.md +346 -0
  14. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/05-phan-5-standardized-vocabularies/lessons/bai-14-concept-vocabulary-nen-tang-tu-dien-chuan.md +298 -0
  15. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/05-phan-5-standardized-vocabularies/lessons/bai-15-concept-relationship-concept-ancestor.md +336 -0
  16. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/05-phan-5-standardized-vocabularies/lessons/bai-16-drug-strength-cac-bang-vocabulary-con-lai.md +295 -0
  17. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/06-phan-6-health-system-economics-derived/lessons/bai-17-location-care-site-provider.md +334 -0
  18. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/06-phan-6-health-system-economics-derived/lessons/bai-18-payer-plan-period-cost.md +343 -0
  19. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/06-phan-6-health-system-economics-derived/lessons/bai-19-condition-era-drug-era-dose-era.md +418 -0
  20. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/chapters/07-phan-7-metadata-cohort-tong-ket/lessons/bai-20-cdm-source-metadata-cohort-tong-ket.md +517 -0
  21. package/content/series/architecture/omop-cdm-5-4-cho-nguoi-moi-bat-dau/index.md +385 -0
  22. package/package.json +1 -1
@@ -0,0 +1,354 @@
1
+ ---
2
+ id: 019f1a00-a108-7b01-e001-omopcdm54008
3
+ title: "Bài 8: DRUG_EXPOSURE — Thuốc, Kê đơn & Vaccine"
4
+ slug: bai-8-drug-exposure-thuoc-dieu-tri
5
+ description: >-
6
+ Ghi nhận lịch sử dùng thuốc: kê đơn (prescription), cấp thuốc
7
+ (dispensing), sử dụng thuốc (administration). Hiểu RxNorm vocab,
8
+ quantity/days_supply/refills, route_concept_id, sig, liên kết
9
+ DRUG_STRENGTH.
10
+ duration_minutes: 65
11
+ is_free: true
12
+ video_url: null
13
+ sort_order: 8
14
+ section_title: "Phần 3: Sự kiện lâm sàng chính"
15
+ course:
16
+ id: 019f1a00-a100-7b01-e001-omopcdm54001
17
+ title: "OMOP CDM 5.4 cho Người mới — Hiểu từ A đến Z"
18
+ slug: omop-cdm-5-4-cho-nguoi-moi-bat-dau
19
+ ---
20
+
21
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 340" style="max-width: 100%; height: auto; border-radius: 12px; margin-bottom: 1.5rem;">
22
+ <defs>
23
+ <linearGradient id="bg-omop08" x1="0%" y1="0%" x2="100%" y2="100%">
24
+ <stop offset="0%" style="stop-color:#0c1222"/>
25
+ <stop offset="100%" style="stop-color:#1e293b"/>
26
+ </linearGradient>
27
+ </defs>
28
+ <rect width="1200" height="340" rx="12" fill="url(#bg-omop08)"/>
29
+ <g>
30
+ <circle cx="680" cy="90" r="24" fill="#818cf8" opacity="0.12"/>
31
+ <circle cx="740" cy="110" r="30" fill="#818cf8" opacity="0.09"/>
32
+ <circle cx="820" cy="140" r="18" fill="#818cf8" opacity="0.08"/>
33
+ <circle cx="900" cy="160" r="22" fill="#818cf8" opacity="0.10"/>
34
+ <line x1="620" y1="170" x2="1100" y2="240" stroke="#818cf8" stroke-width="0.5" opacity="0.1"/>
35
+ </g>
36
+ <rect x="60" y="50" width="4" height="60" rx="2" fill="#818cf8"/>
37
+ <rect x="80" y="50" width="121" height="28" rx="14" fill="#818cf8" opacity="0.15"/>
38
+ <text x="92" y="69" font-family="system-ui,-apple-system,sans-serif" font-size="13" font-weight="600" fill="#818cf8">🏗️ Kiến trúc — Bài 8</text>
39
+ <text x="60" y="140" font-family="system-ui,-apple-system,sans-serif" font-size="34" font-weight="700" fill="#f1f5f9">
40
+ <tspan x="60" dy="0">DRUG_EXPOSURE</tspan>
41
+ <tspan x="60" dy="42">Thuốc, Kê đơn &amp; Vaccine</tspan>
42
+ </text>
43
+ <text x="60" y="244" font-family="system-ui,-apple-system,sans-serif" font-size="15" fill="#94a3b8" opacity="0.8">OMOP CDM 5.4 cho Người mới — Hiểu từ A đến Z</text>
44
+ <text x="60" y="268" font-family="system-ui,-apple-system,sans-serif" font-size="13" fill="#64748b" opacity="0.6">Phần 3: Sự kiện lâm sàng chính</text>
45
+ <text x="1140" y="320" font-family="system-ui,-apple-system,sans-serif" font-size="12" fill="#475569" text-anchor="end" opacity="0.4">xdev.asia</text>
46
+ </svg>
47
+
48
+ ![Phân cấp thuốc: Ingredient → Clinical Drug → Branded Drug](/storage/uploads/2026/04/omop-cdm-bai8-drug-hierarchy.png)
49
+
50
+ ## Giới thiệu
51
+
52
+ **DRUG_EXPOSURE** là bảng ghi nhận mọi sự kiện liên quan đến thuốc — từ lúc bác sĩ kê đơn, nhà thuốc cấp phát, đến y tá tiêm truyền. Đây là bảng phức tạp nhất trong nhóm Clinical Data vì phải xử lý nhiều nguồn dữ liệu khác nhau: đơn thuốc ngoại trú, thuốc nội trú, vaccine, truyền dịch.
53
+
54
+ ---
55
+
56
+ ## 1. Cấu trúc bảng
57
+
58
+ | Cột | Kiểu | Bắt buộc | Mô tả |
59
+ |-----|------|----------|-------|
60
+ | `drug_exposure_id` | INTEGER | ✅ PK | ID duy nhất |
61
+ | `person_id` | INTEGER | ✅ FK | Bệnh nhân |
62
+ | `drug_concept_id` | INTEGER | ✅ | Standard Concept (RxNorm) |
63
+ | `drug_exposure_start_date` | DATE | ✅ | Ngày bắt đầu |
64
+ | `drug_exposure_start_datetime` | DATETIME | | Ngày giờ bắt đầu |
65
+ | `drug_exposure_end_date` | DATE | ✅ | Ngày kết thúc |
66
+ | `drug_exposure_end_datetime` | DATETIME | | Ngày giờ kết thúc |
67
+ | `verbatim_end_date` | DATE | | End date gốc (trước suy luận) |
68
+ | `drug_type_concept_id` | INTEGER | ✅ | Nguồn dữ liệu |
69
+ | `stop_reason` | VARCHAR(20) | | Lý do ngừng thuốc |
70
+ | `refills` | INTEGER | | Số lần refill |
71
+ | `quantity` | FLOAT | | Số lượng cấp phát |
72
+ | `days_supply` | INTEGER | | Số ngày cung cấp |
73
+ | `sig` | CLOB | | Hướng dẫn sử dụng gốc |
74
+ | `route_concept_id` | INTEGER | | Đường dùng (uống, tiêm...) |
75
+ | `lot_number` | VARCHAR(50) | | Số lô (quan trọng cho vaccine) |
76
+ | `provider_id` | INTEGER | FK | Bác sĩ kê đơn |
77
+ | `visit_occurrence_id` | INTEGER | FK | Visit liên quan |
78
+ | `visit_detail_id` | INTEGER | FK | Visit detail |
79
+ | `drug_source_value` | VARCHAR(50) | | Mã thuốc gốc |
80
+ | `drug_source_concept_id` | INTEGER | | Concept gốc |
81
+ | `route_source_value` | VARCHAR(50) | | Đường dùng gốc |
82
+ | `dose_unit_source_value` | VARCHAR(50) | | Đơn vị liều gốc |
83
+
84
+ ---
85
+
86
+ ## 2. RxNorm — Vocabulary chuẩn cho thuốc
87
+
88
+ ### 2.1. Cấu trúc phân cấp RxNorm
89
+
90
+ ```
91
+ ┌──────────────────────────────────────────┐
92
+ │ Ingredient (IN) │
93
+ │ VD: Metformin (concept 1503297) │
94
+ │ │
95
+ │ ┌── Clinical Drug Form (CDF) ──┐ │
96
+ │ │ Metformin Oral Tablet │ │
97
+ │ │ │ │
98
+ │ │ ┌── Clinical Drug (CD) ──┐ │ │
99
+ │ │ │ Metformin 500mg Tab │ │ │
100
+ │ │ │ (concept 1503328) │ │ │
101
+ │ │ └────────────────────────┘ │ │
102
+ │ └───────────────────────────────┘ │
103
+ │ │
104
+ │ ┌── Branded Drug (BD) ────────┐ │
105
+ │ │ Glucophage 500mg Tab │ │
106
+ │ └─────────────────────────────┘ │
107
+ └───────────────────────────────────────────┘
108
+ ```
109
+
110
+ ### 2.2. Chọn đúng cấp RxNorm
111
+
112
+ | Level | Khi nào dùng | Ví dụ |
113
+ |-------|-------------|-------|
114
+ | **Ingredient** | Chỉ biết hoạt chất | "Metformin" |
115
+ | **Clinical Drug** | Biết hoạt chất + liều + dạng | "Metformin 500mg Tablet" |
116
+ | **Branded Drug** | Biết tên thương mại | "Glucophage 500mg Tab" |
117
+ | **Clinical Drug Component** | Hoạt chất + liều (combo) | "Metformin 500mg" |
118
+
119
+ > **Khuyến nghị:** Map ở mức **Clinical Drug** hoặc **Branded Drug** nếu có đủ thông tin. Nếu dữ liệu nguồn chỉ có tên hoạt chất, dùng **Ingredient**.
120
+
121
+ ---
122
+
123
+ ## 3. drug_type_concept_id — Nguồn dữ liệu
124
+
125
+ | Concept ID | Tên | Use case |
126
+ |-----------|-----|----------|
127
+ | 32838 | EHR prescription | Đơn thuốc từ HIS |
128
+ | 32839 | EHR dispensing | Nhà thuốc cấp phát |
129
+ | 32818 | EHR administration | Y tá ghi nhận tiêm/truyền |
130
+ | 32869 | Patient self-reported | BN tự khai thuốc đang dùng |
131
+ | 32810 | Claim | Dữ liệu BHXH |
132
+
133
+ ---
134
+
135
+ ## 4. Tính days_supply và drug_exposure_end_date
136
+
137
+ ### 4.1. Quy tắc CDM
138
+
139
+ ```
140
+ drug_exposure_end_date =
141
+ drug_exposure_start_date + days_supply - 1
142
+ ```
143
+
144
+ ### 4.2. Ví dụ tính toán
145
+
146
+ ```sql
147
+ -- Kê đơn: Metformin 500mg x 2 viên/ngày x 30 ngày
148
+ INSERT INTO drug_exposure (
149
+ drug_exposure_id, person_id, drug_concept_id,
150
+ drug_exposure_start_date, drug_exposure_end_date,
151
+ drug_type_concept_id,
152
+ quantity, days_supply, refills,
153
+ sig, route_concept_id,
154
+ drug_source_value
155
+ ) VALUES (
156
+ 80001, 100001, 1503328, -- RxNorm: Metformin 500mg Tab
157
+ '2024-06-01', '2024-06-30', -- 30 days
158
+ 32838, -- EHR prescription
159
+ 60, 30, 2, -- 60 viên, 30 ngày, 2 refills
160
+ 'Uống 2 viên/ngày, sáng chiều sau ăn',
161
+ 4132161, -- Oral
162
+ 'METFORMIN500'
163
+ );
164
+ ```
165
+
166
+ ### 4.3. Truyền dịch / Tiêm
167
+
168
+ ```sql
169
+ -- Truyền NaCl 0.9% 500ml trong 2 giờ
170
+ INSERT INTO drug_exposure (
171
+ drug_exposure_id, person_id, drug_concept_id,
172
+ drug_exposure_start_date, drug_exposure_start_datetime,
173
+ drug_exposure_end_date, drug_exposure_end_datetime,
174
+ drug_type_concept_id,
175
+ quantity, days_supply,
176
+ route_concept_id,
177
+ drug_source_value
178
+ ) VALUES (
179
+ 80002, 100001, 19049105, -- RxNorm: NaCl 0.9% Injectable
180
+ '2024-06-10', '2024-06-10 08:00:00',
181
+ '2024-06-10', '2024-06-10 10:00:00',
182
+ 32818, -- EHR administration
183
+ 500, 1, -- 500ml, 1 ngày
184
+ 4171047, -- Intravenous
185
+ 'NACL09_500'
186
+ );
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 5. route_concept_id — Đường dùng thuốc
192
+
193
+ | Concept ID | Route | Tiếng Việt |
194
+ |-----------|-------|-----------|
195
+ | 4132161 | Oral | Uống |
196
+ | 4171047 | Intravenous | Tiêm tĩnh mạch |
197
+ | 4302612 | Intramuscular | Tiêm bắp |
198
+ | 4142048 | Subcutaneous | Tiêm dưới da |
199
+ | 4186838 | Topical | Bôi ngoài da |
200
+ | 4290759 | Inhaled | Hít / khí dung |
201
+ | 4163768 | Rectal | Trực tràng |
202
+ | 4186747 | Ophthalmic | Nhỏ mắt |
203
+
204
+ ---
205
+
206
+ ## 6. Vaccine trong DRUG_EXPOSURE
207
+
208
+ Vaccine cũng lưu trong DRUG_EXPOSURE, không có bảng riêng.
209
+
210
+ ```sql
211
+ -- Tiêm vaccine COVID-19 (Pfizer) — liều 1
212
+ INSERT INTO drug_exposure (
213
+ drug_exposure_id, person_id, drug_concept_id,
214
+ drug_exposure_start_date, drug_exposure_end_date,
215
+ drug_type_concept_id,
216
+ quantity, days_supply,
217
+ route_concept_id, lot_number,
218
+ drug_source_value
219
+ ) VALUES (
220
+ 80003, 100001, 37003436, -- CVX: COVID-19 vaccine Pfizer
221
+ '2024-03-15', '2024-03-15', -- Tiêm 1 lần
222
+ 32818, -- Administration
223
+ 1, 1,
224
+ 4302612, -- Intramuscular
225
+ 'FK1234', -- Số lô vaccine
226
+ 'COVID19_PFIZER_DOSE1'
227
+ );
228
+ ```
229
+
230
+ **Lưu ý lot_number:** Đặc biệt quan trọng cho vaccine — dùng để trace lô nếu có adverse event.
231
+
232
+ ---
233
+
234
+ ## 7. ETL thuốc Việt Nam
235
+
236
+ ### 7.1. Vấn đề phổ biến
237
+
238
+ | Vấn đề | Giải pháp |
239
+ |--------|-----------|
240
+ | HIS dùng mã riêng | Map qua SOURCE_TO_CONCEPT_MAP |
241
+ | Tên thuốc tiếng Việt | Usagi mapping tool |
242
+ | Thuốc combo (Metformin + Glipizide) | Map về RxNorm combo concept |
243
+ | Không biết liều/dạng | Map về Ingredient level |
244
+ | Thuốc đông y / thuốc nam | concept_id = 0, giữ source_value |
245
+
246
+ ### 7.2. Ví dụ ETL
247
+
248
+ ```sql
249
+ SELECT
250
+ ROW_NUMBER() OVER() AS drug_exposure_id,
251
+ pm.person_id,
252
+ COALESCE(cr.concept_id_2, 0) AS drug_concept_id,
253
+ dt.ngay_ke AS drug_exposure_start_date,
254
+ dt.ngay_ke + dt.so_ngay - 1 AS drug_exposure_end_date,
255
+ 32838 AS drug_type_concept_id,
256
+ dt.so_luong AS quantity,
257
+ dt.so_ngay AS days_supply,
258
+ dt.so_lan_tai_ke AS refills,
259
+ dt.huong_dan_su_dung AS sig,
260
+ COALESCE(r.concept_id, 0) AS route_concept_id,
261
+ dt.ma_thuoc AS drug_source_value,
262
+ COALESCE(c_source.concept_id, 0) AS drug_source_concept_id,
263
+ dt.duong_dung_goc AS route_source_value,
264
+ dt.don_vi_lieu AS dose_unit_source_value
265
+ FROM donthuoc_his dt
266
+ JOIN person_mapping pm ON dt.ma_bn = pm.source_id
267
+ LEFT JOIN source_to_concept_map stcm
268
+ ON dt.ma_thuoc = stcm.source_code
269
+ AND stcm.source_vocabulary_id = 'VN_DRUG'
270
+ LEFT JOIN concept c_std
271
+ ON stcm.target_concept_id = c_std.concept_id
272
+ AND c_std.standard_concept = 'S'
273
+ LEFT JOIN concept c_source
274
+ ON dt.ma_thuoc = c_source.concept_code
275
+ LEFT JOIN concept_relationship cr
276
+ ON c_source.concept_id = cr.concept_id_1
277
+ AND cr.relationship_id = 'Maps to'
278
+ LEFT JOIN concept r
279
+ ON dt.duong_dung_goc = r.concept_name
280
+ AND r.domain_id = 'Route';
281
+ ```
282
+
283
+ ---
284
+
285
+ ## 8. Liên kết với DRUG_STRENGTH
286
+
287
+ Bảng **DRUG_STRENGTH** (trong Vocabularies) chứa thông tin liều lượng chi tiết:
288
+
289
+ ```sql
290
+ -- Tra liều Metformin 500mg Tablet
291
+ SELECT
292
+ ds.drug_concept_id,
293
+ c_drug.concept_name AS drug_name,
294
+ ds.ingredient_concept_id,
295
+ c_ing.concept_name AS ingredient_name,
296
+ ds.amount_value,
297
+ c_unit.concept_name AS amount_unit
298
+ FROM drug_strength ds
299
+ JOIN concept c_drug ON ds.drug_concept_id = c_drug.concept_id
300
+ JOIN concept c_ing ON ds.ingredient_concept_id = c_ing.concept_id
301
+ LEFT JOIN concept c_unit ON ds.amount_unit_concept_id = c_unit.concept_id
302
+ WHERE ds.drug_concept_id = 1503328;
303
+ -- Kết quả: Metformin 500 mg
304
+ ```
305
+
306
+ ---
307
+
308
+ ## 9. SQL phân tích
309
+
310
+ ```sql
311
+ -- Top 10 thuốc được kê nhiều nhất
312
+ SELECT
313
+ c.concept_name AS drug_name,
314
+ COUNT(DISTINCT de.person_id) AS patient_count,
315
+ COUNT(*) AS prescription_count
316
+ FROM drug_exposure de
317
+ JOIN concept c ON de.drug_concept_id = c.concept_id
318
+ WHERE de.drug_concept_id != 0
319
+ GROUP BY c.concept_name
320
+ ORDER BY patient_count DESC
321
+ LIMIT 10;
322
+
323
+ -- Polypharmacy: BN dùng >= 5 thuốc cùng lúc
324
+ SELECT
325
+ de.person_id,
326
+ COUNT(DISTINCT de.drug_concept_id) AS concurrent_drugs
327
+ FROM drug_exposure de
328
+ WHERE de.drug_exposure_start_date <= '2024-06-01'
329
+ AND de.drug_exposure_end_date >= '2024-06-01'
330
+ GROUP BY de.person_id
331
+ HAVING COUNT(DISTINCT de.drug_concept_id) >= 5
332
+ ORDER BY concurrent_drugs DESC;
333
+ ```
334
+
335
+ ---
336
+
337
+ ## Tổng kết
338
+
339
+ 1. **DRUG_EXPOSURE** = kê đơn + cấp phát + tiêm truyền + vaccine
340
+ 2. **drug_concept_id** dùng **RxNorm** (Ingredient → Clinical Drug → Branded Drug)
341
+ 3. **days_supply** + **quantity** + **refills** tạo bức tranh đầy đủ
342
+ 4. **route_concept_id** cho đường dùng, **lot_number** cho vaccine
343
+ 5. **drug_type_concept_id** phân biệt prescription vs dispensing vs administration
344
+ 6. ETL VN: mapping qua SOURCE_TO_CONCEPT_MAP hoặc Usagi
345
+
346
+ **Bài tiếp theo:** PROCEDURE_OCCURRENCE — thủ thuật, phẫu thuật, và can thiệp.
347
+
348
+ ---
349
+
350
+ ## Tài liệu tham khảo
351
+
352
+ - [OMOP CDM 5.4 — DRUG_EXPOSURE](https://ohdsi.github.io/CommonDataModel/cdm54.html#DRUG_EXPOSURE)
353
+ - [RxNorm on Athena](https://athena.ohdsi.org/)
354
+ - [DRUG_STRENGTH](https://ohdsi.github.io/CommonDataModel/cdm54.html#DRUG_STRENGTH)
@@ -0,0 +1,291 @@
1
+ ---
2
+ id: 019f1a00-a109-7b01-e001-omopcdm54009
3
+ title: "Bài 9: PROCEDURE_OCCURRENCE — Thủ thuật & Phẫu thuật"
4
+ slug: bai-9-procedure-occurrence-thu-thuat-phau-thuat
5
+ description: >-
6
+ Ghi nhận thủ thuật, phẫu thuật, can thiệp y khoa.
7
+ SNOMED / CPT4 / ICD-10-PCS mapping, modifier_concept_id,
8
+ phân biệt Procedure vs Measurement vs Drug, thực hành ETL
9
+ dữ liệu bệnh viện Việt Nam.
10
+ duration_minutes: 55
11
+ is_free: true
12
+ video_url: null
13
+ sort_order: 9
14
+ section_title: "Phần 3: Sự kiện lâm sàng chính"
15
+ course:
16
+ id: 019f1a00-a100-7b01-e001-omopcdm54001
17
+ title: "OMOP CDM 5.4 cho Người mới — Hiểu từ A đến Z"
18
+ slug: omop-cdm-5-4-cho-nguoi-moi-bat-dau
19
+ ---
20
+
21
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 340" style="max-width: 100%; height: auto; border-radius: 12px; margin-bottom: 1.5rem;">
22
+ <defs>
23
+ <linearGradient id="bg-omop09" x1="0%" y1="0%" x2="100%" y2="100%">
24
+ <stop offset="0%" style="stop-color:#0c1222"/>
25
+ <stop offset="100%" style="stop-color:#1e293b"/>
26
+ </linearGradient>
27
+ </defs>
28
+ <rect width="1200" height="340" rx="12" fill="url(#bg-omop09)"/>
29
+ <g>
30
+ <circle cx="700" cy="95" r="26" fill="#818cf8" opacity="0.12"/>
31
+ <circle cx="760" cy="120" r="20" fill="#818cf8" opacity="0.09"/>
32
+ <circle cx="850" cy="100" r="32" fill="#818cf8" opacity="0.06"/>
33
+ <circle cx="910" cy="170" r="18" fill="#818cf8" opacity="0.10"/>
34
+ <line x1="640" y1="160" x2="1100" y2="230" stroke="#818cf8" stroke-width="0.5" opacity="0.1"/>
35
+ </g>
36
+ <rect x="60" y="50" width="4" height="60" rx="2" fill="#818cf8"/>
37
+ <rect x="80" y="50" width="121" height="28" rx="14" fill="#818cf8" opacity="0.15"/>
38
+ <text x="92" y="69" font-family="system-ui,-apple-system,sans-serif" font-size="13" font-weight="600" fill="#818cf8">🏗️ Kiến trúc — Bài 9</text>
39
+ <text x="60" y="140" font-family="system-ui,-apple-system,sans-serif" font-size="34" font-weight="700" fill="#f1f5f9">
40
+ <tspan x="60" dy="0">PROCEDURE_OCCURRENCE</tspan>
41
+ <tspan x="60" dy="42">Thủ thuật &amp; Phẫu thuật</tspan>
42
+ </text>
43
+ <text x="60" y="244" font-family="system-ui,-apple-system,sans-serif" font-size="15" fill="#94a3b8" opacity="0.8">OMOP CDM 5.4 cho Người mới — Hiểu từ A đến Z</text>
44
+ <text x="60" y="268" font-family="system-ui,-apple-system,sans-serif" font-size="13" fill="#64748b" opacity="0.6">Phần 3: Sự kiện lâm sàng chính</text>
45
+ <text x="1140" y="320" font-family="system-ui,-apple-system,sans-serif" font-size="12" fill="#475569" text-anchor="end" opacity="0.4">xdev.asia</text>
46
+ </svg>
47
+
48
+ ## Giới thiệu
49
+
50
+ **PROCEDURE_OCCURRENCE** ghi nhận mọi thủ thuật, phẫu thuật, và can thiệp y khoa được thực hiện trên bệnh nhân. Từ đo huyết áp đơn giản đến phẫu thuật tim mở phức tạp — tất cả đều được chuẩn hóa trong bảng này. Bài học sẽ giúp bạn hiểu khi nào dùng PROCEDURE, khi nào dùng MEASUREMENT hay DRUG.
51
+
52
+ ---
53
+
54
+ ## 1. Cấu trúc bảng
55
+
56
+ | Cột | Kiểu | Bắt buộc | Mô tả |
57
+ |-----|------|----------|-------|
58
+ | `procedure_occurrence_id` | INTEGER | ✅ PK | ID duy nhất |
59
+ | `person_id` | INTEGER | ✅ FK | Bệnh nhân |
60
+ | `procedure_concept_id` | INTEGER | ✅ | Standard Concept |
61
+ | `procedure_date` | DATE | ✅ | Ngày thực hiện |
62
+ | `procedure_datetime` | DATETIME | | Ngày giờ |
63
+ | `procedure_end_date` | DATE | | Ngày kết thúc (CDM 5.4 mới) |
64
+ | `procedure_end_datetime` | DATETIME | | Giờ kết thúc |
65
+ | `procedure_type_concept_id` | INTEGER | ✅ | Nguồn dữ liệu |
66
+ | `modifier_concept_id` | INTEGER | | Bổ sung (trái/phải, lần 2...) |
67
+ | `quantity` | INTEGER | | Số lần thực hiện |
68
+ | `provider_id` | INTEGER | FK | Bác sĩ thực hiện |
69
+ | `visit_occurrence_id` | INTEGER | FK | Visit liên quan |
70
+ | `visit_detail_id` | INTEGER | FK | Visit detail |
71
+ | `procedure_source_value` | VARCHAR(50) | | Mã gốc |
72
+ | `procedure_source_concept_id` | INTEGER | | Concept gốc |
73
+ | `modifier_source_value` | VARCHAR(50) | | Modifier gốc |
74
+
75
+ **Mới trong CDM 5.4:** `procedure_end_date` và `procedure_end_datetime` — quan trọng cho phẫu thuật kéo dài nhiều giờ/ngày.
76
+
77
+ ---
78
+
79
+ ## 2. Vocabulary cho Procedure
80
+
81
+ ### 2.1. Các vocabulary phổ biến
82
+
83
+ | Vocabulary | Vai trò | Ví dụ |
84
+ |-----------|---------|-------|
85
+ | **SNOMED CT** | Standard concept | Appendectomy (44783086) |
86
+ | **CPT4** | US billing code | 44970 (Laparoscopic appendectomy) |
87
+ | **ICD-10-PCS** | US inpatient procedures | 0DTJ4ZZ |
88
+ | **ICD-9-Proc** | Legacy US procedures | 47.01 |
89
+ | **HCPCS** | US outpatient services | G0101 |
90
+
91
+ ### 2.2. Domain routing quy tắc
92
+
93
+ ```
94
+ ICD-10-PCS mã = '0DTJ4ZZ' (Lapar appendectomy)
95
+
96
+ │ concept_relationship: Maps to
97
+
98
+ SNOMED concept_id = 44783086
99
+ concept_name = 'Laparoscopic appendectomy'
100
+ domain_id = 'Procedure'
101
+
102
+ └──→ Lưu vào PROCEDURE_OCCURRENCE ✓
103
+
104
+
105
+ CPT4 mã = '80053' (Basic metabolic panel)
106
+
107
+ │ concept_relationship: Maps to
108
+
109
+ SNOMED concept_id = 3019897
110
+ domain_id = 'Measurement'
111
+
112
+ └──→ Lưu vào MEASUREMENT ✗ (không phải Procedure!)
113
+ ```
114
+
115
+ > **Quy tắc vàng:** Luôn check domain_id của Standard Concept. Dù mã nguồn là CPT4 (procedure code), nếu Standard Concept có domain = Measurement, phải lưu vào MEASUREMENT.
116
+
117
+ ---
118
+
119
+ ## 3. Procedure vs Measurement vs Drug — Ranh giới
120
+
121
+ | Dữ liệu gốc | Ở đâu? | Lý do |
122
+ |-------------|---------|-------|
123
+ | Phẫu thuật ruột thừa | **PROCEDURE** | Domain = Procedure |
124
+ | Siêu âm bụng | **PROCEDURE** | Domain = Procedure (imaging) |
125
+ | Xét nghiệm máu (kết quả 5.8 mmol/L) | **MEASUREMENT** | Có giá trị đo → Measurement |
126
+ | Chụp X-quang tim phổi (không kết quả) | **PROCEDURE** | Imaging → Procedure |
127
+ | Tiêm insulin | **DRUG_EXPOSURE** | Drug administration |
128
+ | Nội soi đại tràng + sinh thiết | **PROCEDURE** | Can thiệp thủ thuật |
129
+ | Vật lý trị liệu 30 phút | **PROCEDURE** | Procedure domain |
130
+ | Truyền máu | **PROCEDURE** | Transfusion = Procedure |
131
+
132
+ ---
133
+
134
+ ## 4. modifier_concept_id — Bổ sung thông tin
135
+
136
+ | Concept ID | Modifier | Ý nghĩa |
137
+ |-----------|----------|---------|
138
+ | 4148525 | Left | Bên trái |
139
+ | 4149625 | Right | Bên phải |
140
+ | 4236436 | Bilateral | Cả hai bên |
141
+ | 4215561 | Initial encounter | Lần đầu |
142
+ | 4215562 | Subsequent encounter | Tái khám |
143
+
144
+ ```sql
145
+ -- Phẫu thuật cắt ruột thừa nội soi (bên phải)
146
+ INSERT INTO procedure_occurrence (
147
+ procedure_occurrence_id, person_id, procedure_concept_id,
148
+ procedure_date, procedure_end_date,
149
+ procedure_type_concept_id,
150
+ modifier_concept_id, quantity,
151
+ provider_id, visit_occurrence_id,
152
+ procedure_source_value
153
+ ) VALUES (
154
+ 90001, 100001, 44783086, -- SNOMED: Lapar appendectomy
155
+ '2024-06-15', '2024-06-15',
156
+ 32817, -- EHR
157
+ 4149625, 1, -- Right side, 1 time
158
+ 5001, 50001,
159
+ '0DTJ4ZZ' -- ICD-10-PCS
160
+ );
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 5. ETL dữ liệu VN
166
+
167
+ ### 5.1. Nguồn dữ liệu phổ biến
168
+
169
+ | Nguồn | Mô tả | Vocabulary gốc |
170
+ |------|-------|----------------|
171
+ | Danh mục DVKT BV | Dịch vụ kỹ thuật BV | Mã nội bộ |
172
+ | ICD-9-CM Proc | Mã phẫu thuật cũ | ICD9Proc |
173
+ | Danh mục BHXH | Mã dịch vụ BHXH | Mã BH nội bộ |
174
+
175
+ ### 5.2. SQL ETL
176
+
177
+ ```sql
178
+ SELECT
179
+ ROW_NUMBER() OVER() AS procedure_occurrence_id,
180
+ pm.person_id,
181
+ COALESCE(cr.concept_id_2, 0) AS procedure_concept_id,
182
+ tt.ngay_thuchien AS procedure_date,
183
+ tt.ngay_ketthuc AS procedure_end_date,
184
+ 32817 AS procedure_type_concept_id,
185
+ 0 AS modifier_concept_id,
186
+ tt.so_lan AS quantity,
187
+ tt.ma_dvkt AS procedure_source_value,
188
+ COALESCE(c_source.concept_id, 0) AS procedure_source_concept_id
189
+ FROM thuthuat_his tt
190
+ JOIN person_mapping pm ON tt.ma_bn = pm.source_id
191
+ LEFT JOIN source_to_concept_map stcm
192
+ ON tt.ma_dvkt = stcm.source_code
193
+ AND stcm.source_vocabulary_id = 'VN_PROCEDURE'
194
+ LEFT JOIN concept c_std
195
+ ON stcm.target_concept_id = c_std.concept_id
196
+ AND c_std.standard_concept = 'S'
197
+ AND c_std.domain_id = 'Procedure' -- ← Chỉ Procedure domain!
198
+ LEFT JOIN concept c_source
199
+ ON tt.ma_dvkt = c_source.concept_code
200
+ LEFT JOIN concept_relationship cr
201
+ ON c_source.concept_id = cr.concept_id_1
202
+ AND cr.relationship_id = 'Maps to';
203
+ ```
204
+
205
+ ### 5.3. Xử lý domain routing
206
+
207
+ ```sql
208
+ -- DVKT "Xét nghiệm HbA1c" → mã CPT 83036
209
+ -- Standard concept domain = Measurement → KHÔNG lưu vào PROCEDURE
210
+
211
+ -- Bước 1: Tìm Standard Concept
212
+ SELECT c.*
213
+ FROM concept c
214
+ JOIN concept_relationship cr ON c.concept_id = cr.concept_id_2
215
+ AND cr.relationship_id = 'Maps to'
216
+ JOIN concept c_src ON cr.concept_id_1 = c_src.concept_id
217
+ WHERE c_src.concept_code = '83036'
218
+ AND c_src.vocabulary_id = 'CPT4';
219
+ -- domain_id = 'Measurement' → route sang MEASUREMENT table
220
+
221
+ -- Bước 2: Lưu vào đúng bảng
222
+ -- Nếu domain = 'Procedure' → procedure_occurrence
223
+ -- Nếu domain = 'Measurement' → measurement
224
+ -- Nếu domain = 'Observation' → observation
225
+ -- Nếu domain = 'Drug' → drug_exposure
226
+ ```
227
+
228
+ ---
229
+
230
+ ## 6. SQL phân tích
231
+
232
+ ```sql
233
+ -- Top 10 thủ thuật phổ biến
234
+ SELECT
235
+ c.concept_name AS procedure_name,
236
+ COUNT(*) AS procedure_count,
237
+ COUNT(DISTINCT po.person_id) AS patient_count
238
+ FROM procedure_occurrence po
239
+ JOIN concept c ON po.procedure_concept_id = c.concept_id
240
+ WHERE po.procedure_concept_id != 0
241
+ GROUP BY c.concept_name
242
+ ORDER BY procedure_count DESC
243
+ LIMIT 10;
244
+
245
+ -- Thống kê phẫu thuật theo tháng
246
+ SELECT
247
+ DATE_TRUNC('month', po.procedure_date) AS month,
248
+ c.concept_name AS procedure_name,
249
+ COUNT(*) AS total
250
+ FROM procedure_occurrence po
251
+ JOIN concept c ON po.procedure_concept_id = c.concept_id
252
+ WHERE po.procedure_concept_id = 44783086 -- Appendectomy
253
+ GROUP BY month, c.concept_name
254
+ ORDER BY month;
255
+
256
+ -- BN có cả chẩn đoán + phẫu thuật liên quan
257
+ SELECT
258
+ po.person_id,
259
+ co_cond.concept_name AS diagnosis,
260
+ co_proc.concept_name AS procedure_name,
261
+ co.condition_start_date,
262
+ po.procedure_date
263
+ FROM procedure_occurrence po
264
+ JOIN condition_occurrence co ON po.person_id = co.person_id
265
+ AND po.visit_occurrence_id = co.visit_occurrence_id
266
+ JOIN concept co_cond ON co.condition_concept_id = co_cond.concept_id
267
+ JOIN concept co_proc ON po.procedure_concept_id = co_proc.concept_id
268
+ WHERE co.condition_concept_id = 441604 -- Appendicitis
269
+ AND po.procedure_concept_id = 44783086 -- Appendectomy
270
+ LIMIT 20;
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Tổng kết
276
+
277
+ 1. **PROCEDURE_OCCURRENCE** = thủ thuật, phẫu thuật, can thiệp, imaging
278
+ 2. Standard Vocabulary chính: **SNOMED CT**
279
+ 3. **Domain routing** cực quan trọng: CPT4 code có thể map sang Measurement, không phải Procedure
280
+ 4. CDM 5.4 bổ sung **procedure_end_date** cho phẫu thuật kéo dài
281
+ 5. **modifier_concept_id** cho trái/phải, lần đầu/tái khám
282
+ 6. ETL VN: mã DVKT nội bộ → SOURCE_TO_CONCEPT_MAP → Standard SNOMED
283
+
284
+ **Bài tiếp theo:** MEASUREMENT — xét nghiệm, đo lường, và giá trị số.
285
+
286
+ ---
287
+
288
+ ## Tài liệu tham khảo
289
+
290
+ - [OMOP CDM 5.4 — PROCEDURE_OCCURRENCE](https://ohdsi.github.io/CommonDataModel/cdm54.html#PROCEDURE_OCCURRENCE)
291
+ - [Athena — Procedure Domain](https://athena.ohdsi.org/)