Xem bản video
1. Primitive Types
Primitive types là các giá trị đơn giản, "nguyên tử" trong FHIR.
| Type | Mô tả | Ví dụ |
|---|---|---|
| boolean | true/false | true |
| integer | Số nguyên 32-bit | 42 |
| integer64 | Số nguyên 64-bit (R5 mới) | 9223372036854775807 |
| string | Chuỗi Unicode (≤ 1MB) | "Nguyễn Văn A" |
| decimal | Số thực (precision tùy ý) | 3.14159 |
| uri | URI (RFC 3986) | "http://loinc.org" |
| url | URL | "https://fhir.example.com" |
| canonical | URL đến conformance resource | "http://hl7.org/fhir/StructureDefinition/Patient" |
| uuid | UUID (RFC 4122) | "urn:uuid:c757873d-ec9a-4326-a141-556f43239520" |
| id | Resource ID (1-64 chars, [A-Za-z0-9\-.]) | "patient-001" |
| date | Ngày (YYYY, YYYY-MM, YYYY-MM-DD) | "2025-01-15" |
| dateTime | Ngày giờ với timezone | "2025-01-15T10:30:00+07:00" |
| instant | Thời điểm chính xác (xs:dateTime) | "2025-01-15T10:30:00.000Z" |
| time | Giờ trong ngày | "10:30:00" |
| code | Giá trị từ ValueSet | "male" |
| oid | OID (ISO) | "urn:oid:2.16.840.1.113883.6.1" |
| markdown | Markdown text | "**Bold** and *italic*" |
| base64Binary | Base64 encoded | Binary data |
| positiveInt | Số nguyên > 0 | 1 |
| unsignedInt | Số nguyên ≥ 0 | 0 |
Extensions trên Primitive
Ngay cả primitives cũng có thể mang extensions (sử dụng underscore convention):
{
"birthDate": "1990-05-15",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "1990-05-15T14:30:00+07:00"
}
]
}
}
2. Complex Types — General-Purpose
Identifier
{
"use": "official",
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0203",
"code": "NI",
"display": "National unique individual identifier"
}
],
"text": "CCCD"
},
"system": "http://cccd.gov.vn",
"value": "012345678901",
"period": {
"start": "2021-01-01",
"end": "2036-01-01"
},
"assigner": {
"display": "Bộ Công an"
}
}
HumanName
{
"use": "official",
"text": "Nguyễn Văn A",
"family": "Nguyễn",
"given": ["Văn", "A"],
"prefix": ["BS."],
"suffix": ["ThS."],
"period": {
"start": "1990-05-15"
}
}
Address
{
"use": "home",
"type": "physical",
"text": "123 Đường Lê Lợi, Phường Bến Nghé, Quận 1, TP.HCM",
"line": ["123 Đường Lê Lợi"],
"city": "Hồ Chí Minh",
"district": "Quận 1",
"state": "TP.HCM",
"postalCode": "700000",
"country": "VN"
}
ContactPoint
[
{
"system": "phone",
"value": "+84901234567",
"use": "mobile",
"rank": 1
},
{
"system": "email",
"value": "[email protected]",
"use": "home"
}
]
Coding và CodeableConcept
// Coding — một mã duy nhất
{
"system": "http://loinc.org",
"version": "2.77",
"code": "8480-6",
"display": "Systolic blood pressure"
}
// CodeableConcept — nhiều Codings + text
{
"coding": [
{
"system": "http://hl7.org/fhir/sid/icd-10",
"code": "I10",
"display": "Essential (primary) hypertension"
},
{
"system": "http://snomed.info/sct",
"code": "38341003",
"display": "Hypertensive disorder"
}
],
"text": "Tăng huyết áp nguyên phát"
}
CodeableConcept cho phép biểu diễn cùng một khái niệm bằng nhiều CodeSystems khác nhau — hỗ trợ interoperability.
Quantity
{
"value": 145,
"comparator": ">=",
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
}
Period và Timing
// Period
{
"start": "2025-01-15T08:00:00+07:00",
"end": "2025-01-15T08:45:00+07:00"
}
// Timing (cho medication dosage)
{
"repeat": {
"frequency": 2,
"period": 1,
"periodUnit": "d",
"when": ["ACM", "ACV"],
"boundsPeriod": {
"start": "2025-01-15",
"end": "2025-02-15"
}
},
"code": {
"text": "Ngày 2 lần, sáng và tối sau ăn"
}
}
Reference
{
"reference": "Patient/patient-001",
"type": "Patient",
"identifier": {
"system": "http://hospital.vn/mrn",
"value": "MRN12345"
},
"display": "Nguyễn Văn A"
}
Reference có thể chứa reference (literal URL), identifier (logical reference), hoặc cả hai.
3. Narrative (Human-Readable)
{
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>Bệnh nhân: Nguyễn Văn A, Nam, sinh ngày 15/05/1990</p></div>"
}
}
| Status | Mô tả |
|---|---|
| generated | Tạo tự động từ structured data |
| extensions | Có thông tin từ extensions không có trong structured data |
| additional | Có thông tin bổ sung không có trong structured data |
| empty | Không có text (narrative trống) |
4. BackboneElement
BackboneElement là complex type chỉ tồn tại bên trong resource cha, không thể dùng lại ở nơi khác. Ví dụ: Patient.contact, Encounter.participant, Encounter.diagnosis.
{
"resourceType": "Patient",
"contact": [
{
"relationship": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0131",
"code": "N",
"display": "Next-of-Kin"
}
]
}
],
"name": {
"text": "Nguyễn Thị B (vợ)"
},
"telecom": [
{
"system": "phone",
"value": "+84907654321"
}
]
}
]
}
5. Choice Types [x]
Một số elements cho phép nhiều data types — ký hiệu bằng [x]:
| Element definition | Sử dụng thực tế |
|---|---|
| value[x] | valueQuantity, valueString, valueCodeableConcept, valueBoolean, ... |
| onset[x] | onsetDateTime, onsetAge, onsetPeriod, onsetRange, onsetString |
| effective[x] | effectiveDateTime, effectivePeriod, effectiveInstant, effectiveTiming |
| deceased[x] | deceasedBoolean, deceasedDateTime |
| multipleBirth[x] | multipleBirthBoolean, multipleBirthInteger |
// Observation value dạng Quantity
{"valueQuantity": {"value": 37.2, "unit": "°C"}}
// Observation value dạng CodeableConcept
{"valueCodeableConcept": {"coding": [{"code": "positive"}]}}
// Observation value dạng string
{"valueString": "Bình thường"}
6. Tổng kết
Primitive types — 20+ types cơ bản (string, date, code, uri, ...), hỗ trợ extensions
Complex types — HumanName, Address, Identifier, CodeableConcept, Quantity, Reference, ...
CodeableConcept — Quan trọng nhất, cho phép multi-coding cho interoperability
Narrative — Human-readable XHTML trong mọi DomainResource
BackboneElement — Complex type nội bộ resource
Choice types [x] — Linh hoạt chọn data type phù hợp