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

レッスン 10: 検索パラメータと高度な検索

検索パラメーターのタイプ (文字列、トークン、参照、日付、数値、数量、uri)、修飾子 (:exact、:contains、:missing、:not)、連鎖、逆連鎖 (_has)、_include、_revinclude、_summary、_elements、_count、ページング、複合検索パラメーター、カスタム SearchParameter。

🏗️ アーキテクチャ — レッスン 10 レッスン 10: 検索パラメータと高度な検索 高い

HL7 FHIR - 基本から高度な医療データ標準

パート 3: FHIR RESTful API とデータ交換

xdev.asia

1. 検索パラメータの種類

種類説明たとえば
文字列.文字列テキストを検索する患者?名前=グエン
トークンコード/識別子患者?性別=男性
参考。参照別のリソースへの参照観察?被験者=患者/123
日付。日付日付患者?生年月日=1990-05-15
番号。番号いいえリスク評価?確率=gt0.8
量。量数値+単位観察?値-量=gt5.4|http://unitsofmeasure.org|mg
ウリURI値セット?url=http://hl7.org/fhir/ValueSet/example
複合材複数のパラメータを結合する観測?コード値数量=...
特別な特に位置?近く=42.2|-71.0|10|km
# Default: starts-with, case-insensitive
GET /Patient?name=Nguyen

# Exact match
GET /Patient?name:exact=Nguyễn

# Contains
GET /Patient?name:contains=van

# Text (full-text search trên narrative)
GET /Patient?_text=hypertension
# Chỉ code
GET /Patient?gender=male

# System + code
GET /Condition?code=http://hl7.org/fhir/sid/icd-10|I10

# Chỉ system (tìm tất cả codes trong system)
GET /Condition?code=http://snomed.info/sct|

# Identifier
GET /Patient?identifier=http://hospital.vn/mrn|MRN12345

# :not modifier
GET /Patient?gender:not=male

# :text modifier (tìm trên display text)
GET /Condition?code:text=hypertension
# Exact date
GET /Patient?birthdate=1990-05-15

# Prefixes: eq, ne, gt, lt, ge, le, sa (starts after), eb (ends before)
GET /Patient?birthdate=gt1990-01-01
GET /Encounter?date=ge2025-01-01&date=le2025-01-31
GET /Observation?date=sa2025-01-01T00:00:00Z

# Precision matters
GET /Patient?birthdate=1990      # born in 1990
GET /Patient?birthdate=1990-05   # born in May 1990
# Relative reference
GET /Observation?subject=Patient/patient-001

# Chỉ ID (nếu type rõ ràng)
GET /Observation?subject=patient-001

# Absolute reference
GET /Observation?subject=https://fhir-server.example.com/fhir/r5/Patient/patient-001

# Identifier trên referenced resource
GET /Observation?subject:identifier=http://hospital.vn/mrn|MRN12345

6. 連鎖 — 参考文献を検索する

# Tìm Observation của Patient có tên "Nguyen"
GET /Observation?subject:Patient.name=Nguyen

# Chain sâu hơn
GET /Observation?subject:Patient.organization.name=Bach%20Mai

# Tìm MedicationRequest kê bởi Practitioner chuyên khoa Tim mạch
GET /MedicationRequest?requester:Practitioner.qualification=cardiology

7. リバースチェーン (_has)

# Tìm Patient có Observation với code=hba1c và value>7
GET /Patient?_has:Observation:subject:code=4548-4&_has:Observation:subject:value-quantity=gt7

# Tìm Patient có Condition "hypertension" active
GET /Patient?_has:Condition:subject:code=I10&_has:Condition:subject:clinical-status=active

# Tìm Practitioner có ít nhất 1 Encounter
GET /Practitioner?_has:Encounter:participant:date=ge2025-01-01

8. _include と _revinclude

# _include: kéo theo referenced resources
# Tìm Encounter VÀ Patient của Encounter đó
GET /Encounter?date=ge2025-01-15&_include=Encounter:subject

# Multiple includes
GET /MedicationRequest?status=active
  &_include=MedicationRequest:subject
  &_include=MedicationRequest:requester
  &_include=MedicationRequest:medication

# _revinclude: kéo theo resources reference ngược lại
# Tìm Patient VÀ tất cả Observation, Condition reference đến Patient
GET /Patient?_id=patient-001
  &_revinclude=Observation:subject
  &_revinclude=Condition:subject

# :iterate — recursive include
GET /MedicationRequest?_include:iterate=MedicationRequest:medication

9. 結果パラメータ

# _count — số entry per page
GET /Patient?name=Nguyen&_count=20

# _sort — sắp xếp
GET /Observation?subject=Patient/patient-001&_sort=-date  # descending
GET /Patient?_sort=family,given                            # multi-sort

# _summary — trả về tóm tắt
GET /Patient?_summary=true      # chỉ `mandatory` elements
GET /Patient?_summary=count     # chỉ count, không trả resources
GET /Patient?_summary=text      # text + id + meta + mandatory

# _elements — chọn elements cụ thể
GET /Patient?_elements=name,birthDate,gender,identifier

# _total — kiểm soát tính total
GET /Patient?_total=accurate    # tính chính xác total
GET /Patient?_total=none        # không tính total (nhanh hơn)

10. ページング

{
  "resourceType": "Bundle",
  "type": "searchset",
  "total": 150,
  "link": [
    {"relation": "self",     "url": "...?_count=10&_offset=0"},
    {"relation": "first",    "url": "...?_count=10&_offset=0"},
    {"relation": "next",     "url": "...?_count=10&_offset=10"},
    {"relation": "last",     "url": "...?_count=10&_offset=140"}
  ]
}

クライアントはリンクをたどります 次に。次へ 次のページを取得します。 独自の URL を作成しないでください — 常にサーバー応答からのリンクを使用します。

11. カスタム検索パラメータ

{
  "resourceType": "SearchParameter",
  "url": "http://hospital.vn/fhir/SearchParameter/patient-cccd",
  "name": "cccd",
  "status": "active",
  "description": "Tìm Patient theo số CCCD",
  "code": "cccd",
  "base": ["Patient"],
  "type": "token",
  "expression": "Patient.identifier.where(system='http://hospital.vn/cccd')"
}
# Sử dụng custom search parameter
GET /Patient?cccd=012345678901

12. まとめ

  • 9種類のパラメータ — 文字列、トークン、参照、日付、数値、数量、URI、複合、特殊

  • 修飾子 — :exact、:contains、:missing、:not、:text、:identifier

  • 連鎖 — チェーン参照の検索 (件名:Patient.name)

  • _あります — 逆連鎖、他のリソースによって参照されているリソースの検索

  • _include / _revinclude — 参照リソースを結果にドラッグします

  • _summary、_elements、_sort、_count — 制御応答性