Commit Graph
16 Commits
Author SHA1 Message Date
Lizandro GuarnizoandClaude Sonnet 4.6 8b2f8eb3be fix: add rel.DESCUENTO to all SQL queries; update debug endpoint with discount check
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-01 12:11:00 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 4b77f0a0ac fix: quitar rel.DESCUENTO — columna no existe en tabla RELACION de Firebird
json_generator ya usa row.get('DESCUENTO') or 0 como fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 21:15:10 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 c7428a196b fix: quitar codFormaPago header, fechaAutorizacion=hoy, descuento de Firebird
- Elimina codFormaPago del header RDA (no va segun JSON de referencia)
- fechaAutorizacion usa fecha de hoy, no la de recepcion
- descuento toma rel.DESCUENTO de Firebird en vez de hardcodeado 0
- Agrega rel.DESCUENTO al SELECT en test_rda y automation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 16:12:48 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 be1910b5d8 fix: send numero sin prefijo LHXC en RDA TNS
TNS espera solo el numero numerico (ej: "4001"), no el formato
combinado con prefijo (ej: "LHXC04001"). El codigoPrefijo "00"
ya referencia la serie correcta en la configuracion de TNS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 21:09:58 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 90de09b22c Fix RDA: quitar campos demograficos del RDA (solo van en Tercero); identidadGenero con ceros "01"/"02"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 20:50:39 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 58bdb4ae55 Agrega campos demograficos paciente en RDA y Tercero (etnia, zona, identidadGenero, divPolitica, antecedentes, fechaNac, direccion)
- SQL RDA join PACIENTE para obtener datos demograficos
- generar_rda_paciente: incluye etnia, identidadGenero, zona, divisionPoliticaAdministrativa, antecedentes, fechaNacimiento, direccion
- generar_tercero_api: agrega identidadGenero, divisionPoliticaAdministrativa, antecedentes; default ciudad Cucuta 54001

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 20:49:12 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 69372a5673 Agrega filtro convenio en automation/transaccion/test-rda y fix particular (contrato 12)
- automation: filtro contrato en SQL pacientes+RDA, numero LHXC en run()
- transaccion: filtro contrato en preview/send-one/send
- test-rda: filtro tipo_usuario (11/07/12), default contrato "12", acepta "12"/"012"
- json_generator: detecta particular por CODCONTRATO "12"/"012" además de NIT_EMPRESA PART; fuerza tipousuario="12", codFormaPago="CLIP", plazoDias="0"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 20:23:00 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 c64a68ec6f Add test-rda page, fix prefijo/remisionante/especialidad for TNS RDA sends
- New /test-rda route: list Firebird candidates with valid contract/factura,
  send individual RDA with auto tercero creation and full result display
- json_generator: use prefijo_tns_default config instead of Firebird PREFIJO,
  add profesionalRemisionante from DOCIDMEDICO or remisionante_default config
- All queries: add DOCIDMEDICO column from MEDICO JOIN
- automation/transaccion: add remisionante_default and prefijo_tns_default params
- config: add remisionante_default (00) and prefijo_tns_default (00) keys
- automation SQL: filter NUM_FACTURA > 0 to skip unbilled records
- config.html: add UI fields for new config keys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 18:57:54 -05:00
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 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 dbaf49b30e Automation preview: show RDA per patient on click
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>
2026-06-25 19:49:21 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 b4a7271d8d Fix param validation errors and add TNS config section
- 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>
2026-06-25 19:29:32 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 3755a51562 feat: envío masivo por fecha — Terceros + RDA en un solo paso
- 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>
2026-06-25 19:08:01 -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