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

# OutputSchema

> Define the shape of each Smart Template field's output

`OutputSchema` is a recursive JSON-Schema-like structure that describes what each field should return. Every schema **requires** an `instructions` field — that's how the model knows what to extract for this slot.

<Note>
  This page describes the **authoring** format you send when you create a template. When you read a
  template back with `GET /v1/medical-record-configurations/{id}`, each `object` schema returns its
  `properties` as an ordered array of `{ "key": ..., "schema": ... }` entries — not the map form
  shown here. The content is identical; only the serialization differs.
</Note>

## Types

These are the **only** keywords the API persists. Anything else is silently dropped — see [Not supported](#not-supported).

| Type                 | Required                                 | Optional                                                          |
| -------------------- | ---------------------------------------- | ----------------------------------------------------------------- |
| `string`             | `instructions`                           | `enum`, `format`, `minLength`, `maxLength`, `required`, `default` |
| `number` / `integer` | `instructions`                           | `minimum`, `maximum`, `enum`, `required`, `default`               |
| `boolean`            | `instructions`                           | `required`, `default`                                             |
| `object`             | `instructions`, `properties` (recursive) | `required`                                                        |
| `array`              | `instructions`, `items` (recursive)      | `required`                                                        |

Supported `format` values for `string`: `date-time`, `date`, `time`, `duration`, `email`, `uuid`, `ipv4`, `ipv6`. A `string` with `format` of `date`, `time`, or `date-time` is returned as an ISO 8601 value.

## Required and default

* `required` (boolean, defaults to `true`) — when `false`, the field is optional: the model may return `null` for it.
* `default` (leaf fields only) — substituted when the model extracts nothing (returns `null`). Its type must match the field `type`; for an `enum` field it must be one of the enum values.

**Interaction:** `default` only takes effect when `required` is `false`. A `required: true` field is always generated, so its `default` never fires. Set `required: false` together with `default` to guarantee a fallback value when the encounter doesn't mention the field.

## Not supported

The following JSON-Schema keywords are **accepted by the request parser but silently dropped** — they never persist and never affect generation. Don't rely on them.

| Keyword                                                         | Use instead                                                                       |
| --------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `anyOf`, `oneOf`, `allOf`, `not`                                | An optional field: `required: false` (the model may return `null`)                |
| `if` / `then` / `else`, `dependentRequired`, `dependentSchemas` | No conditional logic. Branching belongs in the RPA layer, not in a Smart Template |
| `const`                                                         | `enum` with a single `{ label, value }`                                           |
| `pattern`, `examples`, `template`                               | Describe the format in `instructions`                                             |
| `exclusiveMinimum`, `exclusiveMaximum`                          | `minimum` / `maximum`                                                             |
| `minItems`, `maxItems`                                          | — (no array-length bound)                                                         |

## Enum options

`enum` (on `string` fields, including the `items` of a multi-select `array`) accepts two forms:

* **Plain strings** — the displayed text *is* the stored value: `"enum": ["Low", "Medium", "High"]`.
* **`{ label, value }` objects** — decouple display from storage: show `label`, store `value` (a stable code such as a catalog id, ICD-10, or SNOMED). Generation returns the **`value`**; the `label` is for display only, so labels can be renamed or translated without changing what your integration receives.

`value` must be unique within a field. The two forms can be mixed in one list (a plain string is treated as `label == value`).

```jsonc theme={null}
{
  "type": "string",
  "instructions": "Visit type",
  "enum": [
    { "label": "First visit", "value": "FIRST_VISIT" },
    { "label": "Follow-up",   "value": "FOLLOW_UP" }
  ]
}
// generated record stores "FIRST_VISIT" / "FOLLOW_UP"
```

## Limits

| Limit                                    | Value   |
| ---------------------------------------- | ------- |
| Max nesting depth                        | 10      |
| Max total properties                     | 5,000   |
| Max chars (names + enum values combined) | 120,000 |
| Max enum values across all properties    | 1,000   |

## Example — object section

```jsonc theme={null}
{
  "type": "object",
  "instructions": "Patient vitals",
  "properties": {
    "bloodPressure": {
      "type": "string",
      "instructions": "Systolic/diastolic in mmHg, e.g. 120/80",
      "maxLength": 7
    },
    "heartRate": {
      "type": "integer",
      "instructions": "Beats per minute",
      "minimum": 20,
      "maximum": 300
    }
  }
}
```

## Example — optional field with default

```jsonc theme={null}
{
  "type": "object",
  "instructions": "Symptoms",
  "properties": {
    "fever": {
      "type": "number",
      "instructions": "Maximum measured temperature in °C",
      "minimum": 30,
      "maximum": 45,
      "required": false,
      "default": 37
    }
  }
}
```

## Example — array of structured items

```jsonc theme={null}
{
  "type": "array",
  "instructions": "List of medications mentioned",
  "items": {
    "type": "object",
    "instructions": "One medication entry",
    "properties": {
      "name": { "type": "string", "instructions": "Generic or brand name" },
      "dose": { "type": "string", "instructions": "Dose with unit, e.g. 500 mg" }
    }
  }
}
```
