> ## Documentation Index
> Fetch the complete documentation index at: https://docs.olira.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# get_logs

> Get event log entries for the patient with optional time, type, trace, and JMESPath projection filters.

Get event log entries for the patient with optional time, type, trace, and JMESPath projection filters.

## Parameters

| Parameter    | Required | Type                    | Description                                                                                                                                                                                                                                                                         |
| ------------ | -------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `patient_id` | Yes      | `string`                | Patient user ID                                                                                                                                                                                                                                                                     |
| `date_from`  | No       | `string` (ISO 8601)     | Inclusive lower bound on `EventLog.timestamp`. Date-only values (e.g. `"2018-07-01"`) are localized to start-of-day in `timezone` before converting to UTC.                                                                                                                         |
| `date_to`    | No       | `string` (ISO 8601)     | Inclusive upper bound on `EventLog.timestamp`. Date-only values are treated as end-of-day in `timezone`.                                                                                                                                                                            |
| `timezone`   | No       | `string` (IANA)         | Timezone for resolving date-only `date_from` / `date_to` (default: `"America/New_York"`). Full ISO timestamps with a time component are honored verbatim.                                                                                                                           |
| `limit`      | No       | `integer`               | Maximum number of logs to return (max 200, default: `50`)                                                                                                                                                                                                                           |
| `sort`       | No       | `"desc"` or `"asc"`     | Timestamp sort order (default: `"desc"`, newest first; use `"asc"` when scanning from the start of an observation window).                                                                                                                                                          |
| `log_types`  | No       | `array`                 | Optional list of `EventLog.type` values to filter by                                                                                                                                                                                                                                |
| `trace_type` | No       | `string`                | Filter by `trace.object_type` (e.g. `"check_in_response"`)                                                                                                                                                                                                                          |
| `trace_id`   | No       | `string`                | Filter by `trace.object_id` (opaque id string)                                                                                                                                                                                                                                      |
| `query`      | No       | `string` (JMESPath)     | JMESPath expression applied server-side to the serialized logs array. The expression root is the list of log entries. List results replace `logs`; non-list results (e.g. `length([])`) appear under `result`. Use to project only the payload fields you need; see examples below. |
| `format`     | No       | `"raw"` or `"markdown"` | Output format (default: `raw`). `"pretty"` is accepted as a deprecated alias for `"markdown"`.                                                                                                                                                                                      |

## `query` examples

```text theme={null}
# Extract only the Chief Complaint section from clinical notes (drops Medications / HPI / Social History)
[*].{timestamp: timestamp, complaint: payload.sections[?section_label == 'Chief Complaint'] | [0].content}

# Filter to notes and extract Assessment And Plan only
[?type == 'clinical_note'].{timestamp: timestamp, plan: payload.sections[?section_label == 'Assessment And Plan'] | [0].content}

# Project the first lab result per entry
[*].{timestamp: timestamp, test_name: payload.results[0].test_name, value: payload.results[0].value_numeric, unit: payload.results[0].unit}

# Count procedures by name (case-insensitive; see note below)
length([?icontains(payload.procedure_name, 'chemotherapy')])
```

<Tip>
  `clinical_note` payloads include Medications, History Of Present
  Illness, and Social History sections that are typically 200–700 characters
  each and nearly identical across notes. Always pass a `query` that projects
  only the sections you need when fetching clinical notes; this can reduce
  response size by 80–95%.
</Tip>

<Note>
  **Case-insensitive matching:** the built-in JMESPath `contains()` is
  **case-sensitive**. Because clinical entity names are typically Title-Case
  (e.g. `"Chemotherapy (procedure)"`), the server also provides three custom
  functions in `query` expressions: `lower(str)`, `upper(str)`, and
  `icontains(haystack, needle)`: a case-insensitive, null-safe substring test.
  Prefer `icontains(field, 'value')` (or `contains(lower(field), 'value')`) for
  any name/text filter. These functions are available on both `get_logs` and
  [`get_view_block`](/mcp-server/tools/get-view-block) queries.
</Note>

## Example output

Illustrative: `format: raw` returns structured records in the `logs` array; a `query` replaces `logs` with the projected result.

```json theme={null}
{
  "count": 1,
  "logs": [
    {
      "type": "symptom_report",
      "timestamp": "2026-03-18T09:00:00Z",
      "payload": {
        "instrument": "esas_r",
        "symptoms": [{ "name": "fatigue", "score": 6 }]
      }
    }
  ]
}
```
