Cobranca em duplicidade em Pronto Socorro
Overview
Implements the same-day return-consultation rule for improper charges. Agent: C072 The rule detects successive consultations in PRONTO_SOCORRO performed on the same day for the same beneficiary, provider, and specialty context. In these cases, the return is treated as continuity of care and a new consultation charge is considered ineligible. Professional criteria (id_profissional and cbo) can be optionally used in scope filtering and return key composition. When use_id_profissional is enabled, conselho_obrigatorio must specify the required professional board type (e.g. "CRM", "CFM") so that only matching professionals are considered in scope. Rule flow --------- 1) prepare_data: - validates required columns from input and normalizes key fields; - validates professional data quality (state, board, and registration number) with fallback from executor -> requester; - applies scope filters: target event, target regime, valid professional data, valid provider, and vl_pago > min_paid_value (with optional professional/CBO filters); - creates id_profissional as the professional key in the format uf_conselho_profissional-conselho-numero_conselho_profissional; - creates pk_retorno as the comparison key in the format partner_id+id_prestador+id_matricula+id_evento_predicted+regime_atendimento + valor unitário pago (vl_unitario_pago, arredondado) para não tratar retorno com desconto como duplicidade da mesma sequência, e opcionalmente anexa id_profissional e cbo_profissional; - produces evaluated with initial out-of-scope tracking. 2) rule_assessment: - runs iterative assessment by pk_retorno: sorts consultations chronologically per group, computes dt_atendimento_anterior and dias_desde_ultima, marks flag_glosa_elegivel only when the interval is 0 days (same day), and marks flag_glosa_aprovada only for the first eligible item in sequence; at the end of each round, removes denied items and reprocesses remaining items until no new approvals exist; - enriches output with denial fields, reasons, and metadata; - when evaluated=True, consolidates final assessment reasons for the entire processed universe.
Architecture
| Field | Value |
|---|---|
| Name | Cobranca em duplicidade em Pronto Socorro |
| Agent ID | C072 |
| Version | 0.0.0 |
| Nature | adm |
| Layer | — |
Inheritance
SameDayPSDuplicateConsultationRule → BaseAgent → BaseAgent
Core Functionality
- load_artifacts
- prepare_data
- rule_assessment
Business Rules
Conformidade da cobrança
Consultar código-fonte para regras de negócio detalhadas.
Usage
from agents.samedaypsduplicateconsultationrule import SameDayPSDuplicateConsultationRule
rule = SameDayPSDuplicateConsultationRule()
violations_df = rule.rule_assessment(claims_df)
Configuration
Sem parâmetros configuráveis identificados.
Input Requirements
Consultar expected_input_columns no código-fonte.
Output Format
Glosa DataFrame Columns
| Column | Description |
|---|---|
agent_id |
C072 |
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.