> ## 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.

# Recetario de campos

> Traduce cada campo del formulario del EMR a JSON de Smart Template y construye una plantilla campo por campo

Ya conoces tu pantalla del EMR como un conjunto de **campos de formulario** — una caja de texto, un número, un dropdown, un checkbox. Un Smart Template es esa misma pantalla expresada como JSON: cada campo se convierte en una propiedad del [`OutputSchema`](/scribe-api/smart-templates-output-schema) de una sección. Esta página te da el JSON de cada tipo de campo y luego te guía para armar una plantilla completa.

<Tip>
  Todo campo necesita `instructions` — ese es el prompt que el modelo usa para llenar el slot. Escríbelo como si instruyeras a un escriba: *"el motivo principal de consulta, en palabras del paciente"*.
</Tip>

## Recetario de campos

### Texto

Una entrada de texto libre o textarea.

```html theme={null}
<input type="text" name="chiefComplaint" />
```

```jsonc theme={null}
{
  "type": "string",
  "instructions": "Chief complaint in the patient's own words",
  "maxLength": 500
}
```

### Número

Una entrada numérica. Usa `integer` para enteros, `number` para decimales; acota con `minimum` / `maximum`.

```html theme={null}
<input type="number" name="weightKg" min="0" max="500" />
```

```jsonc theme={null}
{
  "type": "number",
  "instructions": "Body weight in kilograms",
  "minimum": 0,
  "maximum": 500
}
```

### Selección única (dropdown / radio)

Un `<select>` o un grupo de radio buttons — elige exactamente una opción. Usa `{ label, value }` para almacenar un código estable y poder renombrar o traducir el label libremente. La generación retorna el **`value`**.

```html theme={null}
<select name="visitType">
  <option value="FIRST_VISIT">First visit</option>
  <option value="FOLLOW_UP">Follow-up</option>
</select>
```

```jsonc theme={null}
{
  "type": "string",
  "instructions": "Type of visit",
  "enum": [
    { "label": "First visit", "value": "FIRST_VISIT" },
    { "label": "Follow-up",   "value": "FOLLOW_UP" }
  ]
}
```

### Selección múltiple (grupo de checkboxes)

Un grupo de checkboxes donde se pueden seleccionar varias opciones a la vez — un `array` cuyos `items` llevan el `enum`.

```html theme={null}
<input type="checkbox" name="symptoms" value="FEVER" /> Fever
<input type="checkbox" name="symptoms" value="COUGH" /> Cough
```

```jsonc theme={null}
{
  "type": "array",
  "instructions": "All symptoms the patient reports",
  "items": {
    "type": "string",
    "enum": [
      { "label": "Fever", "value": "FEVER" },
      { "label": "Cough", "value": "COUGH" }
    ]
  }
}
```

### Sí / No (checkbox)

Un checkbox único es un `boolean`.

```html theme={null}
<input type="checkbox" name="followUpNeeded" /> Follow-up needed
```

```jsonc theme={null}
{
  "type": "boolean",
  "instructions": "Whether a follow-up appointment is needed"
}
```

### Fecha y hora

Una entrada de fecha u hora — un `string` con un `format`. El valor se retorna como ISO 8601.

```html theme={null}
<input type="date" name="visitDate" />
```

```jsonc theme={null}
{
  "type": "string",
  "instructions": "Date of the visit",
  "format": "date"
}
```

### Campo opcional

Por defecto todo campo es `required: true` (el modelo siempre produce un valor). Pon `required: false` para que retorne `null` cuando el encuentro no lo menciona.

```jsonc theme={null}
{
  "type": "string",
  "instructions": "Secondary diagnosis, if any",
  "required": false
}
```

### Valor por defecto

Combina `required: false` con `default` para garantizar un respaldo. Para un `enum`, el `default` debe ser uno de los `value`.

