AnyLearn
All lessons
Programmingintermediate

FHIR: Resources and the REST API

The modern, web-native healthcare standard. How FHIR models clinical data as modular resources, links them with references, and exchanges them over a plain REST API using JSON. Includes a real Patient resource, the core interactions, profiles and US Core, and the R4 versus R5 reality.

Updated · AI-authored, review-gated · how lessons are made

Not signed in: your progress and quiz score won't be saved.
Progress1 / 8

From pipes to the web

HL7 v2, from the previous lesson, is a pipe-delimited text format designed before the web. FHIR (Fast Healthcare Interoperability Resources), first published by HL7 in 2014 and led by Grahame Grieve, was a deliberate reset: keep the practical, implementer-first spirit of v2, but build on ordinary web technology.

That means three things a web developer already knows: data as resources, exchanged over a REST API, in JSON (or XML). No custom delimiters, no positional parsing. If you can call a REST endpoint and read JSON, you can read FHIR. This is why FHIR is the standard now mandated for new work, especially patient-facing apps and payer-to-provider exchange. FHIR is pronounced "fire".

Full lesson text

All 8 steps on one page, for reading, reference, and search.

Show

1. From pipes to the web

HL7 v2, from the previous lesson, is a pipe-delimited text format designed before the web. FHIR (Fast Healthcare Interoperability Resources), first published by HL7 in 2014 and led by Grahame Grieve, was a deliberate reset: keep the practical, implementer-first spirit of v2, but build on ordinary web technology.

That means three things a web developer already knows: data as resources, exchanged over a REST API, in JSON (or XML). No custom delimiters, no positional parsing. If you can call a REST endpoint and read JSON, you can read FHIR. This is why FHIR is the standard now mandated for new work, especially patient-facing apps and payer-to-provider exchange. FHIR is pronounced "fire".

2. The resource: FHIR's unit of exchange

FHIR breaks healthcare into about 150 resources, each a self-contained, modular chunk of clinical or administrative data. Rather than one giant patient record, you compose small pieces.

The resources you will meet first:

  • Patient and Practitioner: who the person and clinician are.
  • Encounter: a visit or admission.
  • Observation: a measured value (vital sign, lab result).
  • Condition: a diagnosis or problem.
  • MedicationRequest and AllergyIntolerance: prescriptions and allergies.

Each resource has a defined set of elements, a stable structure, and its own URL once stored on a server. Coded elements point at the same terminologies as v2 (LOINC, SNOMED CT, ICD), so the semantic layer carries over. You model a real clinical situation by combining resources and linking them.

3. A Patient resource in JSON

Here is the same patient from the previous lesson, now as a FHIR Patient resource:

{
  "resourceType": "Patient",
  "id": "100457",
  "identifier": [{
    "system": "urn:hosp-a:mrn",
    "value": "100457"
  }],
  "name": [{
    "family": "Dubois",
    "given": ["Marie", "L"]
  }],
  "gender": "female",
  "birthDate": "1982-03-04",
  "address": [{
    "city": "Lausanne",
    "postalCode": "1003",
    "country": "CH"
  }]
}

Every resource declares its resourceType and carries an id. Fields are named, not positional, so nothing depends on counting pipes. A human and a parser read it the same way. That readability is much of FHIR's appeal.

4. References: how resources link

Resources stay small because they reference each other instead of nesting everything. An Observation does not embed the whole patient; it points to one:

{
  "resourceType": "Observation",
  "status": "final",
  "code": { "coding": [{
    "system": "http://loinc.org",
    "code": "2339-0",
    "display": "Glucose"
  }]},
  "subject": { "reference": "Patient/100457" },
  "valueQuantity": { "value": 5.4, "unit": "mmol/L" }
}

The subject field is a reference to Patient/100457. Follow it and you get the patient. When you need several linked resources delivered together, FHIR wraps them in a Bundle: a single resource that contains a list of others, used for search results and batch operations. References plus Bundles are how a flat set of small resources represents a rich, connected clinical picture.

5. The REST API: reading and writing

FHIR resources are exchanged over a standard REST API. Every resource type sits at a predictable path, and the HTTP verb chooses the action:

InteractionRequest
Read oneGET [base]/Patient/100457
SearchGET [base]/Observation?patient=100457&code=2339-0
CreatePOST [base]/Patient (resource in body)
UpdatePUT [base]/Patient/100457
DeleteDELETE [base]/Patient/100457

