Awesome-omni-skill fhir-api
Expert guidance for implementing FHIR RESTful API servers and clients following the HL7 FHIR specification. Use this skill when implementing a FHIR server with REST endpoints, building a FHIR client, designing FHIR API routes and handlers, implementing FHIR operations (read, create, update, delete, search, history), working with FHIR bundles, batch requests, or transactions, handling FHIR content negotiation, headers, and versioning, or implementing conditional operations. Trigger keywords include "FHIR REST", "FHIR API", "FHIR server", "FHIR client", "FHIR endpoint", "FHIR operations", "RESTful FHIR", "implement FHIR".
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/fhir-api" ~/.claude/skills/diegosouzapw-awesome-omni-skill-fhir-api && rm -rf "$T"
skills/development/fhir-api/SKILL.mdFHIR REST API implementation
This skill provides guidance for implementing FHIR RESTful APIs according to the HL7 FHIR specification (R4/R5).
URL structure
All FHIR REST URLs follow the pattern:
[base]/[type]/[id]
: Service base URL (e.g.,[base]
)https://fhir.example.org/r4
: Resource type (e.g.,[type]
,Patient
)Observation
: Logical resource ID[id]
URLs are case-sensitive and use UTF-8 encoding.
Core operations
| Operation | HTTP | URL Pattern | Success |
|---|---|---|---|
| Read | GET | | 200 |
| VRead | GET | | 200 |
| Create | POST | | 201 |
| Update | PUT | | 200/201 |
| Patch | PATCH | | 200 |
| Delete | DELETE | | 200/204 |
| Search | GET/POST | | 200 |
| History | GET | | 200 |
| Capabilities | GET | | 200 |
| Batch/Transaction | POST | | 200 |
For detailed specifications of each operation, see references/operations.md.
Content negotiation
MIME types
| Format | MIME Type |
|---|---|
| JSON | |
| XML | |
| RDF | |
Use the
Accept header for response format and Content-Type for request body format.
The
_format query parameter overrides Accept when clients cannot set headers.
FHIR version
Specify version via MIME type parameter:
Accept: application/fhir+json; fhirVersion=4.0
Version mappings: 1.0 (R2), 3.0 (R3), 4.0 (R4), 4.3 (R4B), 5.0 (R5).
Required headers
Request headers
| Header | Purpose | Example |
|---|---|---|
| Accept | Response format | |
| Content-Type | Request body format | |
| If-Match | Optimistic locking | |
| If-None-Exist | Conditional create | |
| Prefer | Return preference | |
Response headers
| Header | Purpose | Example |
|---|---|---|
| ETag | Version identifier | |
| Location | New resource URL | |
| Last-Modified | Modification time | RFC 7231 date |
Versioning and optimistic locking
FHIR uses weak ETags for version tracking:
- Server returns
with responsesETag: W/"[versionId]" - Client sends
with updatesIf-Match: W/"[versionId]" - Server returns
if version mismatch412 Precondition Failed
Implement version-aware updates when
CapabilityStatement.rest.resource.versioning is versioned-update.
Error handling
Return
OperationOutcome resources for all errors:
{ "resourceType": "OperationOutcome", "issue": [ { "severity": "error", "code": "invalid", "diagnostics": "Patient.birthDate: Invalid date format" } ] }
Status codes
| Code | Meaning |
|---|---|
| 400 | Invalid syntax or validation failure |
| 404 | Resource not found |
| 409 | Version conflict |
| 410 | Resource deleted |
| 412 | Precondition failed (version mismatch) |
| 422 | Business rule violation |
Prefer header
Control response content with
Prefer:
| Value | Response body |
|---|---|
| Empty (headers only) |
| Full resource |
| Validation outcome |
For async operations, use
Prefer: respond-async to get 202 Accepted with status polling URL.
Implementation checklist
Server implementations should:
- Implement CapabilityStatement at
/metadata - Support content negotiation (JSON at minimum)
- Return proper ETags for versioned resources
- Include
header on create/updateLocation - Return
for all errorsOperationOutcome - Support
parameter fallback_format - Honour
header for response contentPrefer
References
- operations.md: Detailed operation specifications
- search.md: Search parameter and result handling
- batch-transaction.md: Batch and transaction processing