Metadata-Version: 2.4
Name: cernia
Version: 0.2.1
Summary: Python SDK for the Cernia FHIR platform
Author: Cernia
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://cerniahealth.com
Project-URL: Repository, https://github.com/kamalcernia/cernia
Project-URL: Documentation, https://api.cerniahealth.com/api/docs
Keywords: fhir,healthcare,cernia
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: httpx<1.0,>=0.27
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: respx>=0.21; extra == "dev"

# cernia (Python SDK)

The official Python SDK for the Cernia FHIR platform.

## Install

```bash
python -m pip install cernia==0.2.1
```

## Usage

```python
import os

from cernia import CerniaClient

client = CerniaClient(
    base_url="https://api.cerniahealth.com",
    get_token=lambda: os.environ["CERNIA_TOKEN"],
    tenant_id="tenant-1",
)

patient = client.read("Patient", "p1")
results = client.search("Patient", {"name": "Alice"})
```

Async usage is preferred in coroutine contexts — every CRUD method has an
`a*` async counterpart (`aread`, `asearch`, etc.).

```python
async with CerniaClient(...) as client:
    patient = await client.aread("Patient", "p1")
```

## Error handling

Every method raises `CerniaApiError` on a 4xx/5xx response. The error
includes:

- `http_status` — the HTTP status code
- `code` — the FHIR issue code, or `"token_expired"` when the server signals
  expiry via the `WWW-Authenticate` header
- `details` — discriminated-union payload describing the body

Network failures surface as `CerniaNetworkError` with the underlying cause
attached.
