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

# Working with OMOP vocabularies

> Work with OMOP vocabularies in the OMOPHub Node.js SDK - list, describe, and query SNOMED, ICD-10, LOINC, RxNorm, and 100+ terminologies from TypeScript.

## List All Vocabularies

Get a paginated list of all available medical vocabularies. The result is wrapped under `vocabularies`; pagination metadata sits on the outer `meta`:

```ts theme={null}
const { data, error, meta } = await client.vocabularies.list();
if (error) throw new Error(error.message);

for (const vocab of data.vocabularies) {
  console.log(`${vocab.vocabulary_id}: ${vocab.vocabulary_name}`);
}

console.log(`Total: ${meta?.pagination?.total_items}`);
```

Include statistics:

```ts theme={null}
const { data } = await client.vocabularies.list({ includeStats: true });
for (const vocab of data?.vocabularies ?? []) {
  console.log(`${vocab.vocabulary_id}: ${vocab.stats?.total_concepts ?? 'N/A'} concepts`);
}
```

Custom sorting and pagination:

```ts theme={null}
const sorted = await client.vocabularies.list({
  sortBy: 'name',
  sortOrder: 'asc',
  page: 1,
  pageSize: 50,
});
```

### Parameters

| Parameter         | Type                                | Default  | Description                   |
| ----------------- | ----------------------------------- | -------- | ----------------------------- |
| `includeStats`    | boolean                             | false    | Include vocabulary statistics |
| `includeInactive` | boolean                             | false    | Include inactive vocabularies |
| `sortBy`          | `'name' \| 'priority' \| 'updated'` | `'name'` | Sort field                    |
| `sortOrder`       | `'asc' \| 'desc'`                   | `'asc'`  | Sort order                    |
| `page`            | number                              | 1        | Page number                   |
| `pageSize`        | number                              | 20       | Results per page (max 1000)   |

## Get Vocabulary Details

Get metadata for a single vocabulary:

```ts theme={null}
const { data } = await client.vocabularies.get('SNOMED');
console.log(`Name: ${data?.vocabulary_name}`);
console.log(`Version: ${data?.vocabulary_version}`);
console.log(`Reference: ${data?.vocabulary_reference}`);
```

Returns `vocabulary_id`, `vocabulary_name`, `vocabulary_reference`, `vocabulary_version`, `vocabulary_concept_id`. For detailed stats, use `client.vocabularies.stats(vocabularyId)`.

## Get Vocabulary Statistics

```ts theme={null}
const { data } = await client.vocabularies.stats('SNOMED');
console.log(`Total concepts: ${data?.total_concepts}`);
console.log(`Standard concepts: ${data?.standard_concepts}`);
```

## Get Domain Statistics

Per-domain breakdown for a vocabulary/domain pair:

```ts theme={null}
const { data } = await client.vocabularies.domainStats('SNOMED', 'Condition');
console.log(data);
```

| Parameter                   | Type   | Description                             |
| --------------------------- | ------ | --------------------------------------- |
| `vocabularyId` (positional) | string | Vocabulary identifier (e.g. `'SNOMED'`) |
| `domainId` (positional)     | string | Domain identifier (e.g. `'Condition'`)  |

## Get Vocabulary Domains

Vocabulary-scoped domain catalog (distinct from `client.domains.list()` which hits `/domains`):

```ts theme={null}
const { data } = await client.vocabularies.domains();
for (const domain of data?.domains ?? []) {
  console.log(`${domain.domain_id}: ${domain.domain_name}`);
}
```

## Get Concept Classes

```ts theme={null}
const { data } = await client.vocabularies.conceptClasses();
for (const cls of data?.concept_classes ?? []) {
  console.log(`${cls.concept_class_id}: ${cls.concept_class_name}`);
}
```

## Get Vocabulary Concepts

Retrieve concepts within a specific vocabulary, wrapped under `concepts`; pagination on outer `meta`:

```ts theme={null}
// Basic
const { data, meta } = await client.vocabularies.concepts('SNOMED', { pageSize: 100 });
for (const concept of data?.concepts ?? []) {
  console.log(`${concept.concept_name} (${concept.concept_id})`);
}

console.log(`Page ${meta?.pagination?.page} of ${meta?.pagination?.total_pages}`);
console.log(`Total: ${meta?.pagination?.total_items} concepts`);
```

Search within a vocabulary:

```ts theme={null}
await client.vocabularies.concepts('SNOMED', {
  search: 'diabetes',
  standardConcept: 'S',
  pageSize: 50,
});

await client.vocabularies.concepts('SNOMED', {
  search: 'hypertension',
  includeRelationships: true,
  includeSynonyms: true,
});

await client.vocabularies.concepts('RxNorm', {
  sortBy: 'name',
  sortOrder: 'desc',
  pageSize: 100,
});

await client.vocabularies.concepts('ICD10CM', {
  includeInvalid: true,
  page: 1,
  pageSize: 50,
});
```

### Parameters

| Parameter                   | Type                                       | Default  | Description                           |
| --------------------------- | ------------------------------------------ | -------- | ------------------------------------- |
| `vocabularyId` (positional) | string                                     | required | Vocabulary identifier                 |
| `search`                    | string                                     | -        | Filter concepts by name or code       |
| `standardConcept`           | `'S' \| 'C' \| 'N' \| 'all'`               | `'all'`  | Filter by standard concept flag       |
| `includeInvalid`            | boolean                                    | false    | Include invalid / deprecated concepts |
| `includeRelationships`      | boolean                                    | false    | Include relationships in each row     |
| `includeSynonyms`           | boolean                                    | false    | Include synonyms in each row          |
| `sortBy`                    | `'name' \| 'concept_id' \| 'concept_code'` | `'name'` | Sort field                            |
| `sortOrder`                 | `'asc' \| 'desc'`                          | `'asc'`  | Sort order                            |
| `page`                      | number                                     | 1        | Page number                           |
| `pageSize`                  | number                                     | 20       | Results per page (max 1000)           |
