REST, search, dan Bundle
Ringkasan satu halaman. Dari Lesson 0008, 0009, 0010, 0011. JSON: application/fhir+json.
Interaksi [1]
| Interaction | Request | Sukses | Gagal umum |
|---|---|---|---|
| read | GET [base]/[type]/[id] | 200 | 404 tidak dikenal · 410 dihapus |
| vread | GET [base]/[type]/[id]/_history/[vid] | 200 | 404 |
| create | POST [base]/[type] | 201 + Location: …/[id]/_history/[vid] | 400 · 422 |
| update | PUT [base]/[type]/[id] | 200 (atau 201 bila update-as-create) | 400 · 409/412 · 422 |
| patch | PATCH [base]/[type]/[id] | 200 | JSON Patch / FHIRPath Patch |
| delete | DELETE [base]/[type]/[id] | 200 / 204 | — |
| search | GET [base]/[type]?… · POST [base]/[type]/_search | 200 + Bundle searchset | 400 |
| history | GET [base]/[type]/[id]/_history | 200 + Bundle history | — |
| capabilities | GET [base]/metadata | CapabilityStatement | — |
| batch/transaction | POST [base] | 200 + batch-response/transaction-response | transaction: 4xx/5xx + OperationOutcome |
Server menentukan id saat create (id di body diabaikan). Error → body OperationOutcome. Prefer: return=minimal | representation.
Search [2]
| Tipe | Sintaks | Modifier / catatan |
|---|---|---|
| string | family=sant | default awalan, case/accent-insensitive · :exact · :contains |
| token | code=http://loinc.org|29463-7 | [system]|[code] · :not · :text |
| reference | patient=123 · subject=Patient/123 | dasar chaining dan _include |
| date | date=ge2024-01-01 | prefix eq(default) ne gt lt ge le sa eb ap |
| semua | gender:missing=true | true = tidak punya nilai · false = punya nilai |
- AND = parameter diulang:
date=ge2010-01-01&date=le2011-12-31. OR = koma:code=a|1,a|2. - Parameter tak dikenal biasanya diabaikan;
Prefer: handling=strictminta error. Cek linkselfuntuk parameter yang benar-benar dipakai. - Lainnya:
_count(ukuran halaman) ·_sort·_summary=count(hanya jumlah) ·_total.
Chaining vs include [2]
| Contoh | Efek | |
|---|---|---|
| Chaining (filter) | DiagnosticReport?subject:Patient.name=peter | hanya DiagnosticReport yang subject-nya Patient bernama peter |
_include (tambah, maju) | Observation?patient=123&_include=Observation:patient | + Patient yang dirujuk hasil |
_revinclude (tambah, balik) | Patient?_id=123&_revinclude=Observation:patient | + Observation yang merujuk hasil |
Format: [tipe sumber]:[search param](:[tipe target]); berantai hanya dengan :iterate. Chaining terbalik: _has (dukungan terbatas).
Bundle [3] [4]
type | Untuk | Yang perlu diingat |
|---|---|---|
searchset | hasil search | total = jumlah match semua halaman · entry.search.mode = match | include | outcome · link self/next (opaque, ikuti saja) |
transaction | tulis atomik | semua sukses atau semua gagal · referensi antar-entry lewat fullUrl: urn:uuid:… · urutan proses: DELETE → POST → PUT/PATCH → GET/HEAD |
batch | aksi independen | respons per entry, sebagian boleh gagal · tanpa ketergantungan antar-entry |
history | hasil _history | daftar versi |
collection, document, message | paket / dokumen / pesan | bukan interaksi REST di lesson ini |
Entry transaction/batch: resource + request: { method, url, ifNoneExist?, ifMatch? }; respons: entry.response.
Conditional + versioning [1]
| Request | 0 cocok | 1 cocok | > 1 cocok |
|---|---|---|---|
Conditional create: POST + If-None-Exist: identifier=sys|val | create (201) | abaikan, 200 | 412 |
Conditional update: PUT [base]/Patient?identifier=sys|val | create | update resource itu | 412 |
GET /Patient/123 → ETag: W/"3" (= meta.versionId)
PUT /Patient/123 If-Match: W/"3"
→ 200 bila versi masih 3 · 412 Precondition Failed bila sudah berubah (lost update dicegah)
Error + discovery [5] [6]
OperationOutcome.issue[]:severity(fatal/error/warning/information) ·code(IssueType: invalid, required, not-found, conflict, business-rule…) ·diagnostics·expression(lokasi elemen).- 400 = tidak bisa di-parse / validasi dasar · 422 = melanggar profil atau aturan bisnis · 409/412 = konflik versi atau kriteria conditional tidak selektif.
GET [base]/metadata→ CapabilityStatement:fhirVersion,format,rest.security, per resourceinteraction+searchParam(+updateCreate).
Jawaban 60–90 detik
"Observation milik pasien beserta Patient-nya": Observation?patient=123&code=http://loinc.org|29463-7&_include=Observation:patient, hasil Bundle searchset,
bedakan lewat search.mode, paging dengan link next.
Transaction vs batch: atomik vs independen, urn:uuid hanya di transaction.
Lost update: ETag = versionId, kirim If-Match, tangani 412. Error selalu OperationOutcome; kemampuan server di /metadata.
Sumber (FHIR R4 4.0.1): [1] RESTful API · [2] Search · [3] Bundle · [4] BundleType · [5] OperationOutcome · [6] CapabilityStatement