```jsonc theme={null}
{
  "type": "string",
  "instructions": "Triage priority",
  "enum": [
    { "label": "Routine", "value": "ROUTINE" },
    { "label": "Urgent",  "value": "URGENT" }
  ],
  "required": false,
  "default": "ROUTINE"
}
```

## No soportado

**No hay lógica condicional** en un Smart Template — nada de "mostrar el campo B solo si el campo A es X". Keywords como `anyOf`, `if/then/else`, `pattern` y `minItems` se descartan silenciosamente. Modela la opcionalidad con `required: false` + `default`; pon la ramificación en la capa RPA. Lista completa: [OutputSchema → No soportado](/scribe-api/smart-templates-output-schema#no-soportado).

## Construye una plantilla, campo por campo

<Steps>
  <Step title="Lista los campos de tu pantalla">
    Anota cada campo del formulario y su tipo (texto, número, selección, checkbox, fecha).
  </Step>

  <Step title="Elige el JSON de cada uno">
    Usa el [recetario](#recetario-de-campos) de arriba para convertir cada campo en un `OutputSchema`.
  </Step>

  <Step title="Agrúpalos en una sección">
    Una sección es un `object` cuyas `properties` son tus campos — una sección por cada parte del registro.

    ```jsonc theme={null}
    {
      "type": "object",
      "instructions": "Consultation summary",
      "properties": {
        "chiefComplaint": { "type": "string", "instructions": "Main complaint" },
        "followUpNeeded": { "type": "boolean", "instructions": "Follow-up needed" }
      }
    }
    ```
  </Step>

  <Step title="Adjunta una estrategia de prompt">
    Dale a la sección un `telepatiaPromptId` curado, o tu propio `systemPrompt`. Ver [Secciones](/scribe-api/smart-templates-nodes).
  </Step>

  <Step title="Créala y luego referénciala">
    `POST /v1/medical-record-configurations` (idempotente — contenido idéntico retorna el mismo `id`), luego pasa `medicalRecordConfigurationId` en [`set-consultation-context`](/scribe-api/consultations).
  </Step>
</Steps>

## Receta completa: una plantilla de prescripción

Una plantilla completa que cubre cada tipo de campo — texto, número, selección única, selección múltiple, boolean y una fecha opcional con default:

```bash theme={null}
curl -X POST https://scribe-api.telepatia.ai/v1/medical-record-configurations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Prescription",
    "configuration": {
      "prescription": {
        "systemPrompt": "Extract the prescription details from the consultation.",
        "schema": {
          "type": "object",
          "instructions": "Prescription issued during the visit",
          "properties": {
            "patientName": {
              "type": "string",
              "instructions": "Full name of the patient",
              "maxLength": 200
            },
            "itemCount": {
              "type": "integer",
              "instructions": "Number of medications prescribed",
              "minimum": 0,
              "maximum": 50
            },
            "visitType": {
              "type": "string",
              "instructions": "Type of visit",
              "enum": [
                { "label": "First visit", "value": "FIRST_VISIT" },
                { "label": "Follow-up",   "value": "FOLLOW_UP" }
              ]
            },
            "medications": {
              "type": "array",
              "instructions": "Medications prescribed, with dose",
              "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" }
                }
              }
            },
            "followUpNeeded": {
              "type": "boolean",
              "instructions": "Whether a follow-up is needed"
            },
            "visitDate": {
              "type": "string",
              "instructions": "Date of the visit",
              "format": "date",
              "required": false,
              "default": "1970-01-01"
            }
          }
        }
      }
    }
  }'
```

## Próximos pasos

<CardGroup cols={2}>
  <Card title="Referencia de OutputSchema" icon="brackets-curly" href="/scribe-api/smart-templates-output-schema">
    Cada campo soportado, tipo por tipo.
  </Card>

  <Card title="Secciones" icon="diagram-project" href="/scribe-api/smart-templates-nodes">
    Cómo se resuelven los prompts por sección.
  </Card>
</CardGroup>
