fhirlab
Clinical Core· 12 min read· hands-on

Observation — the vital sign

Body temperature, blood pressure, labs. All one resource.

What did you measure, when, and what did it say?

That's the question Observation answers. A body temperature of 38.6°C. A systolic blood pressure of 142. A COVID-19 PCR result of "positive." A PHQ-9 depression score of 14. Different clinical worlds, wildly different units, one FHIR resource.

If Patient is the who, Observation is nearly all of the what. In a real EHR integration you'll see hundreds of Observations for every Patient — and they all share the exact JSON shape you're about to build.

Anatomy of an Observation

FHIR R4 marks two fields as required on every Observation:

  • status — a single code from a fixed list: registered, preliminary, final, amended, corrected, cancelled, entered-in-error, unknown. Most real observations you'll ever see are final.
  • code — a CodeableConcept saying what was measured. This is where terminologies earn their keep. "Body temperature" is LOINC 8310-5. "Heart rate" is LOINC 8867-4. The code carries its source system URL alongside it so no one has to guess.

You almost always also provide a subject — a reference to the Patient (or Group, Device, or Location) this measurement is about — and an effectiveDateTime saying when the measurement happened.

The value[x] trick

Here's the clever part. A temperature is a number with a unit. A COVID result is a coded answer. A free-text nursing note is a string. A "was the patient fasting?" flag is a boolean. FHIR collapses all of these into one resource via value[x] polymorphism — exactly one of these fields appears per Observation:

  • valueQuantity — a number plus a UCUM unit. Temperature, weight, heart rate.
  • valueCodeableConcept — a coded answer. "Positive", "Negative", "Not detected."
  • valueString — free text when nothing better fits.
  • valueBoolean, valueInteger, valueRange, valueRatio, valueDateTime, valuePeriod — the long tail.

One resource covers numbers, categories, and free text. That's why Observation is the workhorse of clinical FHIR.

1 · Create an Observation (body temperature)

Press Run. You're sending a complete vital-sign reading to the public HAPI sandbox. The code uses LOINC 8310-5 (Body temperature) and the valueQuantity uses UCUM Cel — the two most-used terminologies in clinical FHIR, both cited by URL so any server on Earth agrees what you mean.

The subject.reference below points at Patient/example — a stock Patient that already exists on the HAPI sandbox. If you kept the id from the Patient you created in the previous lesson, swap it in.

POST /Observation
Create a body-temperature Observation. Edit the value, the unit, the LOINC code — anything — and press Run again.
POST
https://hapi.fhir.org/baseR4
Request body
Your learner tag meta.tag: loading is added automatically so you can find this resource later.
Switch the response tab to JSONPath and try $.valueQuantity.value, then $.code.coding[0].code. Every FHIR server in the world will have those exact paths populated.

2 · Read it back

The id from the response above auto-fills below. Press Run to fetch the same Observation back by its canonical URL.

GET /Observation/{id}
Fetch the Observation you just created. The id auto-fills from the POST above.
GET
https://hapi.fhir.org/baseR4
URL still contains a placeholder ({ID}). Create a Observation first above, or paste an id here.

3 · One shape, many values

Now watch the shape of the resource stay identical while the value flips from a number to a coded answer. This one is a qualitative result — the kind a lab returns for a rapid test. Notice there's no valueQuantity at all; valueCodeableConcept takes its place.

We're using code.text and valueCodeableConcept.text without a coding system here — FHIR allows this when you don't have a verified code handy, and it's a useful pattern for prototyping before you've wired up a real terminology server.

POST /Observation (qualitative)
Same resource, same required fields — a coded value instead of a numeric one.
POST
https://hapi.fhir.org/baseR4
Request body
Your learner tag meta.tag: loading is added automatically so you can find this resource later.

Two Observations, two completely different clinical answers, zero structural difference in the JSON. That's value[x] earning its keep.

4 · Find all your Observations

Same search trick as before — every resource you POST through this course gets stamped with your anonymous learner tag, so you can fish them back out of the shared sandbox.

GET /Observation?_tag=...|{YOUR_UID}
Every Observation you've created in this lesson, newest first.
GET
https://hapi.fhir.org/baseR4
URL still contains a placeholder ({UID}). Waiting for your anonymous ID…

The response is a Bundle. Try $.entry[*].resource.code.coding[0].display in the JSONPath tab to see what each one measured, or $.entry[*].resource.valueQuantity.value to pull the numeric readings (qualitative entries will come back as null — which tells you something real about value[x]).

What just happened

  • You created two Observations with wildly different clinical meaning and identical structure — status, code, subject, value[x].
  • You used LOINC for the measurement code and UCUM for the unit. Those two vocabularies, referenced by their canonical system URLs, are what make a 38.6°C reading unambiguous across every system in the world.
  • You saw value[x] in practice: one resource, many shapes — valueQuantity for numbers, valueCodeableConcept for coded answers. The pattern repeats across FHIR wherever a field could legitimately hold more than one type.

Up next: Encounter. A single visit to a clinic produces dozens of these Observations — plus a diagnosis, a prescription, maybe a procedure. Encounter is the envelope that ties them all together under one episode of care.