|
|
|
|
@ -7,12 +7,209 @@
|
|
|
|
|
*/
|
|
|
|
|
package siprp.data.outer;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public final class TrabalhadoresEcdsDatasData extends siprp.data.inner.TrabalhadoresEcdsDatas
|
|
|
|
|
import siprp.MedicinaConstants;
|
|
|
|
|
|
|
|
|
|
import com.evolute.adt.OrderedMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final class TrabalhadoresEcdsDatasData extends siprp.data.inner.TrabalhadoresEcdsDatas implements MedicinaConstants
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public TrabalhadoresEcdsDatasData()
|
|
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDataString()
|
|
|
|
|
{
|
|
|
|
|
return getData() == null ? "" : DATE_FORMAT.format( getData() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getEstadoString()
|
|
|
|
|
{
|
|
|
|
|
return getEstado() == null || getEstado() >= ESTADOS_EXAME_STR.length ? "" : ESTADOS_EXAME_STR[getEstado()];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, String> getEstados()
|
|
|
|
|
{
|
|
|
|
|
HashMap<Integer, String> result = new HashMap<Integer, String>();
|
|
|
|
|
for( int i = 0; i < ESTADOS_EXAME_STR.length; ++i )
|
|
|
|
|
{
|
|
|
|
|
if( ESTADOS_EXAME_STR[i] != null )
|
|
|
|
|
{
|
|
|
|
|
result.put( new Integer( i ), ESTADOS_EXAME_STR[i] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setData( Date date )
|
|
|
|
|
{
|
|
|
|
|
if( date != null && this.toTrabalhadores_ecds_id() != null && this.getEstado() != null && new Integer( ESTADO_POR_REALIZAR ).equals( this.getEstado() ) )
|
|
|
|
|
{
|
|
|
|
|
this.toTrabalhadores_ecds_id().setData( date );
|
|
|
|
|
}
|
|
|
|
|
super.setData( date );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString()
|
|
|
|
|
{
|
|
|
|
|
return getDataString() + ": " + getEstadoString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrderedMap<PrtGruposProtocoloData> getStatesForeGruposExames()
|
|
|
|
|
{
|
|
|
|
|
OrderedMap<PrtGruposProtocoloData> grupos = new OrderedMap<PrtGruposProtocoloData>();
|
|
|
|
|
List<TrabalhadoresEcdData> exames = this.fromTrabalhadoresEcd_trabalhadores_ecds_datas_id();
|
|
|
|
|
if( exames != null )
|
|
|
|
|
{
|
|
|
|
|
for( TrabalhadoresEcdData exame : exames )
|
|
|
|
|
{
|
|
|
|
|
String estadoString = MedicinaConstants.ESTADOS_EXAME_STR[exame.getEstado()];
|
|
|
|
|
PrtGruposProtocoloData grupo = exame.toEcd_id().toGrupo_protocolo_id();
|
|
|
|
|
if( !grupos.containsKey( grupo ) )
|
|
|
|
|
{
|
|
|
|
|
grupos.putLast( grupo, grupo.getDescricao() );
|
|
|
|
|
grupos.putLast( grupo, estadoString );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
grupos.order();
|
|
|
|
|
return grupos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PrtTiposElementosProtocoloData> getAllEcdForGrupoForThisMarcacao( PrtGruposProtocoloData grupo )
|
|
|
|
|
{
|
|
|
|
|
List<PrtTiposElementosProtocoloData> result = new ArrayList<PrtTiposElementosProtocoloData>();
|
|
|
|
|
for( TrabalhadoresEcdData ecd : (List<TrabalhadoresEcdData>) fromTrabalhadoresEcd_trabalhadores_ecds_datas_id() )
|
|
|
|
|
{
|
|
|
|
|
if( grupo.equals( ecd.toEcd_id().toGrupo_protocolo_id() ) )
|
|
|
|
|
{
|
|
|
|
|
result.add( ecd.toEcd_id() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PrtTiposElementosProtocoloData> getAllEcdForGrupoAndCurrentPerfil( PrtGruposProtocoloData grupo )
|
|
|
|
|
{
|
|
|
|
|
TrabalhadoresData trabalhador = toTrabalhadores_ecds_id().toTrabalhador_id();
|
|
|
|
|
List<PrtTiposElementosProtocoloData> result = new ArrayList<PrtTiposElementosProtocoloData>();
|
|
|
|
|
Integer perfil = trabalhador.getPerfil();
|
|
|
|
|
if( perfil != null )
|
|
|
|
|
{
|
|
|
|
|
EmpresasData empresa = trabalhador.toEstabelecimento_id().toEmpresa_id();
|
|
|
|
|
List<PrtElementosProtocoloData> ecdsPerfil = empresa.fromPrtElementosProtocolo_empresa_id();
|
|
|
|
|
for( PrtElementosProtocoloData ecdPerfil : ecdsPerfil )
|
|
|
|
|
{
|
|
|
|
|
if( perfil.equals( ecdPerfil.getNumero_perfil() ) )
|
|
|
|
|
{
|
|
|
|
|
PrtTiposElementosProtocoloData ecd = ecdPerfil.toTipo_elemento_protocolo_id();
|
|
|
|
|
if( ecd != null )
|
|
|
|
|
{
|
|
|
|
|
if( ecd.toGrupo_protocolo_id().equals( grupo ) && !result.contains( ecd ) )
|
|
|
|
|
{
|
|
|
|
|
result.add( ecd );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void marcarGrupoExames( PrtGruposProtocoloData grupo )
|
|
|
|
|
{
|
|
|
|
|
for( PrtTiposElementosProtocoloData ecd : getAllEcdForGrupoAndCurrentPerfil( grupo ) )
|
|
|
|
|
{
|
|
|
|
|
TrabalhadoresEcdData trabEcd = new TrabalhadoresEcdData();
|
|
|
|
|
trabEcd.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR );
|
|
|
|
|
trabEcd.setToEcd_id( ecd );
|
|
|
|
|
trabEcd.setToTrabalhadores_ecds_datas_id( this );
|
|
|
|
|
}
|
|
|
|
|
toTrabalhadores_ecds_id().getGruposExamesForPerfil();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStateForGrupoProtocolo( PrtGruposProtocoloData grupo, Integer estado )
|
|
|
|
|
{
|
|
|
|
|
List<PrtTiposElementosProtocoloData> group = getAllEcdForGrupoForThisMarcacao( grupo );
|
|
|
|
|
for(TrabalhadoresEcdData ecd : fromTrabalhadoresEcd_trabalhadores_ecds_datas_id())
|
|
|
|
|
{
|
|
|
|
|
if( group.contains( ecd.toEcd_id() ) )
|
|
|
|
|
{
|
|
|
|
|
ecd.setEstado( estado );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStateForGrupoProtocolo( PrtGruposProtocoloData grupo, String estado )
|
|
|
|
|
{
|
|
|
|
|
for( int i = 0; i < ESTADOS_EXAME_STR.length; ++i )
|
|
|
|
|
{
|
|
|
|
|
String currentEstado = ESTADOS_EXAME_STR[i];
|
|
|
|
|
if( currentEstado != null && new Integer( i ).equals( estado ) )
|
|
|
|
|
{
|
|
|
|
|
setStateForGrupoProtocolo( grupo, i );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void anular()
|
|
|
|
|
{
|
|
|
|
|
setEstadoForAllEcd( MedicinaConstants.ESTADO_ANULADO );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void realizar()
|
|
|
|
|
{
|
|
|
|
|
setEstadoForAllEcd( MedicinaConstants.ESTADO_REALIZADO );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void porRealizar()
|
|
|
|
|
{
|
|
|
|
|
setEstadoForAllEcd( MedicinaConstants.ESTADO_POR_REALIZAR );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void desmarcarSIPRP()
|
|
|
|
|
{
|
|
|
|
|
setEstadoForAllEcd( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void desmarcarTrabalhador()
|
|
|
|
|
{
|
|
|
|
|
setEstadoForAllEcd( MedicinaConstants.ESTADO_DESMARCADO_TRABALHADOR );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void faltou()
|
|
|
|
|
{
|
|
|
|
|
setEstadoForAllEcd( MedicinaConstants.ESTADO_FALTOU );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setEstadoForAllEcd( Integer estado )
|
|
|
|
|
{
|
|
|
|
|
List<TrabalhadoresEcdData> allEcd = fromTrabalhadoresEcd_trabalhadores_ecds_datas_id();
|
|
|
|
|
if(allEcd != null)
|
|
|
|
|
{
|
|
|
|
|
for(TrabalhadoresEcdData ecd : allEcd )
|
|
|
|
|
{
|
|
|
|
|
ecd.setEstado( estado );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
super.setEstado( estado );
|
|
|
|
|
toTrabalhadores_ecds_id().getGruposExamesForPerfil();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setEstado( Integer estado ){
|
|
|
|
|
super.setEstado( estado );
|
|
|
|
|
toTrabalhadores_ecds_id().getGruposExamesForPerfil();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|