Añado los fuentes de java
This commit is contained in:
@@ -0,0 +1,717 @@
|
||||
/**
|
||||
* @(#) PersistenciaTamedico.java
|
||||
*/
|
||||
|
||||
package com.tarisan.control;
|
||||
|
||||
import com.tarisan.data.Tamedico;
|
||||
import com.tarisan.excepcion.*;
|
||||
import com.tarisan.log.*;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Controla los accesos a la persistencia para la entidad <code>Tamedico</code>.
|
||||
* @author <a href="mailto:sistemas@imqnavarra.com">Dpto. Informática</a>.
|
||||
* @version 1.0, 24/09/2003
|
||||
*/
|
||||
public class PersistenciaTamedico
|
||||
{
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selecciona los registros de la tabla TAMEDICO en función de la sentencia SELECT indicada.
|
||||
* @param sqlSelect La sentencia SELECT de selección.
|
||||
* @param pagina Número de página a mostrar.
|
||||
* @param aCondiciones Array que contiene los parámetros utilizados en la sentencia SELECT.
|
||||
* @return El Vector con los registros seleccionados (todos pertenencientes a la clase <code>tamedico</code>).
|
||||
* @throws
|
||||
*/
|
||||
public Vector seleccionar(String sqlSelect, int pagina, Object[] aCondiciones) throws ExcepcionTarisan
|
||||
{
|
||||
int elementosPaginacion=1;
|
||||
|
||||
Vector vResultado = new Vector();
|
||||
Tamedico tamedico = null;
|
||||
|
||||
try
|
||||
{
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect, aCondiciones);
|
||||
|
||||
objPaginacion.inicializarPaginacion(rs);
|
||||
if (objPaginacion.getNumeroRegistrosTotales()!=0)
|
||||
{
|
||||
objPaginacion.realizarPaginacion(rs, pagina);
|
||||
|
||||
while(rs.next() && (elementosPaginacion <= Paginacion.getFilasPorPagina()))
|
||||
{
|
||||
tamedico = new Tamedico();
|
||||
tamedico.setApellidos(rs.getString("APELLIDOS"));
|
||||
tamedico.setColegiadoCab(rs.getString("COLEGIADO_CAB"));
|
||||
tamedico.setCpCab(rs.getInt("CP_CAB"));
|
||||
tamedico.setDireccionCab(rs.getString("DIRECCION_CAB"));
|
||||
tamedico.setEspecialidad(rs.getInt("ESPECIALIDAD"));
|
||||
tamedico.setEspecialidadCab(rs.getString("ESPECIALIDAD_CAB"));
|
||||
tamedico.setMedico(rs.getInt("MEDICO"));
|
||||
tamedico.setNombre(rs.getString("NOMBRE"));
|
||||
tamedico.setNombreCab(rs.getString("NOMBRE_CAB"));
|
||||
tamedico.setParam1(rs.getInt("PARAM1"));
|
||||
tamedico.setParam2(rs.getInt("PARAM2"));
|
||||
tamedico.setPassword(rs.getString("PASSWORD"));
|
||||
tamedico.setPoblacionCab(rs.getString("POBLACION_CAB"));
|
||||
tamedico.setTarifa(rs.getInt("TARIFA"));
|
||||
tamedico.setTelefonoCab(rs.getString("TELEFONO_CAB"));
|
||||
tamedico.setNum_deter(rs.getInt("NUM_DETER"));
|
||||
tamedico.setEmailCab(rs.getString("EMAIL_CAB"));
|
||||
vResultado.addElement(tamedico);
|
||||
if (pagina!=0) //Se quiere realizar la paginacion
|
||||
elementosPaginacion++;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TAMEDICO (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
return vResultado;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el médico que ha realizado la prescripción del análisis al paciente.
|
||||
* @param autorizacion Autorización de la prescripción.
|
||||
* @param colectivo Número de colectivo.
|
||||
* @param póliza Número de póliza.
|
||||
* @param beneficiario Número de beneficiario.
|
||||
* @return El objeto <code>Tamedico</code> que ha realizado la prescripción del análisis al paciente.
|
||||
* @throws
|
||||
*/
|
||||
public Tamedico obtenerMedicoPrescripcionAnalisis(long autorizacion, long colectivo, double poliza, int beneficiario) throws ExcepcionTarisan
|
||||
{
|
||||
Tamedico tamedico = null;
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object aCondiciones[]=null;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT tapresca_tarisan.PRESCRIPTOR, TAMEDICO.ESPECIALIDAD");
|
||||
strSql.append(" FROM tapresca_tarisan, TAMEDICO");
|
||||
strSql.append(" WHERE tapresca_tarisan.PRESCRIPTOR=TAMEDICO.MEDICO");
|
||||
strSql.append(" AND tapresca_tarisan.AUTORIZACION=?");
|
||||
strSql.append(" AND tapresca_tarisan.COLEC=?");
|
||||
strSql.append(" AND tapresca_tarisan.POLIZA=?");
|
||||
strSql.append(" AND tapresca_tarisan.ORDEN=?");
|
||||
|
||||
aCondiciones = new Object[4];
|
||||
aCondiciones[0] = Long.valueOf(autorizacion);
|
||||
aCondiciones[1] = Long.valueOf(colectivo);
|
||||
aCondiciones[2] = Double.valueOf(poliza);
|
||||
aCondiciones[3] = Integer.valueOf(beneficiario);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
if (rs.next())
|
||||
{
|
||||
tamedico = new Tamedico();
|
||||
tamedico.setEspecialidad(rs.getInt("ESPECIALIDAD"));
|
||||
tamedico.setMedico(rs.getInt("PRESCRIPTOR"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la obtención del codigo del prescriptor de la tabla tapresca_tarisan (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan("Error en la obtención del prescriptor del analisis.");
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "El codigo del prescriptor obtenido de la tabla tapresca_tarisan es: " + tamedico.getMedico() + " (" + strSql.toString() + ")");
|
||||
}
|
||||
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de tapresca_tarisan: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de tapresca_tarisan: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de tapresca_tarisan: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de tapresca_tarisan: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
return tamedico;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtiene el password del médico que está conectado a la aplicación de la tabla TAMEDICO.
|
||||
* @param medico Código del médico conectado.
|
||||
* @param especialidad Código de la especialidad del médico conectado.
|
||||
* @return El Vector con los registros seleccionados (todos pertenencientes a la clase <code>tamedico</code>).
|
||||
* @throws
|
||||
*/
|
||||
public Vector obtenerPassword(int medico, int especialidad) throws ExcepcionTarisan
|
||||
{
|
||||
Vector vResultado = new Vector();
|
||||
Tamedico tamedico = null;
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object aCondiciones[]=null;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT password");
|
||||
strSql.append(" FROM tamedico");
|
||||
strSql.append(" WHERE medico=?");
|
||||
strSql.append(" AND especialidad=?");
|
||||
|
||||
aCondiciones = new Object[2];
|
||||
aCondiciones[0]=Integer.valueOf(medico);
|
||||
aCondiciones[1]=Integer.valueOf(especialidad);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
objPaginacion.inicializarPaginacion(rs);
|
||||
if (objPaginacion.getNumeroRegistrosTotales()!=0)
|
||||
{
|
||||
//nos posicionamos en el registro
|
||||
rs.next();
|
||||
//obtenemos el password
|
||||
tamedico = new Tamedico();
|
||||
tamedico.setPassword(rs.getString("PASSWORD"));
|
||||
vResultado.addElement(tamedico);
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TAMEDICO (" + strSql.toString() + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
return vResultado;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtiene el valor del campo Param1 del médico indicado de la tabla TAMEDICO.
|
||||
* @param medico Código del médico conectado.
|
||||
* @return El valor del campo Param1 del médico en cuestión.
|
||||
* @throws
|
||||
*/
|
||||
public int obtenerValorParam1(int medico) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object aCondiciones[]=null;
|
||||
int intParam1 = 0;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT param1");
|
||||
strSql.append(" FROM tamedico");
|
||||
strSql.append(" WHERE medico=?");
|
||||
|
||||
aCondiciones = new Object[1];
|
||||
aCondiciones[0]=Integer.valueOf(medico);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
//nos posicionamos en el registro
|
||||
if (rs.next())
|
||||
//obtenemos el campo PARAM1
|
||||
intParam1 = rs.getInt("PARAM1");
|
||||
else
|
||||
{
|
||||
//lanzamos error al no encontrar el registro del medico indicado
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la obtención del campo PARAM1 de la tabla TAMEDICO: (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan("Error en la obtención de los datos del médico.");
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el valor " + intParam1 + " del campo PARAM1 de la tabla TAMEDICO (" + strSql.toString() + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
return intParam1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int obtenerEspecialidad(int medico) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object aCondiciones[]=null;
|
||||
int intEspe = 0;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT especialidad");
|
||||
strSql.append(" FROM tamedico");
|
||||
strSql.append(" WHERE medico=?");
|
||||
|
||||
aCondiciones = new Object[1];
|
||||
aCondiciones[0]=Integer.valueOf(medico);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
//nos posicionamos en el registro
|
||||
if (rs.next())
|
||||
//obtenemos el campo PARAM1
|
||||
intEspe = rs.getInt("ESPECIALIDAD");
|
||||
else
|
||||
{
|
||||
//lanzamos error al no encontrar el registro del medico indicado
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la obtención del campo ESPECIALIDAD de la tabla TAMEDICO: (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan("Error en la obtención de los datos del médico.");
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el valor " + intEspe + " del campo ESPECIALIDAD de la tabla TAMEDICO (" + strSql.toString() + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
return intEspe;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifica la tabla TAMEDICO en función de la sentencia UPDATE indicada.
|
||||
* @param sqlSelect La sentencia UPDATE.
|
||||
* @param aValores Array que contiene los valores de los parámetros utilizados en la sentencia.
|
||||
* @param aCondiciones Array que contiene los parámetros de la condición utilizados en la sentencia.
|
||||
* @throws
|
||||
*/
|
||||
public void modificarMedico(String sqlSelect, Object[] aValores, Object[] aCondiciones) throws ExcepcionTarisan
|
||||
{
|
||||
try
|
||||
{
|
||||
ParametrosConfiguracion.dataStore.actualizar(sqlSelect, aValores, aCondiciones);
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifica la tabla TAMEDICO en función de la sentencia UPDATE indicada.
|
||||
* @param sqlSelect La sentencia UPDATE.
|
||||
* @param aValores Array que contiene los valores de los parámetros utilizados en la sentencia.
|
||||
* @param aCondiciones Array que contiene los parámetros de la condición utilizados en la sentencia.
|
||||
* @param conexion La conexión por la que se ejecuta la sentencia. Utilizado para el uso transacciones.
|
||||
* @throws
|
||||
*/
|
||||
public void modificarMedico(String sqlSelect, Object[] aValores, Object[] aCondiciones, Connection conexion) throws ExcepcionTarisan
|
||||
{
|
||||
try
|
||||
{
|
||||
ParametrosConfiguracion.dataStore.actualizar(sqlSelect, aValores, aCondiciones, conexion);
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selecciona el registro de la tabla TAMEDICO correspondiente al usuario seleccionado en función de la sentencia SELECT indicada.
|
||||
* @param medico El código de usuario seleccionado.
|
||||
* @return El objeto <code>Tamedico</code> seleccionado, o null si no encuentra nada.
|
||||
* @throws
|
||||
*/
|
||||
public Tamedico seleccionar(int medico) throws ExcepcionTarisan
|
||||
{
|
||||
Tamedico tamedico = null;
|
||||
StringBuffer sqlSelect = new StringBuffer();
|
||||
|
||||
try
|
||||
{
|
||||
sqlSelect.append("SELECT MEDICO");
|
||||
sqlSelect.append(", NOMBRE");
|
||||
sqlSelect.append(", APELLIDOS");
|
||||
sqlSelect.append(", ESPECIALIDAD");
|
||||
sqlSelect.append(", BLOQUEO_CLAVE");
|
||||
sqlSelect.append(", FECHA_ULT_ACCESO");
|
||||
sqlSelect.append(", FECHA_MODIF_CLAVE");
|
||||
sqlSelect.append(", NUM_DETER");
|
||||
sqlSelect.append(", DIRECCION_CAB");
|
||||
sqlSelect.append(", CP_CAB");
|
||||
sqlSelect.append(", POBLACION_CAB");
|
||||
sqlSelect.append(", EMAIL_CAB");
|
||||
sqlSelect.append(" FROM TAMEDICO");
|
||||
sqlSelect.append(" WHERE MEDICO = ?");
|
||||
|
||||
Object aCondiciones[] = new Object[1];
|
||||
aCondiciones[0] = Integer.valueOf(medico);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
||||
|
||||
while(rs.next())
|
||||
{
|
||||
tamedico = new Tamedico();
|
||||
tamedico.setMedico(rs.getInt("MEDICO"));
|
||||
tamedico.setNombre(rs.getString("NOMBRE"));
|
||||
tamedico.setApellidos(rs.getString("APELLIDOS"));
|
||||
tamedico.setEspecialidad(rs.getInt("ESPECIALIDAD"));
|
||||
tamedico.setBloqueoClave(rs.getString("BLOQUEO_CLAVE"));
|
||||
tamedico.setFechaUltimoAcceso(rs.getDate("FECHA_ULT_ACCESO"));
|
||||
tamedico.setFechaModifClave(rs.getDate("FECHA_MODIF_CLAVE"));
|
||||
tamedico.setDireccionCab(rs.getString("DIRECCION_CAB"));
|
||||
tamedico.setCpCab(rs.getInt("CP_CAB"));
|
||||
tamedico.setPoblacionCab(rs.getString("POBLACION_CAB"));
|
||||
tamedico.setNum_deter(rs.getInt("NUM_DETER"));
|
||||
tamedico.setEmailCab(rs.getString("EMAIL_CAB"));
|
||||
}
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el usuario " + medico + " de la tabla TAMEDICO (" + sqlSelect + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
return tamedico;
|
||||
}
|
||||
|
||||
public boolean actualizar_noticia(int noticia, int medico)
|
||||
{
|
||||
boolean resultado = false;
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Connection conexion = null;
|
||||
|
||||
strSql.append("update tamedico");
|
||||
strSql.append(" set param2 = "+ noticia);
|
||||
strSql.append(" where medico = "+medico);
|
||||
|
||||
try
|
||||
{
|
||||
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
resultado = ParametrosConfiguracion.dataStore.actualizar(strSql.toString(), conexion);
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Actualizado el registro de la tabla TAMEDICO (" + strSql.toString() + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la actualizacion de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la actualizacion de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
}
|
||||
|
||||
return resultado;
|
||||
}
|
||||
|
||||
public int obtener_intNoticia(int medico)
|
||||
{
|
||||
int resultado = 0;
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Connection conexion = null;
|
||||
Tamedico tamedico = null;
|
||||
Object aCondiciones[] = new Object[1];
|
||||
|
||||
strSql.append("Select PARAM2");
|
||||
strSql.append(" from tamedico");
|
||||
strSql.append(" where medico = ?");
|
||||
|
||||
aCondiciones[0] = Integer.valueOf(medico);
|
||||
|
||||
try {
|
||||
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet resul = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
if(resul.next())
|
||||
{
|
||||
tamedico = new Tamedico();
|
||||
tamedico.setParam2(resul.getInt("PARAM2"));
|
||||
}
|
||||
resultado = tamedico.getParam2();
|
||||
resul.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
} catch (ExcepcionTarisan e) {
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error al obtener la siguiente noticia. ExcecionTarisan");
|
||||
} catch (SQLException e) {
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error al obtener la siguiente noticia. SQLExcepcion");
|
||||
}
|
||||
return resultado;
|
||||
}
|
||||
|
||||
public String obtenerPosicionLogotipo(int medico) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object aCondiciones[]=null;
|
||||
String logo = "";
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT logo_cab");
|
||||
strSql.append(" FROM tamedico");
|
||||
strSql.append(" WHERE medico=?");
|
||||
|
||||
aCondiciones = new Object[1];
|
||||
aCondiciones[0]=Integer.valueOf(medico);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
//nos posicionamos en el registro
|
||||
if (rs.next())
|
||||
logo = rs.getString("LOGO_CAB");
|
||||
/*else
|
||||
{
|
||||
//lanzamos error al no encontrar el registro del medico indicado
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la obtención del campo ESPECIALIDAD de la tabla TAMEDICO: (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan("Error en la obtención de los datos del médico.");
|
||||
}*/
|
||||
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el valor " + logo + " del campo LOGO_CAB de la tabla TAMEDICO (" + strSql.toString() + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
return logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el valor del campo NUM_DETER del médico indicado de la tabla TAMEDICO.
|
||||
* @param medico Código del médico conectado.
|
||||
* @return El valor del campo NUM_DETER del médico en cuestión.
|
||||
* @throws
|
||||
*/
|
||||
public int obtenerNumeroDeterminaciones(int medico) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object aCondiciones[]=null;
|
||||
int num_deter = 0;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT num_deter");
|
||||
strSql.append(" FROM tamedico");
|
||||
strSql.append(" WHERE medico=?");
|
||||
|
||||
aCondiciones = new Object[1];
|
||||
aCondiciones[0]=Integer.valueOf(medico);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
//nos posicionamos en el registro
|
||||
if (rs.next())
|
||||
//obtenemos el campo PARAM1
|
||||
num_deter = rs.getInt("NUM_DETER");
|
||||
else
|
||||
{
|
||||
//lanzamos error al no encontrar el registro del medico indicado
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la obtención del campo NUM_DETER de la tabla TAMEDICO: (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan("Error en la obtención de los datos del médico.");
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, medico + " - Seleccionado el valor " + num_deter + " del campo NUM_DETER de la tabla TAMEDICO (" + strSql.toString() + ")");
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, medico + " - Error en la selección de TAMEDICO: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
return num_deter;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user