Commit Graph
13 Commits
Author SHA1 Message Date
Lizandro GuarnizoandClaude Sonnet 4.6 3017c7956e Fix numeroContrato: use EMPRESA.CODCONTRATO from Firebird, sucursal default 00
- Join EMPRESA table in all RDA queries to get CODCONTRATO (TNS contract code)
- Use EMPRESA.CODCONTRATO as numeroContrato instead of raw NIT_EMPRESA
- Especialidad always uses default_especialidad (ignore Firebird COD_ESPECIALIDAD)
- sucursal defaults to '00' (not empty) in config and endpoints
- Fix config template label: especialidad default is TNS code not Firebird code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 18:01:32 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 1f49f5bff5 Fix time format: clean spaces before truncating to avoid cutting seconds
Previous order: [:19] then replace(": ", ":") would truncate "06: 59: 28"
to "06: 59: " before cleaning, losing the seconds entirely.
Correct order: clean spaces first, then [:19].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 17:08:29 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 4e85dff07d profesional always uses TNS default (02=Lab); Firebird MEDICO codes don't match TNS catalog
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 17:05:06 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 83ce80a74b Send profesional/especialidad as null instead of empty string when no value
TNS schema marks both as optional — null may bypass company-level validation
that rejects empty string "". Falls back to config default if set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 16:43:31 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 c70f0f1062 Fix profesional/especialidad: use MEDICO.CODIGO first, add config defaults
- SQL query now prioritizes MEDICO.CODIGO over RECEPCION.USUARIO as profesional
  (USUARIO is the billing clerk; MEDICO is the medical professional)
- Add profesional_default and especialidad_default config keys for when
  Firebird data is empty or contains invalid values (e.g. especialidad = ".")
- generar_rda_paciente accepts default_profesional and default_especialidad params
- ensure_defaults in queries.py now updates existing query records on startup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 16:12:16 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 0ec4ae3e66 Fix JSON generation: numero factura, forma pago, tipousuario, hora format
- numero: usar NUM_FACTURA en lugar de cadena vacía
- codFormaPago: CLIP (particular) / INST (EPS) según TNS real
- tipousuario: fallback desde TIPOUSU cuando TIPOUSUSISPRO es NULL
- fechaHoraEgreso: última FECHA_REPORTADO en lugar de FECHA_RECEPCION
- _fmt_datetime: eliminar espacios en tiempo ("06: 08: 29" → "06:08:29")
- especialidad: limpiar valores basura (., -, 0, 00)
- telefono: fallback "0000000" cuando vacío (campo requerido TNS)
- profesional: COALESCE(USUARIO, MEDICO.CODIGO) en queries SQL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 20:48:22 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 7dc8f37c36 Fix fdb named parameter support: convert :name to positional ?
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>
2026-06-25 19:40:57 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 6d5a85c55f feat: integración completa con API TNS v2
- 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>
2026-06-25 18:56:31 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 774ce7d728 feat: queries reales Firebird y generadores JSON para API ERP
- 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>
2026-06-25 17:27:00 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 569bb43a62 Fix: errores 500 silenciosos en run-sql y esquema
- _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>
2026-06-18 12:57:22 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 c663df006b Fix: serializar tipos Firebird no-JSON (date, datetime, Decimal) en execute_query
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 12:30:13 -05:00
Lizandro Guarnizo 408ea50d21 hola 2026-06-18 12:25:44 -05:00
Lizandro Guarnizo 8ae3b44bc9 Initial commit: RIPS Manager web system 2026-06-17 13:22:39 -05:00