📑 DiagnosticReport/_search

Searches for diagnostic reports 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>/DiagnosticReport/_search
  • Headers: One of
  • Body (x-www-form-urlencoded):
    • Optional filters:
      • _id: The ID of the DiagnosticReport. Must be a GUID.
      • date: Filter by the EffectiveDate property. See the FHIR documentation for possible values.
      • identifier: Filter by other identifier. Currently only the ServReport/ServProvId from KITH Labsvar is supported here.
    • Optional includes (See how to include related resources):
      • _include: Include referenced resources (max depth: 1). E.g. DiagnosticReport:based-on.
      • _include:iterate: Include referenced resources recursively. E.g. ServiceRequest:requester.
      • _revinclude: Not applicable for DiagnosticReport, because no resources reference it.
      • _revinclude:iterate: Include resources referencing included resources recursively. E.g. Observation: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 DiagnosticReports 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 DiagnosticReports for Patient "Brun Lenestol" (First Page)

Request:

POST <base-url>/DiagnosticReport/_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:24:33.1194688+02:00",
  "total": 1788,
  "link": [ ... ],
  "entry": [
    {
      "fullUrl": "DiagnosticReport/2cd597ce-ffa9-50c7-8dbd-b685790d791d",
      "resource": { ... },
      "search": {
        "mode": "match"
      }
    },
    {
      "fullUrl": "DiagnosticReport/af036583-adc6-583d-b9db-ea23fbb67d26",
      "resource": { ... },
      "search": {
        "mode": "match"
      }
    },
    ...
  ]
}

Example 2 - Get DiagnosticReport by ID and Include All Its Observations

While _include=DiagnosticReport:result will include all the top level Observations in the DiagnosticReport, there may be nested Observations as well. Use _include:iterate=Observation:has-member to also include those, as shown below. For more details on includes, see how to include related resources.

Request:

POST <base-url>/DiagnosticReport/_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 27650612-4c1d-5146-a4bb-c7a382c49f72
_include DiagnosticReport:result
_include:iterate Observation:has-member

Response:

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