155 lines
5.0 KiB
Java
155 lines
5.0 KiB
Java
package com.tarisan.chipcard.tpvvs.webservicetrayicon.accesodatos;
|
|
|
|
import java.util.Vector;
|
|
import es.chipcard.util.*;
|
|
|
|
public class ActoMedicoBean extends ClsDBBase{
|
|
public static final String TABLENAME="ACTO_MEDICO";
|
|
|
|
public ActoMedicoBean(){
|
|
if(!tableExistLocally()){
|
|
createLocalTable();
|
|
}
|
|
}
|
|
|
|
public String getTableName(){
|
|
return TABLENAME;
|
|
}
|
|
|
|
|
|
public java.util.Vector getListaActos(){
|
|
String sSQL="SELECT * FROM "+TABLENAME;
|
|
return getActosMedicos(sSQL);
|
|
}
|
|
|
|
public Vector getActosMedicosOf(int nTer,int nComp,int nEspe,String sProf,int codLA){
|
|
String sSQL="SELECT * FROM "+TABLENAME+" WHERE ID_TER="+DataBaseUtil.FormatSQLIntegerField(nTer)+" AND ID_PROF="+DataBaseUtil.FormatSQLStringField(sProf)+" AND ID_COMP="+DataBaseUtil.FormatSQLIntegerField(nComp)+" AND ID_ESPE="+DataBaseUtil.FormatSQLIntegerField(nEspe)+" AND ID_LACTOS="+DataBaseUtil.FormatSQLIntegerField(codLA);
|
|
return getActosMedicos(sSQL);
|
|
}
|
|
|
|
public ActoMedico getActoMedicoByCompAndEspeAndIDLActosAndIDActo(int nIDComp,int nIDEspe, int lactos, int nActo){
|
|
String sSQL="SELECT * FROM "+TABLENAME+" WHERE ID_ESPE="+nIDEspe+" AND ID_COMP="+nIDComp+" AND ID_LACTOS="+lactos+" AND ID_ACTO="+nActo+"";
|
|
Vector vActos=getActosMedicos(sSQL);
|
|
if(vActos!=null){
|
|
if(vActos.size()>0){
|
|
return (ActoMedico)vActos.firstElement();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Vector getActosMedicosByTerminalAndProfesional(int nTer,String sProf){
|
|
String sSQL="SELECT * FROM "+TABLENAME+" WHERE ID_TER="+DataBaseUtil.FormatSQLIntegerField(nTer)+" AND ID_PROF="+DataBaseUtil.FormatSQLStringField(sProf);
|
|
return getActosMedicos(sSQL);
|
|
}
|
|
|
|
public Vector getProfesionales(int nTer){
|
|
String sSQL="SELECT * FROM "+TABLENAME+" WHERE ID_TER="+DataBaseUtil.FormatSQLIntegerField(nTer);
|
|
return getActosMedicos(sSQL);
|
|
}
|
|
|
|
public Vector getActosMedicosByTerminal(int nTer){
|
|
String sSQL="SELECT * FROM "+TABLENAME+" WHERE ID_TER="+DataBaseUtil.FormatSQLIntegerField(nTer);
|
|
return getActosMedicos(sSQL);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Vector getActosMedicosByProf(String sProf){
|
|
String sSQL="SELECT * FROM "+TABLENAME+" WHERE ID_PROF="+DataBaseUtil.FormatSQLStringField(sProf);
|
|
return getActosMedicos(sSQL);
|
|
}
|
|
|
|
private java.util.Vector getActosMedicos(String sSQL){
|
|
java.util.Vector v=new java.util.Vector();
|
|
java.sql.ResultSet rs=null;
|
|
if(rs==null){
|
|
rs=LocalDatabaseControl.getInstance().getQuery(sSQL);
|
|
}
|
|
if(rs!=null){
|
|
try{
|
|
while(rs.next()){
|
|
v.addElement(getActoMedico(rs));
|
|
}
|
|
}catch(Exception err){
|
|
SerClsDebug.aLog(err);
|
|
}
|
|
}
|
|
return v;
|
|
}
|
|
|
|
private ActoMedico getActoMedico(java.sql.ResultSet rs){
|
|
ActoMedico obj=new ActoMedico();
|
|
try{
|
|
obj.setCodigoTerminal(rs.getInt("ID_TER"));
|
|
obj.setCodigoCompania(rs.getInt("ID_COMP"));
|
|
obj.setCodigoEspecialidad(rs.getInt("ID_ESPE"));
|
|
obj.setCodigoProf(rs.getString("ID_PROF"));
|
|
obj.setCodigoLActos(rs.getInt("ID_LACTOS"));
|
|
obj.setCodigoActo(rs.getInt("ID_ACTO"));
|
|
obj.setNombreActo(rs.getString("NOMBRE_ACTO"));
|
|
}catch(Exception err){
|
|
SerClsDebug.aLog(err);
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
|
|
private void repoblateTable(){
|
|
|
|
}
|
|
|
|
public int insertInLocal(ActoMedico objActoMedico){
|
|
return insertInLocal(objActoMedico.getCodigoTerminal(),objActoMedico.getCodigoCompania(),objActoMedico.getCodigoEspecialidad(),objActoMedico.getCodigoProf(),objActoMedico.getCodigoLActos() ,objActoMedico.getCodigoActo(),objActoMedico.getNombreActo());
|
|
}
|
|
|
|
private int insertInLocal(int nIdTer,int sCodComp,int sCodEspe,String sCodProf,int nCodLActos,int nActo,String sNombre){
|
|
int nRetorno=-1;
|
|
try{
|
|
if(nIdTer>0 && sCodComp>0 && sCodEspe>0 && sCodProf!=null && nCodLActos>0 && nActo>0){
|
|
String sSQL="INSERT INTO "+TABLENAME+"(" +
|
|
"ID_TER," +
|
|
"ID_COMP," +
|
|
"ID_ESPE," +
|
|
"ID_PROF," +
|
|
"ID_LACTOS," +
|
|
"ID_ACTO," +
|
|
"NOMBRE_ACTO" +
|
|
") "+
|
|
"VALUES (" +
|
|
DataBaseUtil.FormatSQLIntegerField(nIdTer)+","+
|
|
DataBaseUtil.FormatSQLIntegerField(sCodComp)+","+
|
|
DataBaseUtil.FormatSQLIntegerField(sCodEspe)+","+
|
|
DataBaseUtil.FormatSQLStringField(sCodProf) +","+
|
|
DataBaseUtil.FormatSQLIntegerField(nCodLActos)+","+
|
|
DataBaseUtil.FormatSQLIntegerField(nActo)+","+
|
|
DataBaseUtil.FormatSQLStringField(sNombre) +
|
|
")";
|
|
nRetorno=LocalDatabaseControl.getInstance().executeUpdate(sSQL);
|
|
}
|
|
}catch(Exception err){SerClsDebug.aLog(err);}
|
|
return nRetorno;
|
|
}
|
|
|
|
|
|
|
|
protected int createLocalTable(){
|
|
int nRetorno= LocalDatabaseControl.getInstance().executeUpdate(
|
|
"CREATE TABLE \""+TABLENAME+"\" (" +
|
|
"\"ID_TER\" int NOT NULL," +
|
|
"\"ID_COMP\" int NOT NULL," +
|
|
"\"ID_ESPE\" int NOT NULL," +
|
|
"\"ID_PROF\" VARCHAR(12) NOT NULL," +
|
|
"\"ID_LACTOS\" int NOT NULL," +
|
|
"\"ID_ACTO\" int NOT NULL," +
|
|
"\"NOMBRE_ACTO\" VARCHAR(100) NOT NULL," +
|
|
" PRIMARY KEY (ID_TER, ID_COMP,ID_ESPE,ID_PROF,ID_LACTOS,ID_ACTO)"+
|
|
")"
|
|
);
|
|
repoblateTable();
|
|
return nRetorno;
|
|
}
|
|
}
|