diff --git a/trunk/SIPRPSoft/src/siprp/database/cayenne/objects/TrabalhadoresEcdsDatas.java b/trunk/SIPRPSoft/src/siprp/database/cayenne/objects/TrabalhadoresEcdsDatas.java index e947a401..9fdb9899 100755 --- a/trunk/SIPRPSoft/src/siprp/database/cayenne/objects/TrabalhadoresEcdsDatas.java +++ b/trunk/SIPRPSoft/src/siprp/database/cayenne/objects/TrabalhadoresEcdsDatas.java @@ -151,8 +151,37 @@ public class TrabalhadoresEcdsDatas extends _TrabalhadoresEcdsDatas implements M } } - @Override - public void setEstado( Integer estado ) + 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 allEcd = (List) getTrabalhadoresEcdArray(); if(allEcd != null) diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java index 9a9cd059..ebe9086e 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java @@ -162,6 +162,9 @@ public class MedicinaProcessoLogic extends SIPRPLogic @Action(isSave = true) public static final String REALIZAR_EXAME_MARCACAO = "REALIZAR_EXAME_MARCACAO"; + + @Action(isSave = true) + public static final String REALIZAR_PARCIAL_EXAME_MARCACAO = "REALIZAR_PARCIAL_EXAME_MARCACAO"; @Action(isSave = true) public static final String FALTOU_EXAME_MARCACAO = "FALTOU_EXAME_MARCACAO"; @@ -173,34 +176,34 @@ public class MedicinaProcessoLogic extends SIPRPLogic private Trabalhadores currentTrabalhador = null; - @LeafObject(useWithAction = SAVE_PROCESSO) + @LeafObject(useWith = SAVE_PROCESSO) public TrabalhadoresProcesso currentProcesso = null; - @LeafObject(useWithAction = SAVE_CONSULTA) + @LeafObject(useWith = SAVE_CONSULTA) public TrabalhadoresConsultas currentConsulta = null; - @LeafObject(useWithAction = SAVE_CONSULTA_MARCACAO) + @LeafObject(useWith = SAVE_CONSULTA_MARCACAO) public TrabalhadoresConsultasDatas currentConsultaMarcacao = null; - @LeafObject(useWithAction = SAVE_CONSULTA_MARCACAO_EMAIL) + @LeafObject(useWith = SAVE_CONSULTA_MARCACAO_EMAIL) public TrabalhadoresConsultasDatasEmails currentConsultaMarcacaoEmail = null; - @LeafObject(useWithAction = SAVE_CONSULTA_MARCACAO_OBSERVACOES) + @LeafObject(useWith = SAVE_CONSULTA_MARCACAO_OBSERVACOES) public TrabalhadoresConsultasDatasObservacoes currentConsultaMarcacaoObservacao = null; - @LeafObject(useWithAction = SAVE_FICHA) + @LeafObject(useWith = SAVE_FICHA) public FichaAptidaoMutableTreeNode currentFicha = null; - @LeafObject(useWithAction = SAVE_EXAME_MARCACAO_OBSERVACOES) + @LeafObject(useWith = SAVE_EXAME_MARCACAO_OBSERVACOES) public TrabalhadoresEcdsDatasObservacoes currentExameMarcacaoObservacao = null; - @LeafObject(useWithAction = SAVE_EXAME_MARCACAO_EMAIL) + @LeafObject(useWith = SAVE_EXAME_MARCACAO_EMAIL) public TrabalhadoresEcdsDatasEmails currentExameMarcacaoEmail = null; - @LeafObject(useWithAction = SAVE_EXAME_MARCACAO) + @LeafObject(useWith = { SAVE_EXAME_MARCACAO, REALIZAR_PARCIAL_EXAME_MARCACAO }) public TrabalhadoresEcdsDatas currentExameMarcacao = null; - @LeafObject(useWithAction = SAVE_EXAME) + @LeafObject(useWith = SAVE_EXAME) public TrabalhadoresEcds currentExame = null; public MedicinaProcessoLogic() @@ -309,7 +312,7 @@ public class MedicinaProcessoLogic extends SIPRPLogic { if( currentExameMarcacao != null ) { - currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_EMPRESA ); + currentExameMarcacao.desmarcarSIPRP(); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -319,7 +322,7 @@ public class MedicinaProcessoLogic extends SIPRPLogic { if( currentExameMarcacao != null ) { - currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_DESMARCADO_TRABALHADOR ); + currentExameMarcacao.desmarcarTrabalhador(); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -329,7 +332,7 @@ public class MedicinaProcessoLogic extends SIPRPLogic { if( currentExameMarcacao != null ) { - currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_FALTOU ); + currentExameMarcacao.faltou(); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -339,7 +342,7 @@ public class MedicinaProcessoLogic extends SIPRPLogic { if( currentExameMarcacao != null ) { - currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_ANULADO ); + currentExameMarcacao.anular(); runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -349,7 +352,16 @@ public class MedicinaProcessoLogic extends SIPRPLogic { if( currentExameMarcacao != null ) { - currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_REALIZADO ); + currentExameMarcacao.realizar(); + runActionLater( SAVE_EXAME_MARCACAO ); + } + } + + @LeafLogicActionBinding(actions = REALIZAR_PARCIAL_EXAME_MARCACAO) + public void realizarParcialExame() + { + if( currentExameMarcacao != null ) + { runActionLater( SAVE_EXAME_MARCACAO ); } } @@ -488,7 +500,7 @@ public class MedicinaProcessoLogic extends SIPRPLogic currentExameMarcacao.setToTrabalhadoresEcds( currentExame ); currentExameMarcacao.setToPrestadores( getPrestador(false) ); currentExameMarcacao.setToAnalisador( getAnalisador() ); - currentExameMarcacao.setEstado( MedicinaConstants.ESTADO_POR_REALIZAR ); + currentExameMarcacao.porRealizar(); runActionLater( SAVE_EXAME_MARCACAO ); return currentExameMarcacao; diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/LeafOptionDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/LeafOptionDialog.java index 5eb7a19c..36ed2ed3 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/LeafOptionDialog.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/LeafOptionDialog.java @@ -42,9 +42,9 @@ public class LeafOptionDialog extends JDialog private List selected = new ArrayList(); - private Map mapEnabledForKey = new HashMap(); + private Map mapEnabledForKey = null; - private Map mapChosenForKey = new HashMap(); + private Map mapChosenForKey = null; private String message = null; @@ -75,8 +75,8 @@ public class LeafOptionDialog extends JDialog ordered = true; this.message = message; okLabel = okButton; - this.mapChosenForKey = chosen; - this.mapEnabledForKey = enabled; + this.mapChosenForKey = chosen == null ? new HashMap() : chosen; + this.mapEnabledForKey = enabled == null ? new HashMap() : chosen; if( chosen != null ) { for( KeyClass key : chosen.keySet() ) @@ -159,7 +159,7 @@ public class LeafOptionDialog extends JDialog component.setSelected( isChosen != null && isChosen ); Boolean isEnabled = mapEnabledForKey.get( current ); - component.setClickable( isEnabled != null && isEnabled ); + component.setClickable( isEnabled == null || isEnabled ); component.setPreferredSize( OPTION_SIZE ); getContentPane().add( component, new TableLayoutConstraints( 0, i + shift ) ); diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/MedicinaProcessoWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/MedicinaProcessoWindow.java index cc758d47..a9d7ced1 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/MedicinaProcessoWindow.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/MedicinaProcessoWindow.java @@ -1,14 +1,19 @@ package siprp.medicina.processo.ui; -import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CLOSE; +import static siprp.medicina.processo.logic.MedicinaProcessoLogic.*; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; import java.awt.Dimension; +import java.util.List; import javax.swing.JSeparator; +import siprp.database.cayenne.objects.PrtGruposProtocolo; +import siprp.database.cayenne.objects.TrabalhadoresEcd; +import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas; import siprp.logic.SIPRPLogic.LeafUIActionBinding; +import siprp.medicina.MedicinaConstants; import siprp.medicina.processo.logic.MedicinaProcessoLogic; import siprp.ui.SIPRPWindow; @@ -79,9 +84,59 @@ public class MedicinaProcessoWindow extends SIPRPWindow this.add( panelProcessoDados, new TableLayoutConstraints( 2, 2 ) ); } - @LeafUIActionBinding(action=CLOSE) + @LeafUIActionBinding(action = CLOSE) public void closeWindow() { close(); } + + @LeafUIActionBinding(action = REALIZAR_PARCIAL_EXAME_MARCACAO) + public void realizarExameParcial( TrabalhadoresEcdsDatas marcacao ) + { + boolean atLeastOneRealizado = false; + boolean atLeastOneFalta = false; + if( marcacao != null ) + { + List ecds = marcacao.getTrabalhadoresEcdArray(); + if( ecds != null ) + { + OrderedMap grupos = marcacao.getStatesForeGruposExames(); + LeafOptionDialog option = new LeafOptionDialog( grupos, null, null, "Marcar falta para:", "Faltou >>" ); + List selected = option.getSelected(); + if( selected != null ) + { + for( TrabalhadoresEcd ecd : ecds ) + { + if( selected.contains( ecd.getToPrtTiposElementosProtocolo().getToPrtGruposProtocolo() ) ) + { + ecd.setEstado( MedicinaConstants.ESTADO_FALTOU ); + atLeastOneFalta = true; + }else + { + ecd.setEstado( MedicinaConstants.ESTADO_REALIZADO ); + atLeastOneRealizado = true; + } + } + } + } + } + if(atLeastOneFalta) + { + if(atLeastOneRealizado) + { + marcacao.setEstado( MedicinaConstants.ESTADO_PARCIALMENTE_REALIZADO); + }else + { + marcacao.setEstado( MedicinaConstants.ESTADO_FALTOU); + } + }else + { + if(atLeastOneRealizado) + { + marcacao.setEstado( MedicinaConstants.ESTADO_REALIZADO); + }else + { + } + } + } } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoAccoesPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoAccoesPanel.java index d035e93c..f43faecd 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoAccoesPanel.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoAccoesPanel.java @@ -143,6 +143,9 @@ public class ProcessoAccoesPanel extends JPanel @ActionActivation(onSelect = REALIZAR_EXAME_MARCACAO, onChange = "") public final LeafButton buttonExameMarcacaoRealizar = new LeafButton( "Realizar" ); + + @ActionActivation(onSelect = REALIZAR_PARCIAL_EXAME_MARCACAO, onChange = "") + public final LeafButton buttonExameMarcacaoRealizarParcial = new LeafButton( "Realizar Parcial." ); @ActionActivation(onSelect = FALTOU_EXAME_MARCACAO, onChange = "") public final LeafButton buttonExameMarcacaoFaltou = new LeafButton( "Faltou" ); @@ -346,6 +349,7 @@ public class ProcessoAccoesPanel extends JPanel buttonExameMarcacaoDesmarcarTrabalhador.setEnabled( porRealizar ); buttonExameMarcacaoFaltou.setEnabled( porRealizar ); buttonExameMarcacaoRealizar.setEnabled( porRealizar ); + buttonExameMarcacaoRealizarParcial.setEnabled( porRealizar ); buttonExameMarcacaoAnular.setEnabled( porRealizar ); buttonNovoExameMarcacaoObservacoes.setEnabled( noObservacoes ); cardLayout.show( cardPanel, PANEL_EXAME_MARCACAO_NAME ); @@ -419,7 +423,7 @@ public class ProcessoAccoesPanel extends JPanel JPanel exameMarcacaoUpperPanel = new JPanel(); JPanel exameMarcacaoLowerPanel = new JPanel(); setupSimpleActionsPanel( exameMarcacaoUpperPanel, buttonNovoExameMarcacaoEmail, buttonNovoExameMarcacaoObservacoes, new JPanel() ); - setupSimpleActionsPanel( exameMarcacaoLowerPanel, buttonExameMarcacaoRealizar, buttonExameMarcacaoAnular, buttonExameMarcacaoDesmarcarSiprp, buttonExameMarcacaoDesmarcarTrabalhador, buttonExameMarcacaoFaltou ); + setupSimpleActionsPanel( exameMarcacaoLowerPanel, buttonExameMarcacaoRealizar, buttonExameMarcacaoRealizarParcial, buttonExameMarcacaoFaltou, buttonExameMarcacaoAnular, buttonExameMarcacaoDesmarcarTrabalhador, buttonExameMarcacaoDesmarcarSiprp ); TableLayout exameMarcacaoLayout = new TableLayout(new double[]{TableLayout.FILL}, new double[]{TableLayout.MINIMUM, TableLayout.FILL,TableLayout.MINIMUM}); panelExameMarcacao.setLayout( exameMarcacaoLayout ); panelExameMarcacao.add( exameMarcacaoUpperPanel, new TableLayoutConstraints(0,0) ); diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoDadosPanel.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoDadosPanel.java index 1af42fb9..bd0bf6f5 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoDadosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/ui/ProcessoDadosPanel.java @@ -488,7 +488,7 @@ public class ProcessoDadosPanel extends JPanel } } } - LeafOptionDialog gruposChosen = new LeafOptionDialog( grupos, gruposSelected, gruposEnabled, "Escolha os ECDs para esta marca" +ccedil + atilde + "o" , "Marcar ยป" ); + LeafOptionDialog gruposChosen = new LeafOptionDialog( grupos, gruposSelected, gruposEnabled, "Escolha os ECDs para esta marca" +ccedil + atilde + "o" , "Marcar >>" ); for( PrtGruposProtocolo grupo : gruposChosen.getSelected() ) { marcacao.marcarGrupoExames( grupo ); diff --git a/trunk/SIPRPSoft/src/siprp/ui/SIPRPWindow.java b/trunk/SIPRPSoft/src/siprp/ui/SIPRPWindow.java index c377b4d1..82d4a0fb 100755 --- a/trunk/SIPRPSoft/src/siprp/ui/SIPRPWindow.java +++ b/trunk/SIPRPSoft/src/siprp/ui/SIPRPWindow.java @@ -76,7 +76,7 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio } /** - * Binds data fields to actions + * Binds an Object to actions * * @author tsimao * @@ -86,9 +86,9 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio { /** - * Actions that update this field + * Actions that use this field */ - String useWithAction(); + String [] useWith(); } /** @@ -250,12 +250,18 @@ public class SIPRPWindow extends JFrame implements TrackableWindow, ListSelectio LeafObject leafObject = field.getAnnotation( LeafObject.class ); if( leafObject != null ) { - String updateOn = leafObject.useWithAction(); - if( mapActionByName.containsKey( updateOn ) ) + String [] useWith = leafObject.useWith(); + if( useWith != null ) { - // valid action - mapLeafObjectByActionName.put( updateOn, field ); - mapInstanceByField.put( field, instance ); + for(String current : useWith ) + { + if( mapActionByName.containsKey( current ) ) + { + // valid action + mapLeafObjectByActionName.put( current, field ); + mapInstanceByField.put( field, instance ); + } + } } } }