Preview now returns all patients with their grouped receptions.
Clicking a patient row expands/collapses their RDA list showing
factura, fecha, exam count, diagnosis, and total value.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fdb does not support named parameters (:name + dict). Convert all
:name placeholders to ? and build a positional list from the param
dict in the same order they appear in the query.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- transaccion: append " 00:00:00" / " 23:59:59" to date params so Firebird BETWEEN works correctly with TIMESTAMP columns
- queries.py QUERY_DEFAULTS: remove :prefijo from RDA por factura (matches DB state)
- terceros.html: mark doc_num as required with visual indicator
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- terceros/transaccion: return clear error when required params (doc_num, num_factura) are missing instead of passing empty dict to Firebird causing Column unknown error
- transaccion: remove prefijo from 'por factura' query; parse num_factura as int when digit
- automation: add /preview endpoint to show patient/reception counts before sending; update UI with preview step and disabled run button until preview loads
- config: add TNS credentials section (tns_empresa, tns_usuario, tns_password, api_sucursal) with test-connection button
- config: add POST /config/test-tns endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- automation: reescrito para filtrar por fecha (default hoy), obtener
pacientes únicos del día vía JOIN RECEPCION+PACIENTE+CIUDAD, luego
agrupar recepciones por IDRECEPCION y enviar Tercero/Crear + RdaPaciente/Insertar a TNS v2
- template: UI simplificada con datepicker (default hoy), tabla de
resultados por paciente/factura con estado OK/error por ítem
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- api_client: agrega get_tns_token() — login en /v2/Acceso/Login y retorna JWT
- json_generator: campos en camelCase según swagger v2; agrega nomRegTri y
email placeholder cuando el paciente no tiene correo
- terceros/transaccion routes: obtienen token TNS antes de cada envío,
usan endpoints /v2/tablas/Tercero/Crear y /v2/rda/RdaPaciente/Insertar
- config: agrega tns_empresa, tns_usuario, tns_password
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- json_generator: nuevas funciones generar_tercero_api y generar_rda_paciente
mapeando PACIENTE/RECEPCION/RELACION al formato de los endpoints
Tercero/Crear y RdaPaciente/Insertar
- queries: reemplaza placeholders por consultas reales sobre PACIENTE,
RECEPCION, RELACION, MEDICO y CIUDAD
- config: agrega api_version y api_sucursal; actualiza url y credenciales Firebird
- terceros/transaccion routes: usan nuevos generadores y endpoints correctos
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reemplazado innerHTML con template literals por createElement + addEventListener.
Eliminado JSON embebido en atributos HTML. selectAll ahora busca en el array global.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cambio tojson en atributos onclick por data-* con |e.
dataset decodifica automáticamente " → " sin riesgo de romper el atributo.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _safe() maneja bytes/BLOB, memoryview y cualquier tipo desconocido
- _port() evita ValueError/TypeError si el puerto está vacío o es None
- get_firebird_from_config usa _port() en todos los endpoints
- run-sql y esquema wrapped en try/except → devuelven JSON de error en vez de 500 HTML
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>