Commit Graph

274 Commits

Author SHA1 Message Date
VPS 4 Builder 646458e669 feat: sistema completo de contratos odontológicos 2026-05-14 20:07:54 +02:00
VPS 4 Builder d064aa9058 feat(contratos): sistema completo de contratos odontológicos
- Tabelas contratos e contrato_itens com migrações automáticas
- Endpoints CRUD com itens em transação
- ContratosView: listagem, filtro por status, cards, stats
- ContratoModal: wizard 3 abas (Dados/Itens/Cláusulas), catálogo de
  procedimentos, DnD para reordenar, financeiro completo, print A4
- Sidebar: novo item CONTRATOS
- App.tsx: nova rota /contratos com permissões dentista/funcionario
- PatientsView: botão CONTRATOS no menu financeiro

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 20:04:57 +02:00
VPS 4 Builder 1cafef7ca4 feat: modal de lançamento de procedimento financeiro completo 2026-05-14 18:29:15 +02:00
VPS 4 Builder d6d2bc1e78 feat(financeiro): modal de lançamento de procedimento completo
- Catálogo de procedimentos por especialidade com busca e filtros
- Preço automático pelo convênio/plano do paciente (valoresPlanos)
- Campos de região: dente (texto livre), arcada (Superior/Inferior/Ambas),
  face (V/L/M/D/O multi-select) conforme tipo_regiao e exige_face
- Quantidade por item com +/-
- Painel financeiro: desconto (R$ ou %), entrada (auto-marcada Pago),
  parcelamento até 48x com vencimentos mensais automáticos
- Ao salvar: gera uma entrada de financeiro por parcela + entrada separada
- Integrado no botão LANÇAR do menu financeiro dos pacientes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 18:29:10 +02:00
VPS 4 Builder aedd9ece11 feat: menu clínico com 8 botões — tratamentos, GTOs, agendamentos, relatórios 2026-05-14 18:17:22 +02:00
VPS 4 Builder 6cb8169d62 feat(clinico): adicionar botões tratamentos, GTOs, agendamentos e relatórios ao menu clínico
- Menu clínico expandido para 8 botões em grade 4 colunas (2 no mobile)
- AGENDAMENTOS: reutiliza HistoricoModal existente
- GTOs: exporta useGTOStore do LancarGTO, pré-preenche paciente e navega
  para /lancargto via hash
- TRATAMENTOS: novo modal com stats (total/concluídos/faltas), resumo de
  procedimentos realizados e histórico cronológico
- RELATÓRIOS: novo modal com visão completa imprimível — dados pessoais,
  endereço, vínculos, resumo de atendimentos e observações clínicas

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 18:17:15 +02:00
VPS 4 Builder df9c0c47d2 fix(ui): modais responsivos — 96×98 desktop, tela cheia mobile 2026-05-14 17:24:28 +02:00
VPS 4 Builder 173c1c777e fix(ui): modais responsivos — 96×98 em desktop, tela cheia em mobile 2026-05-14 17:22:41 +02:00
VPS 4 Builder 646e4d207a fix: null[0] em dentistas nos modais de receita e exame 2026-05-14 17:02:49 +02:00
VPS 4 Builder df5c4bacb8 fix(modais): corrigir crash null[0] em dentistas ao abrir ReceitaModal e PedidoExameModal
useHybridBackend inicializa data como null, não undefined — o default = []
na desestruturação não se aplica a null, causando TypeError ao fazer
dentistas[0]. Substituído por operador ?? após a desestruturação.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 17:02:44 +02:00
VPS 4 Builder a7d2172da8 feat: receitas, pedido de exame, edição multi-página de paciente 2026-05-14 16:53:33 +02:00
VPS 4 Builder 15a8527f1c feat(pacientes): modais de receita, pedido de exame e edição em 4 páginas
- ReceitaModal: gerenciamento de modelos de receita por especialidade com
  drag-and-drop para reordenar medicamentos e preview de impressão
- PedidoExameModal: pedido de exames por catálogo (Raio-X / Tomografia /
  Outros) com DnD para ordenar, campos de região/observação por item e
  preview de impressão
- EditarPacienteModal: reformulado em 4 páginas (Dados / Família /
  Endereço / Histórico) com navegação anterior/próximo e modal 2xl
- Backend: tabelas modelos_receita, items_receita, pedidos_exame,
  items_pedido_exame criadas na migração; colunas de endereço adicionadas
  em pacientes; endpoints CRUD para receitas e pedidos de exame
- Integração: botões Receita e Raio-X no menu clínico agora abrem os
  novos modais reais em vez do placeholder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 16:53:28 +02:00