Search is the workhorse: query parameters filter by patient, code, date, status, and more, and results come back as a Bundle. Because this is ordinary HTTP, standard web tooling applies, including OAuth 2.0 for authorization (the SMART on FHIR profile defines how apps get scoped access to a patient's data). Any language with an HTTP client is a FHIR client.

6. A FHIR read, end to end

The flow is exactly a web API call. An app sends an HTTP GET to a FHIR server, the server authorizes the request and looks up the resource, and it returns JSON. If the resource references others, the app follows those references or asks the server to include them. Nothing here is healthcare-specific except the resource shapes.

flowchart LR
  A["Client app"] -->|"GET /Patient/100457"| S["FHIR server"]
  S --> AU["Authorize (SMART on FHIR)"]
  AU --> DB["Look up resource"]
  DB -->|"JSON Patient"| A
  A -->|"GET /Observation?patient=100457"| S
  S -->|"Bundle of Observations"| A

7. Profiles, US Core, and implementation guides

Base FHIR resources are deliberately broad so they fit every country and use case. Real deployments constrain them with profiles: rules that mark which elements are required, which codes are allowed, and which extensions add locally needed data. A set of profiles for a purpose is packaged as an Implementation Guide (IG).

In the United States, the key IG is US Core, which defines the profiles that satisfy USCDI (the United States Core Data for Interoperability), the government-mandated minimum data set. When a US regulation says a system must expose patient data via FHIR, it effectively means US Core profiles on the relevant resources. Other regions maintain their own IGs. So "supports FHIR" is rarely enough on its own; the real question an integration engineer asks is which IG and which version.

8. Versions: R4 is the ground truth

FHIR has released several major versions. In practice, one matters most today. R4, published in 2019, is the production baseline: it is what the major EHR vendors expose in their live APIs and what US regulations target. R5 is published but, per HL7 and vendor guidance, sees limited production adoption; the major EHR platforms do not yet offer production R5 APIs, so apps that read and write real EHR data still use R4. HL7 has signaled that US Core will skip R5 and move from R4 toward the future R6.

The practical rule: build against R4 and the relevant Implementation Guide unless a specific partner requires otherwise. Knowing which version and profile you are targeting is half the job. The next lesson connects all of this, v2 and FHIR alike, through the integration engine that routes and transforms between them.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. What are the three web technologies FHIR is built on that make it approachable to a typical web developer?
    • FTP, CSV, and email
    • Resources, a REST API, and JSON (or XML)
    • Pipe-delimited text, sockets, and positional fields
    • GraphQL, WebSockets, and Protocol Buffers
  2. In FHIR, how does an Observation associate itself with the patient it measured?
    • It embeds a full copy of the Patient resource
    • It uses a reference, such as subject pointing to Patient/100457
    • It stores the patient's name as free text only
    • It requires the patient to be in the same file
  3. Which HTTP request would retrieve a single known patient from a FHIR server?
    • POST [base]/Patient
    • DELETE [base]/Patient/100457
    • GET [base]/Patient/100457
    • PUT [base]/Observation
  4. What is the role of an Implementation Guide like US Core?
    • It replaces JSON with a proprietary binary format
    • It constrains broad base resources with profiles, required elements, and allowed codes for a specific use or jurisdiction
    • It is the networking protocol FHIR runs over
    • It defines the physical database schema every server must use
  5. Which FHIR version should you build against for reading and writing real EHR data today?
    • R5, because it is the newest published version
    • R6, because it is already the production standard
    • R4, because it is the production baseline the major EHR vendors and US regulations target
    • Any version, since all are interchangeable at runtime

Related lessons

Programming
intermediate

Integration Engines and the Interoperability Career

The hub that makes healthcare data flow: how an integration engine like Mirth Connect routes, filters, and transforms messages between systems, how it compares to a general dataflow tool like Apache NiFi, the other standards you will meet, and the concrete skills to break into interoperability engineering.

9 steps·~14 min
Programming
intermediate

Healthcare Interoperability and the HL7 v2 Standard

Why hospital systems cannot talk to each other by default, and the standard that fixes it. Covers the four levels of interoperability, the HL7 family, and the anatomy of an HL7 v2 message: segments, fields, and delimiters. The foundation for a career in healthcare integration.

8 steps·~12 min
AI
advanced

Why Asking Nicely Does Not Guarantee JSON

Prompting for a format gives a high success rate, and a high success rate is not a guarantee. This lesson locates the one place in the decoding loop where a guarantee is possible, shows what masking logits does to the probability distribution, works through why a 5 percent failure rate destroys tail latency rather than average latency, and separates the three families of structured output.

10 steps·~15 min
Science
intermediate

AI for Clinical Documentation, Decision Support, and Imaging

A practical guide to the clinical workflows where AI helps physicians most. Learn how ambient AI scribes reduce documentation burden and burnout, how decision support surfaces guidelines and drug interactions to inform judgment, how imaging AI acts as a second read, and how AI drafts patient communication, all with the physician verification that keeps care safe.

7 steps·~11 min