📑 Observation/_search

Searches for observations that match the query in the body. Works for a single patient at a time, and the patient is specified in the header.

  • Method: POST
  • URL: <base-url>/Observation/_search
  • Headers: One of
  • Body (x-www-form-urlencoded):
    • Optional filters:
      • _id: The ID of the Observation. Must be a GUID.
      • _tags: Filter by tags. Format: <system>:<code> or <code>. E.g. urn:oid:2.16.578.1.12.4.1.1.7280:NPU19767.
      • date: Filter by the EffectiveDate property. See the FHIR documentation for possible values.
      • identifier: Filter by other identifier. Currently only the ResultItem/IdResultItem from KITH Labsvar is supported here.
    • Optional includes (See how to include related resources):
      • _include: Include referenced resources (max depth: 1). E.g. Observation:specimen.
      • _include:iterate: Include referenced resources recursively. E.g. DiagnosticReport:requester.
      • _revinclude: Include resources referencing this resource (max depth: 1). E.g. DiagnosticReport:result.
      • _revinclude:iterate: Include resources referencing included resources recursively. E.g. DiagnosticReport:specimen.
    • Optional pagination (See pagination):
      • _count: How many matching resources to return. Default value: 50
      • _skip: How many matching resources to skip. Default value: 0

Response

200 OK

Returns a Bundle JSON containing the matching Observations and any specified includes. Among the entries of the bundle, there may in some cases also be an OperationOutcome which informs about the presence of a restriction of type sperring, blokkering, or reservasjon.

400 Bad Request or 401 Unauthorized

Returns an OperationOutcome JSON with details about what went wrong.

Unfortunately, in some scenarios, the API may return a plaintext response instead of an OperationOutcome. However, this is not expected to occur for typical usage of the API.

Examples

Example 1 - All Observations for Patient "Brun Lenestol" (First Page)

Request

POST <base-url>/Observation/_search

Headers (with HelseID):

Key Value
person-id 15720255178
... ...
Headers (without HelseID) [Click to expand]
Key Value
x-nilar-patient-id 15720255178
x-nilar-requester-hpr 4128168
... ...

Body (x-www-form-urlencoded): (empty)

Response:

{
  "resourceType": "Bundle",
  "type": "searchset",
  "timestamp": "2025-08-07T15:25:59.0373014+02:00",
  "total": 21076,
  "link": [ ... ],
  "entry": [
    {
      "fullUrl": "Observation/84d2a141-7a8f-550e-aece-083f41cbe29d",
      "resource": { ... },
      "search": {
        "mode": "match"
      }
    },
    {
      "fullUrl": "Observation/449a73e3-e9c4-5e9b-aa23-b81e25305302",
      "resource": { ... },
      "search": {
        "mode": "match"
      }
    },
    ...
  ]
}

Example 2 - Get Observation by ID and Include the DiagnosticReport

The DiagnosticReport only references top level Observations, so a simple _revinclude=DiagnosticReport:result will only work for top level Observations. To include the DiagnosticReport in the general case, do as shown below:

Request:

POST <base-url>/Observation/_search

Headers (with HelseID):

Key Value
person-id 15720255178
... ...
Headers (without HelseID) [Click to expand]
Key Value
x-nilar-patient-id 15720255178
x-nilar-requester-hpr 4128168
... ...

Body (x-www-form-urlencoded):

Key Value
_id 162bd88b-48cb-589b-8379-5694a3bc4af5
_revinclude:iterate Observation:has-member
_revinclude:iterate DiagnosticReport:result

Response:

{
  "resourceType": "Bundle",
  "type": "searchset",
  "timestamp": "2025-08-13T13:29:15.078852+02:00",
  "total": 1,
  "link": [ ... ],
  "entry": [
    {
      "fullUrl": "Observation/162bd88b-48cb-589b-8379-5694a3bc4af5",
      "resource": { ... },
      "search": {
        "mode": "match"
      }
    },
    {
      "fullUrl": "DiagnosticReport/27650612-4c1d-5146-a4bb-c7a382c49f72",
      "resource": { ... },
      "search": {
        "mode": "include"
      }
    },
    {
      "fullUrl": "Observation/643b377f-44eb-5fba-9fc0-fa80b879a6a4",
      "resource": { ... },
      "search": {
        "mode": "include"
      }
    }
  ]
}

For more details on includes, see how to include related resources.