VPS 4 Builder 3cfc247b6e Merge claude/goofy-sinoussi-94238f: date fix, convenio dropdown, grupo familiar redesign 2026-05-14 16:11:47 +02:00
VPS 4 Builder 3d287a4579 chore: bump APP_VERSION V1.0.3 → V1.0.4
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 15:59:24 +02:00
VPS 4 Builder ee3f6c3bb2 feat(patients): fix date bug, convenio dropdown, redesign grupo familiar
- Fix dataNascimento date format error: convert dd/MM/yyyy → yyyy-MM-dd when
  loading EditarPacienteModal so <input type="date"> validates correctly
- Change convênio field from free text to dropdown populated from planos table
- Redesign grupo familiar: search a patient as family member instead of named
  group, with parentesco field (datalist with common options, accepts custom)
- GET /api/pacientes: proper camelCase aliases, LEFT JOINs for grupoFamiliarNome
  and indicadoPorNome, sort parameter support (az/za/convenio/recentes)
- Add startup migrations: ADD COLUMN IF NOT EXISTS for grupofamiliarid,
  grupofamiliarrelacao, indicadorporid on pacientes table
- savePaciente: preserve caller-supplied id instead of overwriting with Math.random
- Add grupoFamiliarRelacao to Paciente type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 15:54:54 +02:00
VPS 4 Builder 1e873cb653 fix(login): resolve merge conflict — preloader now uses APP_VERSION
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 08:01:55 +02:00
VPS 4 Builder 15ba7ffe95 fix(agenda): fix $.map crash and getPacientes type mismatch; restore preloader
AgendaView:
- Fix agendamentos?.filter(...).map(...) crash: optional chain didn't guard .map when agendamentos is null on initial render
- Fix getPacientes fetcher to extract .data array — API now returns {data, total} not Paciente[], causing searchResults.map crash

LoginView:
- Restore 3s preloader splash screen with {APP_VERSION} instead of hardcoded version string

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 08:01:18 +02:00
VPS 4 Builder 3229572d3b Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 07:50:25 +02:00
VPS 4 Builder e0be095055 fix(patients): prevent $.map crash in AgendamentoModal and AutocompleteField
- Fix agendamentos?.filter(...).map(...) — optional chain didn't protect .map, crashing when agendamentos is null on first render
- Add Array.isArray guard in AutocompleteField before setResults to prevent non-array from backend error responses breaking subsequent .map
- Add array guard in getGruposFamiliares to return [] on backend error instead of propagating error object

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:50:22 +02:00
VPS 4 Builder cabd2b9118 Merge claude/youthful-mendel-0c569f: grupo familiar + indicado por
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:32:30 +02:00
VPS 4 Builder 4c39a04654 feat(pacientes): grupo familiar + indicado por — DB migration, routes, autocomplete UI, family modal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:32:27 +02:00
VPS 4 Builder 11b0c2d2bf Merge claude/youthful-mendel-0c569f: patient UI overhaul
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:19:14 +02:00
VPS 4 Builder b411ab3c01 feat(pacientes): compact cards (6/screen), sort pills, clean search bar, 20-default limit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:19:11 +02:00
VPS 4 Builder 58d875b4fc Merge claude/youthful-mendel-0c569f: patient card redesign + dataNascimento fix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:12:01 +02:00
VPS 4 Builder 51cbd07125 fix(pacientes): alias dataNascimento in query; show full name; add CopyField component per data field
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:11:58 +02:00
VPS 4 Builder 6b67fbc26e fix(sync): truncate fields in import-legacy to match column VARCHAR limits
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:05:31 +02:00
VPS 4 Builder ca584dca72 Merge claude/youthful-mendel-0c569f: import-legacy + server-side pacientes search
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:03:58 +02:00
VPS 4 Builder 162404f4e8 feat(sync): add import-legacy route for Apps Script patients; fix pacientes API to use server-side search
- POST /api/sync/import-legacy: reads PACIENTES-CONSULTT-CLINIC tab (1755 patients),
  maps Nome+SobreNome→nome, CPF, Credenciada→convenio, DataNasci, TefefonePrincipal→telefone
