All generar_rda_paciente calls in transaccion.py (4) and test_rda.py (2)
now pass sin_contrato_set so contract 040 sends numeroContrato: null
consistently across all send paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- candidatos: omite contratos con excluir=1 del listado
- preview: retorna flag excluido y pasa contrato_map (fix bug)
- enviar: bloquea si contrato excluido, pasa contrato_map al generar RDA
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Joins TARIFA using EMPRESA.TARIFA to get the base price per exam,
then calculates descuento = round((sum(TARIFA) - sum(PRECIO)) / sum(TARIFA) * 100)
and sends it as integer percentage in the RDA header encabezado.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pulls r.VALORDESC in all SQL queries (automation, test_rda, queries
defaults) and maps it to the top-level descuento field in the
RdaPaciente JSON encabezado.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
LEFT JOIN ITEM on COD_EXAMEN to get CUPS_DETALLE. Falls back to
COD_EXAMEN if CUPS is empty. Applied to automation, test_rda, and
saved queries in SQLite.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- json_generator: send valor:0 per item instead of PRECIO from Firebird
- test_rda + transaccion: accept "LHXC03726" format — extracts numeric part
for NUM_FACTURA and letter prefix for PREFIJO filter when prefix present
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 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>
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>
El numero del kardex en TNS ahora incluye el PREFIJO de Firebird y el
NUM_FACTURA zero-padded a 5 dígitos, igual al numFactura del RIPS
(ej: LHXC03404). Se agrega -{idrecepcion} al final para garantizar
unicidad ya que múltiples IDRECEPCION comparten el mismo NUM_FACTURA.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Elimina la lógica condicional que dependía de rda_test_log para detectar
colisiones. Ahora cada IDRECEPCION siempre genera un numero único y
reproducible en TNS sin consultar historial previo.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- json_generator: agrega parámetro numero_override para usar un número alternativo
- test_rda: detecta si el NUM_FACTURA ya fue enviado exitosamente (sesión o rda_test_log) y usa "{factura}-{idrecepcion}" como numero único en TNS
- transaccion: misma lógica en envío masivo, evita que el segundo IDRECEPCION de la misma factura falle con 409
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 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>