feat(pacientes): verificar WhatsApp al ingresar teléfono, vincular user_id al guardar

fix(recepcion): mostrar nombre_completo en resultados de búsqueda de paciente

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-24 08:44:48 -05:00
co-authored by Claude Sonnet 4.6
parent 018d445846
commit af584bcc26
4 changed files with 56 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* GET /api/lab/check_whatsapp.php?phone=573001234567
* Verifica si un número de teléfono está registrado en WhatsApp (tabla users).
*/
require_once __DIR__ . '/_helpers.php';
requireAuth();
$phone = trim($_GET['phone'] ?? '');
if (!$phone) { jsonError('phone requerido', 400); }
$pdo = db();
$stmt = $pdo->prepare("SELECT id, name, phone_number FROM users WHERE phone_number = ? LIMIT 1");
$stmt->execute([$phone]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
jsonOk([
'found' => (bool)$user,
'user_id' => $user ? (int)$user['id'] : null,
'phone_number' => $user ? $user['phone_number'] : null,
]);