- GET /api/pacientes: now supports ?q= server-side search, returns {data, total} — avoids loading all 1755 rows in client
- PatientsView: uses {data, total} response, shows count of all patients in header
- SyncView: adds "Importar Planilha Legada" button (amber)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 07:03:51 +02:00
VPS 4 Builder 1d2d164a73 fix(docker): expand frontend build context to root so update-version.js is accessible
WORKDIR changed to /app/frontend so ../update-version.js resolves correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:52:58 +02:00
VPS 4 Builder 1b56d729bf Merge claude/youthful-mendel-0c569f: add update-version.js build bump
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:52:07 +02:00
VPS 4 Builder 084a8f46c5 feat(build): add update-version.js to auto-increment patch on every build
Script runs before vite build via package.json "build" script.
Reads/writes APP_VERSION in frontend/constants.ts (now at V1.0.3).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:52:03 +02:00
VPS 4 Builder c718e888d7 Merge claude/youthful-mendel-0c569f: add APP_VERSION to ConfiguracoesView
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:48:58 +02:00
VPS 4 Builder 8331e87d26 feat(frontend): centralize APP_VERSION in constants.ts, show in ConfiguracoesView header
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:48:55 +02:00
VPS 4 Builder 424c2e4728 Merge claude/youthful-mendel-0c569f: fix realTab propagation in Sheets sync
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:46:33 +02:00
VPS 4 Builder 6cf18c049f fix(sync): propagate real tab name in pushTableToSheet and pullTableFromSheet
Ensures values.update and values.get use the actual tab title returned by
ensureSheetTab (case-insensitive match) so writes don't fail when existing
Apps Script tabs have different casing than our expected names.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:46:30 +02:00
VPS 4 Builder 06ae8ce98b Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 06:36:26 +02:00
VPS 4 Builder 319c0dcedd fix(oauth): check googleCreds not process.env in URL guard
process.env is only set if env var exists; credentials saved via UI
live in googleCreds. Guard was blocking users who saved via DB.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 06:36:22 +02:00
VPS 4 Builder 7d61550ae6 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 05:56:03 +02:00
VPS 4 Builder 263c98d74f feat(settings): Google OAuth credentials UI in Configurações
Backend:
- Load GOOGLE_CLIENT_ID/SECRET from DB at startup (env vars take priority)
- GET /api/settings/google-credentials → masked status (secret never returned)
- POST /api/settings/google-credentials → save to DB, hot-reload in memory
- /api/auth/google/url returns 503 with clear message when unconfigured

Frontend (ConfiguracoesView):
- OAuth credential inputs (Client ID + Client Secret with show/hide toggle)
- Shows configured status badge (ENV vs DB) and masked clientIdHint
- Instructions with redirect URI shown inline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:56:00 +02:00
VPS 4 Builder 96b0cd0172 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 05:52:36 +02:00
VPS 4 Builder fc891ab878 fix(oauth): set GOOGLE_REDIRECT_URI in docker-compose; guard missing credentials
- Add APP_URL and GOOGLE_REDIRECT_URI=https://scoreodonto.com/api/oauth2callback
  to docker-compose backend environment
- /api/auth/google/url returns 503 with clear message when CLIENT_ID/SECRET unset
- GoogleConnectButton shows alert instead of silently breaking on API error

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:52:33 +02:00
VPS 4 Builder 3b6c7f43d6 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 05:44:59 +02:00
VPS 4 Builder 63962d51c1 feat(sync): Google Sheets bidirectional backup (PG ↔ Sheets)
Backend:
- Add SYNC_TABLES config (pacientes, agendamentos, financeiro, leads, guias)
- Add getSheetsClient(), ensureSheetTab(), pushTableToSheet(), pullTableFromSheet()
- Add schedulePush() debounced 5s auto-push after every write to main tables
- Add GET /api/sync/status, POST /api/sync/push, POST /api/sync/pull
- Update OAuth scope to include spreadsheets

Frontend:
- Redesign SyncView: per-table status grid, two-button operation (Backup/Restore),
  terminal log with color-coded lines, auto-backup info notice

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:44:52 +02:00
VPS 4 Builder 8922354772 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 05:02:53 +02:00
VPS 4 Builder c70b2cde66 fix(ui): replace all MySQL references with PostgreSQL
Update SyncView description, security note, mock progress logs,
dbConfig, loading text in PatientsView, UpdateDbView warning, and
metadata.json description. Rename syncGoogleSheetsToMysql →
syncGoogleSheetsToPg.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:02:49 +02:00
VPS 4 Builder 7abda1dc58 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 04:54:25 +02:00
VPS 4 Builder 2a284f9e6e feat(ui): add Configurações page with profile/integration cards
Move user profile card and Google connect button from sidebar footer
to a dedicated Configurações view. Sidebar footer now shows a compact
user button that navigates to settings. All roles have access.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 04:54:22 +02:00
VPS 4 Builder 829489d216 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 04:44:55 +02:00
VPS 4 Builder 2f3c0420e3 feat(routing): switch from hash routing to HTML5 History API
Remove all window.location.hash assignments and hashchange events.
Navigate with history.pushState; listen on popstate. Fix base href to
'/' so assets resolve correctly on deep paths. Update magic link URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 04:44:53 +02:00
VPS 4 Builder edf04c9735 Merge branch 'claude/youthful-mendel-0c569f' 2026-05-14 04:26:07 +02:00