RNDS para Python
Identificadores brasileiros e códigos da RNDS em uma biblioteca Python, CLI e servidor MCP. Tudo funciona localmente, sem chamadas de rede.
Projeto de código aberto da Voa Health, não afiliado ao Ministério da Saúde nem ao DATASUS. Este pacote não se conecta à RNDS, não autentica e não envia recursos.
Início rápido
pip install rnds
rnds cpf 987.654.321-00
rnds cns 712345678901236
rnds cnes 1234567
rnds codigos
Use a biblioteca para validar identificadores:
from rnds import cns, cpf, cnes
cpf.valido("987.654.321-00")
cns.valido("712345678901236")
cnes.valido("1234567")
Liste CodeSystems e ValueSets ou consulte conceitos offline:
from rnds.codigos import busca, conceitos, sistemas, valido
for sistema in sistemas():
print(sistema.nome, sistema.total)
url = "https://rnds-fhir.saude.gov.br/CodeSystem/BRNacionalidade"
print(conceitos(url))
print(valido(url, "B"))
url = "https://rnds-fhir.saude.gov.br/ValueSet/BRResultadoQualitativoExame-2.0"
origem = "https://rnds-fhir.saude.gov.br/CodeSystem/BRTipoResultadoAVIDEZ"
print(busca(url, "1"))
print(valido(url, "1", origem=origem))
Converta um identificador local para o sistema oficial sem alterar seu valor:
from rnds.sistemas import LOCAL_CPF, para_oficial
identificador = para_oficial({"system": LOCAL_CPF, "value": "98765432100"})
print(identificador)
Instale pip install "rnds[mcp]" para iniciar rnds mcp ou rnds-mcp. O servidor usa transporte stdio e consulta os mesmos dados locais da biblioteca, incluindo rnds_validate para validar Bundles.
Os valores nos exemplos são sintéticos. A biblioteca não acessa serviços hospedados.
Validar um Bundle
Valide um Bundle FHIR localmente, sem conexão ou envio à RNDS:
from rnds import validar
bundle = {"resourceType": "Bundle", "type": "collection", "entry": []}
achados = validar(bundle)
Também é possível validar um arquivo pela linha de comando ou ler da entrada padrão:
rnds validate bundle.json
cat bundle.json | rnds validate -
A validação verifica que a entrada seja um Bundle, que fullUrl não se repita,
que referências relativas (Tipo/id e Tipo/id/_history/v) ou URN
(urn:uuid: e urn:oid:) sejam resolvidas, que CPF, CNS e CNES sejam válidos para
seus sistemas, que sistemas urn:voa:br: mapeados indiquem o sistema oficial,
que códigos pertençam aos CodeSystems empacotados e que o display corresponda ao conceito.
Erros retornam código de saída 1; somente avisos ou nenhum achado retornam 0.
Problemas de leitura, JSON ou limites retornam 2. O arquivo pode ter até 10 MB e
64 níveis de aninhamento.
A validação de referências não verifica referências absolutas http(s), referências
contidas iniciadas por # nem formatos fora de Tipo/id, Tipo/id/_history/v,
urn:uuid: e urn:oid:.
Este recurso não verifica perfis completos de StructureDefinition, binding de ValueSet por elemento, nem envia dados ou se conecta à RNDS.
Metadata
Release files for rnds 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rnds-0.1.0.tar.gz | 357.5 kB | With provenance | Details for rnds-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rnds-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for rnds-0.1.0-py3-none-any.whl |
Total release size: 604.5 kB
Release files / rnds-0.1.0.tar.gz
| Download URL | rnds-0.1.0.tar.gz |
|---|---|
| Size | 357.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db0cacc4035fbdac4757c45eb549d9020a6d493918fdab7ace7e7180e19d3a1d
|
|
BLAKE2b-256 checksum How to use checksums |
bf303dab5655641814bdab1c28f0ab7e80388768a7d3d4271a257cbe483adefd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / rnds-0.1.0-py3-none-any.whl
| Download URL | rnds-0.1.0-py3-none-any.whl |
|---|---|
| Size | 247.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac45dd349fbb61f1d3c0fc6e827ea3f12a4b001b944023d4b0a57c643bc8ce78
|
|
BLAKE2b-256 checksum How to use checksums |
32f22112b757f4dfd3317ead245175b8bad6d4980c83a958e50f5fb0cf90ac54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for rnds 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for rnds-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.