Skip to content

Conversation

@ThePauloRoberto
Copy link
Contributor

@ThePauloRoberto ThePauloRoberto commented Dec 4, 2025

✅ Tipo

New feature (ready): adição de nova funcionalidade pronta para publicação

🧾 Descrição

Esta Pull Request implementa um novo endpoint de estatísticas para obter dados totais de encaminhamentos (referrals) e a porcentagem de paciente por encaminhamento com filtros temporais. O endpoint GET /statistics/referrals/total permite que usuários autorizados visualizem métricas de encaminhamentos com diferentes períodos de análise.

Principais alterações:

  • Nova Rota de API: GET /statistics/referrals/total com suporte a filtros de período
  • Controle de Acesso Baseado em Roles: Acesso restrito a manager, nurse e admin
  • Filtros Temporais: Suporte a períodos pré-definidos (last-year, last-month, last-week, today)
  • Métricas Calculadas:
    • Total de encaminhamentos no período
    • Percentual de pacientes não-pendentes com encaminhamentos

Checklist

  • Eu revisei meu código
  • As alterações passam pelos testes e lint locais
  • Implementei validações de segurança

🧪 Instruções para Teste

  1. Fazer login na aplicação para obter o token de acesso
  2. Testar o endpoint:
    • GET /statistics/referrals/total`
    • Validações:

      Com período específico

      • GET /statistics/referrals/total?period=last-month

      Sem período (usa default: 'today')

      • GET /statistics/referrals/total

Tarefas ou Issue

- Implement ReferralsRepository.getReferralsTotal() method
- Add period filtering (last-year, last-month, last-week, today)
- Calculate percentage of non-pending patients with referrals
- Use raw SQL for date filtering in MySQL queries
- Return { total: number, percentage: number } response
- Implement getReferralsTotal in ReferralsService
- Delegate logic to referrals repository
- Maintain consistent DTO and response types
- Create controller endpoint for referrals total statistics
- Apply role-based authorization (manager, nurse, admin)
- Integrate service layer and Zod validation
- Follow consistent API response pattern
@julianosill julianosill merged commit b5f6306 into dev Dec 6, 2025
2 checks passed
@julianosill julianosill deleted the feature/statistics-total-referrals-endpoint branch December 6, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants