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

# Referencia

> Referencia completa de @fhiron/sdk: clase Fhiron, tipos ValidateResult e Issue, opciones y exports.

## `new Fhiron(options?)`

| Opción          | Tipo     | Default                                  | Descripción                                |
| --------------- | -------- | ---------------------------------------- | ------------------------------------------ |
| `apiKey`        | `string` | `process.env.FHIRON_API_KEY`             | API key del tenant.                        |
| `baseUrl`       | `string` | `https://fhiron.cl` (o `FHIRON_API_URL`) | Base de la API.                            |
| `timeout`       | `number` | `10000`                                  | Timeout por petición (ms).                 |
| `clCoreVersion` | `string` | resuelto por el tenant                   | Fija la versión de CL Core, ej. `"1.9.4"`. |
| `language`      | `string` | `"es"`                                   | Idioma de los mensajes (`"es"` \| `"en"`). |

## Métodos

### `validate(resource, opts?): Promise<ValidateResult>`

Validación remota contra CL Core. Descuenta cuota. `opts`: `{ profile?, clCoreVersion?, timeout? }`. Ver [validate](/sdk/validate).

### `lint(resource): Issue[]`

Lint estructural offline, síncrono. No descuenta cuota. Ver [lint](/sdk/lint).

### `check(resource, opts?): Promise<ValidateResult & { localIssues: Issue[] }>`

Lint local más validación remota en un llamado.

## `ValidateResult`

```ts theme={null}
interface ValidateResult {
  valid: boolean;
  ok: boolean;
  engineDegraded: boolean;
  resourceType: string | null;
  profile: string | null;
  issues: Issue[];
  errors: Issue[];
  warnings: Issue[];
  information: Issue[];
  messages: { errors: string[]; warnings: string[] };
  raw: Record<string, unknown>;
}
```

## `Issue`

```ts theme={null}
interface Issue {
  code: string;          // identificador estable, ej. "cl-run-01"
  severity: 'error' | 'warning' | 'information' | 'info';
  path: string;          // ruta FHIR (Patient.identifier[0].value)
  message: string;       // en español
  why?: string;          // por qué es un problema
  profileUrl?: string;   // StructureDefinition / CodeSystem que falla
  docsUrl?: string;
  suggestion?: string;
  quickFix?: { title: string; jsonPointer: string; replacement: unknown };
}
```

## Errores

`FhironError` y subclases (`FhironAuthError`, `FhironQuotaError`, `FhironRequestError`, `FhironServerError`, `FhironTimeoutError`, `FhironNetworkError`). Ver [errores](/sdk/errores).

## Funciones y constantes

| Export                        | Descripción                                               |
| ----------------------------- | --------------------------------------------------------- |
| `versionFromProfile(profile)` | `"hl7.fhir.cl.clcore@1.9.4"` → `"1.9.4"`; otros → `null`. |
| `VERSION`                     | Versión del SDK instalado.                                |

## Exports

```ts theme={null}
import {
  Fhiron,
  // tipos
  ValidateResult, Issue, QuickFix, Severity, FhironOptions, ValidateOptions,
  // errores
  FhironError, FhironAuthError, FhironQuotaError,
  FhironRequestError, FhironServerError, FhironTimeoutError, FhironNetworkError,
  // utilidades
  versionFromProfile, VERSION,
} from '@fhiron/sdk';
```

CommonJS:

```js theme={null}
const { Fhiron, FhironQuotaError, versionFromProfile } = require('@fhiron/sdk');
```
