Añado los fuentes de java
This commit is contained in:
@@ -0,0 +1,726 @@
|
||||
/**
|
||||
* @(#) PersistenciaPaciente.java
|
||||
*/
|
||||
|
||||
package com.tarisan.control;
|
||||
|
||||
import com.tarisan.data.Paciente;
|
||||
import com.tarisan.data.Tarjeta;
|
||||
import com.tarisan.excepcion.*;
|
||||
import com.tarisan.log.*;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
/**
|
||||
* Controla los accesos a la persistencia para la entidad <code>Paciente</code>.
|
||||
* @author <a href="mailto:sistemas@imqnavarra.com">Dpto. Informática</a>.
|
||||
* @version 1.0, 24/09/2003
|
||||
*/
|
||||
public class PersistenciaPaciente implements Constantes
|
||||
{
|
||||
|
||||
/**
|
||||
* Selecciona el primer registro de la tabla ttbenefi encontrado para la tarjeta de paciente pasada por el médico.
|
||||
* @param tarjeta El objeto <code>Tarjeta</code> para el que se realiza la búsqueda.
|
||||
* @return El <code>Paciente</code> encontrado en la tabla de beneficiarios,
|
||||
* o null si se produce alguna excepción.
|
||||
* @throws
|
||||
*/
|
||||
public Object seleccionar(Tarjeta tarjeta, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
Object retorno = null;
|
||||
Paciente paciente = null;
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
sqlSelect.append("SELECT ttbenefi.TARJETA");
|
||||
sqlSelect.append(", ttbenefi.CLIENTE");
|
||||
sqlSelect.append(", ttbenefi.FECHA_BAJA");
|
||||
sqlSelect.append(", ttbenefi.LPD_AUT");
|
||||
sqlSelect.append(", ttbenefi.ENTIDAD");
|
||||
sqlSelect.append(", ttclient.SEXO");
|
||||
sqlSelect.append(", ttclient.FECHA_NACIMIENTO");
|
||||
sqlSelect.append(" FROM ttbenefi, ttclient");
|
||||
sqlSelect.append(" WHERE TARJETA = ? AND");
|
||||
sqlSelect.append(" ttbenefi.cliente = ttclient.cliente");
|
||||
sqlSelect.append(" and (ttbenefi.fecha_baja is null or ttbenefi.fecha_baja > sysdate) ");
|
||||
//sqlSelect.append(" AND POLIZA = ?");
|
||||
//sqlSelect.append(" AND ORDEN = ?");
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
Object aCondiciones[] = new Object[1];
|
||||
aCondiciones[0] = Integer.valueOf(tarjeta.getTarjeta());
|
||||
//aCondiciones[1] = Double.valueOf(tarjeta.getPoliza());
|
||||
//aCondiciones[2] = Integer.valueOf(tarjeta.getBeneficiario());
|
||||
@SuppressWarnings("unused")
|
||||
int numTarjeta = 0;
|
||||
int codCliente = 0;
|
||||
Date fecBaja = null;
|
||||
String autorizado = "";
|
||||
String sexo = "";
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
while(rs.next())
|
||||
{
|
||||
paciente = new Paciente();
|
||||
tarjeta.setEntidadIMQ(rs.getInt("ENTIDAD"));
|
||||
paciente.setTarjeta(tarjeta);
|
||||
numTarjeta = rs.getInt("TARJETA");
|
||||
codCliente = rs.getInt("CLIENTE");
|
||||
fecBaja = rs.getDate("FECHA_BAJA");
|
||||
autorizado = rs.getString("LPD_AUT");
|
||||
sexo = rs.getString("SEXO");
|
||||
paciente.setSexo(sexo);
|
||||
paciente.setEdad(com.tarisan.util.Utilidades.calcularEdad(rs.getDate("FECHA_NACIMIENTO"), Calendar.getInstance().getTime()));
|
||||
}
|
||||
rs.close();
|
||||
|
||||
Calendar calendario = Calendar.getInstance();
|
||||
/*if((numTarjeta != tarjeta.getTarjeta()) && (tarjeta.getTarjeta() > 0))
|
||||
{
|
||||
//La tarjeta del beneficiario (que no es Visa) está caducada (se ha emitido una posterior)
|
||||
retorno = TARJETA_CADUCADA;
|
||||
}
|
||||
else
|
||||
*/
|
||||
if((fecBaja != null) && (calendario.getTime().after((java.util.Date)fecBaja)))
|
||||
{
|
||||
//esa tarjeta está de baja, vamos a buscar por col-pol-orden a ver si tiene una activa
|
||||
sqlSelect.append("SELECT TARJETA");
|
||||
sqlSelect.append(", CLIENTE");
|
||||
sqlSelect.append(", FECHA_BAJA");
|
||||
sqlSelect.append(", LPD_AUT");
|
||||
sqlSelect.append(" FROM ttbenefi");
|
||||
sqlSelect.append(" WHERE COLECTIVO = ?");
|
||||
sqlSelect.append(" AND POLIZA = ?");
|
||||
sqlSelect.append(" AND ORDEN = ?");
|
||||
sqlSelect.append(" AND ENTIDAD = ?");
|
||||
sqlSelect.append(" AND (fecha_baja is null or fecha_baja > sysdate) ");
|
||||
Object bCondiciones[] = new Object[4];
|
||||
bCondiciones[0] = Long.valueOf(tarjeta.getColectivo());
|
||||
bCondiciones[1] = Double.valueOf(tarjeta.getPoliza());
|
||||
bCondiciones[2] = Integer.valueOf(tarjeta.getBeneficiario());
|
||||
bCondiciones[3] = Integer.valueOf(tarjeta.getEntidadIMQ());
|
||||
int numTarjeta2 = 0;
|
||||
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
while(rs.next())
|
||||
{
|
||||
numTarjeta2 = rs.getInt("TARJETA");
|
||||
}
|
||||
rs.close();
|
||||
if(numTarjeta2 != 0)
|
||||
{
|
||||
//La tarjeta pasada está de baja, pero hay otra de alta: tarjeta caducada.
|
||||
retorno = TARJETA_CADUCADA;
|
||||
}
|
||||
else
|
||||
{
|
||||
//El beneficiario está dado de baja
|
||||
retorno = TARJETA_BAJA;
|
||||
}
|
||||
}
|
||||
else if (this.clienteConMorosidad(tarjeta.getColectivo(), tarjeta.getPoliza(), medico))
|
||||
{
|
||||
//La tarjeta del paciente está suspendida (es moroso)
|
||||
retorno = TARJETA_SUSPENSO;
|
||||
}
|
||||
else if ((ParametrosConfiguracion.autorizacion.trim().toUpperCase().compareTo("S") == 0))
|
||||
{
|
||||
//El sistema comprobará la autorización para mostrar los resultados de las analíticas
|
||||
paciente.setNombre(this.obtenerNombreAsegurado(codCliente,medico));
|
||||
if(autorizado == null)
|
||||
{
|
||||
paciente.setAutorizado("N");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(autorizado.compareTo("S")==0)
|
||||
paciente.setAutorizado(autorizado);
|
||||
else
|
||||
paciente.setAutorizado("N");
|
||||
}
|
||||
retorno = paciente;
|
||||
}
|
||||
else
|
||||
{
|
||||
//La tarjeta del beneficiario es correcta y no comprobaremos si el paciente ha firmado la autorización
|
||||
paciente.setNombre(this.obtenerNombreAsegurado(codCliente,medico));
|
||||
paciente.setAutorizado("S");
|
||||
retorno = paciente;
|
||||
}
|
||||
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el paciente " + paciente + " de la tabla ttbenefi (" + sqlSelect + ")");
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de paciente: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan();
|
||||
}
|
||||
|
||||
return retorno;
|
||||
}
|
||||
|
||||
public Object seleccionarColPolOrd(Tarjeta tarjeta, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
Object retorno = null;
|
||||
/*Paciente paciente = null;*/
|
||||
Paciente paciente = new Paciente();
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
boolean encontrado = false;
|
||||
try
|
||||
{
|
||||
sqlSelect.append("SELECT ttbenefi.TARJETA");
|
||||
sqlSelect.append(", ttbenefi.CLIENTE");
|
||||
sqlSelect.append(", ttbenefi.FECHA_BAJA");
|
||||
sqlSelect.append(", ttbenefi.LPD_AUT");
|
||||
sqlSelect.append(", ttbenefi.ENTIDAD");
|
||||
sqlSelect.append(", ttclient.SEXO");
|
||||
sqlSelect.append(", ttclient.FECHA_NACIMIENTO");
|
||||
sqlSelect.append(" FROM ttbenefi, ttclient");
|
||||
sqlSelect.append(" WHERE COLECTIVO = ? AND");
|
||||
sqlSelect.append(" POLIZA = ? AND");
|
||||
sqlSelect.append(" ORDEN = ? AND");
|
||||
sqlSelect.append(" ttbenefi.cliente = ttclient.cliente");
|
||||
sqlSelect.append(" and (ttbenefi.fecha_baja is null or ttbenefi.fecha_baja > sysdate) ");
|
||||
//sqlSelect.append(" AND POLIZA = ?");
|
||||
//sqlSelect.append(" AND ORDEN = ?");
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
Object aCondiciones[] = new Object[3];
|
||||
aCondiciones[0] = Long.valueOf(tarjeta.getColectivo());
|
||||
aCondiciones[1] = Double.valueOf(tarjeta.getPoliza());
|
||||
aCondiciones[2] = Integer.valueOf(tarjeta.getBeneficiario());
|
||||
//aCondiciones[1] = Double.valueOf(tarjeta.getPoliza());
|
||||
//aCondiciones[2] = Integer.valueOf(tarjeta.getBeneficiario());
|
||||
@SuppressWarnings("unused")
|
||||
int numTarjeta = 0;
|
||||
int codCliente = 0;
|
||||
Date fecBaja = null;
|
||||
String autorizado = "";
|
||||
String sexo = "";
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
while(rs.next())
|
||||
{
|
||||
paciente = new Paciente();
|
||||
tarjeta.setEntidadIMQ(rs.getInt("ENTIDAD"));
|
||||
paciente.setTarjeta(tarjeta);
|
||||
numTarjeta = rs.getInt("TARJETA");
|
||||
codCliente = rs.getInt("CLIENTE");
|
||||
fecBaja = rs.getDate("FECHA_BAJA");
|
||||
autorizado = rs.getString("LPD_AUT");
|
||||
sexo = rs.getString("SEXO");
|
||||
paciente.setSexo(sexo);
|
||||
if(rs.getDate("FECHA_NACIMIENTO") == null){
|
||||
paciente.setEdad(99);
|
||||
}else {
|
||||
paciente.setEdad(com.tarisan.util.Utilidades.calcularEdad(rs.getDate("FECHA_NACIMIENTO"), Calendar.getInstance().getTime()));
|
||||
}
|
||||
|
||||
encontrado = true;
|
||||
}
|
||||
rs.close();
|
||||
|
||||
Calendar calendario = Calendar.getInstance();
|
||||
/*if((numTarjeta != tarjeta.getTarjeta()) && (tarjeta.getTarjeta() > 0))
|
||||
{
|
||||
//La tarjeta del beneficiario (que no es Visa) está caducada (se ha emitido una posterior)
|
||||
retorno = TARJETA_CADUCADA;
|
||||
}
|
||||
else
|
||||
*/
|
||||
if(((fecBaja != null) && (calendario.getTime().after((java.util.Date)fecBaja)) ) || (fecBaja == null && encontrado == false))
|
||||
{
|
||||
//esa tarjeta está de baja, vamos a buscar por col-pol-orden a ver si tiene una activa
|
||||
StringBuffer sqlSelect2 = new StringBuffer();
|
||||
sqlSelect2.append("SELECT TARJETA");
|
||||
sqlSelect2.append(", CLIENTE");
|
||||
sqlSelect2.append(", FECHA_BAJA");
|
||||
sqlSelect2.append(", LPD_AUT");
|
||||
sqlSelect2.append(" FROM ttbenefi");
|
||||
sqlSelect2.append(" WHERE COLECTIVO = ?");
|
||||
sqlSelect2.append(" AND POLIZA = ?");
|
||||
sqlSelect2.append(" AND ORDEN = ?");
|
||||
sqlSelect2.append(" AND ENTIDAD = ?");
|
||||
sqlSelect2.append(" AND (fecha_baja is null or fecha_baja > sysdate) ");
|
||||
Object bCondiciones[] = new Object[4];
|
||||
bCondiciones[0] = Long.valueOf(tarjeta.getColectivo());
|
||||
bCondiciones[1] = Double.valueOf(tarjeta.getPoliza());
|
||||
bCondiciones[2] = Integer.valueOf(tarjeta.getBeneficiario());
|
||||
bCondiciones[3] = Integer.valueOf(tarjeta.getEntidadIMQ());
|
||||
int numTarjeta2 = 0;
|
||||
ResultSet rs2 = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect2.toString(), bCondiciones);
|
||||
while(rs2.next())
|
||||
{
|
||||
numTarjeta2 = rs.getInt("TARJETA");
|
||||
}
|
||||
rs2.close();
|
||||
if(numTarjeta2 != 0)
|
||||
{
|
||||
//La tarjeta pasada está de baja, pero hay otra de alta: tarjeta caducada.
|
||||
retorno = TARJETA_CADUCADA;
|
||||
}
|
||||
else
|
||||
{
|
||||
//El beneficiario está dado de baja
|
||||
retorno = TARJETA_BAJA;
|
||||
}
|
||||
}
|
||||
else if (this.clienteConMorosidad(tarjeta.getColectivo(), tarjeta.getPoliza(), medico))
|
||||
{
|
||||
//La tarjeta del paciente está suspendida (es moroso)
|
||||
retorno = TARJETA_SUSPENSO;
|
||||
}
|
||||
else if ((ParametrosConfiguracion.autorizacion.trim().toUpperCase().compareTo("S") == 0))
|
||||
{
|
||||
//El sistema comprobará la autorización para mostrar los resultados de las analíticas
|
||||
paciente.setNombre(this.obtenerNombreAsegurado(codCliente,medico));
|
||||
if(autorizado == null)
|
||||
{
|
||||
paciente.setAutorizado("N");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(autorizado.compareTo("S")==0)
|
||||
paciente.setAutorizado(autorizado);
|
||||
else
|
||||
paciente.setAutorizado("N");
|
||||
}
|
||||
retorno = paciente;
|
||||
}
|
||||
else
|
||||
{
|
||||
//La tarjeta del beneficiario es correcta y no comprobaremos si el paciente ha firmado la autorización
|
||||
paciente.setNombre(this.obtenerNombreAsegurado(codCliente,medico));
|
||||
paciente.setAutorizado("S");
|
||||
retorno = paciente;
|
||||
}
|
||||
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el paciente " + paciente.getNombre() + " de la tabla ttbenefi (" + sqlSelect.toString() + ")");
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de paciente: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan();
|
||||
}
|
||||
|
||||
return retorno;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Comprueba en la tabla TARECOFI si el cliente buscado tiene morosidad o no.
|
||||
* @param colectivo El número de colectivo.
|
||||
* @param póliza El número de póliza.
|
||||
* @return El valor booleano según sea o no moroso el cliente.
|
||||
* @throws ExcepcionTarisan
|
||||
*/
|
||||
private boolean clienteConMorosidad(long colectivo, double poliza, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
boolean retorno;
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
|
||||
try
|
||||
{
|
||||
sqlSelect.append("SELECT PENDIENTE");
|
||||
sqlSelect.append(" FROM TARECOFI, TTCOLECT");
|
||||
sqlSelect.append(" WHERE COLEC = ?");
|
||||
sqlSelect.append(" AND POLIZA = ?");
|
||||
sqlSelect.append(" AND TARECOFI.ENTIDAD = TTCOLECT.ENTIDAD");
|
||||
sqlSelect.append(" AND TARECOFI.COLEC = TTCOLECT.COLECTIVO");
|
||||
sqlSelect.append(" AND COPAGO <> 3");
|
||||
|
||||
/* Se excluyen los colectivos que tienen copago transferido (TTCOLECT.COPAGO = 3) */
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
Object aCondiciones[] = new Object[2];
|
||||
aCondiciones[0] = Long.valueOf(colectivo);
|
||||
aCondiciones[1] = Double.valueOf(poliza);
|
||||
|
||||
double importe = -1.0;
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
while(rs.next())
|
||||
{
|
||||
importe = rs.getDouble("PENDIENTE");
|
||||
}
|
||||
rs.close();
|
||||
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
|
||||
if (importe >= 0.0)
|
||||
{
|
||||
retorno = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
retorno = false;
|
||||
}
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado la morosidad del cliente: " + importe + " de la tabla TARECOFI (" + sqlSelect + ")");
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
retorno = false;
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de morosidad del cliente: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan();
|
||||
}
|
||||
|
||||
return retorno;
|
||||
}
|
||||
|
||||
|
||||
public String obtenerNombreAsegurado(Tarjeta tarj, int medico)
|
||||
{
|
||||
String resul ="";
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
try
|
||||
{
|
||||
//SELECT * FROM TTBENEFI WHERE COLECTIVO=3 AND POLIZA=9.5957400185E11 AND ENTIDAD=5 AND ORDEN = 1
|
||||
sqlSelect.append("SELECT CLIENTE FROM TTBENEFI WHERE COLECTIVO=? AND POLIZA=? AND ENTIDAD=? AND ORDEN = ?");
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
Object aCondiciones[] = new Object[4];
|
||||
aCondiciones[0] = Long.valueOf(tarj.getColectivo());
|
||||
aCondiciones[1] = Long.valueOf(tarj.getPoliza());
|
||||
aCondiciones[2] = Integer.valueOf(tarj.getEntidadIMQ());
|
||||
aCondiciones[3] = Integer.valueOf(tarj.getBeneficiario());
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
while(rs.next())
|
||||
{
|
||||
resul = obtenerNombreAsegurado(rs.getInt("CLIENTE"), medico);
|
||||
}
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el cliente: " + resul + " de la tabla TTBENEFI (" + sqlSelect + ")");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - PersistenciaPaciente - obtenerNombreAsegurado(Tarjeta) - Excepcion "+e.toString());
|
||||
} catch (ExcepcionTarisan e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return resul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recupera el nombre y apellidos del cliente correspondiente a la tarjeta de paciente.
|
||||
* @param codCliente Código del cliente correspondiente a la tarjeta del paciente.
|
||||
* @return El nombre y apellidos del cliente.
|
||||
* @throws
|
||||
*/
|
||||
private String obtenerNombreAsegurado(int codCliente, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
/*StringBuffer nombre = new StringBuffer();*/
|
||||
String nombre = "";
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
|
||||
try
|
||||
{
|
||||
sqlSelect.append("SELECT NOMBRE");
|
||||
sqlSelect.append(", APELLIDOS");
|
||||
sqlSelect.append(" FROM ttclient");
|
||||
sqlSelect.append(" WHERE CLIENTE = ?");
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
Object aCondiciones[] = new Object[1];
|
||||
aCondiciones[0] = Integer.valueOf(codCliente);
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
while(rs.next())
|
||||
{
|
||||
if(rs.getString("APELLIDOS").contains(rs.getString("NOMBRE").trim()))
|
||||
{
|
||||
/*nombre.append(rs.getString("APELLIDOS"));*/
|
||||
nombre = rs.getString("APELLIDOS");
|
||||
}
|
||||
else
|
||||
{
|
||||
/*nombre.append(rs.getString("NOMBRE"));
|
||||
nombre.append(" ");
|
||||
nombre.append(rs.getString("APELLIDOS"));*/
|
||||
nombre = rs.getString("NOMBRE") + " " + rs.getString("APELLIDOS");
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el cliente: " + nombre/*.toString()*/ + " de la tabla ttclient (" + sqlSelect + ")");
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección del cliente: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan();
|
||||
}
|
||||
|
||||
/*return nombre.toString();*/
|
||||
return nombre;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Marca el flag de autorización con el valor 'S' a la firma de la autorización por parte del beneficiario.
|
||||
* @param tarjeta El objeto <code>Tarjeta</code> del paciente beneficiario.
|
||||
* @return El resultado de la actualización en base de datos.
|
||||
* @throws
|
||||
*
|
||||
* Se cambia TABENEFI a vista materializada, no se puede hacer update en ella. Se requiere que el médico
|
||||
* lleve el papel de la autorización firmada al IMQ.
|
||||
*/
|
||||
public boolean firmarAutorizacion(Tarjeta tarjeta, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
boolean resultado = true;
|
||||
/*
|
||||
Connection conexion = null;
|
||||
|
||||
StringBuffer sqlUpdate = new StringBuffer();
|
||||
sqlUpdate.append("UPDATE ttbenefi");
|
||||
sqlUpdate.append(" SET LPD_AUT = ?");
|
||||
sqlUpdate.append(" WHERE COLECTIVO = ?");
|
||||
sqlUpdate.append(" AND POLIZA = ?");
|
||||
sqlUpdate.append(" AND ORDEN = ?");
|
||||
sqlUpdate.append(" AND ENTIDAD = ?");
|
||||
|
||||
try
|
||||
{
|
||||
Object[] aValores = new Object[1];
|
||||
aValores[0] = "S";
|
||||
|
||||
Object[] aCondiciones = new Object[4];
|
||||
aCondiciones[0] = Integer.valueOf(tarjeta.getColectivo());
|
||||
aCondiciones[1] = Double.valueOf(tarjeta.getPoliza());
|
||||
aCondiciones[2] = Integer.valueOf(tarjeta.getBeneficiario());
|
||||
aCondiciones[3] = Integer.valueOf(tarjeta.getEntidadIMQ());
|
||||
|
||||
resultado = ParametrosConfiguracion.dataStore.actualizar(sqlUpdate.toString(), aValores, aCondiciones);
|
||||
}
|
||||
catch(ExcepcionTarisan ex)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la actualización de la firma del beneficiario " + tarjeta + ": " + ex + " (" + sqlUpdate + ")");
|
||||
throw ex;
|
||||
}*/
|
||||
|
||||
LogTarisan.logger.log(NivelLog.INFO, medico + " - Ya no se actualiza ttbenefi por que es vista materializada ");
|
||||
|
||||
return resultado;
|
||||
}
|
||||
|
||||
public boolean clienteCompatible(int medico)
|
||||
{
|
||||
boolean esCompatible = false;
|
||||
|
||||
return esCompatible;
|
||||
}
|
||||
|
||||
public Calendar obtenerFechaNacimiento(Tarjeta tarjeta, int medico)
|
||||
{
|
||||
Calendar fecnac = Calendar.getInstance();
|
||||
fecnac.set(Calendar.DAY_OF_MONTH, 1);
|
||||
fecnac.set(Calendar.MONTH, 1);
|
||||
fecnac.set(Calendar.YEAR, 1900);
|
||||
Connection conexion;
|
||||
try {
|
||||
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
sqlSelect.append("Select fecha_nacimiento ");
|
||||
sqlSelect.append("from ttbenefi, ttclient ");
|
||||
sqlSelect.append("where ttclient.cliente = ttbenefi.cliente ");
|
||||
sqlSelect.append(" and (ttbenefi.fecha_baja is null or ttbenefi.fecha_baja > sysdate) ");
|
||||
|
||||
Object[] aCondiciones = new Object[1];
|
||||
if(tarjeta.getTarjeta()==0)
|
||||
{
|
||||
sqlSelect.append("and trim(ttbenefi.tarjeta_chipcard) = trim(?)");
|
||||
aCondiciones[0]=new String(tarjeta.getTarjetaDesplazado());
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlSelect.append("and ttbenefi.tarjeta = ?");
|
||||
aCondiciones[0]=Integer.valueOf(tarjeta.getTarjeta());
|
||||
}
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
|
||||
try {
|
||||
while(rs.next())
|
||||
{
|
||||
if(rs.getDate("fecha_nacimiento") != null)
|
||||
fecnac.setTime(rs.getDate("fecha_nacimiento"));
|
||||
}
|
||||
rs.close();
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionada la fecha de nacimiento: " + fecnac + " del cliente: " + tarjeta.getTarjetaDesplazado() + "/" + tarjeta.getTarjeta() + "de la tabla ttbenefi (" + sqlSelect + ")");
|
||||
} catch (SQLException e) {
|
||||
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
}
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
} catch (ExcepcionTarisan e1) {
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error al obtener la fecha de nacimiento de la tarjeta: "+tarjeta);
|
||||
}
|
||||
|
||||
return fecnac;
|
||||
}
|
||||
|
||||
public String obtenerNIF(Tarjeta tarjeta, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
String nif = "";
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
sqlSelect.append("Select nif ");
|
||||
sqlSelect.append("from ttbenefi, ttclient ");
|
||||
sqlSelect.append("where ttclient.cliente = ttbenefi.cliente ");
|
||||
sqlSelect.append(" and (ttbenefi.fecha_baja is null or ttbenefi.fecha_baja > sysdate) ");
|
||||
Object[] aCondiciones = new Object[1];
|
||||
if(tarjeta.getTarjeta()==0)
|
||||
{
|
||||
sqlSelect.append("and trim(ttbenefi.tarjeta_chipcard) = trim(?)");
|
||||
aCondiciones[0]=new String(tarjeta.getTarjetaDesplazado());
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlSelect.append("and ttbenefi.tarjeta = ?");
|
||||
aCondiciones[0]=Integer.valueOf(tarjeta.getTarjeta());
|
||||
}
|
||||
|
||||
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
|
||||
try {
|
||||
while(rs.next())
|
||||
{
|
||||
nif = rs.getString("nif");
|
||||
}
|
||||
rs.close();
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el nif: " + nif + "del cliente: " + tarjeta.getTarjeta() + " de la tabla ttclient (" + sqlSelect + ")");
|
||||
|
||||
} catch (SQLException e) {
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - ERROR. "+e.toString());
|
||||
}
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
return nif;
|
||||
}
|
||||
|
||||
public String obtenerDomicilio(Tarjeta tarjeta, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
String direccion = "";
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
sqlSelect.append("select ttclient.CP, ttclient.DIRECCION, ttclient.POBLACION");
|
||||
sqlSelect.append(" from ttclient, ttbenefi");
|
||||
sqlSelect.append(" where ttbenefi.CLIENTE = ttclient.CLIENTE ");
|
||||
|
||||
Object[] aCondiciones = new Object[1];
|
||||
if(tarjeta.getTarjeta()==0)
|
||||
{
|
||||
sqlSelect.append("and trim(ttbenefi.tarjeta_chipcard) = trim(?)");
|
||||
aCondiciones[0]=new String(tarjeta.getTarjetaDesplazado());
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlSelect.append("and ttbenefi.tarjeta = ?");
|
||||
aCondiciones[0]=Integer.valueOf(tarjeta.getTarjeta());
|
||||
}
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
|
||||
try{
|
||||
while(rs.next())
|
||||
{
|
||||
direccion = rs.getString("DIRECCION").trim() + ", CP: " + rs.getString("CP").trim() + ". " + rs.getString("POBLACION").trim();
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Obtenida dirección: "+direccion);
|
||||
}
|
||||
rs.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - ERROR. "+e.toString());
|
||||
}
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
|
||||
|
||||
return direccion;
|
||||
}
|
||||
|
||||
public boolean tieneDental(String chipCard, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
boolean dental = false;
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
sqlSelect.append("Select ttbenefi.COLECTIVO ");
|
||||
sqlSelect.append("from ttbenefi, TTCOLECT ");
|
||||
sqlSelect.append("where ttbenefi.cliente in (select cliente from ttbenefi where tarjeta_chipcard = '" + chipCard + "') ");
|
||||
sqlSelect.append(" AND TTCOLECT.COLECTIVO = TTBENEFI.COLECTIVO ");
|
||||
sqlSelect.append(" AND TTCOLECT.CONTRATO = 723 ");
|
||||
sqlSelect.append(" and (TTBENEFI.FECHA_BAJA > sysdate OR TTBENEFI.FECHA_BAJA IS NULL)");
|
||||
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString());
|
||||
|
||||
try {
|
||||
if(rs.next())
|
||||
{
|
||||
dental = true;
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - ERROR. "+e.toString());
|
||||
}
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
|
||||
return dental;
|
||||
}
|
||||
|
||||
public boolean tieneSalud(int entidad, long colectivo, int medico) throws ExcepcionTarisan
|
||||
{
|
||||
boolean salud = false;
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
sqlSelect.append("Select ttcolect.CONTRATO ");
|
||||
sqlSelect.append("from ttbenefi, TTCOLECT ");
|
||||
sqlSelect.append(" WHERE TTCOLECT.ENTIDAD = ? ");
|
||||
sqlSelect.append(" AND TTCOLECT.COLECTIVO = ? ");
|
||||
sqlSelect.append(" AND TTCOLECT.COLECTIVO = TTBENEFI.COLECTIVO ");
|
||||
sqlSelect.append(" AND TTCOLECT.ENTIDAD = TTBENEFI.ENTIDAD ");
|
||||
sqlSelect.append(" AND TTCOLECT.CONTRATO <> 723 ");
|
||||
sqlSelect.append(" and (TTBENEFI.FECHA_BAJA > sysdate OR TTBENEFI.FECHA_BAJA IS NULL)");
|
||||
|
||||
Object aCondiciones[] = new Object[2];
|
||||
aCondiciones[0] = Integer.valueOf(entidad);
|
||||
aCondiciones[1] = Long.valueOf(colectivo);
|
||||
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
|
||||
try {
|
||||
if(rs.next())
|
||||
{
|
||||
salud = true;
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - ERROR. "+e.toString());
|
||||
}
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
|
||||
return salud;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user