Añado los fuentes de java
This commit is contained in:
@@ -0,0 +1,588 @@
|
||||
/**
|
||||
* @(#) PersistenciaTaprimer.java
|
||||
*/
|
||||
|
||||
package com.tarisan.control;
|
||||
|
||||
import com.tarisan.log.*;
|
||||
import com.tarisan.data.Usuario;
|
||||
import com.tarisan.excepcion.ExcepcionTarisan;
|
||||
import java.sql.*;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Controla los accesos a la persistencia para la entidad <code>Taprimer</code>.
|
||||
* @author <a href="mailto:sistemas@imqnavarra.com">Dpto. Informática</a>.
|
||||
* @version 1.0, 24/09/2003
|
||||
*/
|
||||
public class PersistenciaTaprimer
|
||||
{
|
||||
|
||||
/**
|
||||
* Obtiene si se trata de la primera visita del paciente.
|
||||
* @param medico Código del médico.
|
||||
* @param colectivo Número de colectivo.
|
||||
* @param poliza Número de póliza.
|
||||
* @param beneficiario Número de beneficiario.
|
||||
* @return Valor booleano que nos indica si se trata de la primera visita del paciente.
|
||||
* @throws
|
||||
*/
|
||||
public boolean esPrimeraVisita(int medico, long colectivo, double poliza, int beneficiario) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object[] aCondiciones;
|
||||
boolean esPrimeraVisita = false;
|
||||
|
||||
try
|
||||
{
|
||||
java.sql.Date dtFecha = this.obtenerFechaPrimeraVisita(medico, colectivo, poliza, beneficiario);
|
||||
|
||||
if (dtFecha!=null) //existe registro. Se comprueba si es la primera visita
|
||||
{
|
||||
Calendar calFechaPrimeraVisita = Calendar.getInstance();
|
||||
calFechaPrimeraVisita.setTime(dtFecha);
|
||||
Calendar calFechaActual = Calendar.getInstance();
|
||||
|
||||
if (ParametrosConfiguracion.periodoNatural.equalsIgnoreCase("si")) //se trata de un periodo natural
|
||||
{
|
||||
if (calFechaActual.get(Calendar.YEAR)>calFechaPrimeraVisita.get(Calendar.YEAR)) { //años diferentes
|
||||
esPrimeraVisita = true;
|
||||
} else {
|
||||
if (calFechaActual.get(Calendar.YEAR)==calFechaPrimeraVisita.get(Calendar.YEAR )) //mismo año
|
||||
{
|
||||
//le sumamos a la fecha obtenida el periodo de meses para conocer si es primera visita
|
||||
calFechaPrimeraVisita.add(Calendar.MONTH, ParametrosConfiguracion.periodoPrimeraVisita);
|
||||
|
||||
if ( calFechaPrimeraVisita.getTime().compareTo( calFechaActual.getTime() ) < 0 ) { //la fecha de la primera visita mas el periodo es inferior a la fecha actual
|
||||
esPrimeraVisita = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //se trata de un periodo no natural
|
||||
{
|
||||
//le sumamos a la fecha obtenida el periodo de meses para conocer si es primera visita
|
||||
calFechaPrimeraVisita.add(Calendar.MONTH, ParametrosConfiguracion.periodoPrimeraVisita);
|
||||
|
||||
if ( calFechaPrimeraVisita.getTime().compareTo( calFechaActual.getTime() ) < 0 ) //la fecha de la primera visita mas el periodo es inferior a la fecha actual
|
||||
esPrimeraVisita = true;
|
||||
}
|
||||
} else { //No existe registro. Es primera visita
|
||||
esPrimeraVisita = true;
|
||||
}
|
||||
|
||||
//LogTarisan.logger.log(NivelLog.DEBUG, "Es primera visita: " + esPrimeraVisita +" (" + strSql.toString() + ")");
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Es primera visita: " + esPrimeraVisita);
|
||||
|
||||
}
|
||||
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
return esPrimeraVisita;
|
||||
|
||||
}
|
||||
|
||||
public boolean sePuedeAutoprescribible(int medico, int entidad, long colectivo, double poliza, int orden, int acto){
|
||||
return sePuedeAutoprescribible(medico, entidad, colectivo, poliza, orden, acto, 0);
|
||||
}
|
||||
|
||||
public boolean sePuedeAutoprescribible(int medico, int entidad, long colectivo, double poliza, int orden, int acto, int contrato)
|
||||
{
|
||||
boolean resultado = false;
|
||||
LogTarisan.logger.log(NivelLog.INFO, "Empezamos a comprobar si se puede imputar un acto autoprescribible");
|
||||
//selecionamos entidad, colectivo, poliza, orden con la tarjeta
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
java.sql.Date dtFechaUltimoTamovext = null;
|
||||
Object[] aCondiciones;
|
||||
Connection conexion = null;
|
||||
Usuario usu = new Usuario();
|
||||
PersistenciaUsuario perUsu= new PersistenciaUsuario();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
usu = perUsu.seleccionar(medico);
|
||||
int especialidad = usu.getEspecialidad();
|
||||
if((especialidad == Integer.parseInt(Constantes.PERFIL_DENTISTA)) || (especialidad == 19))
|
||||
resultado = true;
|
||||
|
||||
if(!resultado)
|
||||
{
|
||||
|
||||
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
strSql = new StringBuffer();
|
||||
strSql.append("select FECHA");
|
||||
if(contrato==723){
|
||||
strSql.append(" from tamovext_dental");
|
||||
}else{
|
||||
strSql.append(" from tamovext");
|
||||
}
|
||||
strSql.append(" where entidad = ?");
|
||||
strSql.append(" and colectivo = ?");
|
||||
strSql.append(" and poliza = ?");
|
||||
strSql.append(" and orden = ?");
|
||||
strSql.append(" and medico = ?");
|
||||
strSql.append(" and acto = ?");
|
||||
strSql.append(" ORDER BY FECHA DESC");
|
||||
aCondiciones = null;
|
||||
aCondiciones = new Object[6];
|
||||
aCondiciones[0] = Integer.valueOf(entidad);
|
||||
aCondiciones[1] = Long.valueOf(colectivo);
|
||||
aCondiciones[2] = Double.valueOf(poliza);
|
||||
aCondiciones[3] = Integer.valueOf(orden);
|
||||
aCondiciones[4] = Integer.valueOf(medico);
|
||||
aCondiciones[5] = Integer.valueOf(acto);
|
||||
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
if(rs.next())
|
||||
{
|
||||
dtFechaUltimoTamovext = rs.getDate("FECHA");
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTaprimer - sePuedeAutoprescribible - Llega a 132 fecha: "+dtFechaUltimoTamovext);
|
||||
}
|
||||
rs.close();
|
||||
//si la fecha del movimiento es distinto de null es que hay movimientos comparamos el año, mes, día con la fecha actual y si corresponde ponemos resultado a cierto
|
||||
if(dtFechaUltimoTamovext != null)
|
||||
{
|
||||
Calendar calFechaUltTamovext = Calendar.getInstance();
|
||||
Calendar hoy = Calendar.getInstance();
|
||||
calFechaUltTamovext.setTime(dtFechaUltimoTamovext);
|
||||
if(hoy.get(Calendar.YEAR)>calFechaUltTamovext.get(Calendar.YEAR))
|
||||
{
|
||||
resultado = true;
|
||||
}
|
||||
else if(hoy.get(Calendar.MONTH)>calFechaUltTamovext.get(Calendar.MONTH))
|
||||
{
|
||||
resultado = true;
|
||||
}
|
||||
else if(hoy.get(Calendar.DAY_OF_MONTH)>calFechaUltTamovext.get(Calendar.DAY_OF_MONTH))
|
||||
{
|
||||
resultado = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
resultado = true;
|
||||
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
}
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de sePuedeAutoprescribible: " + sqle + " (" + strSql.toString() + ")");
|
||||
} catch (SQLException e) {
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error SQL en la selección de sePuedeAutoprescribible: " + e + " (" + strSql.toString() + ")");
|
||||
}
|
||||
LogTarisan.logger.log(NivelLog.INFO, "Terminamos de comprobar si se puede el acto: "+acto+" para ent, col, pol, ord: "+entidad+", "+colectivo+", "+poliza+", "+orden+" con resultado: "+resultado);
|
||||
return resultado;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Devuelve la fecha más reciente de la primera visita realizada para el médico y paciente indicado.
|
||||
* En caso de que no exista ningún registro para el médico y paciente indicado, la función devolverá el valor null.
|
||||
* @param medico Código del médico.
|
||||
* @param colectivo Número de colectivo.
|
||||
* @param poliza Número de póliza.
|
||||
* @param beneficiario Número de beneficiario.
|
||||
* @return La Fecha más reciente perteneciente a la primera visita. En caso de no encontrar ningún registro, devolverá el valor null.
|
||||
* @throws
|
||||
* @param orden: si es cierto ordena descendentemente, sino ascendentemente (obtener primera visita o la última)
|
||||
*/
|
||||
public java.sql.Date obtenerFechaPrimeraVisita(int medico, long colectivo, double poliza, int beneficiario) throws ExcepcionTarisan
|
||||
{
|
||||
return this.obtenerFechaPrimeraVisita(medico,colectivo,poliza,beneficiario, true);
|
||||
}
|
||||
|
||||
public java.sql.Date obtenerFechaPrimeraVisita(int medico, long colectivo, double poliza, int beneficiario, boolean orden) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object[] aCondiciones;
|
||||
boolean esPrimeraVisita = false;
|
||||
java.sql.Date dtFechaPrimeraVisita = null;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT FECHA");
|
||||
strSql.append(" FROM TAPRIMER");
|
||||
strSql.append(" WHERE MEDICO = ?");
|
||||
strSql.append(" AND COLEC=?");
|
||||
strSql.append(" AND POLIZA=?");
|
||||
strSql.append(" AND ORDEN=?");
|
||||
//strSql.append(" AND ACTO=1");
|
||||
//strSql.append(" AND ACTO=1");
|
||||
strSql.append(" AND ACTO<>1460");
|
||||
if(orden)
|
||||
strSql.append(" ORDER BY FECHA DESC");
|
||||
else
|
||||
strSql.append(" ORDER BY FECHA ASC");
|
||||
|
||||
aCondiciones = new Object[4];
|
||||
aCondiciones[0] = Integer.valueOf(medico);
|
||||
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()) //existe registro.
|
||||
dtFechaPrimeraVisita = rs.getDate("FECHA");
|
||||
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "La fecha de la primera visita obtenida ha sido: " + dtFechaPrimeraVisita +" (" + strSql.toString() + ")");
|
||||
}
|
||||
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
return dtFechaPrimeraVisita;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifica la tabla TAPRIMER 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 modificarPrimeraVisita(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 TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifica la tabla TAPRIMER 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 modificarPrimeraVisita(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 TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifica la tabla TAPRIMER 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.
|
||||
* @throws
|
||||
*/
|
||||
public void insertarPrimeraVisita(String sqlSelect, Object[] aValores) throws ExcepcionTarisan
|
||||
{
|
||||
try
|
||||
{
|
||||
ParametrosConfiguracion.dataStore.insertar(sqlSelect, aValores);
|
||||
}
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifica la tabla TAPRIMER 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 insertarPrimeraVisita(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 insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public java.sql.Date obtenerFechaPrimeraLimpieza(int medico, long colectivo, double poliza, int beneficiario) throws ExcepcionTarisan
|
||||
{
|
||||
return this.obtenerFechaPrimeraLimpieza(medico,colectivo,poliza,beneficiario, true);
|
||||
}
|
||||
|
||||
public java.sql.Date obtenerFechaPrimeraLimpieza(int medico, long colectivo, double poliza, int beneficiario, boolean orden) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object[] aCondiciones;
|
||||
boolean esPrimeraLimpieza = false;
|
||||
java.sql.Date dtFechaPrimeraLimpieza = null;
|
||||
|
||||
try
|
||||
{
|
||||
strSql.append("SELECT FECHA");
|
||||
strSql.append(" FROM TAPRIMER");
|
||||
strSql.append(" WHERE MEDICO = ?");
|
||||
strSql.append(" AND COLEC=?");
|
||||
strSql.append(" AND POLIZA=?");
|
||||
strSql.append(" AND ORDEN=?");
|
||||
strSql.append(" AND ACTO=?");
|
||||
if(orden)
|
||||
strSql.append(" ORDER BY FECHA DESC");
|
||||
else
|
||||
strSql.append(" ORDER BY FECHA ASC");
|
||||
|
||||
aCondiciones = new Object[5];
|
||||
aCondiciones[0] = Integer.valueOf(medico);
|
||||
aCondiciones[1] = Long.valueOf(colectivo);
|
||||
aCondiciones[2] = Double.valueOf(poliza);
|
||||
aCondiciones[3] = Integer.valueOf(beneficiario);
|
||||
aCondiciones[4] = Integer.valueOf(ParametrosConfiguracion.codigoPrimeraLimpieza);
|
||||
|
||||
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
||||
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones);
|
||||
|
||||
if (rs.next()) //existe registro.
|
||||
dtFechaPrimeraLimpieza = rs.getDate("FECHA");
|
||||
|
||||
rs.close();
|
||||
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "La fecha de la primera limpieza de boca obtenida ha sido: " + dtFechaPrimeraLimpieza +" (" + strSql.toString() + ")");
|
||||
}
|
||||
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(SQLException sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
return dtFechaPrimeraLimpieza;
|
||||
|
||||
}
|
||||
|
||||
public boolean esPrimeraLimpieza(int medico, long colectivo, double poliza, int beneficiario) throws ExcepcionTarisan
|
||||
{
|
||||
StringBuffer strSql = new StringBuffer();
|
||||
Object[] aCondiciones;
|
||||
boolean esPrimeraLimpieza = false;
|
||||
|
||||
try
|
||||
{
|
||||
java.sql.Date dtFecha = this.obtenerFechaPrimeraLimpieza(medico, colectivo, poliza, beneficiario);
|
||||
|
||||
if (dtFecha!=null) //existe registro. Se comprueba si es la primera limpieza de boca
|
||||
{
|
||||
Calendar calFechaPrimeraLimpieza = Calendar.getInstance();
|
||||
calFechaPrimeraLimpieza.setTime(dtFecha);
|
||||
Calendar calFechaActual = Calendar.getInstance();
|
||||
|
||||
if (ParametrosConfiguracion.periodoNatural.equalsIgnoreCase("si")) //se trata de un periodo natural
|
||||
{
|
||||
if (calFechaActual.get(Calendar.YEAR)>calFechaPrimeraLimpieza.get(Calendar.YEAR)) { //años diferentes
|
||||
esPrimeraLimpieza = true;
|
||||
} else {
|
||||
if (calFechaActual.get(Calendar.YEAR)==calFechaPrimeraLimpieza.get(Calendar.YEAR )) //mismo año
|
||||
{
|
||||
//le sumamos a la fecha obtenida el periodo de meses para conocer si es primera visita
|
||||
calFechaPrimeraLimpieza.add(Calendar.MONTH, ParametrosConfiguracion.periodoPrimeraVisita);
|
||||
|
||||
if ( calFechaPrimeraLimpieza.getTime().compareTo( calFechaActual.getTime() ) < 0 ) { //la fecha de la primera limpieza de boca mas el periodo es inferior a la fecha actual
|
||||
esPrimeraLimpieza = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //se trata de un periodo no natural
|
||||
{
|
||||
//le sumamos a la fecha obtenida el periodo de meses para conocer si es primera limpieza de boca
|
||||
calFechaPrimeraLimpieza.add(Calendar.MONTH, ParametrosConfiguracion.periodoPrimeraVisita);
|
||||
|
||||
if ( calFechaPrimeraLimpieza.getTime().compareTo( calFechaActual.getTime() ) < 0 ) //la fecha de la primera limpieza de boca mas el periodo es inferior a la fecha actual
|
||||
esPrimeraLimpieza = true;
|
||||
}
|
||||
} else { //No existe registro. Es primera limpieza de boca
|
||||
esPrimeraLimpieza = true;
|
||||
}
|
||||
|
||||
LogTarisan.logger.log(NivelLog.DEBUG, "Es primera limpieza: " + esPrimeraLimpieza);
|
||||
|
||||
}
|
||||
|
||||
catch (ExcepcionTarisan sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAPRIMER: " + sqle + " (" + strSql.toString() + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
|
||||
return esPrimeraLimpieza;
|
||||
|
||||
}
|
||||
|
||||
public void modificarPrimeraLimpieza(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 TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la modificacion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void insertarPrimeraLimpieza(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 insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw (ExcepcionTarisan)sqle;
|
||||
}
|
||||
catch(Exception sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
}
|
||||
catch(Throwable sqle)
|
||||
{
|
||||
LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAPRIMER: " + sqle + " (" + sqlSelect + ")");
|
||||
throw new ExcepcionTarisan(sqle.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user