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

# Extract and write to EHR

> Build schema tools that turn a clinical fact into a coded record, a documentation suggestion the clinician confirms before it is saved.

The clinician states a clinical fact: a symptom, a vital, an allergy, a diagnosis. The agent turns it into a structured record, a documentation suggestion that is not saved until the clinician confirms. Each clinical family has its own schema tool, and the agent picks the one matching the fact.

![Extract flow: the clinician states a clinical fact, the agent classifies it, codes the concepts, and emits a structured suggestion. The clinician confirms before it is saved.](https://mintcdn.com/corti/OdqulwjO6Fo6Jlod/images/recipes-extract-light.svg?fit=max\&auto=format\&n=OdqulwjO6Fo6Jlod\&q=85\&s=604c90e8236a001b9115eeec29f62ab8)

A clinical fact becomes a structured suggestion. The clinician confirms before it is saved.

## Before you start

* [How a recipe works](https://docs.corti.ai/agentic/cookbook/overview#how-a-recipe-works) explains the split between the agent, the system prompt, and your application.
* [Connectors](https://docs.corti.ai/agentic/connectors.md) defines the `schema` connector type and the `transition` field.
* [Create and configure an agent](https://docs.corti.ai/agentic/guides/create-agent.md) shows how to create an agent with connectors and a system prompt.

## Build a schema tool

Each step adds one part of a schema tool. The example is an allergy: the clinician says "Allergic to penicillin, hives." and the agent emits a coded allergy record for the clinician to confirm.

### 1. Start from the connector body

A schema tool is a request body you post. It is a schema-tool create body (`CommonSchemaConnectorCreate` in the v2 API) with five fields:

```json theme={null}
{
  "type": "schema",
  "name": "tool_name",
  "description": "What this tool does and when to use it.",
  "schema": {
    "type": "object",
    "additionalProperties": false,
    "properties": {}
  },
  "transition": "input_required"
}
```

* `type` is always `"schema"`. It tells the framework this connector is a tool you define.
* `name` is how the agent and your system prompt refer to the tool.
* `description` is prose the model reads to decide when and how to call the tool.
* `schema` is plain JSON Schema, the same shape tool definitions use across the LLM ecosystem. It is the complete contract for what the agent may emit.
* `transition` is the agent's exit state after it calls the tool.

The next steps fill in each field, using the allergy example.

### 2. Name the tool and write its description

Name the tool after the one thing it emits, and put the tool's rules in the `description`. The model reads this string every time it decides whether to call the tool, so rules written here travel with the tool to every agent that uses it.

```json theme={null}
"name": "extract_allergy",
"description": "Extract an allergy or intolerance from free text or dictation. Resolve the allergen (code) and each reaction manifestation to SNOMED CT concepts using the coding connector. Fill onsetDateTime or onsetAge only with an exact date or age the clinician said, put anything relative or vague in onsetString, and never calculate a date. Emit one suggestion per invocation. Nothing is saved until the clinician confirms."
```

Each sentence carries one rule: what input the tool takes, how to code concepts, how to record onset, how many records per call, and that the output is a suggestion.

### 3. Close the object and mark what is required

The top level of `schema` is an object with `additionalProperties: false`. The agent can then emit only the fields you defined, nothing invented. `required` lists the fields every suggestion must carry. Fields not in `required`, such as `criticality`, are filled only when the clinician says them.

```json theme={null}
"schema": {
  "type": "object",
  "additionalProperties": false,
  "required": ["resourceType", "text", "code", "type", "clinicalStatus", "verificationStatus"],
  "properties": { ... }
}
```

Give the record a `resourceType` field that can hold only one value. A `const` allows exactly one value, so every record this tool emits carries `"resourceType": "AllergyIntolerance"`. The client reads that field to know what kind of record it received, for example to choose which write API to call. The field sits in `properties` next to the other fields:

```json theme={null}
"properties": {
  "resourceType": { "const": "AllergyIntolerance" },
  ...
}
```

`text` is the record's short summary in plain words, such as "Penicillin allergy".

### 4. Model the coded concepts

The allergen and each reaction's manifestation are coded concepts. The allergen field is named `code`, and it holds four fields:

* `system` names the terminology the code belongs to, as a URI. `http://snomed.info/sct` is SNOMED CT.
* `code` is the identifier in that terminology, so the allergen's identifier sits at `code.code`.
* `display` is the code's human label.
* `text` keeps what the clinician said, for when the code is less precise than their words.

```json theme={null}
"code": {
  "type": "object",
  "additionalProperties": false,
  "required": ["display"],
  "properties": {
    "system": { "const": "http://snomed.info/sct" },
    "code": { "type": "string" },
    "display": { "type": "string" },
    "text": { "type": "string" }
  }
}
```

Only `display` is required. That is deliberate: the agent can always record what the clinician said, even when no code resolves, and your apply-step decides what to do with an uncoded concept. `system` is a `const` here because the coding connector resolves SNOMED CT. Widen it to an `enum` if your EHR uses more than one terminology.

`reaction` is an array. Each reaction holds a `manifestation` array of the same coded-concept object, with at least one item, and an optional `severity`.

### 5. Constrain values with enums

Wherever a field accepts a fixed set of values, use an `enum`. The agent then picks from that set instead of writing free text that your apply-step has to interpret.

```json theme={null}
"type": { "enum": ["allergy", "intolerance"] },
"criticality": { "enum": ["low", "high", "unable-to-assess"] },
"clinicalStatus": { "enum": ["active", "inactive", "resolved"] },
"verificationStatus": { "enum": ["unconfirmed", "confirmed", "refuted"] }
```

`clinicalStatus` is whether the allergy is current, and `verificationStatus` is how certain it is. `criticality` is the risk of a future severe reaction. How severe a past reaction was goes in that reaction's `severity` (`mild`, `moderate`, or `severe`), so "mild rash as a child, anaphylaxis last year" keeps both. If the clinician calls an allergy severe or life-threatening without naming a reaction, the agent sets `criticality` to `high`.

### 6. Choose the transition

`transition` is the agent's exit state after it calls the tool:

* `complete`: the agent is done. Extract uses this because the suggestion is the whole result.
* `input_required`: the agent yields and waits for the client to send something back, such as the EHR data in [Retrieve patient data](https://docs.corti.ai/agentic/cookbook/retrieve.md).

```json theme={null}
"transition": "complete"
```

The framework enforces both the schema and the `transition`.

### 7. Attach it with the coding connector

Coding a concept needs a coding tool, so attach the `coding-expert` registry connector in the same `connectors` array as the schema tool. See [Medical Coding](https://docs.corti.ai/agentic/registry/medical-coding.md).

```json theme={null}
{
  "connectors": [
    { "type": "schema", "name": "extract_allergy", "...": "the full body below" },
    { "type": "registry", "name": "coding-expert" }
  ]
}
```

Include the connectors when you create the agent, as shown in [Create and configure an agent](https://docs.corti.ai/agentic/guides/create-agent.md), or POST them to the connector sub-resource, as shown in [Manage connectors](https://docs.corti.ai/agentic/guides/manage-connectors.md).

### The full body

```json expandable theme={null}
{
  "type": "schema",
  "name": "extract_allergy",
  "description": "Extract an allergy or intolerance from free text or dictation. Resolve the allergen (code) and each reaction manifestation to SNOMED CT concepts using the coding connector. Fill onsetDateTime or onsetAge only with an exact date or age the clinician said, put anything relative or vague in onsetString, and never calculate a date. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
  "schema": {
    "type": "object",
    "additionalProperties": false,
    "required": ["resourceType", "text", "code", "type", "clinicalStatus", "verificationStatus"],
    "properties": {
      "resourceType": { "const": "AllergyIntolerance" },
      "text": { "type": "string", "description": "A short summary of the record in plain words." },
      "code": {
        "type": "object", "additionalProperties": false,
        "required": ["display"],
        "properties": {
          "system": { "const": "http://snomed.info/sct" },
          "code": { "type": "string" },
          "display": { "type": "string" },
          "text": { "type": "string", "description": "What the clinician said, when the code is less precise." }
        }
      },
      "type": { "enum": ["allergy", "intolerance"] },
      "category": {
        "type": "array",
        "items": { "enum": ["food", "medication", "environment", "biologic"] }
      },
      "criticality": {
        "enum": ["low", "high", "unable-to-assess"],
        "description": "Risk of a future severe reaction. Set high when the clinician calls the allergy severe or life-threatening without naming a reaction."
      },
      "clinicalStatus": { "enum": ["active", "inactive", "resolved"] },
      "verificationStatus": { "enum": ["unconfirmed", "confirmed", "refuted"] },
      "reaction": {
        "type": "array",
        "items": {
          "type": "object", "additionalProperties": false,
          "required": ["manifestation"],
          "properties": {
            "manifestation": {
              "type": "array", "minItems": 1,
              "items": {
                "type": "object", "additionalProperties": false,
                "required": ["display"],
                "properties": {
                  "system": { "const": "http://snomed.info/sct" },
                  "code": { "type": "string" },
                  "display": { "type": "string" },
                  "text": { "type": "string", "description": "What the clinician said, when the code is less precise." }
                }
              }
            },
            "severity": { "enum": ["mild", "moderate", "severe"] }
          }
        }
      },
      "asserter": {
        "enum": ["patient", "related-person", "practitioner"],
        "description": "Who stated the allergy. The client resolves it to a reference."
      },
      "onsetDateTime": {
        "type": "string",
        "description": "Only an exact date the clinician said, such as 2024, 2024-03, or 2024-03-15. Never calculate a date. Set at most one onset field."
      },
      "onsetAge": {
        "type": "object", "additionalProperties": false,
        "required": ["value", "unit"],
        "description": "Only an exact age the clinician said. Set at most one onset field.",
        "properties": {
          "value": { "type": "number" },
          "unit": { "enum": ["a", "mo", "wk", "d"], "description": "a is years, mo is months, wk is weeks, d is days." }
        }
      },
      "onsetString": {
        "type": "string",
        "description": "A relative or vague onset in the clinician's words, such as \"three years ago\". Set at most one onset field."
      },
      "note": { "type": "string" }
    }
  },
  "transition": "complete"
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| `resourceType` | const `AllergyIntolerance` | yes | The kind of record |
| `text` | string | yes | A short summary of the record in plain words |
| `code` | object | yes | The coded allergen. Within it, only `display` is required, and `system`, `code`, and `text` are optional |
| `type` | enum | yes | `allergy` or `intolerance` |
| `category` | array of enum | no | `food`, `medication`, `environment`, `biologic` |
| `criticality` | enum | no | The risk of a future severe reaction: `low`, `high`, `unable-to-assess` |
| `clinicalStatus` | enum | yes | `active`, `inactive`, `resolved` |
| `verificationStatus` | enum | yes | `unconfirmed`, `confirmed`, `refuted` |
| `reaction` | array | no | Each item holds `manifestation` (at least one coded concept, required) and an optional `severity`: `mild`, `moderate`, `severe` |
| `asserter` | enum | no | Who stated the allergy: `patient`, `related-person` (such as a family member), or `practitioner`. The client resolves it to a reference to the person |
| `onsetDateTime` | string | no | An exact onset date the clinician said. Partial dates such as `2024` or `2024-03` are allowed |
| `onsetAge` | object | no | An exact onset age the clinician said: `value` and `unit` (`a` years, `mo` months, `wk` weeks, `d` days) |
| `onsetString` | string | no | A relative or vague onset in the clinician's words |
| `note` | string | no | Anything else the clinician said about the allergy |

The agent sets at most one of the three onset fields. Only an exact date or age the clinician said goes into `onsetDateTime` or `onsetAge`. Anything relative or vague, such as "three years ago" or "in her forties", stays in `onsetString` in the clinician's words. The agent never calculates a date.

## Point the system prompt at the tools

The schema tools define what the agent can emit. The system prompt routes each request to the right tool. For extract, the hardest routing decision is the family: the agent must pick one of the family tools, not emit a mix. A minimal prompt only needs the routing:

```text theme={null}
Role: turn clinician-stated clinical facts into structured record suggestions, for clinicians.

You have one tool per clinical family: extract_allergy, extract_diagnosis, extract_observations, and so on. Each ends the run when called.

Route each request to exactly one tool:
- states a clinical fact        -> that fact's family tool
- asks about this patient       -> (outside this agent, see the retrieve flow)
- unclear                       -> ask one question, then stop
```

Add [the rules every flow shares](https://docs.corti.ai/agentic/cookbook/overview#write-the-system-prompt) to this prompt. Extract is the flow likeliest to break the last of them, "Never report a record as saved". With `transition: complete`, the agent's output looks finished to a client that is not watching for the seam, so the prompt must keep "suggestion" distinct from "saved". If suggestions go straight into the record, check that the client treats an `extract_` call as a proposal, not a write, before adding prompt rules. For more on writing a `systemPrompt`, see [Create and configure an agent](https://docs.corti.ai/agentic/guides/create-agent.md).

## Run it

The agent handles a stated fact in one response: it classifies the family, codes the concepts, and emits the record. The system prompt and the tool descriptions produce this sequence.

### 1. Clinician states a fact

"Allergic to penicillin, hives."

### 2. Classify the family

The agent routes the fact to `extract_allergy`.

### 3. Code the concepts

The agent uses `coding-expert` to resolve the allergen and the reaction to coded concepts.

### 4. Emit the structured record

The agent calls `extract_allergy` and ends in `complete`. The record is pending confirmation, not yet saved.

The agent emits this suggestion. "Hives" resolves to the SNOMED CT concept whose preferred term is "Wheal": `display` records the concept, not the clinician's phrasing. `code.text` stays empty because the code is as precise as what the clinician said.

```json theme={null}
{
  "resourceType": "AllergyIntolerance",
  "text": "Penicillin allergy",
  "code": { "system": "http://snomed.info/sct", "code": "764146007", "display": "Penicillin" },
  "type": "allergy",
  "category": ["medication"],
  "clinicalStatus": "active",
  "verificationStatus": "confirmed",
  "reaction": [
    {
      "manifestation": [
        { "system": "http://snomed.info/sct", "code": "247472004", "display": "Wheal" }
      ]
    }
  ]
}
```

Nothing is saved yet. The client shows the suggestion, and when the clinician confirms, it adds the patient reference and anything else your EHR needs, then writes the record through your EHR's write API. The schema's contract is a coded concept (`system`, `code`, `display`, `text`), not a particular code system, so you can swap the coding connector or the terminology.

## The other families

Allergy is one of seven families, and they fall into three shapes, so do not assume one schema fits all of them. Each family is its own schema tool, built with the same parts as allergy. Build one schema per family. The fields shown are the minimum we recommend, but your EHR may need more.

| Family | Shape | `resourceType` | Coded-concept fields | Needs coding? |
| - | - | - | - | - |
| Allergy | Flat object | `const: AllergyIntolerance` | `code`, `reaction[].manifestation` | yes |
| Diagnosis / finding | Flat object | `const: Condition` | `code`, `bodySite` | yes |
| Family history | Flat object | `const: FamilyMemberHistory` | `condition[].code` | yes |
| Pregnancy or breastfeeding | Array wrapper `{items[]}` | none | `code` per item, from a fixed LOINC list | no |
| Observations and vital signs | Array wrapper `{language, items[]}` | none | `code` per item | yes |
| Tasks | Array wrapper `{language, items[]}` | none | none | no |
| Clinical notes | Notes wrapper `{notes[]}` | none | none | no |

The wrapper families carry no `resourceType`, because every item a wrapper tool emits is the same kind of record.

> [accordion] Diagnosis / finding
>
> Flat object, `resourceType` is `const: Condition`. The coded-concept fields are `code` and `bodySite[]`. Whether the record is a diagnosis or a finding is carried by the SNOMED CT code itself, so the schema needs no field for it.
>
> * `category` says where the record belongs: `problem-list-item` (the patient's ongoing problem list) or `encounter-diagnosis` (a diagnosis for this visit).
> * `clinicalStatus` adds `recurrence`, `relapse`, and `remission` to the allergy set, and `verificationStatus` adds `provisional` and `differential`.
> * The side of the body goes into the body-site code, such as a SNOMED CT concept for the left knee. When the code is less precise, its `text` keeps what the clinician said, such as "left knee".
> * `use`\* marks a chief complaint (`CC`) or an admission diagnosis (`AD`). The client copies it onto the visit record.
> * `severity` is a SNOMED CT concept limited to Severe, Moderate, and Mild, and is left out when the clinician gives none.
> * Onset follows the same exact-or-text rule as allergy. `abatementDateTime`, `abatementAge`, and `abatementString` record when the condition ended, follow the same rule, and apply only when `clinicalStatus` is `resolved`, `inactive`, or `remission`.
>
> \* Differs slightly from [FHIR R4](https://docs.corti.ai/agentic/cookbook/overview#based-on-fhir-r4), where a simpler field is easier for the agent to fill.
>
> ```json expandable theme={null}
> {
>   "type": "schema",
>   "name": "extract_diagnosis",
>   "description": "Extract a diagnosis, finding, or condition from free text or dictation. Resolve the condition (code) and each body site to SNOMED CT concepts using the coding connector, coding the side of the body into the body-site concept. Fill onsetDateTime, onsetAge, abatementDateTime, and abatementAge only with an exact date or age the clinician said, put anything relative or vague in onsetString or abatementString, and never calculate a date. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
>   "schema": {
>     "type": "object",
>     "additionalProperties": false,
>     "required": ["resourceType", "text", "code", "clinicalStatus", "verificationStatus"],
>     "properties": {
>       "resourceType": { "const": "Condition" },
>       "text": { "type": "string", "description": "A short summary of the record in plain words." },
>       "code": {
>         "type": "object", "additionalProperties": false,
>         "required": ["display"],
>         "properties": {
>           "system": { "const": "http://snomed.info/sct" },
>           "code": { "type": "string" },
>           "display": { "type": "string" },
>           "text": { "type": "string", "description": "What the clinician said, when the code is less precise." }
>         }
>       },
>       "category": {
>         "type": "array",
>         "items": { "enum": ["problem-list-item", "encounter-diagnosis"] }
>       },
>       "clinicalStatus": { "enum": ["active", "recurrence", "relapse", "inactive", "remission", "resolved"] },
>       "verificationStatus": { "enum": ["unconfirmed", "provisional", "differential", "confirmed", "refuted"] },
>       "severity": {
>         "type": "object", "additionalProperties": false,
>         "required": ["system", "code", "display"],
>         "description": "24484000 is Severe, 6736007 is Moderate, 255604002 is Mild. Leave out when the clinician gives no severity.",
>         "properties": {
>           "system": { "const": "http://snomed.info/sct" },
>           "code": { "enum": ["24484000", "6736007", "255604002"] },
>           "display": { "enum": ["Severe", "Moderate", "Mild"] }
>         }
>       },
>       "bodySite": {
>         "type": "array",
>         "items": {
>           "type": "object", "additionalProperties": false,
>           "required": ["display"],
>           "properties": {
>             "system": { "const": "http://snomed.info/sct" },
>             "code": { "type": "string" },
>             "display": { "type": "string" },
>             "text": { "type": "string", "description": "What the clinician said, such as \"left knee\", when the code is less precise." }
>           }
>         }
>       },
>       "use": {
>         "type": "array",
>         "items": { "enum": ["CC", "AD"] },
>         "description": "CC is the chief complaint, AD is an admission diagnosis. The client copies it onto the Encounter."
>       },
>       "asserter": {
>         "enum": ["patient", "related-person", "practitioner"],
>         "description": "Who stated the condition. The client resolves it to a reference."
>       },
>       "onsetDateTime": {
>         "type": "string",
>         "description": "Only an exact date the clinician said, such as 2024, 2024-03, or 2024-03-15. Never calculate a date. Set at most one onset field."
>       },
>       "onsetAge": {
>         "type": "object", "additionalProperties": false,
>         "required": ["value", "unit"],
>         "description": "Only an exact age the clinician said. Set at most one onset field.",
>         "properties": {
>           "value": { "type": "number" },
>           "unit": { "enum": ["a", "mo", "wk", "d"], "description": "a is years, mo is months, wk is weeks, d is days." }
>         }
>       },
>       "onsetString": {
>         "type": "string",
>         "description": "A relative or vague onset in the clinician's words, such as \"in her forties\". Set at most one onset field."
>       },
>       "abatementDateTime": {
>         "type": "string",
>         "description": "When the condition ended, only as an exact date the clinician said. Only when clinicalStatus is resolved, inactive, or remission. Set at most one abatement field."
>       },
>       "abatementAge": {
>         "type": "object", "additionalProperties": false,
>         "required": ["value", "unit"],
>         "description": "When the condition ended, only as an exact age the clinician said. Only when clinicalStatus is resolved, inactive, or remission. Set at most one abatement field.",
>         "properties": {
>           "value": { "type": "number" },
>           "unit": { "enum": ["a", "mo", "wk", "d"], "description": "a is years, mo is months, wk is weeks, d is days." }
>         }
>       },
>       "abatementString": {
>         "type": "string",
>         "description": "When the condition ended, relative or vague, in the clinician's words. Only when clinicalStatus is resolved, inactive, or remission. Set at most one abatement field."
>       },
>       "note": { "type": "string" }
>     }
>   },
>   "transition": "complete"
> }
> ```

> [accordion] Family history
>
> Flat object, `resourceType` is `const: FamilyMemberHistory`. One record describes one relative, and that relative's conditions go in `condition[]`. Each condition has a coded `code`, an optional `contributedToDeath`, and an onset as `onsetAge` or `onsetString`, following the same exact-or-text rule as allergy.
>
> * `relationship` takes standard family-member codes, such as `MTH` (mother), `FTH` (father), `MGRMTH` (maternal grandmother), and `HSIS` (half-sister). `FAMMEMB` (family member) covers a relative no closer code fits.
> * `name` tells apart two relatives with the same relationship, such as two sisters.
> * `deceasedBoolean` or `deceasedAge` records that the relative has died, at most one of them.
> * `dataAbsentReason` records why the history is missing, such as `subject-unknown` when the patient is adopted and the family history is unknown.
> * `verificationStatus`\* records doubt, such as "not sure if dad had diabetes".
> * Family history has no `clinicalStatus` and no `asserter`.
>
> \* Differs slightly from [FHIR R4](https://docs.corti.ai/agentic/cookbook/overview#based-on-fhir-r4), where a simpler field is easier for the agent to fill.
>
> ```json expandable theme={null}
> {
>   "type": "schema",
>   "name": "extract_family_history",
>   "description": "Extract one relative's family history from free text or dictation. Resolve each condition to a SNOMED CT concept using the coding connector. Fill onsetAge only with an exact age the clinician said, put anything relative or vague in onsetString, and never calculate an age. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
>   "schema": {
>     "type": "object",
>     "additionalProperties": false,
>     "required": ["resourceType", "text", "relationship", "verificationStatus"],
>     "properties": {
>       "resourceType": { "const": "FamilyMemberHistory" },
>       "text": { "type": "string", "description": "A short summary of the record in plain words." },
>       "relationship": {
>         "enum": ["MTH", "FTH", "SIS", "BRO", "HSIS", "HBRO", "SON", "DAU", "CHILD", "MGRMTH", "MGRFTH", "PGRMTH", "PGRFTH", "AUNT", "UNCLE", "COUSN", "NIECE", "NEPHEW", "FAMMEMB"],
>         "description": "HL7 family-member code. Use FAMMEMB when no closer code fits."
>       },
>       "name": { "type": "string", "description": "The relative's name, to tell apart two relatives with the same relationship." },
>       "deceasedBoolean": { "type": "boolean", "description": "Set at most one of deceasedBoolean and deceasedAge." },
>       "deceasedAge": {
>         "type": "object", "additionalProperties": false,
>         "required": ["value", "unit"],
>         "description": "The relative's age at death, only as an exact age the clinician said. Set at most one of deceasedBoolean and deceasedAge.",
>         "properties": {
>           "value": { "type": "number" },
>           "unit": { "enum": ["a", "mo", "wk", "d"], "description": "a is years, mo is months, wk is weeks, d is days." }
>         }
>       },
>       "verificationStatus": { "enum": ["unconfirmed", "confirmed", "refuted"] },
>       "dataAbsentReason": {
>         "enum": ["subject-unknown", "withheld", "unable-to-obtain", "deferred"],
>         "description": "Why the family history is missing, such as subject-unknown when the patient is adopted."
>       },
>       "condition": {
>         "type": "array", "minItems": 1,
>         "items": {
>           "type": "object", "additionalProperties": false,
>           "required": ["code"],
>           "properties": {
>             "code": {
>               "type": "object", "additionalProperties": false,
>               "required": ["display"],
>               "properties": {
>                 "system": { "const": "http://snomed.info/sct" },
>                 "code": { "type": "string" },
>                 "display": { "type": "string" },
>                 "text": { "type": "string", "description": "What the clinician said, when the code is less precise." }
>               }
>             },
>             "contributedToDeath": { "type": "boolean" },
>             "onsetAge": {
>               "type": "object", "additionalProperties": false,
>               "required": ["value", "unit"],
>               "description": "Only an exact age the clinician said. Set at most one onset field.",
>               "properties": {
>                 "value": { "type": "number" },
>                 "unit": { "enum": ["a", "mo", "wk", "d"], "description": "a is years, mo is months, wk is weeks, d is days." }
>               }
>             },
>             "onsetString": {
>               "type": "string",
>               "description": "A relative or vague onset in the clinician's words, such as \"in his fifties\". Set at most one onset field."
>             }
>           }
>         }
>       },
>       "note": { "type": "string" }
>     }
>   },
>   "transition": "complete"
> }
> ```

> [accordion] Pregnancy or breastfeeding
>
> Each pregnancy or breastfeeding fact is one item, identified by a fixed LOINC code. The tool emits `items[]`, one item per fact, and each item takes exactly one value field:
>
> | LOINC code | Display | Value field |
> | - | - | - |
> | `82810-3` | Pregnancy status | `valueCodeableConcept`: Pregnant, Not pregnant, or Unknown |
> | `63895-7` | Breastfeeding status | `valueCodeableConcept`: Currently breastfeeding, Not currently breastfeeding, Exclusively breastfeeding, or Supplementing |
> | `8665-2` | Last menstrual period start date | `valueDateTime` for an exact date, `valueString` for a vague one |
> | `11778-8` | Delivery date Estimated | `valueDateTime` for an exact date, `valueString` for a vague one |
> | `11996-6` | \[#] Pregnancies | `valueInteger`: the gravida count |
> | `11977-6` | \[#] Parity | `valueInteger`: the parity count |
>
> The two status answers are LOINC answer codes, so the tool needs no coding connector. `verificationStatus`\* applies only to the two status items. `performer` records who stated the fact, with the same values as `asserter` on allergy. A pregnancy or labor admission is a Condition with `use: ["AD"]`, extracted with `extract_diagnosis`.
>
> \* Differs slightly from [FHIR R4](https://docs.corti.ai/agentic/cookbook/overview#based-on-fhir-r4), where a simpler field is easier for the agent to fill.
>
> For "She's 8 weeks pregnant, second pregnancy, one previous birth, LMP was 1 October 2026", the agent emits four items. It does not calculate an estimated delivery date.
>
> ```json theme={null}
> {
>   "items": [
>     {
>       "code": { "system": "http://loinc.org", "code": "82810-3", "display": "Pregnancy status" },
>       "valueCodeableConcept": { "system": "http://loinc.org", "code": "LA15173-0", "display": "Pregnant" },
>       "verificationStatus": "confirmed",
>       "note": "8 weeks pregnant"
>     },
>     {
>       "code": { "system": "http://loinc.org", "code": "11996-6", "display": "[#] Pregnancies" },
>       "valueInteger": 2
>     },
>     {
>       "code": { "system": "http://loinc.org", "code": "11977-6", "display": "[#] Parity" },
>       "valueInteger": 1
>     },
>     {
>       "code": { "system": "http://loinc.org", "code": "8665-2", "display": "Last menstrual period start date" },
>       "valueDateTime": "2026-10-01"
>     }
>   ]
> }
> ```
>
> ```json expandable theme={null}
> {
>   "type": "schema",
>   "name": "extract_pregnancy_breastfeeding",
>   "description": "Extract pregnancy and breastfeeding facts from free text or dictation, one item per fact. Give each item exactly one value field: valueCodeableConcept for the two status items, valueDateTime or valueString for the two dates, valueInteger for the two counts. Put a date in valueDateTime only when the clinician said it exactly, put anything relative or vague in valueString, and never calculate a date such as an estimated delivery date. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
>   "schema": {
>     "type": "object",
>     "additionalProperties": false,
>     "required": ["items"],
>     "properties": {
>       "items": {
>         "type": "array", "minItems": 1,
>         "items": {
>           "type": "object", "additionalProperties": false,
>           "required": ["code"],
>           "properties": {
>             "code": {
>               "type": "object", "additionalProperties": false,
>               "required": ["system", "code", "display"],
>               "description": "82810-3 Pregnancy status, 63895-7 Breastfeeding status, 8665-2 Last menstrual period start date, 11778-8 Delivery date Estimated, 11996-6 [#] Pregnancies (gravida), 11977-6 [#] Parity.",
>               "properties": {
>                 "system": { "const": "http://loinc.org" },
>                 "code": { "enum": ["82810-3", "63895-7", "8665-2", "11778-8", "11996-6", "11977-6"] },
>                 "display": { "enum": ["Pregnancy status", "Breastfeeding status", "Last menstrual period start date", "Delivery date Estimated", "[#] Pregnancies", "[#] Parity"] }
>               }
>             },
>             "valueCodeableConcept": {
>               "type": "object", "additionalProperties": false,
>               "required": ["system", "code", "display"],
>               "description": "Only for 82810-3 and 63895-7. Pregnancy status: LA15173-0 Pregnant, LA26683-5 Not pregnant, LA4489-6 Unknown. Breastfeeding status: LA29252-6 Currently breastfeeding, LA29253-4 Not currently breastfeeding, LA29254-2 Exclusively breastfeeding, LA29255-9 Supplementing.",
>               "properties": {
>                 "system": { "const": "http://loinc.org" },
>                 "code": { "enum": ["LA15173-0", "LA26683-5", "LA4489-6", "LA29252-6", "LA29253-4", "LA29254-2", "LA29255-9"] },
>                 "display": { "enum": ["Pregnant", "Not pregnant", "Unknown", "Currently breastfeeding", "Not currently breastfeeding", "Exclusively breastfeeding", "Supplementing"] }
>               }
>             },
>             "valueDateTime": { "type": "string", "description": "Only for 8665-2 and 11778-8, and only a date the clinician said exactly, such as 2026-10-01." },
>             "valueInteger": { "type": "integer", "description": "Only for 11996-6 and 11977-6." },
>             "valueString": { "type": "string", "description": "Only for 8665-2 and 11778-8: a relative or vague date in the clinician's words." },
>             "verificationStatus": { "enum": ["unconfirmed", "confirmed", "refuted"], "description": "Only for 82810-3 and 63895-7." },
>             "performer": {
>               "enum": ["patient", "related-person", "practitioner"],
>               "description": "Who stated the fact. The client resolves it to a reference."
>             },
>             "note": { "type": "string" }
>           }
>         }
>       }
>     }
>   },
>   "transition": "complete"
> }
> ```

> [accordion] Observations and vital signs
>
> Array wrapper `{language, items[]}`. `language` is the language of the input, such as `en`. Each item has a coded `code` and exactly one value: `valueQuantity`, a number with its unit, or `valueString` for a result that is not a number, such as "positive" or "trace". Scores (GCS, pain) have no `unit`. Blood pressure is two items, systolic and diastolic.
>
> The codes are SNOMED CT\*, because [Medical Coding](https://docs.corti.ai/agentic/registry/medical-coding.md) resolves SNOMED CT.
>
> \* Differs slightly from [FHIR R4](https://docs.corti.ai/agentic/cookbook/overview#based-on-fhir-r4), which suggests LOINC codes for observations.
>
> Units are written as the clinician said them. If a measurement needs a unit and the clinician did not say one, the agent asks instead of guessing. To store units in a standard form, your application can map `unit` to [UCUM](https://ucum.org), a widely used unit standard.
>
> ```json expandable theme={null}
> {
>   "type": "schema",
>   "name": "extract_observations",
>   "description": "Extract observations or vital signs from free text or dictation. Resolve each item's code to a SNOMED CT concept using the coding connector. Give each item exactly one of valueQuantity or valueString. Record blood pressure as two items, systolic and diastolic. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
>   "schema": {
>     "type": "object",
>     "additionalProperties": false,
>     "required": ["language", "items"],
>     "properties": {
>       "language": { "type": "string", "description": "The language of the input, such as \"en\"." },
>       "items": {
>         "type": "array", "minItems": 1,
>         "items": {
>           "type": "object", "additionalProperties": false,
>           "required": ["code"],
>           "description": "Set exactly one of valueQuantity and valueString.",
>           "properties": {
>             "code": {
>               "type": "object", "additionalProperties": false,
>               "required": ["display"],
>               "properties": {
>                 "system": { "const": "http://snomed.info/sct" },
>                 "code": { "type": "string" },
>                 "display": { "type": "string" },
>                 "text": { "type": "string", "description": "What the clinician said, when the code is less precise." }
>               }
>             },
>             "valueQuantity": {
>               "type": "object", "additionalProperties": false,
>               "required": ["value"],
>               "properties": {
>                 "value": { "type": "number" },
>                 "unit": { "type": "string", "description": "The unit as the clinician said it. If a unit is needed and not said, ask. Omit for scores (GCS, pain)." }
>               }
>             },
>             "valueString": { "type": "string", "description": "A result that is not a number, such as \"positive\" or \"trace\"." }
>           }
>         }
>       }
>     }
>   },
>   "transition": "complete"
> }
> ```

> [accordion] Tasks
>
> Array wrapper `{language, items[]}`. Each item is a Task with a required `description`, an optional `dueDate`\*, and an optional `priority` (`routine`, `urgent`, `asap`, or `stat`). The client adds the task's `status` and `intent`.
>
> \* Differs slightly from [FHIR R4](https://docs.corti.ai/agentic/cookbook/overview#based-on-fhir-r4), where a simpler field is easier for the agent to fill.
>
> ```json expandable theme={null}
> {
>   "type": "schema",
>   "name": "extract_tasks",
>   "description": "Extract tasks from free text or dictation. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
>   "schema": {
>     "type": "object",
>     "additionalProperties": false,
>     "required": ["language", "items"],
>     "properties": {
>       "language": { "type": "string", "description": "The language of the input, such as \"en\"." },
>       "items": {
>         "type": "array", "minItems": 1,
>         "items": {
>           "type": "object", "additionalProperties": false,
>           "required": ["description"],
>           "properties": {
>             "description": { "type": "string" },
>             "dueDate": { "type": "string", "format": "date-time" },
>             "priority": { "enum": ["routine", "urgent", "asap", "stat"] }
>           }
>         }
>       }
>     }
>   },
>   "transition": "complete"
> }
> ```

> [accordion] Clinical notes
>
> Notes wrapper `{notes[]}`. Each note carries plain-text `content`, an optional `date`, and an optional `description` (the note's title). The agent writes only words, and the client encodes `content` for storage.
>
> ```json expandable theme={null}
> {
>   "type": "schema",
>   "name": "extract_clinical_notes",
>   "description": "Extract clinical notes from free text or dictation. Emit one suggestion per invocation. Nothing is saved until the clinician confirms.",
>   "schema": {
>     "type": "object",
>     "additionalProperties": false,
>     "required": ["notes"],
>     "properties": {
>       "notes": {
>         "type": "array", "minItems": 1,
>         "items": {
>           "type": "object", "additionalProperties": false,
>           "required": ["content"],
>           "properties": {
>             "content": { "type": "string", "description": "The note in plain text." },
>             "date": { "type": "string", "format": "date-time" },
>             "description": { "type": "string", "description": "The note's title." }
>           }
>         }
>       }
>     }
>   },
>   "transition": "complete"
> }
> ```

## Adapt it

Map each record to your EHR's write API in your apply-step where its names differ. Widen a `system` const to an `enum` if your EHR uses more than one terminology, then attach each body to your agent. Add a schema tool for any clinical family you expose. The seven above cover the families this recipe walks through, not an exhaustive list. The `transition` is `complete` on every family: the agent emits a suggestion and stops, pending confirmation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.