feat(secretaria): tools da agenda cientes de sala (B)
listar_horarios inclui `local` (nome da sala alugada ou "Clínica") e codifica o sala_id no slot_id; agendar_horario repassa sala_id ao /book para reservar no quarto certo. Par do satélite (scoreodonto): folga do dentista (A) + salas (B). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -95,12 +95,14 @@ export const BUILTIN_TOOLS: ToolDef[] = [
|
||||
return {
|
||||
disponivel: true,
|
||||
horarios: slots.map((s) => ({
|
||||
// slot_id sintético (não há registro persistente — o slot é calculado)
|
||||
id: `${s.dentista_id}|${s.start}|${s.end}`,
|
||||
// slot_id sintético (não há registro persistente — o slot é calculado).
|
||||
// Inclui sala_id (vazio p/ clínica) p/ o agendar saber onde reservar.
|
||||
id: `${s.dentista_id}|${s.start}|${s.end}|${s.sala_id ?? ''}`,
|
||||
dentista: s.dentista_nome,
|
||||
data: String(s.start).slice(0, 10),
|
||||
inicio: String(s.start).slice(11, 16),
|
||||
fim: String(s.end).slice(11, 16),
|
||||
local: s.local ?? 'Clínica', // nome da sala alugada, ou "Clínica"
|
||||
})),
|
||||
}
|
||||
} catch (e: any) {
|
||||
@@ -155,8 +157,8 @@ export const BUILTIN_TOOLS: ToolDef[] = [
|
||||
// Agenda REAL do scoreodonto (ponte) quando configurada.
|
||||
if (ctx.agenda?.url && ctx.agenda.clinicaId) {
|
||||
const parts = String(args['slot_id'] ?? '').split('|')
|
||||
if (parts.length !== 3) return { ok: false, erro: 'slot_id inválido. Chame listar_horarios novamente.' }
|
||||
const [dentistaId, start, end] = parts
|
||||
if (parts.length < 3) return { ok: false, erro: 'slot_id inválido. Chame listar_horarios novamente.' }
|
||||
const [dentistaId, start, end, salaId] = parts // salaId vazio = agenda da clínica
|
||||
// telefone: do argumento OU derivado do JID do contato (extChatId = tenant:jid)
|
||||
let telefone = String(args['telefone_cliente'] ?? '').replace(/\D/g, '')
|
||||
if (!telefone && ctx.extChatId) {
|
||||
@@ -172,6 +174,7 @@ export const BUILTIN_TOOLS: ToolDef[] = [
|
||||
signal: AbortSignal.timeout(12_000),
|
||||
body: JSON.stringify({
|
||||
clinica_id: ctx.agenda.clinicaId, dentista_id: dentistaId, start, end,
|
||||
...(salaId ? { sala_id: salaId } : {}), // reserva no quarto alugado, se aplicável
|
||||
paciente_nome: args['nome_cliente'], paciente_celular: telefone || null,
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user