Validação CNES
Overview
Validates CNES format and existence in the national registry. Denial reasons (blocking in authorization context): - Format invalid: CNES is not exactly 7 numeric digits. - Not found: CNES does not exist in cnes_tbestabelecimento. If the BQ artifact cannot be loaded at initialization, the exception propagates and the agent is not created (same behaviour as C066/C067).
Architecture
| Field |
Value |
| Name |
Validação CNES |
| Agent ID |
T003 |
| Version |
0.0.0 |
| Nature |
tech |
| Layer |
— |
Inheritance
CnesValidationRule → BaseAgent → BaseAgent
Core Functionality
- load_artifacts
- prepare_data
- rule_assessment
Business Rules
Consultar código-fonte para regras de negócio detalhadas.
Usage
from agents.cnesvalidationrule import CnesValidationRule
rule = CnesValidationRule()
violations_df = rule.rule_assessment(claims_df)
Configuration
rule = CnesValidationRule(
origin="Contas",
evaluated=False,
origin=origin,
evaluated=evaluated,
artifact_loader=ArtifactLoader(self.logger),
_cnes_set=set(),
df=self.artifact_loader.load_artifact(,
columns=[_CNES_COLUMN],
)
| Column |
Type |
Description |
EVENT_COLUMNS.id |
- |
- |
EVENT_COLUMNS.id_evento |
- |
- |
PROVIDER_COLUMNS.cnes |
- |
- |
Glosa DataFrame Columns
| Column |
Description |
agent_id |
T003 |
version |
0.0.0 |
id_arvo |
Original record ID |
vl_glosa_arvo |
Glosa value |
qt_glosa_arvo |
Glosa quantity |
score_arvo |
Confidence score |
motivo_glosa_arvo |
Detailed reason in Portuguese |
motivo_glosa_ANS |
ANS standard code |
data_dict |
JSON metadata with calculation details |
Error Handling
- DataFrames vazios retornam estrutura vazia com colunas obrigatórias.
- Colunas ausentes geram warning mas não causam crash.
- Conversões numéricas usam
errors="coerce" para evitar falhas.