Skip to main content

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.

Instalacao

pip install 3s-rnds-client

Visao geral

O cliente concentra a infraestrutura comum de:

  • autenticacao CERT e API
  • 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

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/
RNDS_CNS_GESTOR=

Para compatibilidade com configuracoes legadas, a biblioteca tambem aceita 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.pacientes
  • client.estabelecimentos
  • client.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:

  • RndsConfigurationError
  • RndsAuthenticationError

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

3s_rnds_client-0.1.3.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

3s_rnds_client-0.1.3-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file 3s_rnds_client-0.1.3.tar.gz.

File metadata

  • Download URL: 3s_rnds_client-0.1.3.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for 3s_rnds_client-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c02b994ab2c013d8691a11e617986bb3b05a3f061613e618684b45d7cd98ba7c
MD5 46d2d225f23f5f1ea4f28ecebf911e9b
BLAKE2b-256 95d0799c49214246226241dc1995a5f4a8b8661a38d57b80ba164a01182b01d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for 3s_rnds_client-0.1.3.tar.gz:

Publisher: publish.yml on 3S-Saude/3s-rnds-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file 3s_rnds_client-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: 3s_rnds_client-0.1.3-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

Hashes for 3s_rnds_client-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9bd17604c43e907f7d67c2d940e8f9516b0ef07a1e3be3e2257e0362e9747471
MD5 a13de222e8e0e053250248bd166ea6a5
BLAKE2b-256 106c10c7e1778ee4810255033866a42c003cf2108011a051cc4755148e62a29d

See more details on using hashes here.

Provenance

The following attestation bundles were made for 3s_rnds_client-0.1.3-py3-none-any.whl:

Publisher: publish.yml on 3S-Saude/3s-rnds-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page