Cliente Python assíncrono para integração com a RNDS em aplicações Django.
Project description
3s-rnds-client
3s-rnds-client e uma biblioteca Python assincrona para integracao com a RNDS em aplicacoes Django.
O pacote foi estruturado para publicacao no pip, com layout src/, metadata em pyproject.toml e namespace proprio em rnds_client.
Instalacao
pip install 3s-rnds-client
Visao geral
O cliente concentra a infraestrutura comum de:
- autenticacao
CERTeAPI - cache de token RNDS usando o cache configurado do Django
- transporte HTTP assincrono com
httpx - retry automatico em falhas transientes
- organizacao por capacidades de dominio
Estrutura do pacote
src/rnds_client/
├── auth.py
├── base_client.py
├── capabilities/
├── client.py
├── exceptions.py
├── parsers.py
├── settings.py
└── tokens.py
Uso rapido
from rnds_client import RndsClient
async def buscar_paciente(identificador: str):
async with await RndsClient.create() as client:
return await client.pacientes.buscar_pessoa(identificador)
Configuracao no Django
O pacote usa o cache padrao do Django para armazenar o token RNDS. Antes de usar o client, garanta que o projeto tenha CACHES configurado.
Exemplo de variaveis de ambiente:
RNDS_API_URL=https://rn-ehr-services.saude.gov.br/api/
RNDS_AUTH_TOKEN_URL=https://ehr-auth.saude.gov.br/api/
CNS_SEC_SAUDE=
Modo CERT
RNDS_AUTH_METHOD=CERT
RNDS_CERT=/caminho/para/cert.pem
RNDS_KEY=/caminho/para/key.pem
Modo API
RNDS_AUTH_METHOD=API
RNDS_AUTH_LOGIN_URL=https://api-intermediaria.exemplo/login
RNDS_AUTH_TOKEN_URL=https://api-intermediaria.exemplo/token
RNDS_USER=usuario
RNDS_PASSWORD=senha
Se RNDS_AUTH_METHOD nao for informado, o pacote escolhe API quando houver RNDS_USER ou RNDS_PASSWORD; caso contrario, usa CERT.
API publica
O ponto de entrada principal continua sendo RndsClient, com capacidades expostas por dominio:
client.pacientesclient.estabelecimentosclient.rira
Uso explicito da infraestrutura base:
from httpx import AsyncClient
from rnds_client.base_client import RndsBaseClient
from rnds_client.client import RndsClient
from rnds_client.settings import RndsSettings
async def criar_client_manual():
settings = RndsSettings.from_environment()
base_client = RndsBaseClient(settings=settings, http_client=AsyncClient())
return RndsClient(base_client=base_client)
Tratamento de erros
As excecoes proprias do pacote sao:
RndsConfigurationErrorRndsAuthenticationError
Chamadas HTTP tambem podem propagar erros do httpx.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file 3s_rnds_client-0.1.1.tar.gz.
File metadata
- Download URL: 3s_rnds_client-0.1.1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ea0f4f56ee18193d3959850965dc236856a572e9ece86585a7b3b1c4a5fd7a6
|
|
| MD5 |
231ccf5ce402eeecfaeadf9fd4ad633d
|
|
| BLAKE2b-256 |
8011d509ffd6b4938dd64ee0414334de018853a2f6a49a1e36a1889b2fd4a4a8
|
Provenance
The following attestation bundles were made for 3s_rnds_client-0.1.1.tar.gz:
Publisher:
publish.yml on 3S-Saude/3s-rnds-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
3s_rnds_client-0.1.1.tar.gz -
Subject digest:
1ea0f4f56ee18193d3959850965dc236856a572e9ece86585a7b3b1c4a5fd7a6 - Sigstore transparency entry: 1291523797
- Sigstore integration time:
-
Permalink:
3S-Saude/3s-rnds-client@367e78473ee74fe282eb6a18fdaa12d1b5f19d7b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/3S-Saude
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@367e78473ee74fe282eb6a18fdaa12d1b5f19d7b -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file 3s_rnds_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: 3s_rnds_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5dae332ed05cb16084136a2160015306879435b23ad7e6471e405aff467d5dd
|
|
| MD5 |
64cbcb692d53198b533dd98e362dfdb8
|
|
| BLAKE2b-256 |
95761be5818f8738538c3d9db5f7c110f84ad6886e966c989872c5db12e23bc7
|
Provenance
The following attestation bundles were made for 3s_rnds_client-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on 3S-Saude/3s-rnds-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
3s_rnds_client-0.1.1-py3-none-any.whl -
Subject digest:
e5dae332ed05cb16084136a2160015306879435b23ad7e6471e405aff467d5dd - Sigstore transparency entry: 1291523894
- Sigstore integration time:
-
Permalink:
3S-Saude/3s-rnds-client@367e78473ee74fe282eb6a18fdaa12d1b5f19d7b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/3S-Saude
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@367e78473ee74fe282eb6a18fdaa12d1b5f19d7b -
Trigger Event:
pull_request
-
Statement type: