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

# Python SDK - Working with OMOP vocabularies

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

## List All Vocabularies

Get a paginated list of all available medical vocabularies:

```python theme={null}
# Basic list
result = client.vocabularies.list()
for vocab in result["data"]["vocabularies"]:
    print(f"{vocab['vocabulary_id']}: {vocab['vocabulary_name']}")

# Include statistics
result = client.vocabularies.list(include_stats=True)
for vocab in result["data"]["vocabularies"]:
    print(f"{vocab['vocabulary_id']}: {vocab.get('concept_count', 'N/A')} concepts")

# Custom sorting and pagination
result = client.vocabularies.list(
    sort_by="name",
    sort_order="asc",
    page=1,
    page_size=50
)
```

### Parameters

| Parameter          | Type | Default | Description                                |
| ------------------ | ---- | ------- | ------------------------------------------ |
| `include_stats`    | bool | False   | Include vocabulary statistics              |
| `include_inactive` | bool | False   | Include inactive vocabularies              |
| `sort_by`          | str  | "name"  | Sort field ("name", "priority", "updated") |
| `sort_order`       | str  | "asc"   | Sort order ("asc", "desc")                 |
| `page`             | int  | 1       | Page number                                |
| `page_size`        | int  | 20      | Results per page (max 1000)                |

## Get Vocabulary Details

Get detailed information about a specific vocabulary:

```python theme={null}
vocab = client.vocabularies.get("SNOMED")
print(f"Name: {vocab['data']['vocabulary_name']}")
print(f"Version: {vocab['data']['vocabulary_version']}")
print(f"Reference: {vocab['data']['vocabulary_reference']}")
```

### Parameters

| Parameter       | Type | Default  | Description                                       |
| --------------- | ---- | -------- | ------------------------------------------------- |
| `vocabulary_id` | str  | required | Vocabulary identifier (e.g., "SNOMED", "ICD10CM") |

### Response Fields

Returns `vocabulary_id`, `vocabulary_name`, `vocabulary_reference`, `vocabulary_version`, `vocabulary_concept_id`.

For detailed statistics, use `client.vocabularies.stats(vocabulary_id)`.

## Get Vocabulary Statistics

Get statistical information about a vocabulary:

```python theme={null}
stats = client.vocabularies.stats("SNOMED")
print(f"Total concepts: {stats['total_concepts']}")
print(f"Standard concepts: {stats['standard_concepts']}")
```

## Get Domain Statistics

Get statistics for a specific domain within a vocabulary:

```python theme={null}
result = client.vocabularies.domain_stats("SNOMED", "Condition")
print(f"Total concepts: {result['data']['total_concepts']}")
print(f"Standard concepts: {result['data']['standard_concepts']}")

# View concept class breakdown
for cls in result["data"]["concept_classes"]:
    print(f"{cls['concept_class_id']}: {cls['concept_count']} concepts")
```

### Parameters

| Parameter       | Type | Default  | Description                                                |
| --------------- | ---- | -------- | ---------------------------------------------------------- |
| `vocabulary_id` | str  | required | Vocabulary identifier (e.g., "SNOMED", "ICD10CM")          |
| `domain_id`     | str  | required | Domain identifier (e.g., "Condition", "Drug", "Procedure") |

## Get Vocabulary Domains

Get all standard OHDSI domains:

```python theme={null}
result = client.vocabularies.domains()
for domain in result["data"]["domains"]:
    print(f"{domain['domain_id']}: {domain['domain_name']}")
```

Returns all available domains with `domain_id`, `domain_name`, and `description`.

## Get Concept Classes

Get all available concept classes:

```python theme={null}
result = client.vocabularies.concept_classes()
for cls in result["data"]:
    print(f"{cls['concept_class_id']}: {cls['concept_class_name']}")
```

Returns concept classes with `concept_class_id`, `concept_class_name`, and `concept_class_concept_id`.

## Get Vocabulary Concepts

Retrieve concepts within a specific vocabulary with filtering and pagination:

```python theme={null}
# Basic usage
result = client.vocabularies.concepts("SNOMED", page_size=100)
for concept in result["data"]["concepts"]:
    print(f"{concept['concept_name']} ({concept['concept_id']})")

# Search within vocabulary
result = client.vocabularies.concepts(
    "SNOMED",
    search="diabetes",
    standard_concept="S",
    page_size=50
)

# Include additional data
result = client.vocabularies.concepts(
    "SNOMED",
    search="hypertension",
    include_relationships=True,
    include_synonyms=True
)

# With sorting
result = client.vocabularies.concepts(
    "RxNorm",
    sort_by="concept_id",
    sort_order="desc",
    page_size=100
)

# Include invalid/deprecated concepts
result = client.vocabularies.concepts(
    "ICD10CM",
    include_invalid=True,
    page=1,
    page_size=50
)

# Pagination
print(f"Page {result['meta']['pagination']['page']} of {result['meta']['pagination']['total_pages']}")
print(f"Total: {result['meta']['pagination']['total_items']} concepts")
```

### Parameters

| Parameter               | Type | Default  | Description                                         |
| ----------------------- | ---- | -------- | --------------------------------------------------- |
| `vocabulary_id`         | str  | required | Vocabulary identifier (e.g., "SNOMED", "ICD10CM")   |
| `search`                | str  | None     | Search term to filter concepts by name or code      |
| `standard_concept`      | str  | "all"    | Filter by standard concept status ("S", "C", "all") |
| `include_invalid`       | bool | True     | Include invalid or deprecated concepts              |
| `include_relationships` | bool | False    | Include concept relationships in response           |
| `include_synonyms`      | bool | False    | Include concept synonyms in response                |
| `sort_by`               | str  | "name"   | Sort field ("name", "concept\_id", "concept\_code") |
| `sort_order`            | str  | "asc"    | Sort order ("asc", "desc")                          |
| `page`                  | int  | 1        | Page number                                         |
| `page_size`             | int  | 20       | Results per page (max 1000)                         |
