Cliente Python assíncrono para o serviço SOAP oficial do CNES.
Project description
3s-cnes-client
Cliente Python assíncrono para consultar estabelecimentos, leitos e profissionais nos serviços SOAP públicos do CNES (Cadastro Nacional de Estabelecimentos de Saúde).
O pacote é exclusivamente assíncrono e usa zeep[async] para consumir os
serviços SOAP.
Instalação
pip install 3s-cnes-client
Uso
import asyncio
from cnes_client import CNESClient
async def main():
async with CNESClient() as client:
estabelecimento = await client.estabelecimento("7869231")
leitos = await client.leitos("4013484")
profissionais = await client.profissionais("4013484")
print(estabelecimento)
print(leitos)
print(profissionais)
asyncio.run(main())
Se preferir fechar o cliente manualmente:
from cnes_client import CNESClient
client = CNESClient()
try:
leitos = await client.leitos("4013484")
finally:
await client.close()
Métodos disponíveis
estabelecimento(cnes: str) -> dict
Consulta os dados completos de um estabelecimento pelo código CNES informado.
Retorno: um dicionário com o resultado completo do serviço
consultarEstabelecimentoSaude, incluindo dados do estabelecimento,
profissionais, leitos, habilitações, equipamentos, SAMU e sumário quando
presentes no retorno do CNES.
{
"EstabelecimentoSaude": {
"CodigoCNES": {
"codigo": "7869231"
},
"CodigoUnidade": {
"codigo": "5105307869231"
},
"nomeFantasia": {
"Nome": "CENTRAL DE REGULACAO"
},
"nomeEmpresarial": {
"Nome": "PREFEITURA MUNICIPAL DE LUCIARA"
},
"dataAtualizacao": "2026-06-24",
"fluxoClientela": "ATENDIMENTO DE DEMANDA REFERENCIADA"
},
"profissional": [],
"leito": [],
"habilitacao": [],
"equipamento": [],
"samu": [],
"sumario": {
"quantidadeProfissionaisSaude": 3,
"quantidadeLeitos": 0
}
}
leitos(cnes: str) -> list[dict]
Consulta os perfis de leitos vinculados ao código CNES informado.
Retorno: uma lista de dicionários contendo as informações de cada perfil de leito.
[
{
"codigo": "96",
"descricao": "SUPORTE VENTILATORIO PULMONAR",
"dataAtualizacao": "2026-05-18T00:00:00",
"quantidadeLeito": 4,
"quantidadeLeitoSUS": 4
},
{
"codigo": "02",
"descricao": "CARDIOLOGIA",
"dataAtualizacao": "2026-05-18T00:00:00",
"quantidadeLeito": 6,
"quantidadeLeitoSUS": 0
}
]
profissionais(cnes: str) -> list[dict]
Consulta os profissionais vinculados ao código CNES informado.
Retorno: uma lista de dicionários contendo o CPF e o CNS de cada profissional ligado ao CNES.
[
{
"CNS": "709809023050097",
"CPF": "413******00"
},
{
"CNS": "708408234337161",
"CPF": "050******35"
},
{
"CNS": "704102842163350",
"CPF": "085******52"
},
{
"CNS": "700509551692756",
"CPF": "116******74"
}
]
Desenvolvimento
python -m pip install -e ".[dev]"
ruff check .
mypy src
pytest
python -m build
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_cnes_client-0.2.2.tar.gz.
File metadata
- Download URL: 3s_cnes_client-0.2.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78b935d9ea96738b755ca6bd2759a02daf429c562335395ca2ff0aed5ac993c7
|
|
| MD5 |
199a5ef48b8de27ffc8f2a6ca4001069
|
|
| BLAKE2b-256 |
5858a3186cb47ec90647c1f4e796f4d80ae1c863d2d5467d1690a430d48640e4
|
Provenance
The following attestation bundles were made for 3s_cnes_client-0.2.2.tar.gz:
Publisher:
publish.yml on 3S-Saude/3s-cnes-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
3s_cnes_client-0.2.2.tar.gz -
Subject digest:
78b935d9ea96738b755ca6bd2759a02daf429c562335395ca2ff0aed5ac993c7 - Sigstore transparency entry: 2087282332
- Sigstore integration time:
-
Permalink:
3S-Saude/3s-cnes-client@b0d9e0a7a1558b4e5bb42e950a83df269731d3bc -
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@b0d9e0a7a1558b4e5bb42e950a83df269731d3bc -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file 3s_cnes_client-0.2.2-py3-none-any.whl.
File metadata
- Download URL: 3s_cnes_client-0.2.2-py3-none-any.whl
- Upload date:
- Size: 6.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 |
820d0efc2537a7907a3c6a59fce6b079abd6781ac9df8bc1641dbcf0e2f2a4cf
|
|
| MD5 |
6f9552301bd5d65a31d37926ea401152
|
|
| BLAKE2b-256 |
a7a689504f35b305143bdea494e3fa9b51aef6f5bd099b7ae71dd90685707023
|
Provenance
The following attestation bundles were made for 3s_cnes_client-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on 3S-Saude/3s-cnes-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
3s_cnes_client-0.2.2-py3-none-any.whl -
Subject digest:
820d0efc2537a7907a3c6a59fce6b079abd6781ac9df8bc1641dbcf0e2f2a4cf - Sigstore transparency entry: 2087282428
- Sigstore integration time:
-
Permalink:
3S-Saude/3s-cnes-client@b0d9e0a7a1558b4e5bb42e950a83df269731d3bc -
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@b0d9e0a7a1558b4e5bb42e950a83df269731d3bc -
Trigger Event:
pull_request
-
Statement type: