forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
210 lines
5.3 KiB
210 lines
5.3 KiB
package siprp.database.cayenne.providers;
|
|
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import siprp.MedicinaConstants;
|
|
import siprp.ProcessoConstants;
|
|
import siprp.data.outer.EmpresasData;
|
|
import siprp.data.outer.ExamesData;
|
|
import siprp.data.outer.LembretesTiposData;
|
|
import siprp.data.outer.PrestadoresData;
|
|
import siprp.data.outer.PrtGruposProtocoloData;
|
|
import siprp.data.outer.TrabalhadoresConsultasDatasData;
|
|
import siprp.data.outer.TrabalhadoresData;
|
|
import siprp.data.outer.TrabalhadoresEcdData;
|
|
import siprp.data.outer.TrabalhadoresEcdsDatasData;
|
|
import siprp.data.outer.TrabalhadoresProcessoData;
|
|
import siprp.database.cayenne.objects.Prestadores;
|
|
|
|
import com.evolute.entity.ProviderInterface;
|
|
import com.evolute.utils.Singleton;
|
|
import com.evolute.utils.dataedition.persistence.Persistent;
|
|
import com.evolute.utils.db.DBManager;
|
|
import com.evolute.utils.db.Executer;
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
public class MedicinaDataProvider
|
|
{
|
|
private static MedicinaDataProvider INSTANCE = null;
|
|
|
|
private ProviderInterface< Persistent< ? >, Exception > ENTITY_PROVIDER;
|
|
private Executer executer;
|
|
|
|
private MedicinaDataProvider() throws Exception
|
|
{
|
|
DBManager manager = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
|
|
executer = manager.getSharedExecuter( this );
|
|
ENTITY_PROVIDER = ( ProviderInterface< Persistent< ? >, Exception > ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER );
|
|
}
|
|
|
|
public static synchronized MedicinaDataProvider getInstance() throws Exception
|
|
{
|
|
if ( INSTANCE == null )
|
|
{
|
|
INSTANCE = new MedicinaDataProvider();
|
|
}
|
|
return INSTANCE;
|
|
}
|
|
|
|
public TrabalhadoresData getTrabalhadorByID( Integer id )
|
|
{
|
|
TrabalhadoresData result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.load( TrabalhadoresData.class, id );
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public TrabalhadoresConsultasDatasData getConsultaMarcacaoByID( Integer id )
|
|
{
|
|
TrabalhadoresConsultasDatasData result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.load( TrabalhadoresConsultasDatasData.class, id );
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public ExamesData getExameForExameID( Integer currentFichaExameID )
|
|
{
|
|
ExamesData result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.load( ExamesData.class, currentFichaExameID );
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public LembretesTiposData getTipoLembretesCustomizavel()
|
|
{
|
|
LembretesTiposData result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.load( LembretesTiposData.class, 1 );
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public List< EmpresasData > getAllEmpresas()
|
|
{
|
|
List< EmpresasData > result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.listLoad( EmpresasData.class,
|
|
new Object[] { "y" },
|
|
new String[] { EmpresasData.INACTIVO },
|
|
new String[] { EmpresasData.DESIGNACAO_SOCIAL_PLAIN } );
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public List< PrestadoresData > getAllPrestadores()
|
|
{
|
|
List< PrestadoresData > result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.listLoad( PrestadoresData.class,
|
|
new Object[] { "y" }, new String[] { PrestadoresData.ACTIVO },
|
|
new String[] { PrestadoresData.NOME } );
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public List< PrtGruposProtocoloData > getAllPrtGruposProtocolo()
|
|
{
|
|
List< PrtGruposProtocoloData > result = null;
|
|
try
|
|
{
|
|
result = ENTITY_PROVIDER.listLoad( PrtGruposProtocoloData.class,
|
|
new String[] { PrtGruposProtocoloData.DESCRICAO_PLAIN } );
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public void fecharProcesso( TrabalhadoresProcessoData currentProcesso )
|
|
{
|
|
try
|
|
{
|
|
currentProcesso.setEstado( ProcessoConstants.PROCESSO_FECHADO_CODE );
|
|
currentProcesso.save();
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
}
|
|
|
|
|
|
//FIXME : substituir por PrestadoresData.prestadorNulo -> fazer alteracoes aqui
|
|
public PrestadoresData getDefaultPrestador()
|
|
{
|
|
PrestadoresData prestadorNulo = new PrestadoresData();
|
|
prestadorNulo.setNome( "SIPRP" );
|
|
return prestadorNulo;
|
|
}
|
|
|
|
public Collection< TrabalhadoresEcdData > getPendingExamesForAnalisador( Prestadores currentAnalisador )
|
|
{
|
|
Map< TrabalhadoresEcdData, TrabalhadoresEcdData > resultMap = new HashMap< TrabalhadoresEcdData, TrabalhadoresEcdData >();
|
|
try
|
|
{
|
|
List< TrabalhadoresEcdData > all = ENTITY_PROVIDER.listLoad( TrabalhadoresEcdData.class,
|
|
new Object[] { null }, new String[] { TrabalhadoresEcdData.DATA_RECEPCAO }, null );
|
|
for ( TrabalhadoresEcdData ecd : all )
|
|
{
|
|
TrabalhadoresEcdsDatasData data = ecd.toTrabalhadores_ecds_datas_id();
|
|
|
|
if ( new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( data.getEstado() ) )
|
|
{
|
|
if ( currentAnalisador.equals( ecd.toAnalisador_id() ) )
|
|
{
|
|
resultMap.put( ecd ,ecd );
|
|
}
|
|
else if ( Prestadores.prestadorNulo.equals( currentAnalisador ) && ecd.toAnalisador_id() == null )
|
|
{
|
|
resultMap.put( ecd, ecd );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch ( Exception e )
|
|
{
|
|
ErrorLogger.logException( e );
|
|
}
|
|
return resultMap.values();
|
|
}
|
|
|
|
}
|