Resource-Based Architecture
FHIR is built around the concept of Resources - modular, reusable components representing healthcare concepts.
Resource Categories
FHIR resources are organized into five main categories:
- Clinical Resources: Patient, Observation, Condition, Procedure, MedicationRequest
- Administrative Resources: Organization, Practitioner, Location, Encounter
- Financial Resources: Claim, Coverage, ExplanationOfBenefit
- Infrastructure Resources: Bundle, OperationOutcome, Subscription
- Conformance Resources: StructureDefinition, ValueSet, CodeSystem
Core FHIR Concepts
1. Resources
Every resource has these common elements:
- Metadata: id, meta (versionId, lastUpdated, profile, security, tag)
- Human-readable narrative: text element
- Structured data: Resource-specific elements
- Extensions: For additional data not in base specification
2. References
Resources can reference other resources in several ways. References are fundamental to FHIR’s data model, allowing you to link related clinical information together. You can use logical references (pointing to resource IDs), literal references (embedding resources), or identifier-based references (using business identifiers). Choose the appropriate reference type based on whether the referenced resource exists on the same server and how tightly coupled the data needs to be.
// Logical reference
reference.setReference("Patient/123");
// Literal reference (contained resource)
reference.setResource(patientResource);
// Identifier-based reference
reference.setIdentifier(new Identifier()
.setSystem("http://hospital.org/mrn")
.setValue("MRN-12345"));
3. Data Types
FHIR defines both primitive and complex data types:
Primitive Types:
- boolean, integer, decimal, string
- date, dateTime, time, instant
- uri, url, canonical, oid, uuid, base64Binary
Complex Types:
- Identifier, CodeableConcept, Coding, Quantity
- Range, Period, HumanName, Address
- ContactPoint, Attachment
4. Bundles
A Bundle is a container for multiple resources:
Bundle Types:
| Type | Description |
|---|---|
| document | Composed document |
| message | Message-based exchange |
| transaction | Atomic transaction |
| transaction-response | Response to transaction |
| batch | Batch processing |
| batch-response | Response to batch |
| history | History list |
| searchset | Search results |
| collection | General collection |
RESTful API Paradigm
FHIR uses standard HTTP methods for all operations:
| Operation | HTTP Method | Description |
|---|---|---|
| Create | POST | Create new resource |
| Read | GET | Retrieve resource by ID |
| Update | PUT | Update entire resource |
| Patch | PATCH | Partial update |
| Delete | DELETE | Remove resource |
| Search | GET | Query for resources |
| History | GET | Get version history |
Resource URLs
Standard FHIR URL patterns follow a consistent structure. Understanding these URL patterns is essential for interacting with FHIR servers, as they form the foundation of all RESTful operations. The URL structure includes the server base, resource type, resource ID, and optional version or history paths. Mastering these patterns enables you to construct proper API calls for any FHIR operation.
[base]/[type]/[id]
[base]/[type]?[search parameters]
[base]/[type]/[id]/_history
[base]/[type]/[id]/_history/[version]
Examples:
https://fhir.example.com/Patient/123- Read patient with ID 123https://fhir.example.com/Patient?family=Smith- Search for patients named Smithhttps://fhir.example.com/Patient/123/_history- Get all versions of patient 123
Content Negotiation
FHIR supports multiple formats via HTTP headers. Content negotiation allows clients to specify their preferred data format when communicating with FHIR servers. The Accept header declares the desired response format, while Content-Type specifies the request body format. This flexibility enables FHIR to work seamlessly with systems that prefer JSON, XML, or RDF Turtle representations.
Accept: application/fhir+json # JSON format
Accept: application/fhir+xml # XML format
Accept: application/fhir+turtle # RDF Turtle
Content-Type: application/fhir+json # Request body format
Understanding Resource Structure
Every FHIR resource follows this general structure. The structure includes mandatory elements like resourceType and id, along with optional metadata, human-readable narrative, and resource-specific content. Understanding this structure is crucial because it applies universally across all FHIR resources, making it easier to work with any resource type once you understand the pattern.
{
"resourceType": "Patient",
"id": "123",
"meta": {
"versionId": "1",
"lastUpdated": "2024-01-15T10:30:00Z"
},
"text": {
"status": "generated",
"div": "<div>Human readable summary</div>"
},
// Resource-specific content
"name": [{ "family": "Smith", "given": ["John"] }],
"gender": "male",
"birthDate": "1980-06-15"
}