733 lines
27 KiB
Java
733 lines
27 KiB
Java
/**
|
|
* @(#) PersistenciaTapecap.java
|
|
*/
|
|
package com.tarisan.control;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.sql.Timestamp;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Vector;
|
|
|
|
import com.tarisan.data.Taclient;
|
|
import com.tarisan.data.Tapecap;
|
|
import com.tarisan.excepcion.ExcepcionTarisan;
|
|
import com.tarisan.log.LogTarisan;
|
|
import com.tarisan.log.NivelLog;
|
|
import com.tarisan.util.Utilidades;
|
|
|
|
public class PersistenciaTapecap {
|
|
|
|
/**
|
|
* El objeto <code>Paginacion</code> que controla el número de filas a mostrar por cada página.
|
|
*/
|
|
private Paginacion objPaginacion = new Paginacion();
|
|
|
|
/**
|
|
* Obtiene el valor del objeto <code>Paginacion</code> para saber que página se está visualizando.
|
|
* @return El objeto <code>Paginacion</code>.
|
|
*/
|
|
public Paginacion getPaginacion()
|
|
{
|
|
return objPaginacion;
|
|
}
|
|
|
|
/**
|
|
* Obtiene las peticiones analíticas capturadas por el medico indicado.
|
|
* @param medico Medico de las peticiones aceptadas.
|
|
* @return El vector <code>vResultado</code> con las peticiones analíticas capturadas.
|
|
* @throws
|
|
*/
|
|
public Vector obtenerPeticionesCapturadas(int medico, String fecha, int pagina) throws ExcepcionTarisan
|
|
{
|
|
Vector vResultado = new Vector();
|
|
Tapecap tapecap = null;
|
|
//StringBuffer strSql = new StringBuffer();
|
|
Object[] aCondiciones=null;
|
|
int elementosPaginacion=1;
|
|
//Calendar hoy = Calendar.getInstance();
|
|
java.sql.Date hoy = new java.sql.Date(Calendar.getInstance().getTime().getTime());
|
|
String consulta ="";
|
|
|
|
try
|
|
{
|
|
/*strSql.append("SELECT *");
|
|
strSql.append(" FROM TAPECAP");
|
|
strSql.append(" WHERE MEDICO=?");
|
|
strSql.append(" AND FECHA=?");
|
|
strSql.append(" ORDER BY TO_NUMBER(CODIGO) ASC");
|
|
String sql = strSql.toString();*/
|
|
|
|
consulta = "SELECT * FROM TAPECAP WHERE MEDICO= ? AND FECHA= ? ORDER BY TO_NUMBER(CODIGO) ASC";
|
|
|
|
aCondiciones = new Object[2];
|
|
aCondiciones[0] = medico;
|
|
if (fecha.compareTo("")==0){
|
|
aCondiciones[1] = (String)Utilidades.formatear_fecha(hoy);
|
|
//sql = sql + " AND FECHA="+ (String)Utilidades.formatear_fecha(hoy) + " ORDER BY CODIGO ASC";
|
|
}else{
|
|
aCondiciones[1] = fecha;
|
|
//sql = sql + " AND FECHA="+ fecha + " ORDER BY CODIGO ASC";;
|
|
}
|
|
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
//ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sql, aCondiciones);
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, consulta, aCondiciones);
|
|
|
|
objPaginacion.inicializarPaginacion(rs);
|
|
if (objPaginacion.getNumeroRegistrosTotales()!=0)
|
|
{
|
|
objPaginacion.realizarPaginacion(rs, pagina);
|
|
|
|
while(rs.next() && (elementosPaginacion <= Paginacion.getFilasPorPagina()))
|
|
{
|
|
tapecap = new Tapecap();
|
|
tapecap.setApellidos(rs.getString("APELLIDOS"));
|
|
tapecap.setCodigo(rs.getString("CODIGO"));
|
|
tapecap.setCompania(rs.getString("COMPaniA"));
|
|
tapecap.setDireccion(rs.getString("DIRECCION"));
|
|
tapecap.setFecha(rs.getDate("FECHA"));
|
|
tapecap.setFecha_nac(rs.getDate("FECHA_NAC"));
|
|
tapecap.setMedico(rs.getInt("MEDICO"));
|
|
tapecap.setNif(rs.getString("NIF"));
|
|
tapecap.setNombre(rs.getString("NOMBRE"));
|
|
tapecap.setIdentificador(rs.getString("IDENTIFICADOR"));
|
|
tapecap.setTelefono(rs.getString("TELEFONO"));
|
|
tapecap.setAutorizacion(rs.getLong("AUTORIZACION"));
|
|
tapecap.setPrescriptor(rs.getString("PRESCRIPTOR"));
|
|
tapecap.setEspecialidad(rs.getString("ESPECIALIDAD"));
|
|
tapecap.setPoliza(rs.getDouble("POLIZA"));
|
|
tapecap.setOrden(rs.getInt("ORDEN"));
|
|
tapecap.setColectivo(rs.getLong("COLECTIVO"));
|
|
vResultado.addElement(tapecap);
|
|
if (pagina!=0) //Se quiere realizar la paginacion
|
|
elementosPaginacion++;
|
|
}
|
|
}
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado " + rs.getRow() + " registros de la tabla TAPECAP (" + consulta + ")");
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
|
|
return vResultado;
|
|
}
|
|
|
|
/**
|
|
* Inserta un nuevo registro en la tabla TAPECAP en función de la sentencia INSERT indicada.
|
|
* @param sqlSelect La sentencia INSERT.
|
|
* @param aValores Array que contiene los valores de los parámetros utilizados en la sentencia.
|
|
* @param conexion La conexión por la que se ejecuta la sentencia. Utilizado para el uso transacciones.
|
|
* @throws
|
|
*/
|
|
public void insertarPeticionCapturada(String sqlSelect, Object[] aValores, Connection conexion) throws ExcepcionTarisan
|
|
{
|
|
try
|
|
{
|
|
ParametrosConfiguracion.dataStore.insertar(sqlSelect, aValores, conexion);
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPECAP: " + sqle + " (" + sqlSelect + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPECAP: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPECAP: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
|
|
}
|
|
}
|
|
|
|
public int obtenerUltimaTapecapPk() throws ExcepcionTarisan
|
|
{
|
|
StringBuffer strSql = new StringBuffer();
|
|
int pk = 0;
|
|
|
|
try
|
|
{
|
|
strSql.append("SELECT MAX(TAPECAP_PK)");
|
|
strSql.append(" FROM TAPECAP");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString());
|
|
|
|
//nos posicionamos en el registro
|
|
if (rs.next())
|
|
//obtenemos el campo pk
|
|
pk = rs.getInt("TAPECAP_PK");
|
|
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
pk = pk == 0 ? 1 : pk;
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el valor " + pk + " del campo TAPECAP_PK de la tabla TAPECAP (" + strSql.toString() + ")");
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
|
|
}
|
|
|
|
|
|
return pk;
|
|
}
|
|
|
|
/**
|
|
* Obtiene el ultimo codigo de analítica capturada por medico y dia.
|
|
* @param medico Medico de las peticiones aceptadas.
|
|
* @return El int <code>codigo</code> de la ultima analítica capturada.
|
|
* @throws
|
|
*/
|
|
public int obtenerUltimoCodigo(int medico) throws ExcepcionTarisan
|
|
{
|
|
StringBuffer strSql = new StringBuffer();
|
|
int codigo = 0;
|
|
Object[] aCondiciones=null;
|
|
java.sql.Date dtFecha = new java.sql.Date(Calendar.getInstance().getTime().getTime());
|
|
String consulta = "";
|
|
String fec="";
|
|
|
|
try
|
|
{
|
|
/*strSql.append("SELECT MAX(CODIGO) CODIGO");
|
|
strSql.append(" FROM TAPECAP");
|
|
strSql.append(" WHERE MEDICO = ?");
|
|
strSql.append(" AND FECHA = ?");
|
|
|
|
aCondiciones = new Object[2];
|
|
aCondiciones[0] = medico;
|
|
|
|
aCondiciones[1] = (String)Utilidades.formatear_fecha(dtFecha);*/
|
|
|
|
fec = (String)Utilidades.formatear_fecha(dtFecha);
|
|
|
|
consulta = "SELECT MAX(TO_NUMBER(CODIGO))+1 CODIGO FROM TAPECAP WHERE MEDICO = " + medico + " AND FECHA = TO_DATE('" + fec +"','dd/mm/yyyy')";
|
|
|
|
/*consulta = "SELECT CODIGO FROM TAPECAP WHERE MEDICO = " + medico + " AND FECHA = TO_DATE('" + fec +"','dd/mm/yyyy') ORDER BY CODIGO DESC";*/
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
//ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, consulta);
|
|
|
|
//nos posicionamos en el registro
|
|
if (rs.next())
|
|
codigo = rs.getInt("CODIGO");
|
|
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
codigo = codigo == 0 ? 1 : codigo;
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el valor " + codigo + " del campo CODIGO de la tabla TAPECAP (" + strSql.toString() + ")");
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
|
|
}
|
|
|
|
|
|
return codigo;
|
|
}
|
|
|
|
public Vector obtenerDetallePaciente(long colec, double poliza, int orden) throws ExcepcionTarisan
|
|
{
|
|
Vector vResultado = new Vector();
|
|
StringBuffer strSql = new StringBuffer();
|
|
Object[] aCondiciones=null;
|
|
|
|
try
|
|
{
|
|
strSql.append("SELECT TTCLIENT.APELLIDO1,TTCLIENT.APELLIDO2,TTCLIENT.NOMBRE,TTCLIENT.NIF,TTCLIENT.DIRECCION,TTCLIENT.FECHA_NACIMIENTO,TTCLIENT.TELEFONO");
|
|
strSql.append(" FROM TTCLIENT");
|
|
strSql.append(" WHERE TTCLIENT.CLIENTE = (SELECT TTBENEFI.CLIENTE FROM TTBENEFI WHERE TTBENEFI.COLECTIVO = ? AND TTBENEFI.POLIZA = ? AND TTBENEFI.ORDEN = ?)");
|
|
|
|
aCondiciones = new Object[3];
|
|
aCondiciones[0] = colec;
|
|
aCondiciones[1] = poliza;
|
|
aCondiciones[2] = orden;
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
|
|
|
while(rs.next())
|
|
{
|
|
String ape1 = "";
|
|
if (rs.getString("APELLIDO1")!=null){
|
|
ape1 = rs.getString("APELLIDO1").trim();
|
|
}
|
|
String ape2 = "";
|
|
if (rs.getString("APELLIDO2")!=null){
|
|
ape2 = rs.getString("APELLIDO2").trim();
|
|
}
|
|
String nom = "";
|
|
if (rs.getString("NOMBRE")!=null){
|
|
nom = rs.getString("NOMBRE").trim();
|
|
}
|
|
String nif = "";
|
|
if (rs.getString("NIF")!=null){
|
|
nif = rs.getString("NIF").trim();
|
|
}
|
|
String dir = "";
|
|
if (rs.getString("DIRECCION")!=null){
|
|
dir = rs.getString("DIRECCION").trim();
|
|
}
|
|
String fec_na = "";
|
|
if (rs.getDate("FECHA_NACIMIENTO")!=null){
|
|
fec_na = (String)Utilidades.formatear_fecha(rs.getDate("FECHA_NACIMIENTO")).substring(0, 10);
|
|
}
|
|
String tel = "";
|
|
if (rs.getString("TELEFONO")!=null){
|
|
tel = rs.getString("TELEFONO");
|
|
}
|
|
|
|
vResultado.addElement(ape1+" "+ape2);
|
|
vResultado.addElement(nom);
|
|
vResultado.addElement(nif);
|
|
vResultado.addElement(dir);
|
|
vResultado.addElement(fec_na);
|
|
vResultado.addElement(tel);
|
|
}
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado " + rs.getRow() + " registros de la tabla TTCLIENT (" + strSql.toString() + ")");
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TTCLIENT: " + sqle + " (" + strSql.toString() + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TTCLIENT: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TTCLIENT: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TTCLIENT: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
|
|
return vResultado;
|
|
}
|
|
|
|
public Vector imprimirPeticionesCapturadas(int medico, String fecha, int pagina) throws ExcepcionTarisan
|
|
{
|
|
Vector vResultado = new Vector();
|
|
Tapecap tapecap = null;
|
|
StringBuffer strSql = new StringBuffer();
|
|
Object[] aCondiciones=null;
|
|
//Calendar hoy = Calendar.getInstance();
|
|
java.sql.Date hoy = new java.sql.Date(Calendar.getInstance().getTime().getTime());
|
|
|
|
try
|
|
{
|
|
strSql.append("SELECT *");
|
|
strSql.append(" FROM TAPECAP");
|
|
strSql.append(" WHERE MEDICO=?");
|
|
strSql.append(" AND FECHA=?");
|
|
strSql.append(" ORDER BY TO_NUMBER(CODIGO) ASC");
|
|
|
|
aCondiciones = new Object[2];
|
|
aCondiciones[0] = medico;
|
|
if (fecha.compareTo("")==0){
|
|
aCondiciones[1] = (String)Utilidades.formatear_fecha(hoy);
|
|
}else{
|
|
aCondiciones[1] = fecha;
|
|
}
|
|
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
|
|
|
while(rs.next())
|
|
{
|
|
tapecap = new Tapecap();
|
|
tapecap.setApellidos(rs.getString("APELLIDOS"));
|
|
tapecap.setCodigo(rs.getString("CODIGO"));
|
|
tapecap.setCompania(rs.getString("COMPaniA"));
|
|
tapecap.setDireccion(rs.getString("DIRECCION"));
|
|
tapecap.setFecha(rs.getDate("FECHA"));
|
|
tapecap.setFecha_nac(rs.getDate("FECHA_NAC"));
|
|
tapecap.setMedico(rs.getInt("MEDICO"));
|
|
tapecap.setNif(rs.getString("NIF"));
|
|
tapecap.setNombre(rs.getString("NOMBRE"));
|
|
tapecap.setIdentificador(rs.getString("IDENTIFICADOR"));
|
|
tapecap.setTelefono(rs.getString("TELEFONO"));
|
|
tapecap.setAutorizacion(rs.getLong("AUTORIZACION"));
|
|
tapecap.setPrescriptor(rs.getString("PRESCRIPTOR"));
|
|
tapecap.setEspecialidad(rs.getString("ESPECIALIDAD"));
|
|
tapecap.setPoliza(rs.getDouble("POLIZA"));
|
|
tapecap.setOrden(rs.getInt("ORDEN"));
|
|
tapecap.setColectivo(rs.getLong("COLECTIVO"));
|
|
vResultado.addElement(tapecap);
|
|
}
|
|
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado " + rs.getRow() + " registros de la tabla TAPECAP (" + strSql.toString() + ")");
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
|
|
return vResultado;
|
|
}
|
|
|
|
public Vector buscarPaciente(String troquelado, int pagina) throws ExcepcionTarisan
|
|
{
|
|
Vector vResultado = new Vector();
|
|
Tapecap tapecap = null;
|
|
StringBuffer strSql = new StringBuffer();
|
|
Object[] aCondiciones=null;
|
|
int elementosPaginacion=1;
|
|
java.sql.Date hoy = new java.sql.Date(Calendar.getInstance().getTime().getTime());
|
|
|
|
try
|
|
{
|
|
/*strSql.append("SELECT NOMBRE, TRIM (apellido1) || ' ' || TRIM (apellido2) AS APELLIDOS,");
|
|
strSql.append(" TRIM (direccion) || ', ' || TRIM (poblacion) || ', ' || cp AS DIRECCION,");
|
|
strSql.append(" fecha_nacimiento as FECHA_NAC, TELEFONO, NIF, IDENTIFICADOR,");
|
|
strSql.append(" CASE entidad");
|
|
strSql.append(" WHEN 1 THEN 'IMQ'");
|
|
strSql.append(" WHEN 3 THEN 'ADESLAS DESPLAZADO'");
|
|
strSql.append(" WHEN 4 THEN 'ASISA DESPLAZADO'");
|
|
strSql.append(" WHEN 5 THEN 'SANITAS DESPLAZADO'");
|
|
strSql.append(" WHEN 7 THEN 'IMQ-BILBO DESPLAZADO'");
|
|
strSql.append(" WHEN 32 THEN 'DKV DESPLAZADO'");
|
|
strSql.append(" WHEN 60 THEN 'HNA DESPLAZADO'");
|
|
strSql.append(" END as COMPANIA");
|
|
strSql.append(" FROM ttclient, ttbenefi");
|
|
strSql.append(" WHERE TTBENEFI.IDENTIFICADOR LIKE '%"+ troquelado +"%'");
|
|
strSql.append(" AND ttbenefi.cliente = ttclient.cliente");*/
|
|
|
|
strSql.append("SELECT DISTINCT(IDENTIFICADOR), NOMBRE, APELLIDOS, DIRECCION, FECHA_NAC,");
|
|
strSql.append(" TELEFONO, NIF, COMPANIA FROM");
|
|
strSql.append(" (SELECT NOMBRE, TRIM (apellido1) || ' ' || TRIM (apellido2) AS APELLIDOS,");
|
|
strSql.append(" TRIM (direccion) || ', ' || TRIM (poblacion) || ', ' || cp AS DIRECCION,");
|
|
strSql.append(" fecha_nacimiento as FECHA_NAC, TELEFONO, NIF, IDENTIFICADOR,");
|
|
strSql.append(" CASE entidad");
|
|
strSql.append(" WHEN 1 THEN 'IMQ'");
|
|
strSql.append(" WHEN 3 THEN 'ADESLAS DESPLAZADO'");
|
|
strSql.append(" WHEN 4 THEN 'ASISA DESPLAZADO'");
|
|
strSql.append(" WHEN 5 THEN 'SANITAS DESPLAZADO'");
|
|
strSql.append(" WHEN 7 THEN 'IMQ-BILBO DESPLAZADO'");
|
|
strSql.append(" WHEN 32 THEN 'DKV DESPLAZADO'");
|
|
strSql.append(" WHEN 60 THEN 'HNA DESPLAZADO'");
|
|
strSql.append(" END as COMPANIA");
|
|
strSql.append(" FROM ttclient, ttbenefi");
|
|
strSql.append(" WHERE TTBENEFI.IDENTIFICADOR LIKE '%"+ troquelado +"%'");
|
|
strSql.append(" AND ttbenefi.cliente = ttclient.cliente");
|
|
strSql.append(" UNION");
|
|
strSql.append(" SELECT NOMBRE, APELLIDOS, DIRECCION, FECHA_NAC,");
|
|
strSql.append(" TELEFONO, NIF, IDENTIFICADOR, COMPaniA AS COMPANIA");
|
|
strSql.append(" FROM TAPECAP");
|
|
strSql.append(" WHERE IDENTIFICADOR LIKE '%"+ troquelado +"%')");
|
|
strSql.append(" ORDER BY APELLIDOS ASC");
|
|
|
|
|
|
aCondiciones = new Object[1];
|
|
aCondiciones[0] = troquelado;
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString()/*, aCondiciones*/);
|
|
|
|
objPaginacion.inicializarPaginacion(rs);
|
|
if (objPaginacion.getNumeroRegistrosTotales()!=0)
|
|
{
|
|
objPaginacion.realizarPaginacion(rs, pagina);
|
|
|
|
while(rs.next() && (elementosPaginacion <= Paginacion.getFilasPorPagina()))
|
|
{
|
|
|
|
String ape = "";
|
|
if (rs.getString("APELLIDOS")!=null){
|
|
ape = rs.getString("APELLIDOS");
|
|
ape = ape.trim();
|
|
}
|
|
String compa = "";
|
|
if (rs.getString("COMPANIA")!=null){
|
|
compa = rs.getString("COMPANIA");
|
|
compa = compa.trim();
|
|
}
|
|
String dir = "";
|
|
if (rs.getString("DIRECCION")!=null){
|
|
dir = rs.getString("DIRECCION");
|
|
dir = dir.trim();
|
|
}
|
|
String nif = "";
|
|
if (rs.getString("NIF")!=null){
|
|
nif = rs.getString("NIF");
|
|
nif = nif.trim();
|
|
}
|
|
String nom = "";
|
|
if (rs.getString("NOMBRE")!=null){
|
|
nom = rs.getString("NOMBRE");
|
|
nom = nom.trim();
|
|
}
|
|
String iden = "";
|
|
if (rs.getString("IDENTIFICADOR")!=null){
|
|
iden = rs.getString("IDENTIFICADOR");
|
|
iden = iden.trim();
|
|
}
|
|
String tel = "";
|
|
if (rs.getString("TELEFONO")!=null){
|
|
tel = rs.getString("TELEFONO");
|
|
tel = tel.trim();
|
|
}
|
|
|
|
|
|
|
|
tapecap = new Tapecap();
|
|
tapecap.setApellidos(ape);
|
|
/*tapecap.setCodigo(rs.getInt("CODIGO"));*/
|
|
tapecap.setCompania(compa);
|
|
tapecap.setDireccion(dir);
|
|
/*tapecap.setFecha(rs.getDate("FECHA"));*/
|
|
tapecap.setFecha_nac(rs.getDate("FECHA_NAC"));
|
|
/*tapecap.setMedico(rs.getInt("MEDICO"));*/
|
|
tapecap.setNif(nif);
|
|
tapecap.setNombre(nom);
|
|
tapecap.setIdentificador(iden);
|
|
tapecap.setTelefono(tel);
|
|
/*tapecap.setAutorizacion(rs.getLong("AUTORIZACION"));
|
|
tapecap.setPrescriptor(rs.getString("PRESCRIPTOR"));
|
|
tapecap.setEspecialidad(rs.getString("ESPECIALIDAD"));
|
|
tapecap.setPoliza(rs.getDouble("POLIZA"));
|
|
tapecap.setOrden(rs.getInt("ORDEN"));
|
|
tapecap.setColectivo(rs.getLong("COLECTIVO"));*/
|
|
vResultado.addElement(tapecap);
|
|
if (pagina!=0) //Se quiere realizar la paginacion
|
|
elementosPaginacion++;
|
|
}
|
|
}
|
|
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado " + rs.getRow() + " registros de la tabla TAPECAP (" + strSql.toString() + ")");
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + strSql.toString() + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
|
|
return vResultado;
|
|
}
|
|
|
|
/**
|
|
* Obtiene el ultimo codigo de analítica capturada por medico y dia si es de un paciente con más de una autorización.
|
|
* @param medico Medico de las peticiones aceptadas.
|
|
* @return El int <code>codigo</code> de la ultima analítica capturada.
|
|
* @throws
|
|
*/
|
|
public String obtenerUltimoCodigoMismoPaciente(int medico, String identificador) throws ExcepcionTarisan
|
|
{
|
|
String codigo = "";
|
|
java.sql.Date dtFecha = new java.sql.Date(Calendar.getInstance().getTime().getTime());
|
|
String consulta = "";
|
|
String fec="";
|
|
|
|
try
|
|
{
|
|
|
|
fec = (String)Utilidades.formatear_fecha(dtFecha);
|
|
|
|
/*consulta = "SELECT MAX(CODIGO) CODIGO FROM TAPECAP WHERE MEDICO = " + medico + " AND FECHA = TO_DATE('" + fec +"','dd/mm/yyyy') AND IDENTIFICADOR = "+ identificador ;*/
|
|
|
|
consulta = "SELECT CODIGO FROM TAPECAP WHERE MEDICO = " + medico + " AND FECHA = TO_DATE('" + fec +"','dd/mm/yyyy') AND IDENTIFICADOR = "+ identificador + " ORDER BY CODIGO DESC";
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, consulta);
|
|
|
|
//nos posicionamos en el registro
|
|
if (rs.next())
|
|
codigo = rs.getString("CODIGO");
|
|
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
//codigo = codigo == 0 ? 1 : codigo;
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el valor " + codigo + " del campo CODIGO de la tabla TAPECAP (" + consulta + ")");
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
|
|
}
|
|
|
|
|
|
return codigo;
|
|
}
|
|
|
|
/**
|
|
* Comprueba si existe el paciente con otra analítica capturada por el mismo medico el mismo dia.
|
|
* @param medico Medico de las peticiones aceptadas.
|
|
* @return El int <code>codigo</code> de la ultima analítica capturada.
|
|
* @throws
|
|
*/
|
|
public boolean existePaciente(int medico, String embosado) throws ExcepcionTarisan
|
|
{
|
|
boolean existe = false;;
|
|
java.sql.Date dtFecha = new java.sql.Date(Calendar.getInstance().getTime().getTime());
|
|
String consulta = "";
|
|
String fec="";
|
|
if (embosado.compareTo("")==0 ){
|
|
embosado="0";
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
fec = (String)Utilidades.formatear_fecha(dtFecha);
|
|
|
|
consulta = "SELECT CODIGO FROM TAPECAP WHERE MEDICO = " + medico + " AND FECHA = TO_DATE('" + fec +"','dd/mm/yyyy') AND IDENTIFICADOR = "+ embosado ;
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, consulta);
|
|
|
|
//nos posicionamos en el registro
|
|
if (rs.next())
|
|
existe = true;
|
|
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Resultado " + existe + " de comprobar si existe el paciente en TAPECAP (" + consulta + ")");
|
|
}
|
|
catch (ExcepcionTarisan sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw (ExcepcionTarisan)sqle;
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Exception sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
}
|
|
catch(Throwable sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPECAP: " + sqle + " (" + consulta + ")");
|
|
throw new ExcepcionTarisan(sqle.getMessage());
|
|
|
|
}
|
|
|
|
|
|
return existe;
|
|
}
|
|
|
|
}
|